Mercurial > pidgin
annotate finch/libgnt/pygnt/example/rss/gntrss-ui.py @ 18722:8b5082d54c1d
Make the rss-reader look and behave nicer.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sun, 29 Jul 2007 19:00:14 +0000 |
parents | 64a7b13d3b8d |
children | 1aeda1e812a8 |
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 |
64a7b13d3b8d
Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18714
diff
changeset
|
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
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 |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
39 import gnt |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
40 import gobject |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
41 import sys |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
42 |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
43 __version__ = "0.0.1alpha" |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
44 __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
|
45 __copyright__ = "Copyright 2007, Sadrul Habib Chowdhury" |
18715
64a7b13d3b8d
Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18714
diff
changeset
|
46 __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
|
47 |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
48 gnt.gnt_init() |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
49 |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
50 class RssTree(gnt.Tree): |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
51 __gsignals__ = { |
18722
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
52 '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
|
53 } |
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 def __init__(self): |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
56 self.active = None |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
57 gnt.Tree.__init__(self) |
18722
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
58 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
|
59 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
|
60 |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
61 def set_active(self, active): |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
62 if self.active == active: |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
63 return |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
64 if self.active: |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
65 self.set_row_flags(self.active, gnt.TEXT_FLAG_NORMAL) |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
66 old = self.active |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
67 self.active = active |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
68 self.set_row_flags(self.active, gnt.TEXT_FLAG_UNDERLINE) |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
69 self.emit('active_changed', old) |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
70 |
18722
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
71 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
|
72 if text == '\r': |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
73 now = self.get_selection_data() |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
74 self.set_active(now) |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
75 return True |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
76 return False |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
77 |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
78 gobject.type_register(RssTree) |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
79 |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
80 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
|
81 win.set_toplevel(True) |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
82 win.set_title("GntRss") |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
83 win.set_pad(0) |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
84 |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
85 # |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
86 # [[[ Generic feed/item callbacks |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
87 # |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
88 def feed_item_added(feed, item): |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
89 add_feed_item(item) |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
90 |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
91 def add_feed(feed): |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
92 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
|
93 feed.connect('added', feed_item_added) |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
94 feed.connect('notify', update_feed_title) |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
95 feed.set_data('gntrss-connected', True) |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
96 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
|
97 |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
98 def remove_item(item, feed): |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
99 items.remove(item) |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
100 |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
101 def update_feed_item(item, property): |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
102 if property.name == 'unread': |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
103 if feeds.active != item.parent: |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
104 return |
18714
121d1560346c
A few updates to the rss reader.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18682
diff
changeset
|
105 flag = 0 |
121d1560346c
A few updates to the rss reader.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18682
diff
changeset
|
106 if item == items.active: |
121d1560346c
A few updates to the rss reader.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18682
diff
changeset
|
107 flag = gnt.TEXT_FLAG_UNDERLINE |
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
108 if item.unread: |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
109 item.parent.unread = item.parent.unread + 1 |
18714
121d1560346c
A few updates to the rss reader.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18682
diff
changeset
|
110 items.set_row_flags(item, flag | gnt.TEXT_FLAG_BOLD) |
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
111 else: |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
112 item.parent.unread = item.parent.unread - 1 |
18714
121d1560346c
A few updates to the rss reader.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18682
diff
changeset
|
113 items.set_row_flags(item, flag | gnt.TEXT_FLAG_NORMAL) |
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
114 item.parent.notify('unread') |
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 def add_feed_item(item): |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
117 currentfeed = feeds.active |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
118 if item.parent != currentfeed: |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
119 return |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
120 items.add_row_after(item, [str(item.title)], None, None) |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
121 if item.unread: |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
122 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
|
123 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
|
124 item.set_data('gntrss-connected', True) |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
125 item.connect('notify', update_feed_item) |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
126 item.connect('delete', remove_item) |
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 # |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
129 # ]]] Generic feed/item callbacks |
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 |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
132 |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
133 #### |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
134 # [[[ The list of feeds |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
135 ### |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
136 |
18722
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
137 # 'Add Feed' dialog |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
138 add_feed_win = None |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
139 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
|
140 global add_feed_win |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
141 add_feed_win = None |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
142 |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
143 def add_new_feed(): |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
144 global add_feed_win |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
145 |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
146 if add_feed_win: |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
147 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
|
148 return |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
149 win = gnt.Window() |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
150 win.set_title("New Feed") |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
151 |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
152 box = gnt.Box(False, False) |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
153 label = gnt.Label("Link") |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
154 box.add_widget(label) |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
155 entry = gnt.Entry("") |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
156 entry.set_size(40, 1) |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
157 box.add_widget(entry) |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
158 |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
159 win.add_widget(box) |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
160 win.show() |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
161 add_feed_win = win |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
162 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
|
163 |
18681
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 # 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
|
166 def feed_active_changed(tree, old): |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
167 items.remove_all() |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
168 if not tree.active: |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
169 return |
18722
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
170 update_items_title() |
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
171 for item in tree.active.items: |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
172 add_feed_item(item) |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
173 |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
174 # |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
175 # 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
|
176 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
|
177 if tree.is_searching(): |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
178 return |
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
179 if text == 'r': |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
180 feed = tree.get_selection_data() |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
181 tree.perform_action_key('j') |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
182 #tree.perform_action('move-down') |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
183 feed.refresh() |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
184 elif text == 'R': |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
185 feeds = tree.get_rows() |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
186 for feed in feeds: |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
187 feed.refresh() |
18722
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
188 elif text == 'a': |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
189 add_new_feed() |
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
190 else: |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
191 return False |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
192 return True |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
193 |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
194 feeds = RssTree() |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
195 feeds.set_property('columns', 2) |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
196 feeds.set_col_width(0, 20) |
18722
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
197 feeds.set_col_width(1, 8) |
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
198 feeds.set_column_resizable(0, False) |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
199 feeds.set_column_resizable(1, False) |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
200 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
|
201 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
|
202 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
|
203 feeds.set_show_title(True) |
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
204 |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
205 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
|
206 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
|
207 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
|
208 |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
209 #### |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
210 # ]]] The list of feeds |
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 #### |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
214 # [[[ 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
|
215 #### |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
216 |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
217 # |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
218 # 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
|
219 # summary content. |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
220 def item_active_changed(tree, old): |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
221 details.clear() |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
222 if not tree.active: |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
223 return |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
224 item = tree.active |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
225 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
|
226 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
|
227 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
|
228 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
|
229 details.append_text_with_flags(str(item.date) + "\n", gnt.TEXT_FLAG_NORMAL) |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
230 |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
231 details.append_text_with_flags("\n" + str(item.summary), gnt.TEXT_FLAG_NORMAL) |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
232 item.mark_unread(False) |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
233 |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
234 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
|
235 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
|
236 |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
237 # |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
238 # 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
|
239 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
|
240 if tree.is_searching(): |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
241 return |
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
242 current = tree.get_selection_data() |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
243 if text == 'M': # Mark all of the items 'read' |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
244 all = tree.get_rows() |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
245 for item in all: |
18722
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
246 item.mark_unread(False) |
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
247 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
|
248 current.mark_unread(False) |
18714
121d1560346c
A few updates to the rss reader.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18682
diff
changeset
|
249 tree.perform_action_key('j') |
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
250 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
|
251 current.mark_unread(True) |
18714
121d1560346c
A few updates to the rss reader.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18682
diff
changeset
|
252 elif text == 'd': |
121d1560346c
A few updates to the rss reader.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18682
diff
changeset
|
253 current.remove() |
121d1560346c
A few updates to the rss reader.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18682
diff
changeset
|
254 tree.perform_action_key('j') |
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
255 else: |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
256 return False |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
257 return True |
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 items = RssTree() |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
260 items.set_property('columns', 1) |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
261 items.set_col_width(0, 40) |
18722
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
262 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
|
263 items.set_show_title(True) |
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
264 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
|
265 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
|
266 |
18722
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
267 size = gnt.screen_size() |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
268 items.set_size(size[0], size[1]) |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
269 |
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
270 #### |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
271 # ]]] 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
|
272 #### |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
273 |
18722
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
274 # |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
275 # 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
|
276 def update_items_title(): |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
277 feed = feeds.active |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
278 if feed: |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
279 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
|
280 else: |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
281 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
|
282 items.draw() |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
283 |
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
284 # The container on the top |
18682
254823d66aa5
The promised cleanups.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18681
diff
changeset
|
285 line = gnt.Line(vertical = False) |
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
286 |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
287 # 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
|
288 details = gnt.TextView() |
18722
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
289 details.set_take_focus(True) |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
290 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
|
291 details.attach_scroll_widget(details) |
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
292 |
18722
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
293 # Category tree |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
294 cat = gnt.Tree() |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
295 cat.set_property('columns', 1) |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
296 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
|
297 cat.set_show_title(True) |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
298 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
|
299 |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
300 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
|
301 box.set_pad(0) |
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
302 |
18722
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
303 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
|
304 vbox.set_pad(0) |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
305 vbox.add_widget(feeds) |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
306 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
|
307 vbox.add_widget(cat) |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
308 box.add_widget(vbox) |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
309 |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
310 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
|
311 |
18722
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
312 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
|
313 vbox.set_pad(0) |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
314 vbox.add_widget(items) |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
315 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
|
316 vbox.add_widget(details) |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
317 box.add_widget(vbox) |
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 win.add_widget(box) |
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
320 win.show() |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
321 |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
322 def update_feed_title(feed, property): |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
323 if property.name == 'title': |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
324 feeds.change_text(feed, 0, feed.title) |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
325 elif property.name == 'unread': |
18722
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
326 feeds.change_text(feed, 1, 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
|
327 if feeds.active == feed: |
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
328 update_items_title() |
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
329 |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
330 # populate everything |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
331 for feed in gntrss.feeds: |
18682
254823d66aa5
The promised cleanups.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18681
diff
changeset
|
332 feed.refresh() |
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
333 add_feed(feed) |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
334 |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
335 gnt.gnt_main() |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
336 |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
337 gnt.gnt_quit() |
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
338 |