annotate finch/libgnt/pygnt/example/rss/gntrss-ui.py @ 20203:a842ee320d51

applied changes from 78b2ccce7cd45df860c7b3fffac608362438ac6f through 887f4f4c3543d4601502c165918d5ea69ccad247
author Richard Laager <rlaager@wiktel.com>
date Fri, 28 Sep 2007 15:24:35 +0000
parents 80bfc233c9f2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
2
18715
64a7b13d3b8d Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18714
diff changeset
3 """
64a7b13d3b8d Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18714
diff changeset
4 gr - An RSS-reader built using libgnt and feedparser.
64a7b13d3b8d Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18714
diff changeset
5
64a7b13d3b8d Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18714
diff changeset
6 Copyright (C) 2007 Sadrul Habib Chowdhury <sadrul@pidgin.im>
64a7b13d3b8d Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18714
diff changeset
7
64a7b13d3b8d Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18714
diff changeset
8 This application is free software; you can redistribute it and/or
64a7b13d3b8d Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18714
diff changeset
9 modify it under the terms of the GNU Lesser General Public
64a7b13d3b8d Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18714
diff changeset
10 License as published by the Free Software Foundation; either
64a7b13d3b8d Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18714
diff changeset
11 version 2.1 of the License, or (at your option) any later version.
64a7b13d3b8d Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18714
diff changeset
12
64a7b13d3b8d Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18714
diff changeset
13 This application is distributed in the hope that it will be useful,
64a7b13d3b8d Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18714
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
64a7b13d3b8d Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18714
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
64a7b13d3b8d Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18714
diff changeset
16 Lesser General Public License for more details.
64a7b13d3b8d Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18714
diff changeset
17
64a7b13d3b8d Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18714
diff changeset
18 You should have received a copy of the GNU Lesser General Public
64a7b13d3b8d Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18714
diff changeset
19 License along with this application; if not, write to the Free Software
19681
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 18871
diff changeset
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301
18715
64a7b13d3b8d Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18714
diff changeset
21 USA
64a7b13d3b8d Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18714
diff changeset
22 """
64a7b13d3b8d Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18714
diff changeset
23
64a7b13d3b8d Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18714
diff changeset
24 """
64a7b13d3b8d Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18714
diff changeset
25 This file deals with the UI part (gnt) of the application
18722
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
26
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
27 TODO:
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
28 - Allow showing feeds of only selected 'category' and/or 'priority'. A different
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
29 window should be used to change such filtering.
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
30 - Display details of each item in its own window.
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
31 - Add search capability, and allow searching only in title/body. Also allow
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
32 filtering in the search results.
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
33 - Show the data and time for feed items (probably in a separate column .. perhaps not)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
34 - Have a simple way to add a feed.
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
35 - Allow renaming a feed.
18715
64a7b13d3b8d Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18714
diff changeset
36 """
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
37
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
38 import gntrss
18727
778f4fc8cbcc Parse HTML and show bold, italic etc. in the textview.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18725
diff changeset
39 import gnthtml
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
40 import gnt
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
41 import gobject
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
42 import sys
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
43
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
44 __version__ = "0.0.1alpha"
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
45 __author__ = "Sadrul Habib Chowdhury (sadrul@pidgin.im)"
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
46 __copyright__ = "Copyright 2007, Sadrul Habib Chowdhury"
18715
64a7b13d3b8d Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18714
diff changeset
47 __license__ = "GPL" # see full license statement above
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
48
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
49 gnt.gnt_init()
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
50
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
51 class RssTree(gnt.Tree):
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
52 __gsignals__ = {
18722
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
53 'active_changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_OBJECT,))
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
54 }
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
55
18732
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
56 __gntbindings__ = {
19764
80bfc233c9f2 Fix a memory corruption.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
57 'jump-next-unread' : ('jump_next_unread', 'n')
18732
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
58 }
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
59
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
60 def jump_next_unread(self, null):
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
61 first = None
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
62 next = None
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
63 all = self.get_rows()
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
64 for item in all:
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
65 if item.unread:
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
66 if next:
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
67 first = item
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
68 break
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
69 elif not first and self.active != item:
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
70 first = item
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
71 if self.active == item:
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
72 next = item
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
73 if first:
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
74 self.set_active(first)
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
75 self.set_selected(first)
18871
2e41a68009ba Fix a few small bugs in the example code.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18732
diff changeset
76 return True
18732
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
77
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
78 def __init__(self):
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
79 self.active = None
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
80 gnt.Tree.__init__(self)
18722
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
81 gnt.set_flag(self, 8) # remove borders
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
82 self.connect('key_pressed', self.do_key_pressed)
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
83
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
84 def set_active(self, active):
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
85 if self.active == active:
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
86 return
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
87 if self.active:
18725
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
88 flag = gnt.TEXT_FLAG_NORMAL
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
89 if self.active.unread:
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
90 flag = flag | gnt.TEXT_FLAG_BOLD
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
91 self.set_row_flags(self.active, flag)
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
92 old = self.active
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
93 self.active = active
18725
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
94 flag = gnt.TEXT_FLAG_UNDERLINE
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
95 if self.active.unread:
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
96 flag = flag | gnt.TEXT_FLAG_BOLD
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
97 self.set_row_flags(self.active, flag)
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
98 self.emit('active_changed', old)
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
99
18722
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
100 def do_key_pressed(self, null, text):
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
101 if text == '\r':
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
102 now = self.get_selection_data()
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
103 self.set_active(now)
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
104 return True
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
105 return False
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
106
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
107 gobject.type_register(RssTree)
18732
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
108 gnt.register_bindings(RssTree)
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
109
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
110 win = gnt.Box(homo = False, vert = True)
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
111 win.set_toplevel(True)
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
112 win.set_title("GntRss")
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
113 win.set_pad(0)
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
114
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
115 #
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
116 # [[[ Generic feed/item callbacks
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
117 #
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
118 def feed_item_added(feed, item):
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
119 add_feed_item(item)
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
120
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
121 def add_feed(feed):
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
122 if not feed.get_data('gntrss-connected'):
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
123 feed.connect('added', feed_item_added)
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
124 feed.connect('notify', update_feed_title)
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
125 feed.set_data('gntrss-connected', True)
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
126 feeds.add_row_after(feed, [feed.title, str(feed.unread)], None, None)
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
127
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
128 def remove_item(item, feed):
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
129 items.remove(item)
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
130
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
131 def update_feed_item(item, property):
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
132 if property.name == 'unread':
18725
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
133 if feeds.active == item.parent:
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
134 flag = 0
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
135 if item == items.active:
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
136 flag = gnt.TEXT_FLAG_UNDERLINE
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
137 if item.unread:
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
138 flag = flag | gnt.TEXT_FLAG_BOLD
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
139 else:
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
140 flag = flag | gnt.TEXT_FLAG_NORMAL
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
141 items.set_row_flags(item, flag)
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
142
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
143 unread = item.parent.unread
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
144 if item.unread:
18725
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
145 unread = unread + 1
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
146 else:
18725
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
147 unread = unread - 1
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
148 item.parent.set_property('unread', unread)
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
149
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
150 def add_feed_item(item):
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
151 currentfeed = feeds.active
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
152 if item.parent != currentfeed:
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
153 return
18725
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
154 months = ["", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
155 dt = str(item.date_parsed[2]) + "." + months[item.date_parsed[1]] + "." + str(item.date_parsed[0])
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
156 items.add_row_after(item, [str(item.title), dt], None, None)
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
157 if item.unread:
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
158 items.set_row_flags(item, gnt.TEXT_FLAG_BOLD)
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
159 if not item.get_data('gntrss-connected'):
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
160 item.set_data('gntrss-connected', True)
18725
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
161 # this needs to happen *without* having to add the item in the tree
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
162 item.connect('notify', update_feed_item)
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
163 item.connect('delete', remove_item)
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
164
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
165 #
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
166 # ]]] Generic feed/item callbacks
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
167 #
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
168
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
169
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
170 ####
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
171 # [[[ The list of feeds
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
172 ###
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
173
18722
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
174 # 'Add Feed' dialog
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
175 add_feed_win = None
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
176 def add_feed_win_closed(win):
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
177 global add_feed_win
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
178 add_feed_win = None
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
179
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
180 def add_new_feed():
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
181 global add_feed_win
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
182
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
183 if add_feed_win:
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
184 gnt.gnt_window_present(add_feed_win)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
185 return
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
186 win = gnt.Window()
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
187 win.set_title("New Feed")
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
188
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
189 box = gnt.Box(False, False)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
190 label = gnt.Label("Link")
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
191 box.add_widget(label)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
192 entry = gnt.Entry("")
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
193 entry.set_size(40, 1)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
194 box.add_widget(entry)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
195
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
196 win.add_widget(box)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
197 win.show()
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
198 add_feed_win = win
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
199 add_feed_win.connect("destroy", add_feed_win_closed)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
200
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
201 #
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
202 # The active row in the feed-list has changed. Update the feed-item table.
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
203 def feed_active_changed(tree, old):
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
204 items.remove_all()
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
205 if not tree.active:
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
206 return
18722
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
207 update_items_title()
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
208 for item in tree.active.items:
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
209 add_feed_item(item)
18725
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
210 win.give_focus_to_child(items)
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
211
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
212 #
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
213 # Check for the action keys and decide how to deal with them.
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
214 def feed_key_pressed(tree, text):
18722
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
215 if tree.is_searching():
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
216 return
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
217 if text == 'r':
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
218 feed = tree.get_selection_data()
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
219 tree.perform_action_key('j')
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
220 #tree.perform_action('move-down')
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
221 feed.refresh()
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
222 elif text == 'R':
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
223 feeds = tree.get_rows()
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
224 for feed in feeds:
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
225 feed.refresh()
18725
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
226 elif text == 'm':
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
227 feed = tree.get_selection_data()
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
228 if feed:
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
229 feed.mark_read()
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
230 feed.set_property('unread', 0)
18722
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
231 elif text == 'a':
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
232 add_new_feed()
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
233 else:
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
234 return False
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
235 return True
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
236
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
237 feeds = RssTree()
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
238 feeds.set_property('columns', 2)
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
239 feeds.set_col_width(0, 20)
18725
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
240 feeds.set_col_width(1, 6)
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
241 feeds.set_column_resizable(0, False)
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
242 feeds.set_column_resizable(1, False)
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
243 feeds.set_column_is_right_aligned(1, True)
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
244 feeds.set_show_separator(False)
18722
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
245 feeds.set_column_title(0, "Feeds")
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
246 feeds.set_show_title(True)
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
247
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
248 feeds.connect('active_changed', feed_active_changed)
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
249 feeds.connect('key_pressed', feed_key_pressed)
18722
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
250 gnt.unset_flag(feeds, 256) # Fix the width
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
251
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
252 ####
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
253 # ]]] The list of feeds
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
254 ###
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
255
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
256 ####
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
257 # [[[ The list of items in the feed
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
258 ####
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
259
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
260 #
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
261 # The active item in the feed-item list has changed. Update the
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
262 # summary content.
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
263 def item_active_changed(tree, old):
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
264 details.clear()
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
265 if not tree.active:
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
266 return
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
267 item = tree.active
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
268 details.append_text_with_flags(str(item.title) + "\n", gnt.TEXT_FLAG_BOLD)
18722
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
269 details.append_text_with_flags("Link: ", gnt.TEXT_FLAG_BOLD)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
270 details.append_text_with_flags(str(item.link) + "\n", gnt.TEXT_FLAG_UNDERLINE)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
271 details.append_text_with_flags("Date: ", gnt.TEXT_FLAG_BOLD)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
272 details.append_text_with_flags(str(item.date) + "\n", gnt.TEXT_FLAG_NORMAL)
18732
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
273 details.append_text_with_flags("\n", gnt.TEXT_FLAG_NORMAL)
18727
778f4fc8cbcc Parse HTML and show bold, italic etc. in the textview.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18725
diff changeset
274 parser = gnthtml.GParser(details)
778f4fc8cbcc Parse HTML and show bold, italic etc. in the textview.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18725
diff changeset
275 parser.parse(str(item.summary))
18722
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
276 item.mark_unread(False)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
277
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
278 if old and old.unread: # If the last selected item is marked 'unread', then make sure it's bold
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
279 items.set_row_flags(old, gnt.TEXT_FLAG_BOLD)
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
280
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
281 #
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
282 # Look for action keys in the feed-item list.
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
283 def item_key_pressed(tree, text):
18722
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
284 if tree.is_searching():
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
285 return
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
286 current = tree.get_selection_data()
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
287 if text == 'M': # Mark all of the items 'read'
18725
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
288 feed = feeds.active
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
289 if feed:
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
290 feed.mark_read()
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
291 elif text == 'm': # Mark the current item 'read'
18722
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
292 current.mark_unread(False)
18714
121d1560346c A few updates to the rss reader.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18682
diff changeset
293 tree.perform_action_key('j')
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
294 elif text == 'U': # Mark the current item 'unread'
18722
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
295 current.mark_unread(True)
18714
121d1560346c A few updates to the rss reader.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18682
diff changeset
296 elif text == 'd':
121d1560346c A few updates to the rss reader.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18682
diff changeset
297 current.remove()
121d1560346c A few updates to the rss reader.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18682
diff changeset
298 tree.perform_action_key('j')
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
299 else:
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
300 return False
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
301 return True
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
302
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
303 items = RssTree()
18725
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
304 items.set_property('columns', 2)
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
305 items.set_col_width(0, 40)
18725
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
306 items.set_col_width(1, 11)
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
307 items.set_column_resizable(1, False)
18722
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
308 items.set_column_title(0, "Items")
18725
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
309 items.set_column_title(1, "Date")
18722
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
310 items.set_show_title(True)
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
311 items.connect('key_pressed', item_key_pressed)
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
312 items.connect('active_changed', item_active_changed)
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
313
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
314 ####
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
315 # ]]] The list of items in the feed
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
316 ####
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
317
18722
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
318 #
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
319 # Update the title of the items list depending on the selection in the feed list
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
320 def update_items_title():
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
321 feed = feeds.active
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
322 if feed:
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
323 items.set_column_title(0, str(feed.title) + ": " + str(feed.unread) + "(" + str(len(feed.items)) + ")")
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
324 else:
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
325 items.set_column_title(0, "Items")
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
326 items.draw()
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
327
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
328 # The container on the top
18682
254823d66aa5 The promised cleanups.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18681
diff changeset
329 line = gnt.Line(vertical = False)
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
330
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
331 # The textview to show the details of a feed
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
332 details = gnt.TextView()
18722
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
333 details.set_take_focus(True)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
334 details.set_flag(gnt.TEXT_VIEW_TOP_ALIGN)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
335 details.attach_scroll_widget(details)
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
336
18725
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
337 # Make it look nice
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
338 s = feeds.get_size()
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
339 size = gnt.screen_size()
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
340 size[0] = size[0] - s[0]
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
341 items.set_size(size[0], size[1] / 2)
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
342 details.set_size(size[0], size[1] / 2)
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
343
18722
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
344 # Category tree
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
345 cat = gnt.Tree()
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
346 cat.set_property('columns', 1)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
347 cat.set_column_title(0, 'Category')
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
348 cat.set_show_title(True)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
349 gnt.set_flag(cat, 8) # remove borders
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
350
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
351 box = gnt.Box(homo = False, vert = False)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
352 box.set_pad(0)
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
353
18722
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
354 vbox = gnt.Box(homo = False, vert = True)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
355 vbox.set_pad(0)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
356 vbox.add_widget(feeds)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
357 vbox.add_widget(gnt.Line(False))
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
358 vbox.add_widget(cat)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
359 box.add_widget(vbox)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
360
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
361 box.add_widget(gnt.Line(True))
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
362
18722
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
363 vbox = gnt.Box(homo = False, vert = True)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
364 vbox.set_pad(0)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
365 vbox.add_widget(items)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
366 vbox.add_widget(gnt.Line(False))
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
367 vbox.add_widget(details)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
368 box.add_widget(vbox)
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
369
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
370 win.add_widget(box)
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
371 win.show()
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
372
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
373 def update_feed_title(feed, property):
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
374 if property.name == 'title':
18732
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
375 if feed.customtitle:
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
376 title = feed.customtitle
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
377 else:
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
378 title = feed.title
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
379 feeds.change_text(feed, 0, title)
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
380 elif property.name == 'unread':
18722
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
381 feeds.change_text(feed, 1, str(feed.unread) + "(" + str(len(feed.items)) + ")")
18725
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
382 flag = 0
18722
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
383 if feeds.active == feed:
18725
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
384 flag = gnt.TEXT_FLAG_UNDERLINE
18722
8b5082d54c1d Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18715
diff changeset
385 update_items_title()
18725
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
386 if feed.unread > 0:
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
387 flag = flag | gnt.TEXT_FLAG_BOLD
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
388 feeds.set_row_flags(feed, flag)
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
389
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
390 # populate everything
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
391 for feed in gntrss.feeds:
18682
254823d66aa5 The promised cleanups.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18681
diff changeset
392 feed.refresh()
18732
a03c8b79f39b Use __gntbindings__ to specify a 'jump-next-unread' action bound to 'J'. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18727
diff changeset
393 feed.set_auto_refresh(True)
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
394 add_feed(feed)
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
395
18725
1aeda1e812a8 Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18722
diff changeset
396 gnt.gnt_register_action("Stuff", add_new_feed)
18681
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
397 gnt.gnt_main()
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
398
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
399 gnt.gnt_quit()
ef15236a0866 A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
400