~ubuntu-branches/ubuntu/natty/miro/natty

« back to all changes in this revision

Viewing changes to lib/frontends/widgets/statictabs.py

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2011-01-22 02:46:33 UTC
  • mfrom: (1.4.10 upstream) (1.7.5 experimental)
  • Revision ID: james.westby@ubuntu.com-20110122024633-kjme8u93y2il5nmf
Tags: 3.5.1-1ubuntu1
* Merge from debian.  Remaining ubuntu changes:
  - Use python 2.7 instead of python 2.6
  - Relax dependency on python-dbus to >= 0.83.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Miro - an RSS based video player application
 
2
# Copyright (C) 2005-2010 Participatory Culture Foundation
 
3
#
 
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.
 
8
#
 
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.
 
13
#
 
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
 
17
#
 
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
 
20
# library.
 
21
#
 
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.
 
28
 
 
29
"""statictabs.py -- Tabs that are always present."""
 
30
 
 
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
 
36
 
 
37
class StaticTab(object):
 
38
    def __init__(self):
 
39
        self.unwatched = self.downloading = 0
 
40
        self.icon = widgetutil.make_surface(self.icon_name)
 
41
 
 
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")
 
45
    }
 
46
 
 
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'
 
50
    }
 
51
 
 
52
class ChannelGuideTab(StaticTab):
 
53
    id = 'guide'
 
54
    name = u''
 
55
    icon_name = 'icon-guide'
 
56
    tall = True
 
57
 
 
58
    def __init__(self):
 
59
        StaticTab.__init__(self)
 
60
        self._set_from_info(app.widgetapp.default_guide_info)
 
61
        self.browser = browser.BrowserNav(app.widgetapp.default_guide_info)
 
62
 
 
63
    def update(self, guide_info):
 
64
        self._set_from_info(guide_info)
 
65
        self.browser.guide_info = guide_info
 
66
 
 
67
    def _set_from_info(self, guide_info):
 
68
        if guide_info is None:
 
69
            return
 
70
 
 
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
 
73
 
 
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]
 
76
        else:
 
77
            self.name = guide_info.name
 
78
 
 
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)
 
86
        else:
 
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,
 
91
                                                  size=(23, 23))
 
92
            else:
 
93
                self.icon = surface
 
94
 
 
95
class SearchTab(StaticTab):
 
96
    id = 'search'
 
97
    name = _('Video Search')
 
98
    icon_name = 'icon-search'
 
99
    tall = True
 
100
 
 
101
class VideoLibraryTab(StaticTab):
 
102
    id = 'videos'
 
103
    name = _('Video')
 
104
    icon_name = 'icon-video'
 
105
    media_type = u'video'
 
106
 
 
107
class AudioLibraryTab(StaticTab):
 
108
    id = 'audios'
 
109
    name = _('Audio')
 
110
    icon_name = 'icon-audio'
 
111
    media_type = u'audio'
 
112
 
 
113
class OtherLibraryTab(StaticTab):
 
114
    id = 'others'
 
115
    name = _('Other')
 
116
    icon_name = 'icon-other'
 
117
    media_type = u'other'
 
118
 
 
119
class DownloadsTab(StaticTab):
 
120
    id = 'downloading'
 
121
    name = _('Downloading')
 
122
    icon_name = 'icon-downloading'
 
123
 
 
124
class VideoConversionsTab(StaticTab):
 
125
    id = 'conversions'
 
126
    name = _('Conversions')
 
127
    icon_name = 'icon-conversions'