# HG changeset patch # User Sadrul Habib Chowdhury # Date 1185705430 0 # Node ID 121d1560346cb9f4a2f9bc1259e40a27ebf4b798 # Parent 8000beb73585cb9e320907cdba58ec0d3c52a6b3 A few updates to the rss reader. diff -r 8000beb73585 -r 121d1560346c finch/libgnt/pygnt/example/rss/gntrss-ui.py --- 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 diff -r 8000beb73585 -r 121d1560346c finch/libgnt/pygnt/example/rss/gntrss.py --- 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):