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.frmntl.model -- Model customizations for Maemo 5 (2009-11-16)
32 from gpodder
.gtkui
import download
33 from gpodder
.gtkui
import model
34 from gpodder
.gtkui
.frmntl
import style
36 class DownloadStatusModel(download
.DownloadStatusModel
):
38 download
.DownloadStatusModel
.__init
__(self
)
39 head_font
= style
.get_font_desc('SystemFont')
40 head_color
= style
.get_color('ButtonTextColor')
41 head
= (head_font
.to_string(), head_color
.to_string())
42 head
= '<span font_desc="%s" foreground="%s">%%s</span>' % head
43 sub_font
= style
.get_font_desc('SmallSystemFont')
44 sub_color
= style
.get_color('SecondaryTextColor')
45 sub
= (sub_font
.to_string(), sub_color
.to_string())
46 sub
= '<span font_desc="%s" foreground="%s">%%s - %%s</span>' % sub
47 self
._markup
_template
= '\n'.join((head
, sub
))
49 def _format_message(self
, episode
, message
, podcast
):
50 return self
._markup
_template
% (episode
, message
, podcast
)
53 class EpisodeListModel(model
.EpisodeListModel
):
55 model
.EpisodeListModel
.__init
__(self
)
57 normal_font
= style
.get_font_desc('SystemFont')
58 normal_color
= style
.get_color('DefaultTextColor')
59 normal
= (normal_font
.to_string(), normal_color
.to_string())
60 self
._normal
_markup
= '<span font_desc="%s" foreground="%s">%%s</span>' % normal
62 active_font
= style
.get_font_desc('SystemFont')
63 active_color
= style
.get_color('ActiveTextColor')
64 active
= (active_font
.to_string(), active_color
.to_string())
65 self
._active
_markup
= '<span font_desc="%s" foreground="%s">%%s</span>' % active
67 sub_font
= style
.get_font_desc('SmallSystemFont')
68 sub_color
= style
.get_color('SecondaryTextColor')
69 sub
= (sub_font
.to_string(), sub_color
.to_string())
70 sub
= '\n<span font_desc="%s" foreground="%s">%%s</span>' % sub
72 self
._unplayed
_markup
= self
._normal
_markup
+ sub
73 self
._active
_markup
+= sub
75 def _format_description(self
, episode
, include_description
=False, is_downloading
=None):
76 if is_downloading
is not None and is_downloading(episode
):
77 sub
= _('in downloads list')
78 return self
._unplayed
_markup
% (cgi
.escape(episode
.title
), sub
)
79 elif episode
.is_played
:
80 return self
._normal
_markup
% (cgi
.escape(episode
.title
),)
82 if episode
.was_downloaded(and_exists
=True):
83 sub
= _('unplayed download')
85 sub
= _('new episode')
87 return self
._active
_markup
% (cgi
.escape(episode
.title
), sub
)
90 class PodcastListModel(model
.PodcastListModel
):
91 def __init__(self
, *args
):
92 model
.PodcastListModel
.__init
__(self
, *args
)
94 normal_font
= style
.get_font_desc('SystemFont')
95 normal_color
= style
.get_color('DefaultTextColor')
96 normal
= (normal_font
.to_string(), normal_color
.to_string())
97 self
._normal
_markup
= '<span font_desc="%s" foreground="%s">%%s</span>' % normal
99 active_font
= style
.get_font_desc('SystemFont')
100 active_color
= style
.get_color('ActiveTextColor')
101 active
= (active_font
.to_string(), active_color
.to_string())
102 self
._active
_markup
= '<span font_desc="%s" foreground="%s">%%s</span>' % active
104 sub_font
= style
.get_font_desc('SmallSystemFont')
105 sub_color
= style
.get_color('SecondaryTextColor')
106 sub
= (sub_font
.to_string(), sub_color
.to_string())
107 sub
= '\n<span font_desc="%s" foreground="%s">%%s</span>' % sub
109 self
._unplayed
_markup
= self
._normal
_markup
+ sub
110 self
._active
_markup
+= sub
112 def _format_description(self
, channel
, total
, deleted
, \
113 new
, downloaded
, unplayed
):
114 title_markup
= cgi
.escape(channel
.title
)
115 if not unplayed
and not new
:
116 return self
._normal
_markup
% title_markup
118 new_text
= N_('%d new episode', '%d new episodes', new
) % new
119 unplayed_text
= N_('%d unplayed download', '%d unplayed downloads', unplayed
) % unplayed
121 return self
._active
_markup
% (title_markup
, ', '.join((new_text
, unplayed_text
)))
123 return self
._active
_markup
% (title_markup
, new_text
)
125 return self
._unplayed
_markup
% (title_markup
, unplayed_text
)