예제 #1
0
파일: __init__.py 프로젝트: exaile/exaile
    def __init__(self, exaile):
        self.exaile = exaile
        self.do_shutdown = False

        # add menuitem to tools menu
        providers.register(
            'menubar-tools-menu',
            menu.simple_separator('plugin-sep', ['track-properties']),
        )

        item = menu.check_menu_item(
            'shutdown',
            ['plugin-sep'],
            _('Shutdown after Playback'),
            #   checked func                # callback func
            lambda *x: self.do_shutdown,
            lambda w, n, p, c: self.on_toggled(w),
        )
        providers.register('menubar-tools-menu', item)

        self.countdown = None
        self.counter = 10

        self.message = dialogs.MessageBar(
            parent=exaile.gui.builder.get_object('player_box'),
            buttons=Gtk.ButtonsType.CLOSE,
        )
        self.message.connect('response', self.on_response)
예제 #2
0
def on_gui_loaded(*args):
    """
        Creates the main menu button
        which takes care of the rest
    """

    providers.register('main-panel-actions', MainMenuButton)
예제 #3
0
파일: playback.py 프로젝트: dangmai/exaile
def __create_progressbar_context_menu():
    items = []

    items.append(NewMarkerMenuItem('new-marker', []))

    for item in items:
        providers.register('progressbar-context-menu', item)
예제 #4
0
파일: __init__.py 프로젝트: exaile/exaile
    def __init__(self, exaile):
        """
            Connects events to the player object, loads settings and cache
        """
        scrobbler.set_user_agent(exaile.get_user_agent_string('audioscrobbler'))
        self.connected = False
        self.connecting = False
        self.use_menu = False
        self.exaile = exaile
        self.cachefile = os.path.join(xdg.get_data_dirs()[0], "audioscrobbler.cache")
        self.get_options('', '', 'plugin/ascrobbler/cache_size')
        self.get_options('', '', 'plugin/ascrobbler/user')
        self.load_cache()
        event.add_ui_callback(self.get_options, 'plugin_ascrobbler_option_set')
        event.add_callback(self._save_cache_cb, 'quit_application')

        # enable accelerator
        def toggle_submit(*x):
            logger.debug('Toggling AudioScrobbler submissions.')
            settings.set_option('plugin/ascrobbler/submit', not self.submit)

        self.accelerator = Accelerator(
            '<Primary>b', _('Toggle AudioScrobbler submit'), toggle_submit
        )
        providers.register('mainwindow-accelerators', self.accelerator)
예제 #5
0
파일: menu.py 프로젝트: thiblahute/exaile
def __create_view_menu():
    items = []
    accelerators = []

    def show_playing_track_cb(*args):
        get_main().playlist_container.show_current_track()
    items.append(menuitems.ShowCurrentTrackMenuItem('show-playing-track', [],
        show_playing_track_cb, accelerator='<Control>j'))
    accelerators.append(Accelerator('<Control>j', show_playing_track_cb))

    items.append(_sep('show-playing-track-sep', [items[-1].name]))

    def playlist_utilities_cb(widget, name, parent, context):
        settings.set_option('gui/playlist_utilities_bar_visible',
            widget.get_active())
    def playlist_utilities_is_checked(name, parent, context):
        return settings.get_option('gui/playlist_utilities_bar_visible', True)
    items.append(menu.check_menu_item('playlist-utilities', [items[-1].name],
        _("_Playlist Utilities Bar"), playlist_utilities_is_checked, playlist_utilities_cb))

    items.append(_smi('columns', [items[-1].name], _('_Columns'),
        submenu=menu.ProviderMenu('playlist-columns-menu', get_main())))

    def clear_playlist_cb(*args):
        page = get_main().get_selected_page()
        if page:
            page.playlist.clear()
    items.append(_smi('clear-playlist', [items[-1].name], _('C_lear playlist'),
         gtk.STOCK_CLEAR, clear_playlist_cb, accelerator='<Control>l'))
    accelerators.append(Accelerator('<Control>l', clear_playlist_cb))

    for item in items:
        providers.register('menubar-view-menu', item)
    for accelerator in accelerators:
        providers.register('mainwindow-accelerators', accelerator)
예제 #6
0
파일: menu.py 프로젝트: thiblahute/exaile
def __create_edit_menu():
    items = []
    accelerators = []

    def collection_manager_cb(*args):
        from xlgui import get_controller
        get_controller().collection_manager()
    items.append(_smi('collection-manager', [], _("_Collection"), None, collection_manager_cb))

    def queue_cb(*args):
        get_main().playlist_container.show_queue()
    items.append(_smi('queue', [items[-1].name], _("_Queue"),
        callback=queue_cb, accelerator='<Control>m'))
    accelerators.append(Accelerator('<Control>m', queue_cb))

    def cover_manager_cb(*args):
        from xlgui.cover import CoverManager
        dialog = CoverManager(get_main().window, get_main().collection)
    items.append(_smi('cover-manager', [items[-1].name], _("C_overs"), None, cover_manager_cb))

    def preferences_cb(*args):
        from xlgui.preferences import PreferencesDialog
        dialog = PreferencesDialog(get_main().window, get_main().controller)
        dialog.run()
    items.append(_smi('preferences', [items[-1].name],
        icon_name=gtk.STOCK_PREFERENCES, callback=preferences_cb))

    for item in items:
        providers.register('menubar-edit-menu', item)
    for accelerator in accelerators:
        providers.register('mainwindow-accelerators', accelerator)
예제 #7
0
def enable(exaile):
    """
        Enables the plugin
    """
    global MENU_ITEM
    MENU_ITEM = RepeatSegmentMenuItem()
    providers.register('progressbar-context-menu', MENU_ITEM)
예제 #8
0
파일: __init__.py 프로젝트: exaile/exaile
    def on_gui_loaded(self):
        event.add_callback(self.__on_settings_changed, 'plugin_daapclient_option_set')

        menu_ = menu.Menu(None)

        providers.register(
            'menubar-tools-menu', _sep('plugin-sep', ['track-properties'])
        )

        item = _smi('daap', ['plugin-sep'], _('Connect to DAAP...'), submenu=menu_)
        providers.register('menubar-tools-menu', item)

        if AVAHI:
            try:
                avahi_interface = DaapAvahiInterface(self.__exaile, menu_)
            except RuntimeError:  # no dbus?
                avahi_interface = None
                logger.warning('avahi interface could not be initialized (no dbus?)')
            except dbus.exceptions.DBusException as s:
                avahi_interface = None
                logger.error('Got DBUS error: %s' % s)
                logger.error('is avahi-daemon running?')
        else:
            avahi_interface = None
            logger.warn(
                'AVAHI could not be imported, you will not see broadcast shares.'
            )

        self.__manager = DaapManager(self.__exaile, menu_, avahi_interface)
예제 #9
0
def __create_tools_menu():
    items = []
    items.append(
        _smi(
            'device-manager',
            [],
            _('_Device Manager'),
            'multimedia-player',
            lambda *x: get_main().controller.show_devices(),
        )
    )

    items.append(
        _smi(
            'scan-collection',
            [items[-1].name],
            _('_Rescan Collection'),
            'view-refresh',
            get_main().controller.on_rescan_collection,
        )
    )

    items.append(
        _smi(
            'slow-scan-collection',
            [items[-1].name],
            _('Rescan Collection (_slow)'),
            'view-refresh',
            get_main().controller.on_rescan_collection_forced,
        )
    )

    for item in items:
        providers.register('menubar-tools-menu', item)
예제 #10
0
    def add_station(self, station):
        """
            Adds a station to the manager

            @param station: The station to add
        """
        providers.register(self.servicename, station)
예제 #11
0
    def __init__(self, location):
        """
            :param location: The directory to load and store data in.
        """
        providers.ProviderHandler.__init__(self, "covers")
        self.__cache = Cacher(os.path.join(location, 'cache'))
        self.location = location
        self.methods = {}
        self.order = settings.get_option(
                'covers/preferred_order', [])
        self.db = {}
        self.load()
        for method in self.get_providers():
            self.on_provider_added(method)

        default_cover_file = open(xdg.get_data_path('images', 'nocover.png'), 'rb')
        self.default_cover_data = default_cover_file.read()
        default_cover_file.close()

        self.tag_fetcher = TagCoverFetcher()
        self.localfile_fetcher = LocalFileCoverFetcher()

        if settings.get_option('covers/use_tags', True):
            providers.register('covers', self.tag_fetcher)
        if settings.get_option('covers/use_localfile', True):
            providers.register('covers', self.localfile_fetcher)

        event.add_callback(self._on_option_set, 'covers_option_set')
예제 #12
0
 def __create_pre_init_menu_item(self):
     self.premenu=menu.simple_menu_item('Connect to Douban.fm',[],_('_Connect to Douban.fm'),
                                        gtk.STOCK_ADD, lambda e,r,t,y:self.do_init(),
                                        accelerator='<Control>C')
     self.accelerator_pre = Accelerator('<Control>C',lambda e,r,t,y:self.do_init())
     providers.register('menubar-file-menu',self.premenu)
     providers.register('mainwindow-accelerators', self.accelerator_pre)
예제 #13
0
    def do_init(self, captcha_id=None, captcha_solution=None):
        username = settings.get_option("plugin/douban_radio/username")
        password = settings.get_option("plugin/douban_radio/password")
        try:
            self.doubanfm = DoubanFM(username, password, captcha_id, captcha_solution)
        except DoubanLoginException as e:
            if e.data['captcha_id'] is None:
                self.exaile.gui.main.message.show_error(
                    _('Douban FM Error'),
                    _('Failed to login to douban.fm with your credential'))
                return
            else:
                captcha_id = e.data['captcha_id']
                self.show_captcha_dialog(captcha_id)
                return

        self.channels = self.doubanfm.channels

        self.__create_menu_item__()

        self.check_to_enable_dbus()

        self.__register_events()

        self.doubanfm_cover = DoubanFMCover()
        providers.register('covers', self.doubanfm_cover)

        self.doubanfm_mode = DoubanFMMode(self.exaile, self)
예제 #14
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)
예제 #15
0
def __create_help_menu():
    items = []
    accelerators = []
    
    def show_report_issue(*args):
        webbrowser.open('https://github.com/exaile/exaile/issues')
        
    def show_user_guide(*args):
        # TODO: Other languages
        webbrowser.open('http://exaile.readthedocs.org/en/latest/user/index.html')
    
    def show_about_dialog(widget, name, parent, context):
        dialog = dialogs.AboutDialog(parent.window)
        dialog.show()
    
    items.append(_smi('guide', [], _("User's Guide (website)"), 'help',
        show_user_guide))
    items.append(_smi('report', [items[-1].name], _("Report an issue (GitHub)"), None,
        show_report_issue))
    items.append(_sep('about-sep', [items[-1].name]))
    items.append(_smi('about', [items[-1].name], _("_About"), 'help-about',
        show_about_dialog))
    for item in items:
        providers.register('menubar-help-menu', item)
    for accelerator in accelerators:
        providers.register('mainwindow-accelerators', accelerator)
예제 #16
0
파일: playback.py 프로젝트: exaile/exaile
def __create_marker_context_menu():
    items = []

    def on_jumpto_item_activate(widget, name, parent, context):
        # parent.seek(context['current-marker'].props.position)
        position = context['current-marker'].props.position
        player.PLAYER.set_progress(position)

    def on_remove_item_activate(widget, name, parent, context):
        providers.unregister('playback-markers', context['current-marker'])

    items.append(
        menu.simple_menu_item(
            'jumpto-marker', [], _("_Jump to"), 'go-jump', on_jumpto_item_activate
        )
    )
    items.append(MoveMarkerMenuItem('move-marker', [items[-1].name]))
    items.append(
        menu.simple_menu_item(
            'remove-marker',
            [items[-1].name],
            _("_Remove Marker"),
            'list-remove',
            on_remove_item_activate,
        )
    )

    for item in items:
        providers.register('playback-marker-context-menu', item)
예제 #17
0
파일: __init__.py 프로젝트: exaile/exaile
    def on_gui_loaded(self):

        # add a thing to the view menu
        self.menu = menu.simple_menu_item(
            'developer', '', _('Developer Tools'), callback=self.on_view_menu
        )

        providers.register('menubar-tools-menu', self.menu)
예제 #18
0
    def _init_gui(self):
    
        self.pane = gtk.HPaned()
        
        # stolen from main
        self.info_area = main.MainWindowTrackInfoPane(self.player)
        self.info_area.set_auto_update(True)
        self.info_area.set_padding(3, 3, 3, 3)
        self.info_area.hide_all()
        self.info_area.set_no_show_all(True)

        volume_control = playback.VolumeControl(self.player)
        self.info_area.get_action_area().pack_start(volume_control)
        
        self.playpause_button = gtk.Button()
        self.playpause_button.set_relief(gtk.RELIEF_NONE)
        self._on_playback_end(None, None, None)
        self.playpause_button.connect('button-press-event', self._on_playpause_button_clicked)
        
        progress_bar = playback.SeekProgressBar(self.player, use_markers=False)
        
        play_toolbar = gtk.HBox()
        play_toolbar.pack_start(self.playpause_button, expand=False, fill=False)
        play_toolbar.pack_start(progress_bar)
        
        # stick our player controls into this box
        self.pane1_box = gtk.VBox()
        
        self.pane2_box = gtk.VBox()
        self.pane2_box.pack_start(self.info_area, expand=False, fill=False)
        self.pane2_box.pack_start(play_toolbar, expand=False, fill=False) 
        
        self.pane.pack1(self.pane1_box, resize=True, shrink=True)
        self.pane.pack2(self.pane2_box, resize=True, shrink=True)
        
        # setup menus
        
        # add menu item to 'view' to display our playlist 
        self.menu = menu.check_menu_item('preview_player', '', _('Preview Player'), \
            lambda *e: self.hooked, self._on_view )
            
        providers.register('menubar-view-menu', self.menu)
        
        self.preview_menuitem = menu.simple_menu_item('_preview', ['enqueue'], 
                _('Preview'), callback=self._on_preview,
                condition_fn=lambda n,p,c: not c['selection-empty'])
        
        # TODO: Setup on other context menus
        self.preview_provides = [ 'track-panel-menu',
                                  'playlist-context-menu']
        
        for provide in self.preview_provides:
            providers.register(provide, self.preview_menuitem)
        
        self._on_option_set('gui_option_set', settings, 'gui/show_info_area')
        self._on_option_set('gui_option_set', settings, 'gui/show_info_area_covers')
        event.add_callback(self._on_option_set, 'option_set')
예제 #19
0
파일: __init__.py 프로젝트: exaile/exaile
def on_gui_loaded(*args):
    """
        Creates the main menu button
        which takes care of the rest
    """
    if EXAILE.gui.panel_notebook.get_n_pages() == 0:
        raise Exception(_("This plugin needs at least one visible panel"))

    providers.register('main-panel-actions', MainMenuButton)
예제 #20
0
    def on_activate(self, widget, parent, context):
        """
            Inserts the beginning (A) marker
        """
        self.beginning_marker.props.position = context['current-position']
        providers.register('playback-markers', self.beginning_marker)
        context['current-marker'] = self.beginning_marker

        playback.MoveMarkerMenuItem.on_activate(self, widget,
            parent, context)
예제 #21
0
def _enable(eventname, exaile, nothing):
    global JAMENDO_NOTEBOOK_PAGE, COVERS_METHOD
    
    user_agent = exaile.get_user_agent_string('jamendo')
    jamapi.set_user_agent(user_agent)
    
    JAMENDO_NOTEBOOK_PAGE = JamendoPanel(exaile.gui.main.window, exaile)
    COVERS_METHOD = JamendoCoverSearch(user_agent)
    providers.register('main-panel', JAMENDO_NOTEBOOK_PAGE)
    providers.register('covers', COVERS_METHOD)
예제 #22
0
파일: __init__.py 프로젝트: Zarokka/exaile
def enable(exaile):
    """
        Enables the lyrics mania plugin that fetches track lyrics
        from lyricsmania.com
    """
    if lxml:
        providers.register('lyrics', LyricsMania(exaile))
    else:
        raise NotImplementedError('LXML is not available.')
        return False
예제 #23
0
 def on_gui_loaded(self):
     providers.register('mainwindow-info-area-widget', self)
     
     if autodetect_enabled:
         self.menuitem = menu.simple_menu_item('_bpm', ['enqueue'],
             _('Autodetect BPM'), callback=self.on_auto_menuitem,
             condition_fn=lambda n, p, c: not c['selection-empty'])
         
         for p in menu_providers:
             providers.register(p, self.menuitem)
예제 #24
0
파일: __init__.py 프로젝트: exaile/exaile
def enable(exaile):
    """
        Enables the lyric wiki plugin that fetches track lyrics
        from lyrics.wikia.com
    """
    if BeautifulSoup:
        providers.register('lyrics', LyricWiki(exaile))
    else:
        raise NotImplementedError('BeautifulSoup is not available.')
        return False
예제 #25
0
def __create_edit_menu():
    items = []
    accelerators = []

    def collection_manager_cb(*args):
        from xlgui import get_controller

        get_controller().collection_manager()

    items.append(
        _smi('collection-manager', [], _("_Collection"), None, collection_manager_cb)
    )

    def queue_cb(*args):
        get_main().playlist_container.show_queue()

    accelerators.append(Accelerator('<Primary>m', _("_Queue"), queue_cb))
    items.append(_smi('queue', [items[-1].name], callback=accelerators[-1]))

    def cover_manager_cb(*args):
        from xlgui.cover import CoverManager

        CoverManager(get_main().window, get_main().collection)

    items.append(
        _smi(
            'cover-manager',
            [items[-1].name],
            _("C_overs"),
            'image-x-generic',
            cover_manager_cb,
        )
    )

    def preferences_cb(*args):
        from xlgui.preferences import PreferencesDialog

        dialog = PreferencesDialog(get_main().window, get_main().controller)
        dialog.run()

    items.append(
        _smi(
            'preferences',
            [items[-1].name],
            _("_Preferences"),
            'preferences-system',
            preferences_cb,
        )
    )

    for item in items:
        providers.register('menubar-edit-menu', item)
    for accelerator in accelerators:
        providers.register('mainwindow-accelerators', accelerator)
예제 #26
0
 def _on_option_set(self, name, obj, data):
     if data == "covers/use_tags":
         if settings.get_option("covers/use_tags"):
             providers.register('covers', self.tag_fetcher)
         else:
             providers.unregister('covers', self.tag_fetcher)
     elif data == "covers/use_localfile":
         if settings.get_option("covers/use_localfile"):
             providers.register('covers', self.localfile_fetcher)
         else:
             providers.unregister('covers', self.localfile_fetcher)
예제 #27
0
    def save_closed_tab(self, playlist):
        # don't let the list grow indefinitely
        if len(self.tab_history) > settings.get_option('gui/max_closed_tabs', 10):
            self.remove_closed_tab(-1)  # remove last item

        item_name = 'playlist%05d' % self.history_counter
        close_time = datetime.now()
        # define a MenuItem factory that supports dynamic labels

        def factory(menu_, parent, context):
            item = None

            dt = datetime.now() - close_time
            if dt.seconds > 60:
                display_name = _(
                    '{playlist_name} ({track_count} tracks, closed {minutes} min ago)'
                ).format(
                    playlist_name=playlist.name,
                    track_count=len(playlist),
                    minutes=dt.seconds // 60,
                )
            else:
                display_name = _(
                    '{playlist_name} ({track_count} tracks, closed {seconds} sec ago)'
                ).format(
                    playlist_name=playlist.name,
                    track_count=len(playlist),
                    seconds=dt.seconds,
                )
            item = Gtk.ImageMenuItem.new_with_mnemonic(display_name)
            item.set_image(
                Gtk.Image.new_from_icon_name('music-library', Gtk.IconSize.MENU)
            )

            # Add accelerator to top item
            if self.tab_history[0][1].name == item_name:
                key, mods = Gtk.accelerator_parse(self.accelerator.keys)
                item.add_accelerator(
                    'activate', menu.FAKEACCELGROUP, key, mods, Gtk.AccelFlags.VISIBLE
                )

            item.connect(
                'activate', lambda w: self.restore_closed_tab(item_name=item_name)
            )

            return item

        # create menuitem
        item = menu.MenuItem(item_name, factory, [])
        providers.register('playlist-closed-tab-menu', item, self)
        self.history_counter -= 1

        # add
        self.tab_history.insert(0, (playlist, item))
예제 #28
0
파일: __init__.py 프로젝트: exaile/exaile
 def on_gui_loaded(self):
     """
         Called when the player is loaded.
     """
     # add menu item to tools menu
     self.__menu_item = menu.simple_menu_item(
         'equalizer',
         ['plugin-sep'],
         _('_Equalizer'),
         callback=lambda *x: self.__show_gui(),
     )
     providers.register('menubar-tools-menu', self.__menu_item)
예제 #29
0
파일: menu.py 프로젝트: thiblahute/exaile
def __create_help_menu():
    items = []
    accelerators = []
    def show_about_dialog(widget, name, parent, context):
        dialog = dialogs.AboutDialog(parent.window)
        dialog.show()
    items.append(_smi('about', [], icon_name=gtk.STOCK_ABOUT,
        callback=show_about_dialog))
    for item in items:
        providers.register('menubar-help-menu', item)
    for accelerator in accelerators:
        providers.register('mainwindow-accelerators', accelerator)
예제 #30
0
파일: __init__.py 프로젝트: Zarokka/exaile
def _enable(exaile):
    """
        Enable plugin.
            Create menu item.
    """
    # add menuitem to tools menu
    item = menu.simple_menu_item('ipconsole', ['plugin-sep'], _('Show _IPython Console'),
        callback=lambda *x: show_console(exaile)) 
    providers.register('menubar-tools-menu', item)
    
    if settings.get_option('plugin/ipconsole/autostart', False):
        show_console(exaile)
예제 #31
0
def register():
    """
        Registers all control providers
    """
    for control_type in control_types:
        providers.register('minimode-controls', control_type)
예제 #32
0
 def on_gui_loaded(self):
     self.__menu_item = RepeatSegmentMenuItem()
     providers.register('progressbar-context-menu', self.__menu_item)
예제 #33
0
파일: main.py 프로젝트: yellowfour/exaile
    def _setup_hotkeys(self):
        """
            Sets up accelerators that haven't been set up in UI designer
        """
        def factory(integer, description):
            """ Generate key bindings for Alt keys """
            keybinding = '<Alt>%s' % str(integer)
            callback = lambda *_e: self._on_focus_playlist_tab(integer - 1)
            return (keybinding, description, callback)

        hotkeys = (
            (
                '<Primary>S',
                _('Save currently selected playlist'),
                lambda *_e: self.on_save_playlist(),
            ),
            (
                '<Shift><Primary>S',
                _('Save currently selected playlist under a custom name'),
                lambda *_e: self.on_save_playlist_as(),
            ),
            (
                '<Primary>F',
                _('Focus filter in currently focused panel'),
                lambda *_e: self.on_panel_filter_focus(),
            ),
            (
                '<Primary>G',
                _('Focus playlist search'),
                lambda *_e: self.on_search_playlist_focus(),
            ),  # FIXME
            (
                '<Primary><Alt>l',
                _('Clear queue'),
                lambda *_e: player.QUEUE.clear(),
            ),  # FIXME
            (
                '<Primary>P',
                _('Start, pause or resume the playback'),
                self._on_playpause_button,
            ),
            (
                '<Primary>Right',
                _('Seek to the right'),
                lambda *_e: self._on_seek_key(True),
            ),
            (
                '<Primary>Left',
                _('Seek to the left'),
                lambda *_e: self._on_seek_key(False),
            ),
            (
                '<Primary>plus',
                _('Increase the volume'),
                lambda *_e: self._on_volume_key(True),
            ),
            (
                '<Primary>equal',
                _('Increase the volume'),
                lambda *_e: self._on_volume_key(True),
            ),
            (
                '<Primary>minus',
                _('Decrease the volume'),
                lambda *_e: self._on_volume_key(False),
            ),
            ('<Primary>Page_Up', _('Switch to previous tab'),
             self._on_prev_tab_key),
            ('<Primary>Page_Down', _('Switch to next tab'),
             self._on_next_tab_key),
            (
                '<Alt>N',
                _('Focus the playlist container'),
                self._on_focus_playlist_container,
            ),
            # These 4 are subject to change.. probably should do this
            # via a different mechanism too...
            (
                '<Alt>I',
                _('Focus the files panel'),
                lambda *_e: self.controller.focus_panel('files'),
            ),
            # ('<Alt>C', _('Focus the collection panel'),  # TODO: Does not work, why?
            # lambda *_e: self.controller.focus_panel('collection')),
            (
                '<Alt>R',
                _('Focus the radio panel'),
                lambda *_e: self.controller.focus_panel('radio'),
            ),
            (
                '<Alt>L',
                _('Focus the playlists panel'),
                lambda *_e: self.controller.focus_panel('playlists'),
            ),
            factory(1, _('Focus the first tab')),
            factory(2, _('Focus the second tab')),
            factory(3, _('Focus the third tab')),
            factory(4, _('Focus the fourth tab')),
            factory(5, _('Focus the fifth tab')),
            factory(6, _('Focus the sixth tab')),
            factory(7, _('Focus the seventh tab')),
            factory(8, _('Focus the eighth tab')),
            factory(9, _('Focus the ninth tab')),
            factory(0, _('Focus the tenth tab')),
        )

        for keys, helptext, function in hotkeys:
            accelerator = Accelerator(keys, helptext, function)
            providers.register('mainwindow-accelerators', accelerator)
예제 #34
0
            :return: tuple of lyrics text, provider name, URL
            :rtype: Tuple[unicode, basestring, basestring]
            :raise: LyricsNotFoundException if not found
        """
        raise NotImplementedError

    def _set_manager(self, manager):
        """
            Sets the lyrics manager.

            Called when this method is added to the lyrics manager.

            :param manager: the lyrics manager
        """
        self.manager = manager


class LocalLyricSearch(LyricSearchMethod):

    name = "__local"
    display_name = _("Local")

    def find_lyrics(self, track):
        lyrics = track.get_tag_disk('lyrics')
        if not lyrics:
            raise LyricsNotFoundException()
        return (lyrics[0], self.name, "")


providers.register('lyrics', LocalLyricSearch())
예제 #35
0
파일: __init__.py 프로젝트: twa022/exaile
def enable(exaile):
    """
        Enables the plugin
    """
    providers.register('covers', MusicBrainzCoverSearch(exaile))
예제 #36
0
def __register_playlist_columns_menuitems():
    """
        Registers standard menu items for playlist columns
    """
    def is_column_selected(name, parent, context):
        """
            Returns whether a menu item should be checked
        """
        return name in settings.get_option('gui/columns', DEFAULT_COLUMNS)

    def is_resizable(name, parent, context):
        """
            Returns whether manual or automatic sizing is requested
        """
        resizable = settings.get_option('gui/resizable_cols', False)

        if name == 'resizable':
            return resizable
        elif name == 'autosize':
            return not resizable

    def on_column_item_activate(menu_item, name, parent, context):
        """
            Updates columns setting
        """
        columns = settings.get_option('gui/columns', DEFAULT_COLUMNS)

        if name in columns:
            columns.remove(name)
        else:
            columns.append(name)

        settings.set_option('gui/columns', columns)

    def on_sizing_item_activate(menu_item, name, parent, context):
        """
            Updates column sizing setting
        """

        # Ignore the activation if the menu item is not actually active
        if not menu_item.get_active():
            return

        if name == 'resizable':
            settings.set_option('gui/resizable_cols', True)
        elif name == 'autosize':
            settings.set_option('gui/resizable_cols', False)

    columns = [
        'tracknumber',
        'title',
        'artist',
        'album',
        '__length',
        'genre',
        '__rating',
        'date',
    ]

    for provider in providers.get('playlist-columns'):
        if provider.name not in columns:
            columns += [provider.name]

    menu_items = []
    after = []

    for name in columns:
        column = providers.get_provider('playlist-columns', name)
        menu_item = ColumnMenuItem(column, after)
        menu_items += [menu_item]
        after = [menu_item.name]

    separator_item = menu.simple_separator('columns_separator', after)
    menu_items += [separator_item]
    after = [separator_item.name]

    sizing_item = menu.radio_menu_item(
        'resizable',
        after,
        _('_Resizable'),
        'column-sizing',
        is_resizable,
        on_sizing_item_activate,
    )
    menu_items += [sizing_item]
    after = [sizing_item.name]

    sizing_item = menu.radio_menu_item(
        'autosize',
        after,
        _('_Autosize'),
        'column-sizing',
        is_resizable,
        on_sizing_item_activate,
    )
    menu_items += [sizing_item]

    for menu_item in menu_items:
        providers.register('playlist-columns-menu', menu_item)
예제 #37
0
    def __init__(self, exaile):
        """
            Sets up the mini mode main window and
            options to access it
        """
        Gtk.Window.__init__(self)
        self.set_title('Exaile Mini Mode')
        self.set_resizable(False)

        self.exaile_window = exaile.gui.main.window

        controls.register()

        self.box = controls.ControlBox()
        self.box.set_spacing(3)
        alignment = Gtk.Alignment.new(1, 1, 0, 0)
        alignment.set_padding(0, 0, 3, 3)
        alignment.add(self.box)
        self.border_frame = Gtk.Frame()
        self.border_frame.add(alignment)
        self.add(self.border_frame)

        self.menuitem = menu.simple_menu_item(
            'minimode', ['clear-playlist'],
            _('Mini Mode'), 'exaile-minimode',
            self.on_menuitem_activate, accelerator='<Primary><Alt>M')
        self.accelerator = Accelerator('<Primary><Alt>M',
            self.on_menuitem_activate)
        providers.register('menubar-view-menu', self.menuitem)
        providers.register('mainwindow-accelerators', self.accelerator)

        mainbutton = Gtk.Button(_('Mini Mode'))
        mainbutton.set_image(Gtk.Image.new_from_icon_name(
            'exaile-minimode', Gtk.IconSize.BUTTON))
        mainbutton.connect('clicked', self.on_mainbutton_clicked)
        self.mainbutton_alignment = Gtk.Alignment.new(1, 0, 0, 0)
        self.mainbutton_alignment.add(mainbutton)
        action_area = exaile.gui.main.info_area.get_action_area()
        action_area.pack_start(self.mainbutton_alignment, True, True, 0)
        action_area.reorder_child(self.mainbutton_alignment, 0)
        
        self.__active = False
        self.__dirty = True
        # XXX: Until defaults are implemented in xl.settings
        self.__defaults = {
            'plugin/minimode/always_on_top': True,
            'plugin/minimode/show_in_panel': False,
            'plugin/minimode/on_all_desktops': True,
            'plugin/minimode/display_window_decorations': True,
            'plugin/minimode/window_decoration_type': 'full',
            'plugin/minimode/use_alpha': False,
            'plugin/minimode/transparency': 0.3,
            'plugin/minimode/horizontal_position': 10,
            'plugin/minimode/vertical_position': 10
        }

        exaile.gui.main.connect('main-visible-toggle',
            self.on_main_visible_toggle)
        event.add_ui_callback(self.on_option_set, 'plugin_minimode_option_set')
        self.on_option_set('plugin_minimode_option_set', settings,
            'plugin/minimode/button_in_mainwindow')
예제 #38
0
def enable(exaile):
    providers.register("gst_audio_filter", GSTEqualizer)
    if exaile.loading:
        event.add_ui_callback(_enable, 'gui_loaded')
    else:
        _enable(None, exaile, None)
예제 #39
0
 def enable(self, exaile):
     providers.register("gst_audio_filter", GSTEqualizer)
     self.__exaile = exaile
예제 #40
0
def _enable(o1, exaile, o2):
    global LVPANEL
    LVPANEL = LVPanel(exaile)

    providers.register('main-panel', LVPANEL)
예제 #41
0
    def on_gui_loaded(self):

        self.track = None
        self.tag_dialog = None

        migrate_settings()

        self.panel = gt_widgets.GroupTaggerPanel(self.exaile)
        self.panel.show_all()
        self.setup_panel_font(False)

        self.panel.tagger.view.connect('category-changed', self.on_category_change)
        self.panel.tagger.view.connect('category-edited', self.on_category_edited)
        self.panel.tagger.view.connect('group-changed', self.on_group_change)

        # add to exaile's panel interface
        providers.register('main-panel', self.panel)

        # ok, register for some events
        event.add_ui_callback(self.on_playback_track_start, 'playback_track_start')
        event.add_ui_callback(
            self.on_playlist_cursor_changed, 'playlist_cursor_changed'
        )
        event.add_ui_callback(
            self.on_plugin_options_set, 'plugin_grouptagger_option_set'
        )

        # add our own submenu for functionality
        tools_submenu = menu.Menu(None, context_func=lambda p: self.exaile)

        tools_submenu.add_item(
            menu.simple_menu_item(
                'gt_get_tags',
                [],
                _('_Get all tags from collection'),
                callback=self.on_get_tags_menu,
            )
        )

        tools_submenu.add_item(
            menu.simple_menu_item(
                'gt_import',
                [],
                _('_Import tags from directory'),
                callback=self.on_import_tags,
            )
        )

        tools_submenu.add_item(
            menu.simple_menu_item(
                'gt_rename',
                [],
                _('_Mass rename/delete tags'),
                callback=self.on_mass_rename,
            )
        )

        tools_submenu.add_item(
            menu.simple_menu_item(
                'gt_export',
                [],
                _('E_xport collecton tags to JSON'),
                callback=self.on_export_tags,
            )
        )

        # group them together to make it not too long
        self.tools_menuitem = menu.simple_menu_item(
            'grouptagger', ['plugin-sep'], _('_GroupTagger'), submenu=tools_submenu
        )
        providers.register('menubar-tools-menu', self.tools_menuitem)

        # playlist context menu items
        self.provider_items = []
        track_subitem = menu.Menu(None, inherit_context=True)

        track_subitem.add_item(
            menu.simple_menu_item(
                'gt_search_all',
                [],
                _('Show tracks with all tags'),
                callback=self.on_playlist_context_select_all_menu,
                callback_args=[self.exaile],
            )
        )

        track_subitem.add_item(
            menu.simple_menu_item(
                'gt_search_custom',
                ['gt_search_all'],
                _('Show tracks with tags (custom)'),
                callback=self.on_playlist_context_select_custom_menu,
                callback_args=[self.exaile],
            )
        )

        tag_cond_fn = lambda n, p, c: c['selection-count'] > 1

        track_subitem.add_item(
            menu.simple_menu_item(
                'gt_tag_add_multi',
                ['gt_search_custom'],
                _('Add tags to all'),
                callback=self.on_add_tags,
                condition_fn=tag_cond_fn,
                callback_args=[self.exaile],
            )
        )

        track_subitem.add_item(
            menu.simple_menu_item(
                'gt_tag_rm_multi',
                ['gt_tag_add_multi'],
                _('Remove tags from all'),
                callback=self.on_rm_tags,
                condition_fn=tag_cond_fn,
                callback_args=[self.exaile],
            )
        )

        self.provider_items.append(
            menu.simple_menu_item(
                'grouptagger', ['rating'], _('GroupTagger'), submenu=track_subitem
            )
        )

        for item in self.provider_items:
            providers.register('playlist-context-menu', item)
            # Hm, doesn't work..
            # providers.register('track-panel-menu', item)

        # trigger start event if exaile is currently playing something
        if player.PLAYER.is_playing():
            self.set_display_track(player.PLAYER.current)
        else:
            self.panel.tagger.set_categories([], get_group_categories())
예제 #42
0
def exaile_ready(event, exaile, nothing):
    global PODCASTS

    if not PODCASTS:
        PODCASTS = PodcastPanel(main.mainwindow().window)
        providers.register('main-panel', PODCASTS)
예제 #43
0
def _enable(eventname, exaile, nothing):
    global AMAZON, USER_AGENT
    USER_AGENT = exaile.get_user_agent_string('amazoncovers')
    AMAZON = AmazonCoverSearch()
    providers.register('covers', AMAZON)
예제 #44
0
def enable(exaile):
    global PROVIDER
    PROVIDER = MassStorageHandler()
    providers.register("hal", PROVIDER)
예제 #45
0
def _enable(eventname, exaile, nothing):
    global LASTFM
    LASTFM = LastFMCoverSearch()
    providers.register('covers', LASTFM)
예제 #46
0
        Restores the original tooltip
        """
        self.set_tooltip_text(self.__default_tooltip_text)

    def on_drag_data_received(self, widget, context, x, y, selection, info,
                              time):
        """
        Handles dropped data
        """
        tab = self.notebook.create_new_playlist()
        # Forward signal to the PlaylistView in the newly added tab
        tab.page.view.emit('drag-data-received', context, x, y, selection,
                           info, time)


providers.register('playlist-notebook-actions', NewPlaylistNotebookAction)


class PlaylistNotebook(SmartNotebook):
    def __init__(self, manager_name, player, hotkey):
        SmartNotebook.__init__(self)

        self.tab_manager = PlaylistManager(manager_name)
        self.manager_name = manager_name
        self.player = player

        # For saving closed tab history
        self._moving_tab = False
        self.tab_history = []
        self.history_counter = 90000  # to get unique (reverse-ordered) item names
예제 #47
0
        except ValueError:
            w.get_style_context().add_class('warning')
        else:
            w.get_style_context().remove_class('warning')


class TrackNumberColumn(Column):
    name = 'tracknumber'
    # TRANSLATORS: Title of the track number column
    display = _('#')
    menu_title = _('Track Number')
    size = 30
    cellproperties = {'xalign': 1.0, 'width-chars': 4}


providers.register('playlist-columns', TrackNumberColumn)


class TitleColumn(EditableColumn):
    name = 'title'
    display = _('Title')
    size = 200
    autoexpand = True


providers.register('playlist-columns', TitleColumn)


class ArtistColumn(EditableColumn):
    name = 'artist'
    display = _('Artist')
예제 #48
0
    def __init__(self, manager_name, player, hotkey):
        SmartNotebook.__init__(self)

        self.tab_manager = PlaylistManager(manager_name)
        self.manager_name = manager_name
        self.player = player

        # For saving closed tab history
        self._moving_tab = False
        self.tab_history = []
        self.history_counter = 90000  # to get unique (reverse-ordered) item names

        # Build static menu entries
        item = menu.simple_separator('clear-sep', [])
        item.register('playlist-closed-tab-menu', self)

        item = menu.simple_menu_item(
            'clear-history',
            ['clear-sep'],
            _("_Clear Tab History"),
            'edit-clear-all',
            self.clear_closed_tabs,
        )
        item.register('playlist-closed-tab-menu', self)

        # Simple factory for 'Recently Closed Tabs' MenuItem
        submenu = menu.ProviderMenu('playlist-closed-tab-menu', self)

        def factory(menu_, parent, context):
            if self.page_num(parent) == -1:
                return None
            item = Gtk.MenuItem.new_with_mnemonic(_("Recently Closed _Tabs"))
            if len(self.tab_history) > 0:
                item.set_submenu(submenu)
            else:
                item.set_sensitive(False)
            return item

        # Add menu to tab context menu
        item = menu.MenuItem('%s-tab-history' % manager_name, factory,
                             ['tab-close'])
        item.register('playlist-tab-context-menu')

        # Add menu to View menu
        # item = menu.MenuItem('tab-history', factory, ['clear-playlist'])
        # providers.register('menubar-view-menu', item)

        # setup notebook actions
        self.actions = NotebookActionService(self, 'playlist-notebook-actions')

        # Add hotkey
        self.accelerator = Accelerator(hotkey, _('Restore closed tab'),
                                       lambda *x: self.restore_closed_tab(0))
        providers.register('mainwindow-accelerators', self.accelerator)

        # Load saved tabs
        self.load_saved_tabs()

        self.tab_placement_map = {
            'left': Gtk.PositionType.LEFT,
            'right': Gtk.PositionType.RIGHT,
            'top': Gtk.PositionType.TOP,
            'bottom': Gtk.PositionType.BOTTOM,
        }

        self.connect('page-added', self.on_page_added)
        self.connect('page-removed', self.on_page_removed)

        self.on_option_set('gui_option_set', settings, 'gui/show_tabbar')
        self.on_option_set('gui_option_set', settings, 'gui/tab_placement')
        event.add_ui_callback(self.on_option_set, 'gui_option_set')
예제 #49
0
    def _init_gui(self):
        self.pane = Gtk.Paned()

        # stolen from main
        self.info_area = main.MainWindowTrackInfoPane(self.player)
        self.info_area.set_auto_update(True)
        self.info_area.set_border_width(3)
        self.info_area.hide()
        self.info_area.set_no_show_all(True)

        volume_control = playback.VolumeControl(self.player)
        self.info_area.get_action_area().pack_start(volume_control, True, True,
                                                    0)

        self.playpause_button = Gtk.Button()
        self.playpause_button.set_relief(Gtk.ReliefStyle.NONE)
        self._on_playback_end(None, None, None)
        self.playpause_button.connect('button-press-event',
                                      self._on_playpause_button_clicked)

        self.progress_bar = playback.SeekProgressBar(self.player,
                                                     use_markers=False)

        play_toolbar = Gtk.Box()
        play_toolbar.pack_start(self.playpause_button, False, False, 0)
        play_toolbar.pack_start(self.progress_bar, True, True, 0)

        # stick our player controls into this box
        self.pane1_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        self.pane2_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.pane2_box.pack_start(self.info_area, False, False, 0)
        self.pane2_box.pack_start(play_toolbar, False, False, 0)

        self.pane.pack1(self.pane1_box, resize=True, shrink=True)
        self.pane.pack2(self.pane2_box, resize=True, shrink=True)

        # setup menus

        # add menu item to 'view' to display our playlist
        self.menu = menu.check_menu_item('preview_player', '',
                                         _('Preview Player'),
                                         lambda *e: self.hooked, self._on_view)

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

        self.preview_menuitem = menu.simple_menu_item(
            '_preview', ['enqueue'],
            _('Preview'),
            callback=self._on_preview,
            condition_fn=lambda n, p, c: not c['selection-empty'])

        # TODO: Setup on other context menus
        self.preview_provides = [
            'track-panel-menu',
            'playlist-context-menu',
        ]

        for provide in self.preview_provides:
            providers.register(provide, self.preview_menuitem)

        self._on_option_set('gui_option_set', settings, 'gui/show_info_area')
        self._on_option_set('gui_option_set', settings,
                            'gui/show_info_area_covers')
        event.add_ui_callback(self._on_option_set, 'option_set')
예제 #50
0
파일: __init__.py 프로젝트: unkie/exaile
 def on_exaile_loaded(self):
     # verify that hal/whatever is loaded, load correct provider
     if self.__exaile.udisks2 is not None:
         self.__udisks2 = UDisks2CdProvider()
         providers.register('udisks2', self.__udisks2)
예제 #51
0
def _enable(eventname, exaile, nothing):
    global WIKIPANEL
    WIKIPANEL = WikiPanel(exaile.gui.main.window)
    providers.register('main-panel', WIKIPANEL)
예제 #52
0
            value = int(value)
        except ValueError:
            return ''

        return '%d' % value


class TrackNumberTagFormatter(NumberTagFormatter):
    """
    A formatter for the tracknumber of a track
    """
    def __init__(self):
        TagFormatter.__init__(self, 'tracknumber')


providers.register('tag-formatting', TrackNumberTagFormatter())


class DiscNumberTagFormatter(NumberTagFormatter):
    """
    A formatter for the discnumber of a track
    """
    def __init__(self):
        TagFormatter.__init__(self, 'discnumber')


providers.register('tag-formatting', DiscNumberTagFormatter())


class ArtistTagFormatter(TagFormatter):
    """
예제 #53
0
def enable(exaile):
    global ipod_provider
    ipod_provider = iPodHandler()
    providers.register("hal", ipod_provider)
예제 #54
0
def __create_tray_context_menu():
    sep = menu.simple_separator
    items = []
    # Play/Pause
    items.append(
        playback.PlayPauseMenuItem('playback-playpause',
                                   player.PLAYER,
                                   after=[]))
    # Next
    items.append(
        playback.NextMenuItem('playback-next',
                              player.PLAYER,
                              after=[items[-1].name]))
    # Prev
    items.append(
        playback.PrevMenuItem('playback-prev',
                              player.PLAYER,
                              after=[items[-1].name]))
    # Stop
    items.append(
        playback.StopMenuItem('playback-stop',
                              player.PLAYER,
                              after=[items[-1].name]))
    # ----
    items.append(sep('playback-sep', [items[-1].name]))
    # Shuffle
    items.append(
        playlist.ShuffleModesMenuItem('playlist-mode-shuffle',
                                      after=[items[-1].name]))
    # Repeat
    items.append(
        playlist.RepeatModesMenuItem('playlist-mode-repeat',
                                     after=[items[-1].name]))
    # Dynamic
    items.append(
        playlist.DynamicModesMenuItem('playlist-mode-dynamic',
                                      after=[items[-1].name]))
    # ----
    items.append(sep('playlist-mode-sep', [items[-1].name]))

    # Rating
    def rating_get_tracks_func(parent, context):
        current = player.PLAYER.current
        if current:
            return [current]
        else:
            return []

    items.append(
        menuitems.RatingMenuItem('rating', [items[-1].name],
                                 rating_get_tracks_func))
    # Remove
    items.append(playlist.RemoveCurrentMenuItem([items[-1].name]))
    # ----
    items.append(sep('misc-actions-sep', [items[-1].name]))

    # Quit
    def quit_cb(*args):
        from xl import main
        main.exaile().quit()

    items.append(
        menu.simple_menu_item('quit-application', [items[-1].name],
                              icon_name=gtk.STOCK_QUIT,
                              callback=quit_cb))
    for item in items:
        providers.register('tray-icon-context', item)
예제 #55
0
def enable(exaile):
    global LFMS
    LFMS = LastfmSource()
    providers.register("dynamic_playlists", LFMS)
예제 #56
0
def enable(exaile):
    for elem in NEEDED_ELEMS:
        if not Gst.ElementFactory.find(elem):
            raise ImportError("Needed gstreamer element %s missing." % elem)
    providers.register("gst_audio_filter", ReplaygainVolume)
    providers.register("gst_audio_filter", ReplaygainLimiter)
예제 #57
0
def __create_playlist_menu():
    items = []
    for item in items:
        providers.register('menubar-playlist-menu', item)
예제 #58
0
    def __init__(self, exaile):

        self.track = None
        self.tag_dialog = None

        migrate_settings()

        self.panel = gt_widgets.GroupTaggerPanel(exaile)
        self.panel.show_all()
        self.setup_panel_font(False)

        self.panel.tagger.view.connect('category-changed',
                                       self.on_category_change)
        self.panel.tagger.view.connect('category-edited',
                                       self.on_category_edited)
        self.panel.tagger.view.connect('group-changed', self.on_group_change)

        # add to exaile's panel interface
        providers.register('main-panel', self.panel)

        # ok, register for some events
        event.add_callback(self.on_playback_track_start,
                           'playback_track_start')
        event.add_callback(self.on_playlist_cursor_changed,
                           'playlist_cursor_changed')
        event.add_callback(self.on_plugin_options_set,
                           'plugin_grouptagger_option_set')

        # add our own submenu for functionality
        self.tools_submenu = menu.Menu(None, context_func=lambda p: exaile)

        self.tools_submenu.add_item(
            menu.simple_menu_item('gt_get_tags', [],
                                  _('Get all tags from collection'),
                                  callback=self.on_get_tags_menu))

        self.tools_submenu.add_item(
            menu.simple_menu_item('gt_import', [],
                                  _('Import tags from directory'),
                                  callback=self.on_import_tags))

        self.tools_submenu.add_item(
            menu.simple_menu_item('gt_rename', [],
                                  _('Mass rename/delete tags'),
                                  callback=self.on_mass_rename))

        # group them together to make it not too long
        self.tools_menuitem = menu.simple_menu_item('grouptagger',
                                                    ['plugin-sep'],
                                                    _('GroupTagger'),
                                                    submenu=self.tools_submenu)
        providers.register('menubar-tools-menu', self.tools_menuitem)

        # playlist context menu items
        self.selectall_menuitem = menu.simple_menu_item(
            'gt_search_all', ['rating'],
            _('Show tracks with all tags'),
            callback=self.on_playlist_context_select_all_menu,
            callback_args=[exaile])
        providers.register('playlist-context-menu', self.selectall_menuitem)

        self.selectcustom_menuitem = menu.simple_menu_item(
            'gt_search_custom', ['rating'],
            _('Show tracks with tags (custom)'),
            callback=self.on_playlist_context_select_custom_menu,
            callback_args=[exaile])
        providers.register('playlist-context-menu', self.selectcustom_menuitem)

        # trigger start event if exaile is currently playing something
        if player.PLAYER.is_playing():
            self.set_display_track(player.PLAYER.current)
        else:
            self.panel.tagger.set_categories([], get_group_categories())
예제 #59
0
def _enable(o1, exaile, o2):
    global LYRICSVIEWER
    LYRICSVIEWER = LyricsViewer(exaile)
    providers.register('main-panel', LYRICSVIEWER)
예제 #60
0
def __create_file_menu():
    items = []
    accelerators = []

    def new_playlist_cb(*args):
        get_main().playlist_container.create_new_playlist()

    items.append(
        _smi('new-playlist', [],
             _("_New Playlist"),
             'tab-new',
             new_playlist_cb,
             accelerator='<Control>t'))
    accelerators.append(Accelerator('<Control>t', new_playlist_cb))
    items.append(_sep('new-sep', [items[-1].name]))

    def open_cb(*args):
        dialog = dialogs.MediaOpenDialog(get_main().window)
        dialog.connect('uris-selected',
                       lambda d, uris: get_main().controller.open_uris(uris))
        dialog.show()

    items.append(
        _smi('open', [items[-1].name],
             icon_name=gtk.STOCK_OPEN,
             callback=open_cb,
             accelerator='<Control>o'))
    accelerators.append(Accelerator('<Control>o', open_cb))

    def open_uri_cb(*args):
        dialog = dialogs.URIOpenDialog(get_main().window)
        dialog.connect('uri-selected',
                       lambda d, uri: get_main().controller.open_uri(uri))
        dialog.show()

    items.append(
        _smi('open-uri', [items[-1].name],
             _("Open _URL"),
             'applications-internet',
             open_uri_cb,
             accelerator='<Control><Shift>o'))
    accelerators.append(Accelerator('<Control><Shift>o', open_uri_cb))

    def open_dirs_cb(*args):
        dialog = dialogs.DirectoryOpenDialog(get_main().window)
        dialog.props.create_folders = False
        dialog.connect('uris-selected',
                       lambda d, uris: get_main().controller.open_uris(uris))
        dialog.show()

    items.append(
        _smi('open-dirs', [items[-1].name], _("Open Directories"), None,
             open_dirs_cb))

    items.append(_sep('open-sep', [items[-1].name]))

    items.append(
        _smi(
            'import-playlist', [items[-1].name], _("Import Playlist"),
            gtk.STOCK_OPEN, lambda *e: get_main().controller.get_panel(
                'playlists').import_playlist()))

    def export_playlist_cb(*args):
        main = get_main()
        page = get_selected_playlist()
        if not page:
            return

        def on_message(dialog, message_type, message):
            """
                Show messages in the main window message area
            """
            if message_type == gtk.MESSAGE_INFO:
                main.message.show_info(markup=message)
            elif message_type == gtk.MESSAGE_ERROR:
                main.message.show_error(_('Playlist export failed!'), message)
            return True

        dialog = dialogs.PlaylistExportDialog(page.playlist, main.window)
        dialog.connect('message', on_message)
        dialog.show()

    items.append(
        _smi('export-playlist', [items[-1].name],
             _("_Export Current Playlist"), gtk.STOCK_SAVE_AS,
             export_playlist_cb))
    items.append(_sep('export-sep', [items[-1].name]))

    def close_tab_cb(*args):
        get_main().get_selected_page().tab.close()

    items.append(
        _smi('close-tab', [items[-1].name],
             _("Close Tab"),
             gtk.STOCK_CLOSE,
             callback=close_tab_cb,
             accelerator='<Control>w'))
    accelerators.append(Accelerator('<Control>w', close_tab_cb))

    if get_main().controller.exaile.options.Debug:

        def restart_cb(*args):
            from xl import main
            main.exaile().quit(True)

        items.append(
            _smi('restart-application', [items[-1].name],
                 _("Restart"),
                 callback=restart_cb,
                 accelerator='<Control>r'))
        accelerators.append(Accelerator('<Control>r', restart_cb))

    def quit_cb(*args):
        from xl import main
        main.exaile().quit()

    items.append(
        _smi('quit-application', [items[-1].name],
             icon_name=gtk.STOCK_QUIT,
             callback=quit_cb,
             accelerator='<Control>q'))
    accelerators.append(Accelerator('<Control>q', quit_cb))

    for item in items:
        providers.register('menubar-file-menu', item)
    for accelerator in accelerators:
        providers.register('mainwindow-accelerators', accelerator)