Exemple #1
0
    def __init__(self, shell, plugin):
        gobject.GObject.__init__(self)
        self.shell = shell
        self.sp = shell.get_player()
        self.db = shell.get_property('db')
        self.plugin = plugin

        self.top_five = None
        self.current_artist = None
        self.current_album = None
        self.current_song = None
        self.visible = True

        # cache for artist/album information: valid for a month, can be used indefinitely
        # if offline, discarded if unused for six months
        self.info_cache = rb.URLCache(name='info',
                                      path=os.path.join(
                                          'context-pane', 'info'),
                                      refresh=30,
                                      discard=180)
        # cache for rankings (artist top tracks and top albums): valid for a week,
        # can be used for a month if offline
        self.ranking_cache = rb.URLCache(name='ranking',
                                         path=os.path.join(
                                             'context-pane', 'ranking'),
                                         refresh=7,
                                         lifetime=30)

        # maybe move this into an idle handler?
        self.info_cache.clean()
        self.ranking_cache.clean()

        self.init_gui()
        self.init_tabs()

        self.connect_signals()
        self.load_top_five(self.ds['artist'])

        # Set currently displayed tab
        # TODO: make this persistent via gconf key
        self.current = 'artist'
        self.tab[self.current].activate()

        # Add button to toggle visibility of pane
        self.action = ('ToggleContextView', 'gtk-info',
                       _('Toggle Conte_xt Pane'), None,
                       _('Change the visibility of the context pane'),
                       self.toggle_visibility, True)
        self.action_group = gtk.ActionGroup('ContextPluginActions')
        self.action_group.add_toggle_actions([self.action])
        uim = self.shell.get_ui_manager()
        uim.insert_action_group(self.action_group, 0)
        self.ui_id = uim.add_ui_from_string(context_ui)
        uim.ensure_update()
Exemple #2
0
    def __init__(self, shell, plugin):
        GObject.GObject.__init__(self)
        self.shell = shell
        self.sp = shell.props.shell_player
        self.db = shell.props.db
        self.plugin = plugin

        self.current_artist = None
        self.current_album = None
        self.current_song = None
        self.visible = True

        # cache for artist/album information: valid for a month, can be used indefinitely
        # if offline, discarded if unused for six months
        self.info_cache = rb.URLCache(name='info',
                                      path=os.path.join(
                                          'context-pane', 'info'),
                                      refresh=30,
                                      discard=180)
        # cache for rankings (artist top tracks and top albums): valid for a week,
        # can be used for a month if offline
        self.ranking_cache = rb.URLCache(name='ranking',
                                         path=os.path.join(
                                             'context-pane', 'ranking'),
                                         refresh=7,
                                         lifetime=30)

        # maybe move this into an idle handler?
        self.info_cache.clean()
        self.ranking_cache.clean()

        self.init_gui()
        self.init_tabs()

        self.connect_signals()

        # Set currently displayed tab
        # TODO: make this persistent via gsettings key
        self.current = 'artist'
        self.tab[self.current].activate()

        app = shell.props.application
        action = Gio.SimpleAction.new_stateful("view-context-pane", None,
                                               GLib.Variant.new_boolean(True))
        action.connect("activate", self.toggle_visibility, None)

        window = shell.props.window
        window.add_action(action)

        item = Gio.MenuItem.new(label=_("Context Pane"),
                                detailed_action="win.view-context-pane")
        app.add_plugin_menu_item("view", "view-context-pane", item)
Exemple #3
0
    def __init__(self, shell, source, playlist_name):

        self.shell = shell
        #lets fill up the queue with artists
        self.candidate_artist = {}
        self.shell.props.shell_player.connect('playing-song-changed',
                                              self.playing_song_changed)
        self.source = source
        self.search_entry = None
        self.playlist_started = False
        self.played_artist = {}
        self.tracks_not_played = 0
        # cache for artist information: valid for a month, can be used indefinitely
        # if offline, discarded if unused for six months
        self.info_cache = rb.URLCache(name=playlist_name,
                                      path=os.path.join(
                                          'coverart_browser', playlist_name),
                                      refresh=30,
                                      discard=180)
        self.info_cache.clean()
    def __init__(self, button_box, stack, info_paned, source):
        GObject.GObject.__init__(self)

        self.ds = {}
        self.view = {}

        # self.buttons = button_box
        self.source = source
        self.plugin = source.plugin
        self.shell = source.shell
        self.info_paned = info_paned
        self.current_artist = None
        self.current_album_title = None
        self.current = 'artist'
        self._from_paned_handle = 0

        self.stack = stack
        self.stack.set_transition_type(
            Gtk.StackTransitionType.SLIDE_LEFT_RIGHT)
        stack_switcher = Gtk.StackSwitcher()
        stack_switcher.set_stack(self.stack)
        self.stack.connect('notify::visible-child-name', self.change_stack)
        button_box.pack_start(stack_switcher, False, False, 0)
        button_box.show_all()

        # cache for artist/album information: valid for a month, can be used indefinitely
        # if offline, discarded if unused for six months
        self.info_cache = rb.URLCache(name='info',
                                      path=os.path.join(
                                          'coverart_browser', 'info'),
                                      refresh=30,
                                      discard=180)
        # cache for rankings (artist top tracks and top albums): valid for a week,
        # can be used for a month if offline
        self.ranking_cache = rb.URLCache(name='ranking',
                                         path=os.path.join(
                                             'coverart_browser', 'ranking'),
                                         refresh=7,
                                         lifetime=30)

        self.info_cache.clean()
        self.ranking_cache.clean()

        self.ds['link'] = LinksDataSource()
        self.ds['artist'] = ArtistDataSource(self.info_cache,
                                             self.ranking_cache)

        self.view['artist'] = ArtistInfoView()
        self.view['artist'].initialise(self.source, self.shell, self.plugin,
                                       self.stack, self.ds['artist'],
                                       self.ds['link'])

        self.ds['album'] = AlbumDataSource(self.info_cache, self.ranking_cache)
        self.view['album'] = AlbumInfoView()
        self.view['album'].initialise(self.source, self.shell, self.plugin,
                                      self.stack, self.ds['album'])

        self.ds['echoartist'] = EchoArtistDataSource(self.info_cache,
                                                     self.ranking_cache)
        self.view['echoartist'] = EchoArtistInfoView()
        self.view['echoartist'].initialise(self.source, self.shell,
                                           self.plugin, self.stack,
                                           self.ds['echoartist'],
                                           self.ds['link'])

        self.gs = GSetting()
        self.connect_properties()
        self.connect_signals()
        Gdk.threads_add_timeout(GLib.PRIORITY_DEFAULT_IDLE, 50,
                                self._change_paned_pos,
                                self.source.viewmgr.view_name)
        self.view[self.current].activate()
    def __init__(self, button_box, scroll_window, info_paned, source):
        GObject.GObject.__init__(self)
        self.tab = {}
        self.ds = {}
        self.view = {}

        self.buttons = button_box
        self.source = source
        self.plugin = source.plugin
        self.shell = source.shell
        self.info_scrolled_window = scroll_window
        self.info_paned = info_paned
        self.current_artist = None
        self.current_album_title = None

        self.webview = WebKit.WebView()
        self.webview.connect("navigation-requested",
                             self.navigation_request_cb)
        self.webview.connect("notify::title", self.view_title_change)
        self.info_scrolled_window.set_policy(Gtk.PolicyType.NEVER,
                                             Gtk.PolicyType.AUTOMATIC)
        self.info_scrolled_window.add(self.webview)
        self.info_scrolled_window.show_all()

        # cache for artist/album information: valid for a month, can be used indefinitely
        # if offline, discarded if unused for six months
        self.info_cache = rb.URLCache(name='info',
                                      path=os.path.join(
                                          'coverart_browser', 'info'),
                                      refresh=30,
                                      discard=180)
        # cache for rankings (artist top tracks and top albums): valid for a week,
        # can be used for a month if offline
        self.ranking_cache = rb.URLCache(name='ranking',
                                         path=os.path.join(
                                             'coverart_browser', 'ranking'),
                                         refresh=7,
                                         lifetime=30)

        self.info_cache.clean()
        self.ranking_cache.clean()

        self.ds['link'] = LinksDataSource()
        self.ds['artist'] = ArtistDataSource(self.info_cache,
                                             self.ranking_cache)
        self.view['artist'] = ArtistInfoView(self.shell, self.plugin,
                                             self.webview, self.ds['artist'],
                                             self.ds['link'])
        self.tab['artist'] = ArtistInfoTab(self.plugin, self.shell,
                                           self.buttons, self.ds['artist'],
                                           self.view['artist'])
        self.ds['album'] = AlbumDataSource(self.info_cache, self.ranking_cache)
        self.view['album'] = AlbumInfoView(self.shell, self.plugin,
                                           self.webview, self.ds['album'])
        self.tab['album'] = AlbumInfoTab(self.plugin, self.shell, self.buttons,
                                         self.ds['album'], self.view['album'])
        self.ds['echoartist'] = EchoArtistDataSource(self.info_cache,
                                                     self.ranking_cache)
        self.view['echoartist'] = EchoArtistInfoView(self.shell, self.plugin,
                                                     self.webview,
                                                     self.ds['echoartist'],
                                                     self.ds['link'])
        self.tab['echoartist'] = EchoArtistInfoTab(self.plugin, self.shell,
                                                   self.buttons,
                                                   self.ds['echoartist'],
                                                   self.view['echoartist'])

        self.gs = GSetting()
        self.connect_properties()
        self.connect_signals()
        Gdk.threads_add_timeout(GLib.PRIORITY_DEFAULT_IDLE, 50,
                                self._change_paned_pos,
                                self.source.viewmgr.view_name)
        self.current = 'artist'
        self.tab[self.current].activate()