changeset 18732:a03c8b79f39b

Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This works some times. But sometimes it also causes crash :(
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Tue, 31 Jul 2007 12:06:02 +0000
parents 6976a6dae441
children fad7efbb98a6
files finch/libgnt/pygnt/example/rss/gntrss-ui.py
diffstat 1 files changed, 29 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/finch/libgnt/pygnt/example/rss/gntrss-ui.py	Tue Jul 31 12:03:46 2007 +0000
+++ b/finch/libgnt/pygnt/example/rss/gntrss-ui.py	Tue Jul 31 12:06:02 2007 +0000
@@ -53,6 +53,27 @@
         'active_changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_OBJECT,))
     }
 
+    __gntbindings__ = {
+        'jump-next-unread' : ('jump_next_unread', 'J')
+    }
+
+    def jump_next_unread(self, null):
+        first = None
+        next = None
+        all = self.get_rows()
+        for item in all:
+            if item.unread:
+                if next:
+                    first = item
+                    break
+                elif not first and self.active != item:
+                    first = item
+            if self.active == item:
+                next = item
+        if first:
+            self.set_active(first)
+            self.set_selected(first)
+
     def __init__(self):
         self.active = None
         gnt.Tree.__init__(self)
@@ -83,6 +104,7 @@
         return False
 
 gobject.type_register(RssTree)
+gnt.register_bindings(RssTree)
 
 win = gnt.Box(homo = False, vert = True)
 win.set_toplevel(True)
@@ -247,6 +269,7 @@
     details.append_text_with_flags(str(item.link) + "\n", gnt.TEXT_FLAG_UNDERLINE)
     details.append_text_with_flags("Date: ", gnt.TEXT_FLAG_BOLD)
     details.append_text_with_flags(str(item.date) + "\n", gnt.TEXT_FLAG_NORMAL)
+    details.append_text_with_flags("\n", gnt.TEXT_FLAG_NORMAL)
     parser = gnthtml.GParser(details)
     parser.parse(str(item.summary))
     item.mark_unread(False)
@@ -348,7 +371,11 @@
 
 def update_feed_title(feed, property):
     if property.name == 'title':
-        feeds.change_text(feed, 0, feed.title)
+        if feed.customtitle:
+            title = feed.customtitle
+        else:
+            title = feed.title
+        feeds.change_text(feed, 0, title)
     elif property.name == 'unread':
         feeds.change_text(feed, 1, str(feed.unread) + "(" + str(len(feed.items)) + ")")
         flag = 0
@@ -362,6 +389,7 @@
 # populate everything
 for feed in gntrss.feeds:
     feed.refresh()
+    feed.set_auto_refresh(True)
     add_feed(feed)
 
 gnt.gnt_register_action("Stuff", add_new_feed)