def on_previews_box_selection_changed(self, iconview): """ Switches the currently displayed cover """ paths = self.previews_box.get_selected_items() if paths: path = paths[0] db_string = self.covers_model[path][0] source = db_string[0].split(':', 1)[0] provider = providers.get_provider('covers', source) pixbuf = self.covers_model[path][1] self.cover.set_image_pixbuf(pixbuf) self.size_label.set_text( _('{width}x{height} pixels').format( width=pixbuf.get_width(), height=pixbuf.get_height() ) ) # Display readable title of the provider, fallback to its name self.source_label.set_text(getattr(provider, 'title', source)) self.set_button.set_sensitive(True) else: self.set_button.set_sensitive(False)
def format(self, track, markup_escape=False): """ Returns a string for places where track data is presented to the user :param track: a single track to take data from :type track: :class:`xl.trax.Track` :param markup_escape: whether to escape markup-like characters in tag values :type markup_escape: bool :returns: the formatted text :rtype: string """ if not isinstance(track, trax.Track): raise TypeError('First argument to format() needs ' 'to be of type xl.trax.Track') extractions = self.extract() self._substitutions = {} for identifier, (tag, parameters) in extractions.iteritems(): provider = providers.get_provider('tag-formatting', tag) if provider is None: substitute = track.get_tag_display(tag) else: substitute = provider.format(track, parameters) if markup_escape: substitute = GLib.markup_escape_text(substitute).decode('utf-8') self._substitutions[identifier] = substitute return Formatter.format(self)
def format(self, track, markup_escape=False): """ Returns a string for places where track data is presented to the user :param track: a single track to take data from :type track: :class:`xl.trax.Track` :param markup_escape: whether to escape markup-like characters in tag values :type markup_escape: bool :returns: the formatted text :rtype: string """ if not isinstance(track, trax.Track): raise TypeError('First argument to format() needs ' 'to be of type xl.trax.Track') extractions = self.extract() self._substitutions = {} for identifier, (tag, parameters) in extractions.iteritems(): provider = providers.get_provider('tag-formatting', tag) if provider is None: substitute = track.get_tag_display(tag) else: substitute = provider.format(track, parameters) if markup_escape: substitute = glib.markup_escape_text(substitute) self._substitutions[identifier] = substitute return Formatter.format(self)
def clear_markers(self): """ Removes both markers """ for name in ('repeat-beginning', 'repeat-end'): marker = providers.get_provider('playback-markers', name) if marker is not None: providers.unregister('playback-markers', marker)
def factory(self, menu, parent, context): """ Generates the menu item """ item = playback.MoveMarkerMenuItem.factory(self, menu, parent, context) markers = (providers.get_provider('playback-markers', n) for n in ('repeat-beginning', 'repeat-end')) if player.PLAYER.current is None: item.set_sensitive(False) elif None not in markers: # Disable if the markers have already been set item.set_sensitive(False) return item
def on_parent_button_press_event(self, widget, event): """ Finishes or cancels insertion of markers """ if event.button == Gdk.BUTTON_PRIMARY: if self.move_finish(): if providers.get_provider('playback-markers', 'repeat-end') is None: position = event.x / widget.get_allocation().width self.end_marker.props.position = position providers.register('playback-markers', self.end_marker) self.move_begin(self.end_marker) return True elif event.triggers_context_menu(): if self.move_cancel(): self.clear_markers() return True return False
def on_parent_button_press_event(self, widget, event): """ Finishes or cancels insertion of markers """ if event.button == 1: if self.move_finish(): if providers.get_provider('playback-markers', 'repeat-end') is None: position = event.x / widget.allocation.width self.end_marker.props.position = position providers.register('playback-markers', self.end_marker) self.move_begin(self.end_marker) return True elif event.button == 3: if self.move_cancel(): self.clear_markers() return True return False
def on_previews_box_selection_changed(self, iconview): """ Switches the currently displayed cover """ paths = self.previews_box.get_selected_items() if paths: path = paths[0] db_string = self.covers_model[path][0] source = db_string[0].split(':', 1)[0] provider = providers.get_provider('covers', source) pixbuf = self.covers_model[path][1] self.cover.set_image_pixbuf(pixbuf) self.size_label.set_text(_('{width}x{height} pixels').format( width=pixbuf.get_width(), height=pixbuf.get_height())) # Display readable title of the provider, fallback to its name self.source_label.set_text(getattr(provider, 'title', source)) self.set_button.set_sensitive(True) else: self.set_button.set_sensitive(False)
def disable(exaile): providers.unregister("lyrics", providers.get_provider("lyrics", "lyricwiki"))
def disable(exaile): providers.unregister('lyrics', providers.get_provider('lyrics', 'lyricsmania'))
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 """ 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)
def disable(exaile): """ Disables the plugin """ providers.unregister('covers', providers.get_provider('covers', 'musicbrainz'))
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)
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 """ 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)