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 'read' : (gobject
.SIGNAL_RUN_LAST
, gobject
.TYPE_NONE
, ()),
37 #'unread' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
38 'sticky' : (gobject
.SIGNAL_RUN_LAST
, gobject
.TYPE_NONE
, ())
41 def __init__(self
, imageCache
=None):
42 gobject
.GObject
.__init
__(self
)
43 self
.imageCache
= imageCache
44 if not self
.imageCache
:
46 self
.imageCache
= ImageCache
.cache
50 self
.description
= None
52 self
.guidislink
= True
53 self
.pub_date
= time
.localtime()
59 self
.fm_license
= None
60 self
.fm_changes
= None
62 self
.contributors
= list()
63 self
.license_urls
= list()
64 self
.publication_name
= None
65 self
.publication_volume
= None
66 self
.publication_number
= None
67 self
.publication_section
= None
68 self
.publication_starting_page
= None
70 self
.enclosures
= None
72 def __eq__(self
, item
):
73 r
= item
.title
== self
.title
and item
.description
== self
.description
76 elif item
.guid
and self
.guid
and item
.guid
== self
.guid
:
85 def fset(self
, seen
= True):
86 if self
._seen
!= seen
:
89 return property(**locals())
96 def fset(self
, sticky
):
97 if self
._sticky
!= sticky
:
100 return property(**locals())
104 doc
= "Item ID (internal)"
109 return property(**locals())
111 def _add_image(self
, image_name
, restore
):
112 self
.imageCache
.add_refer(image_name
, restore
, self
)
113 self
._images
[image_name
] = self
.imageCache
[image_name
]
115 def add_image(self
, image_name
):
116 self
._add
_image
(image_name
, restore
= False)
118 def restore_image(self
, image_name
):
119 self
._add
_image
(image_name
, restore
= True)
121 def set_image(self
, image_name
, image
):
122 self
._images
[image_name
] = image
124 def get_image(self
, image_name
):
125 return self
._images
.get(image_name
, None)
127 def clear_images(self
):
130 def image_keys(self
):
131 return self
._images
.keys()
133 def set_seen_quiet(self
, seen
= 1):
134 print "XXX: DEPRECATE / FIX"
139 def match(self
, text
):
140 def try_field(field
):
141 return type(field
) in (
142 type(''), type(u
'')) and field
.lower().find(text
.lower()) > -1
143 for f
in self
._searchable
_fields
:
145 if try_field(self
.__getattribute
__(f
)):
147 except AttributeError:
152 for image
in self
._images
:
153 self
.imageCache
.remove_refer(image
)