1 from gobject
import GObject
5 class Category(GObject
):
6 persistent_properties
= [ "id", "parent_id" , "title" ]
7 persistent_table
= "categories"
10 "title": (str, "title", "title", "", gobject
.PARAM_READWRITE
),
11 "unread-count": (int, "unread-count", "unread-count", 0, 999999, 0, gobject
.PARAM_READWRITE
)
15 "unread-count-changed": (gobject
.SIGNAL_RUN_LAST
, gobject
.TYPE_NONE
, (gobject
.TYPE_PYOBJECT
, gobject
.TYPE_PYOBJECT
))
19 GObject
.__init
__(self
)
26 def do_get_property(self
, property):
27 if property.name
== "title":
29 elif property.name
== "unread-count":
30 return self
.unread_count
32 raise AttributeError, "unknown property %s" % property.name
34 def do_set_property(self
, property, value
):
35 if property.name
== "title":
37 elif property.name
== "unread-count":
38 if self
.unread_count
!= value
:
39 delta
= value
- self
.unread_count
40 old_value
= self
.unread_count
41 self
.unread_count
= value
42 self
.emit("unread-count-changed", old_value
, delta
)
44 raise AttributeError, "unknown property %s" % property.name
46 def on_unread_count_changed(self
, obj
, old_value
, delta
):
47 if isinstance(obj
, Feed
) and obj
.category_id
== self
.id:
48 self
.props
.unread_count
+= delta
49 elif isinstance(obj
, Category
):
50 self
.props
.unread_count
+= delta
53 persistent_properties
= [ "id", "title", "location", "category_id", "link" ]
54 persistent_table
= "feeds"
57 "title": (str, "title", "title", "", gobject
.PARAM_READWRITE
),
58 "location": (str, "location", "location", "", gobject
.PARAM_READWRITE
),
59 "status": (int, "status", "status", 0, 9999, 0, gobject
.PARAM_READWRITE
),
60 "unread-count": (int, "unread-count", "unread-count", 0, 9999, 0, gobject
.PARAM_READWRITE
)
64 "unread-count-changed": (gobject
.SIGNAL_RUN_LAST
, gobject
.TYPE_NONE
, (gobject
.TYPE_PYOBJECT
, gobject
.TYPE_PYOBJECT
))
68 GObject
.__init
__(self
)
70 self
.category_id
= None
74 def do_get_property(self
, property):
75 if property.name
== "title":
77 elif property.name
== "location":
79 elif property.name
== "unread-count":
80 return self
.unread_count
81 elif property.name
== "status":
84 raise AttributeError, "unknown property %s" % property.name
86 def do_set_property(self
, property, value
):
87 if property.name
== "title":
89 elif property.name
== "location":
91 elif property.name
== "status":
93 elif property.name
== "unread-count":
94 if self
.unread_count
!= value
:
95 delta
= value
- self
.unread_count
96 old_value
= self
.unread_count
97 self
.unread_count
= value
98 self
.emit("unread-count-changed", old_value
, delta
)
100 raise AttributeError, "unknown property %s" % property.name
102 def add_item(self
, item
):
103 self
.items
.append(item
)
105 def on_is_read_changed(self
, obj
, is_read
):
107 self
.props
.unread_count
-= 1
109 self
.props
.unread_count
+= 1
112 persistent_properties
= [ "id", "title", "feed_id", "is_read", "link", "pub_date", "description" ]
113 persistent_table
= "items"
116 "title": (str, "title", "title", "", gobject
.PARAM_READWRITE
),
117 "location": (str, "location", "location", "", gobject
.PARAM_READWRITE
),
118 "is-read": (gobject
.TYPE_BOOLEAN
, "is-read", "is-read", False, gobject
.PARAM_READWRITE
)
122 "is-read-changed": (gobject
.SIGNAL_RUN_LAST
, gobject
.TYPE_NONE
, (gobject
.TYPE_PYOBJECT
,))
126 GObject
.__init
__(self
)
134 self
.description
= "description"
137 self
.guidislink
= False
139 self
.publication_name
= "publication_name"
140 self
.publication_volume
= "publication_volume"
141 self
.publication_number
= "publication_number"
142 self
.publication_section
= "publication_section"
143 self
.publication_starting_page
= "publication_starting_page"
145 self
.fm_license
= "fm_license"
146 self
.fm_changes
= "fm_changes"
148 self
.creator
= "creator"
150 self
.contributors
= []
152 self
.license_urls
= []
154 def do_get_property(self
, property):
155 if property.name
== "title":
157 elif property.name
== "is-read":
160 raise AttributeError, "unknown property %s" % property.name
162 def do_set_property(self
, property, value
):
163 if property.name
== "title":
165 elif property.name
== "is-read":
166 old_value
= bool(self
.is_read
)
168 if old_value
!= value
:
169 self
.emit("is-read-changed", int(value
))
171 raise AttributeError, "unknown property %s" % property.name
173 class TreeViewNode(GObject
):
174 persistent_properties
= [ "id", "obj_id", "norder", "type" ]
175 persistent_table
= "treeview_nodes"
178 "norder": (int, "norder", "norder", 0, 1000, 0, gobject
.PARAM_READWRITE
),
182 GObject
.__init
__(self
)
188 def do_get_property(self
, property):
189 if property.name
== "norder":
192 raise AttributeError, "unknown property %s" % property.name
194 def do_set_property(self
, property, value
):
195 if property.name
== "norder":
198 raise AttributeError, "unknown property %s" % property.name
200 def obj_changed(self
, obj
, property):
201 if property.name
== "unread-count":
202 self
.store
.set(self
.treeiter
, 3, self
.obj
.unread_count
)
203 elif property.name
== "status":
204 if (self
.obj
.status
& straw
.FS_UPDATING
) > 0:
205 title
= self
.store
.get_value(self
.treeiter
, 1)
206 self
.store
.set(self
.treeiter
, 1, "<i>" + title
+ "</i>")
208 title
= self
.obj
.title
209 self
.store
.set(self
.treeiter
, 1, title
)
213 ''' The title of the node be it a category or a feed '''
214 return self
.obj
.title
217 def unread_count(self
):
218 ''' The title of the node be it a category or a feed '''
219 return self
.obj
.unread_count
223 ''' gets the pixbuf to display according to the status of the feed '''
227 if isinstance(self
.obj
, Feed
):
228 return widget
.render_icon(gtk
.STOCK_FILE
, gtk
.ICON_SIZE_MENU
)
230 return widget
.render_icon(gtk
.STOCK_DIRECTORY
, gtk
.ICON_SIZE_MENU
)
232 # ignore why above is a gtk.Label. We just need
233 # gtk.Widget.render_icon to get a pixbuf out of a stock image.
234 # Fyi, gtk.Widget is abstract that is why we need a subclass to do
237 if self
.obj
.process_status
is not feeds
.Feed
.STATUS_IDLE
:
238 return widget
.render_icon(gtk
.STOCK_EXECUTE
, gtk
.ICON_SIZE_MENU
)
240 return widget
.render_icon(gtk
.STOCK_DIALOG_ERROR
, gtk
.ICON_SIZE_MENU
)
241 except AttributeError, ex
:
242 logging
.exception(ex
)
243 return widget
.render_icon(gtk
.STOCK_DIRECTORY
, gtk
.ICON_SIZE_MENU
)
244 return self
.default_pixbuf