コード例 #1
0
ファイル: __init__.py プロジェクト: yellowfour/exaile
    def on_gui_loaded(self):
        save_on_exit = settings.get_option(
            'plugin/history/save_on_exit',
            history_preferences.save_on_exit_default)
        shown = settings.get_option('plugin/history/shown', False)

        # immutable playlist that stores everything we've played
        self.history_loc = os.path.join(xdg.get_data_dir(), 'history')

        self.history_playlist = HistoryPlaylist(player.PLAYER)

        if save_on_exit:
            self.history_playlist.load_from_location(self.history_loc)

        self.history_page = HistoryPlaylistPage(self.history_playlist,
                                                player.PLAYER)
        self.history_tab = NotebookTab(main.get_playlist_notebook(),
                                       self.history_page)

        # add menu item to 'view' to display our playlist
        self.menu = menu.check_menu_item(
            'history',
            '',
            _('Playback history'),
            lambda *e: self.is_shown(),
            self.on_playback_history,
        )

        providers.register('menubar-view-menu', self.menu)

        # add the history playlist to the primary notebook
        if save_on_exit and shown:
            self.show_history(True)
コード例 #2
0
ファイル: __init__.py プロジェクト: exaile/exaile
    def on_gui_loaded(self):
        save_on_exit = settings.get_option(
            'plugin/history/save_on_exit', history_preferences.save_on_exit_default
        )
        shown = settings.get_option('plugin/history/shown', False)

        # immutable playlist that stores everything we've played
        self.history_loc = os.path.join(xdg.get_data_dir(), 'history')

        self.history_playlist = HistoryPlaylist(player.PLAYER)

        if save_on_exit:
            self.history_playlist.load_from_location(self.history_loc)

        self.history_page = HistoryPlaylistPage(self.history_playlist, player.PLAYER)
        self.history_tab = NotebookTab(main.get_playlist_notebook(), self.history_page)

        # add menu item to 'view' to display our playlist
        self.menu = menu.check_menu_item(
            'history',
            '',
            _('Playback history'),
            lambda *e: self.is_shown(),
            self.on_playback_history,
        )

        providers.register('menubar-view-menu', self.menu)

        # add the history playlist to the primary notebook
        if save_on_exit and shown:
            self.show_history(True)
コード例 #3
0
    def create_tab_from_playlist(self, playlist):
        """
            Create a tab that will contain the passed-in playlist

            :param playlist: The playlist to create tab from
            :type playlist: :class:`xl.playlist.Playlist`
        """
        page = PlaylistPage(playlist, self.player)
        tab = NotebookTab(self, page)
        self.add_tab(tab, page)
        return tab
コード例 #4
0
    def __init__(self, manager_name, player):
        Gtk.Box.__init__(self)

        self.notebooks = []
        self.notebooks.append(
            PlaylistNotebook(manager_name, player, '<Primary><Shift>t')
        )
        self.notebooks.append(
            PlaylistNotebook(manager_name + '2', player, '<Primary><Alt>t')
        )

        self.notebooks[1].set_add_tab_on_empty(False)

        # add notebooks to self
        self.pack_start(self.notebooks[0], True, True, 0)

        # setup the paned window for separate views
        self.paned = Gtk.Paned(orientation=Gtk.Orientation.VERTICAL)
        self.paned.pack2(self.notebooks[1], True, True)

        # setup queue page
        self.queuepage = QueuePage(self, player)
        self.queuetab = NotebookTab(None, self.queuepage)
        if len(player.queue) > 0:
            self.show_queue()

        # ensure default notebook always has a tab in it
        if self.notebooks[0].get_n_pages() == 0:
            self.notebooks[0].add_default_tab()

        # menu item
        item = menu.simple_menu_item(
            'move-tab',
            [],
            _('_Move to Other View'),
            None,
            lambda w, n, p, c: self._move_tab(p.tab),
            condition_fn=lambda n, p, c: True
            if p.tab.notebook in self.notebooks
            else False,
        )
        providers.register('playlist-tab-context-menu', item)
        providers.register('queue-tab-context', item)

        # connect events
        for notebook in self.notebooks:
            notebook.connect('page-reordered', self.on_page_reordered)
            notebook.connect_after(
                'page-removed', lambda *a: self._update_notebook_display()
            )

        self._update_notebook_display()
コード例 #5
0
ファイル: __init__.py プロジェクト: yellowfour/exaile
class HistoryPlugin(object):
    '''Implements logic for plugin'''
    def get_preferences_pane(self):
        return history_preferences

    def enable(self, exaile):
        self.exaile = exaile

    def on_gui_loaded(self):
        save_on_exit = settings.get_option(
            'plugin/history/save_on_exit',
            history_preferences.save_on_exit_default)
        shown = settings.get_option('plugin/history/shown', False)

        # immutable playlist that stores everything we've played
        self.history_loc = os.path.join(xdg.get_data_dir(), 'history')

        self.history_playlist = HistoryPlaylist(player.PLAYER)

        if save_on_exit:
            self.history_playlist.load_from_location(self.history_loc)

        self.history_page = HistoryPlaylistPage(self.history_playlist,
                                                player.PLAYER)
        self.history_tab = NotebookTab(main.get_playlist_notebook(),
                                       self.history_page)

        # add menu item to 'view' to display our playlist
        self.menu = menu.check_menu_item(
            'history',
            '',
            _('Playback history'),
            lambda *e: self.is_shown(),
            self.on_playback_history,
        )

        providers.register('menubar-view-menu', self.menu)

        # add the history playlist to the primary notebook
        if save_on_exit and shown:
            self.show_history(True)

    def teardown(self, exaile):
        '''Called when exaile is exiting'''

        if settings.get_option('plugin/history/save_on_exit',
                               history_preferences.save_on_exit_default):
            self.history_playlist.save_to_location(self.history_loc)
            settings.set_option('plugin/history/shown', self.is_shown())
        else:
            settings.set_option('plugin/history/shown', False)

        self.show_history(False)

    def disable(self, exaile):
        '''Called when the plugin is disabled'''
        if self.menu:
            providers.unregister('menubar-view-menu', self.menu)
            self.menu = None

        self.show_history(False)

        if os.path.exists(self.history_loc):
            # TODO: The parent should be the Preferences window, but we don't
            # have access to it, so this just uses the main window.
            dialog = Gtk.MessageDialog(
                exaile.gui.main.window,
                Gtk.DialogFlags.MODAL,
                Gtk.MessageType.QUESTION,
                Gtk.ButtonsType.YES_NO,
                _('Erase stored history?'),
            )

            if dialog.run() == Gtk.ResponseType.YES:
                try:
                    os.unlink(self.history_loc)
                except Exception:
                    pass

            dialog.destroy()

    def is_shown(self):
        return main.get_playlist_notebook().page_num(self.history_page) != -1

    def on_playback_history(self, menu, name, parent, context):
        self.show_history(not self.is_shown())

    def show_history(self, show):

        if show == self.is_shown():
            return

        if show:
            pn = main.get_playlist_notebook()
            pn.add_tab(self.history_tab, self.history_page)
        else:
            self.history_tab.close()
コード例 #6
0
ファイル: __init__.py プロジェクト: che2/exaile
class HistoryPlugin(object):
    '''Implements logic for plugin'''
    
    def get_preferences_pane(self):
        return history_preferences
    
    def enable(self, exaile):
        self.exaile = exaile
    
    def on_gui_loaded(self):
        save_on_exit = settings.get_option('plugin/history/save_on_exit', history_preferences.save_on_exit_default)
        shown = settings.get_option('plugin/history/shown', False)
    
        # immutable playlist that stores everything we've played
        self.history_loc = os.path.join(xdg.get_data_dir(), 'history')
        
        self.history_playlist = HistoryPlaylist( player.PLAYER )
        
        if save_on_exit:
            self.history_playlist.load_from_location( self.history_loc )
        
        self.history_page = HistoryPlaylistPage( self.history_playlist, player.PLAYER )
        self.history_tab = NotebookTab(main.get_playlist_notebook(), self.history_page )
        
        # add menu item to 'view' to display our playlist 
        self.menu = menu.check_menu_item( 'history', '', _('Playback history'), \
            lambda *e: self.is_shown(), self.on_playback_history )
            
        providers.register( 'menubar-view-menu', self.menu )
        
        # add the history playlist to the primary notebook
        if save_on_exit and shown:
            self.show_history( True )
        
    def teardown(self, exaile):
        '''Called when exaile is exiting'''
        
        if settings.get_option('plugin/history/save_on_exit', history_preferences.save_on_exit_default ):
            self.history_playlist.save_to_location( self.history_loc )
            settings.set_option( 'plugin/history/shown', self.is_shown() )
        else:
            settings.set_option( 'plugin/history/shown', False )
            
        self.show_history(False)
    
    def disable(self, exaile):
    
        '''Called when the plugin is disabled'''
        if self.menu:
            providers.unregister( 'menubar-view-menu', self.menu )
            self.menu = None
            
        self.show_history(False)

        if os.path.exists( self.history_loc ):
            # TODO: The parent should be the Preferences window, but we don't
            # have access to it, so this just uses the main window.
            dialog = Gtk.MessageDialog( exaile.gui.main.window, Gtk.DialogFlags.MODAL, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO,
                                        _('Erase stored history?') )
                
            if dialog.run() == Gtk.ResponseType.YES:
                try:
                    os.unlink( self.history_loc )
                except:
                    pass
                    
            dialog.destroy()
        
    def is_shown(self):
        return main.get_playlist_notebook().page_num( self.history_page ) != -1
    
    def on_playback_history(self, menu, name, parent, context):
        self.show_history( not self.is_shown() )
        
    def show_history(self, show):

        if show == self.is_shown():
            return
    
        if show:
            pn = main.get_playlist_notebook()
            pn.add_tab( self.history_tab, self.history_page  )
        else:
            self.history_tab.close()
コード例 #7
0
ファイル: __init__.py プロジェクト: thiblahute/exaile
class HistoryPlugin(object):
    '''Implements logic for plugin'''
    
    def __init__(self, exaile):
    
        self.exaile = exaile
    
        save_on_exit = settings.get_option('plugin/history/save_on_exit', history_preferences.save_on_exit_default)
        shown = settings.get_option('plugin/history/shown', False)
    
        # immutable playlist that stores everything we've played
        self.history_loc = os.path.join(xdg.get_data_dir(), 'history')
        
        self.history_playlist = HistoryPlaylist( player.PLAYER )
        
        if save_on_exit:
            self.history_playlist.load_from_location( self.history_loc )
        
        self.history_page = HistoryPlaylistPage( self.history_playlist, player.PLAYER )
        self.history_tab = NotebookTab(main.get_playlist_notebook(), self.history_page )
        
        # add menu item to 'view' to display our playlist 
        self.menu = menu.check_menu_item( 'history', '', _('Playback history'), \
            lambda *e: self.is_shown(), self.on_playback_history )
            
        providers.register( 'menubar-view-menu', self.menu )
        
        # add the history playlist to the primary notebook
        if save_on_exit and shown:
            self.show_history( True )
        
    def teardown_plugin(self, exaile):
        '''Called when exaile is exiting'''
        
        if settings.get_option('plugin/history/save_on_exit', history_preferences.save_on_exit_default ):
            self.history_playlist.save_to_location( self.history_loc )
            settings.set_option( 'plugin/history/shown', self.is_shown() )
        else:
            settings.set_option( 'plugin/history/shown', False )
            
        self.show_history(False)
    
    def disable_plugin(self, exaile):
    
        '''Called when the plugin is disabled'''
        if self.menu:
            providers.unregister( 'menubar-view-menu', self.menu )
            self.menu = None
            
        self.show_history(False)

        if os.path.exists( self.history_loc ):
        
            dialog = gtk.MessageDialog( None, gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, 
                                        _('Erase stored history?') )
                
            if dialog.run() == gtk.RESPONSE_YES:
                try:
                    os.unlink( self.history_loc )
                except:
                    pass
                    
            dialog.destroy()
        
    def is_shown(self):
        return main.get_playlist_notebook().page_num( self.history_page ) != -1
    
    def on_playback_history(self, menu, name, parent, context):
        self.show_history( not self.is_shown() )
        
    def show_history(self, show):

        if show == self.is_shown():
            return
    
        if show:
            pn = main.get_playlist_notebook()
            pn.add_tab( self.history_tab, self.history_page  )
        else:
            self.history_tab.close()