1 #!/usr/bin/env python2.5
4 # Copyright (c) 2007-2008 INdT.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Lesser General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # ============================================================================
21 # Author : Yves Marcoz
23 # Description : Simple RSS Reader
24 # ============================================================================
26 from xml.dom.minidom import parse, parseString
28 class OpmlDialog(gtk.Dialog):
29 def parse(self, opmlData):
31 dom1 = parseString(self.opmlData)
33 outlines = dom1.getElementsByTagName('outline')
34 for outline in outlines:
35 title = outline.getAttribute('text')
36 url = outline.getAttribute('xmlUrl')
38 url = outline.getAttribute('htmlUrl')
39 self.feeds.append(title, url)
41 def getFeedLinks(self):
44 def __init__(self, parent, opmlData)
47 gtk.Dialog.__init__(self, "Import OPML Feeds", parent)
49 self.vbox2 = gtk.VBox(False, 10)
51 self.hbox2= gtk.HBox(False, 10)
52 self.pannableArea = hildon.PannableArea()
53 self.treestore = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
54 self.treeview = gtk.TreeView(self.treestore)
55 self.hbox2.pack_start(self.pannableArea, expand=True)
57 self.hbox2.pack_end(self.vbox2, expand=False)
58 self.set_default_size(-1, 600)
59 self.vbox.pack_start(self.hbox2)
63 def displayFeeds(self):
64 self.treeview.destroy()
65 self.treestore = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
66 self.treeview = gtk.TreeView()
68 self.treeview.get_selection().set_mode(gtk.SELECTION_SINGLE)
69 hildon.hildon_gtk_tree_view_set_ui_mode(self.treeview, gtk.HILDON_UI_MODE_EDIT)
71 self.treeview.append_column(gtk.TreeViewColumn('Feed Name', gtk.CellRendererText(), text = 0))
73 self.pannableArea.add(self.treeview)
76 def refreshList(self, selected=None, offset=0):
77 #x = self.treeview.get_visible_rect().x
78 rect = self.treeview.get_visible_rect()
79 y = rect.y+rect.height
80 #self.pannableArea.jump_to(-1, 0)
81 self.treestore = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
82 for (title, url) in self.feeds():
83 item = self.treestore.append([title, url])
84 self.treeview.get_selection().select_iter(item)
85 self.treeview.set_model(self.treestore)
86 self.pannableArea.show_all()
88 def getSelectedItem(self):
89 (model, iter) = self.treeview.get_selection().get_selected()
92 return model.get_value(iter, 1)
94 def findIndex(self, key):
98 for row in self.treestore:
100 return (before, row.iter)
101 if key == list(row)[0]:
105 return (before, None)
107 def buttonDone(self, *args):