Proper startup and text styling for Fremantle
[gpodder.git] / src / gpodder / gtkui / frmntl / opml.py
blob49924b8b372399fbc2c50f3a3f58f3168825f62b
1 # -*- coding: utf-8 -*-
3 # gPodder - A media aggregator and podcast client
4 # Copyright (c) 2005-2009 Thomas Perl and the gPodder Team
6 # gPodder is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # gPodder is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 # gpodder.gtkui.opml - Module for displaying OPML feeds (2009-08-13)
26 import gtk
27 import gobject
29 import gpodder
31 import xml.sax.saxutils
32 import urllib
34 from gpodder.gtkui.frmntl import style
36 class OpmlListModel(gtk.ListStore):
37 C_SELECTED, C_DESCRIPTION_MARKUP, C_URL = range(3)
39 def __init__(self, importer):
40 gtk.ListStore.__init__(self, bool, str, str)
42 head_font = style.get_font_desc('SystemFont')
43 head_color = style.get_color('ButtonTextColor')
44 head = (head_font.to_string(), head_color.to_string())
45 head = '<span font_desc="%s" foreground="%s">%%s</span>' % head
47 sub_font = style.get_font_desc('SmallSystemFont')
48 sub_color = style.get_color('SecondaryTextColor')
49 sub = (sub_font.to_string(), sub_color.to_string())
50 sub = '<span font_desc="%s" foreground="%s">%%s</span>' % sub
51 self._markup_template = '\n'.join((head, sub))
53 for channel in importer.items:
54 self.append([False, self._format_channel(channel), channel['url']])
56 def _format_channel(self, channel):
57 title = xml.sax.saxutils.escape(urllib.unquote_plus(channel['title']))
58 description = xml.sax.saxutils.escape(channel['description'])
59 return self._markup_template % (title, description)