4 __copyright__
= "Copyright (c) 2002-2005 Free Software Foundation, Inc."
6 Straw is free software; you can redistribute it and/or modify it under the
7 terms of the GNU General Public License as published by the Free Software
8 Foundation; either version 2 of the License, or (at your option) any later
11 Straw is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17 Place - Suite 330, Boston, MA 02111-1307, USA. """
23 class SummaryItem(gobject
.GObject
):
24 __slots__
= ('title', 'link', 'description', 'guid', 'pub_date', 'source',
25 '_images', '_seen', '_id', 'feed', '_slots',
26 'fm_license', 'fm_changes', 'creator', 'license_urls',
27 '_searchable_fields', '_sticky', 'publication_name',
28 'publication_volume', 'publication_number',
29 'publication_section', 'publication_starting_page',
30 'guidislink', 'contributors', 'enclosures')
32 _searchable_fields
= ('title', 'description', 'fm_license', 'fm_changes',
33 'creator', 'contributors')
36 'changed' : (gobject
.SIGNAL_RUN_LAST
, gobject
.TYPE_NONE
, ()),
39 def __init__(self
, imageCache
=None):
40 gobject
.GObject
.__init
__(self
)
41 self
.imageCache
= imageCache
42 if not self
.imageCache
:
44 self
.imageCache
= ImageCache
.cache
48 self
.description
= None
50 self
.guidislink
= True
51 self
.pub_date
= time
.localtime()
57 self
.fm_license
= None
58 self
.fm_changes
= None
60 self
.contributors
= list()
61 self
.license_urls
= list()
62 self
.publication_name
= None
63 self
.publication_volume
= None
64 self
.publication_number
= None
65 self
.publication_section
= None
66 self
.publication_starting_page
= None
68 self
.enclosures
= None
70 def __eq__(self
, item
):
71 r
= item
.title
== self
.title
and item
.description
== self
.description
74 elif item
.guid
and self
.guid
and item
.guid
== self
.guid
:
83 def fset(self
, seen
= True):
84 if self
._seen
!= seen
:
87 return property(**locals())
94 def fset(self
, sticky
):
95 if self
._sticky
!= sticky
:
98 return property(**locals())
102 doc
= "Item ID (internal)"
107 return property(**locals())
109 def _add_image(self
, image_name
, restore
):
111 #self.imageCache.add_refer(image_name, restore, self)
112 #self._images[image_name] = self.imageCache[image_name]
114 def add_image(self
, image_name
):
115 self
._add
_image
(image_name
, restore
= False)
117 def restore_image(self
, image_name
):
118 self
._add
_image
(image_name
, restore
= True)
120 def set_image(self
, image_name
, image
):
121 self
._images
[image_name
] = image
123 def get_image(self
, image_name
):
124 return self
._images
.get(image_name
, None)
126 def clear_images(self
):
129 def image_keys(self
):
130 return self
._images
.keys()
132 def match(self
, text
):
133 def try_field(field
):
134 return type(field
) in (
135 type(''), type(u
'')) and field
.lower().find(text
.lower()) > -1
136 for f
in self
._searchable
_fields
:
138 if try_field(self
.__getattribute
__(f
)):
140 except AttributeError:
145 for image
in self
._images
:
146 self
.imageCache
.remove_refer(image
)