1
# Miro - an RSS based video player application
2
# Copyright (C) 2005-2010 Participatory Culture Foundation
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
# In addition, as a special exception, the copyright holders give
19
# permission to link the code of portions of this program with the OpenSSL
22
# You must obey the GNU General Public License in all respects for all of
23
# the code used other than OpenSSL. If you modify file(s) with this
24
# exception, you may extend this exception to your version of the file(s),
25
# but you are not obligated to do so. If you do not wish to do so, delete
26
# this exception statement from your version. If you delete this exception
27
# statement from all source files in the program, then also delete it here.
29
"""statictabs.py -- Tabs that are always present."""
31
from miro import app, prefs
32
from miro.gtcache import gettext as _
33
from miro.frontends.widgets import browser
34
from miro.frontends.widgets import imagepool
35
from miro.frontends.widgets import widgetutil
37
class StaticTab(object):
39
self.unwatched = self.downloading = 0
40
self.icon = widgetutil.make_surface(self.icon_name)
42
# this maps guide urls to titles we'd rather they use.
43
_guide_url_to_title_map = {
44
prefs.CHANNEL_GUIDE_URL.default: _("Miro Guide")
47
# this maps guide urls to icons we'd rather they use.
48
_guide_url_to_icon_map = {
49
prefs.CHANNEL_GUIDE_URL.default: 'icon-guide'
52
class ChannelGuideTab(StaticTab):
55
icon_name = 'icon-guide'
59
StaticTab.__init__(self)
60
self._set_from_info(app.widgetapp.default_guide_info)
61
self.browser = browser.BrowserNav(app.widgetapp.default_guide_info)
63
def update(self, guide_info):
64
self._set_from_info(guide_info)
65
self.browser.guide_info = guide_info
67
def _set_from_info(self, guide_info):
68
if guide_info is None:
71
# XXX This code is a bit ugly, because we want to use pretty defaults for
72
# the Miro Guide, but still allow themes to override
74
if guide_info.default and guide_info.url in _guide_url_to_title_map:
75
self.name = _guide_url_to_title_map[guide_info.url]
77
self.name = guide_info.name
79
if guide_info.default and guide_info.url in _guide_url_to_icon_map:
80
# one of our default guides
81
self.icon_name = _guide_url_to_icon_map[guide_info.url]
82
self.icon = widgetutil.make_surface(self.icon_name)
83
elif guide_info.faviconIsDefault:
84
# theme guide that should use default favicon
85
self.icon = widgetutil.make_surface(self.icon_name)
87
# theme guide with a favicon
88
surface = imagepool.get_surface(guide_info.favicon)
89
if surface.width != 23 or surface.height != 23:
90
self.icon = imagepool.get_surface(guide_info.favicon,
95
class SearchTab(StaticTab):
97
name = _('Video Search')
98
icon_name = 'icon-search'
101
class VideoLibraryTab(StaticTab):
104
icon_name = 'icon-video'
105
media_type = u'video'
107
class AudioLibraryTab(StaticTab):
110
icon_name = 'icon-audio'
111
media_type = u'audio'
113
class OtherLibraryTab(StaticTab):
116
icon_name = 'icon-other'
117
media_type = u'other'
119
class DownloadsTab(StaticTab):
121
name = _('Downloading')
122
icon_name = 'icon-downloading'
124
class VideoConversionsTab(StaticTab):
126
name = _('Conversions')
127
icon_name = 'icon-conversions'