Mercurial > pidgin.yaz
changeset 18714:121d1560346c
A few updates to the rss reader.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sun, 29 Jul 2007 10:37:10 +0000 |
parents | 8000beb73585 |
children | 64a7b13d3b8d |
files | finch/libgnt/pygnt/example/rss/gntrss-ui.py finch/libgnt/pygnt/example/rss/gntrss.py |
diffstat | 2 files changed, 21 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/finch/libgnt/pygnt/example/rss/gntrss-ui.py Sun Jul 29 07:59:10 2007 +0000 +++ b/finch/libgnt/pygnt/example/rss/gntrss-ui.py Sun Jul 29 10:37:10 2007 +0000 @@ -71,12 +71,15 @@ if property.name == 'unread': if feeds.active != item.parent: return + flag = 0 + if item == items.active: + flag = gnt.TEXT_FLAG_UNDERLINE if item.unread: item.parent.unread = item.parent.unread + 1 - items.set_row_flags(item, gnt.TEXT_FLAG_BOLD) + items.set_row_flags(item, flag | gnt.TEXT_FLAG_BOLD) else: item.parent.unread = item.parent.unread - 1 - items.set_row_flags(item, gnt.TEXT_FLAG_NORMAL) + items.set_row_flags(item, flag | gnt.TEXT_FLAG_NORMAL) item.parent.notify('unread') def add_feed_item(item): @@ -158,6 +161,8 @@ details.scroll(0) if item.unread: item.set_property('unread', False) + if old and old.unread: + old.set_property('unread', True) # # Look for action keys in the feed-item list. @@ -170,9 +175,13 @@ elif text == 'm': # Mark the current item 'read' if current.unread: current.set_property('unread', False) + tree.perform_action_key('j') elif text == 'U': # Mark the current item 'unread' if not current.unread: current.set_property('unread', True) + elif text == 'd': + current.remove() + tree.perform_action_key('j') else: return False return True
--- a/finch/libgnt/pygnt/example/rss/gntrss.py Sun Jul 29 07:59:10 2007 +0000 +++ b/finch/libgnt/pygnt/example/rss/gntrss.py Sun Jul 29 10:37:10 2007 +0000 @@ -36,6 +36,8 @@ def remove(self): self.emit('delete', self.parent) + if self.unread: + self.parent.set_property('unread', self.parent.unread - 1) def do_set_property(self, property, value): if property.name == 'unread': @@ -100,17 +102,20 @@ #result = self.thread.result #self.thread = None result = feedparser.parse(self.url) + # XXX Look at result['bozo'] first, and emit some signal that the UI can use + # to indicate (dim the row?) that the feed has invalid XML format or something + channel = result['channel'] self.set_property('link', channel['link']) self.set_property('desc', channel['description']) self.set_property('title', channel['title']) - self.set_property('unread', len(result['items'])) self.timer = 0 items = result['items'] tmp = {} for item in self.items: tmp[hash(item)] = item + unread = self.unread for item in items: try: exist = self.hash[item_hash(item)] @@ -120,9 +125,13 @@ self.items.append(itm) self.emit('added', itm) self.hash[item_hash(item)] = itm + unread = unread + 1 + for hv in tmp: tmp[hv].remove() + if unread != self.unread: + self.set_property('unread', unread) return False def refresh(self):