def _set_text(self, column, renderer, model, treeiter, arg): source = model[treeiter][1] if source is None: renderer.props.weight = Pango.Weight.BOLD renderer.props.text = model[treeiter][0] renderer.props.visible = model[treeiter][2] else: renderer.props.visible = True player = self.shell.props.shell_player playing = \ player.get_playing and player.get_playing_source() == source cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) translation = gettext.gettext(source.props.name) cl.switch_locale(cl.Locale.RB) renderer.props.text = translation if playing: renderer.props.weight = Pango.Weight.BOLD else: renderer.props.weight = Pango.Weight.NORMAL renderer.props.ypad = 3 path = model.get_path(treeiter) if path.get_depth() == 1: renderer.props.ypad = 6 renderer.props.xpad = 3 else: renderer.props.ypad = 3 renderer.props.xpad = 0 renderer.props.ellipsize = Pango.EllipsizeMode.END
def get_gicon(self, source): # locale stuff cl = CoverLocale() cl.switch_locale(cl.Locale.RB) if source.props.name == _("Libre.fm"): return self._libre_gicon else: return self._lastfm_gicon
def get_gicon(self, source): # locale stuff cl = CoverLocale() cl.switch_locale(cl.Locale.RB) if source.props.name == _("Libre.fm"): return self._libre_gicon else: return self._lastfm_gicon
def _get_preference_widget(self, row): try: ext = self._peas.create_extension(row.plugin, PeasGtk.Configurable, None) widget = ext.create_configure_widget() cl = CoverLocale() cl.switch_locale(cl.Locale.RB) return widget except: pass return None
def _get_preference_widget(self, row): try: ext = self._peas.create_extension(row.plugin, PeasGtk.Configurable, None) widget = ext.create_configure_widget() cl = CoverLocale() cl.switch_locale(cl.Locale.RB) return widget except: pass return None
def get_gicon(self, source): # locale stuff cl = CoverLocale() cl.switch_locale(cl.Locale.RB) print(source.props.name) if source.props.name == _('My Top Rated') or source.props.name == 'My Top Rated': return self._toprated_gicon if source.props.name == _('Recently Added') or source.props.name == 'Recently Added': return self._recentlyadded_gicon if source.props.name == _('Recently Played') or source.props.name == 'Recently Played': return self._recentlyplayed_gicon if "StaticPlaylistSource" in type(source).__name__: return self._static_gicon else: return self._auto_gicon
def _set_toggle_tooltip(self, repeat): # locale stuff cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) if self.toggle_button.get_has_tooltip(): if repeat.get_repeat_type() == RepeatPopContainer.ALL_SONGS: message = _("Repeat all tracks") else: message = _("Repeat the current track") self.toggle_button.set_tooltip_text(message) cl = CoverLocale() cl.switch_locale(cl.Locale.RB)
def get_gicon(self, source): # locale stuff cl = CoverLocale() cl.switch_locale(cl.Locale.RB) print(source.props.name) if source.props.name == _('My Top Rated') \ or source.props.name == 'My Top Rated': return self._toprated_gicon if source.props.name == _('Recently Added') \ or source.props.name == 'Recently Added': return self._recentlyadded_gicon if source.props.name == _('Recently Played') \ or source.props.name == 'Recently Played': return self._recentlyplayed_gicon if "StaticPlaylistSource" in type(source).__name__: return self._static_gicon else: return self._auto_gicon
def _set_text(self, column, renderer, model, treeiter, arg): source = model[treeiter][1] if source is None: renderer.props.weight = Pango.Weight.BOLD renderer.props.text = model[treeiter][0] renderer.props.visible = model[treeiter][2] else: renderer.props.visible = True player = self.shell.props.shell_player playing = \ player.get_playing and player.get_playing_source() == source cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) translation = gettext.gettext(source.props.name) cl.switch_locale(cl.Locale.RB) renderer.props.text = translation if playing: renderer.props.weight = Pango.Weight.BOLD else: renderer.props.weight = Pango.Weight.NORMAL renderer.props.ypad = 3 path = model.get_path(treeiter) if path.get_depth() == 1: renderer.props.ypad = 6 renderer.props.xpad = 3 else: renderer.props.ypad = 3 renderer.props.xpad = 0 renderer.props.ellipsize = Pango.EllipsizeMode.END
def _set_toggle_tooltip(self, repeat): # locale stuff cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) if self.toggle_button.get_has_tooltip(): if repeat.get_repeat_type() == RepeatPopContainer.ALL_SONGS: print ("all songs") self.toggle_button.set_tooltip_text(_("Repeat all tracks")) else: self.toggle_button.set_tooltip_text(_("Repeat the current track")) cl = CoverLocale() cl.switch_locale(cl.Locale.RB)
def __init__(self, parent_container, parent_button, *args, **kwargs): super (RepeatPopContainer, self).__init__(*args, **kwargs) self.set_orientation(Gtk.Orientation.HORIZONTAL) self.set_layout(Gtk.ButtonBoxStyle.START) self.props.margin = 5 context = self.get_style_context() context.add_class('linked') icon_size = 4 toggle1 = Gtk.RadioButton.new(None) toggle1.set_mode(False) icon = Gio.ThemedIcon.new_with_default_fallbacks('media-playlist-repeat-symbolic') image = Gtk.Image() image.set_from_gicon(icon, icon_size) image.props.margin = 5 toggle1.set_image(image) toggle1.connect('leave-notify-event', self._on_popover_mouse_over) toggle1.connect('enter-notify-event', self._on_popover_mouse_over) toggle1.connect('toggled', self._on_popover_button_toggled) # locale stuff cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) if parent_button.get_has_tooltip(): toggle1.set_tooltip_text(_("Repeat all tracks")) self._repeat_button = toggle1 self.add(toggle1) self.child_set_property(toggle1, "non-homogeneous", True) toggle1.show_all() self._repeat_image = Gtk.Image() self._repeat_image.set_from_gicon(icon, icon_size) self._repeat_image.props.margin = 5 toggle2 = Gtk.RadioButton.new_from_widget(toggle1) toggle2.set_mode(False) icon2 = Gio.ThemedIcon.new_with_default_fallbacks('media-playlist-repeat-song-symbolic') image2 = Gtk.Image() image2.set_from_gicon(icon2, icon_size) image2.props.margin = 5 toggle2.set_image(image2) if parent_button.get_has_tooltip(): toggle2.set_tooltip_text(_("Repeat the current track")) self._repeat_song_image = Gtk.Image() self._repeat_song_image.set_from_gicon(icon2, icon_size) self._repeat_song_image.props.margin = 5 toggle2.connect('leave-notify-event', self._on_popover_mouse_over) toggle2.connect('enter-notify-event', self._on_popover_mouse_over) toggle2.connect('toggled', self._on_popover_button_toggled) toggle2.show_all() self._repeat_song_button = toggle2 self.add(toggle2) self.child_set_property(toggle2, "non-homogeneous", True) self._popover_inprogress = 0 parent_container.connect('leave-notify-event', self._on_popover_mouse_over) parent_container.connect('enter-notify-event', self._on_popover_mouse_over) parent_button.connect('leave-notify-event', self._on_popover_mouse_over) parent_button.connect('enter-notify-event', self._on_popover_mouse_over) gicon_name = image.props.gicon parent_button.set_image(self._repeat_image) self._parent_container = parent_container self._parent_button = parent_button # now get the repeat-type saved in gsettings # get values from gsettings self.gs = GSetting() self.plugin_settings = self.gs.get_setting(self.gs.Path.PLUGIN) repeat_type = self.plugin_settings[self.gs.PluginKey.REPEAT_TYPE] if repeat_type == RepeatPopContainer.ONE_SONG: self._repeat_song_button.set_active(True)
def __init__(self, parent_window, has_headerbar): if has_headerbar: super(PluginDialog, self).__init__(use_header_bar=True, parent=parent_window, flags=Gtk.DialogFlags.MODAL) else: super(PluginDialog, self).__init__(parent=parent_window, flags=Gtk.DialogFlags.MODAL) self._has_headerbar = has_headerbar self._parent_window = parent_window listbox = Gtk.ListBox.new() listbox.set_sort_func(self._listbox_sort, None) self._listbox = listbox self._items = {} self._peas = Peas.Engine.get_default() plugins = self._peas.get_plugin_list() self._peas.connect_after('unload-plugin', self._on_load_unload_plugin) self._peas.connect_after('load-plugin', self._on_load_unload_plugin) for plugin in plugins: if not plugin.is_builtin() and not plugin.is_hidden(): row = PluginListRow(plugin, self._switch_callback) self._items[plugin.get_module_name()] = row listbox.add(row) # locale stuff cl = CoverLocale() cl.switch_locale(cl.Locale.RB) def extract_text(str): # remove _ and (_A) type expressions translation = gettext.gettext(str) translation = re.sub('\(..\)', '', translation, flags=re.DOTALL) translation = translation.replace('_', '') return translation toolbar = Gtk.Toolbar.new() context = toolbar.get_style_context() context.add_class(Gtk.STYLE_CLASS_INLINE_TOOLBAR) item = Gtk.ToolItem.new() btn = Gtk.Button() icon = Gio.ThemedIcon(name="preferences-system-symbolic") image = Gtk.Image() image.props.margin = 3 btn.add(image) btn.set_tooltip_text(extract_text("_Preferences")) image.set_from_gicon(icon, Gtk.IconSize.BUTTON) box = Gtk.Box() box.pack_start(btn, False, False, 0) item.add(box) toolbar.insert(item, 0) btn.connect('clicked', self._preferences_button_clicked) self._preferences_button = btn minitoolbar_box = Gtk.ButtonBox() context = minitoolbar_box.get_style_context() context.add_class('linked') minitoolbar_box.set_layout(Gtk.ButtonBoxStyle.START) btn = Gtk.Button() icon = Gio.ThemedIcon(name="dialog-information-symbolic") image = Gtk.Image() image.props.margin = 3 btn.add(image) btn.set_tooltip_text(extract_text("_About")) image.set_from_gicon(icon, Gtk.IconSize.BUTTON) minitoolbar_box.add(btn) minitoolbar_box.child_set_property(btn, "non-homogeneous", True) btn.connect('clicked', self._info_button_clicked) self._info_button = btn btn = Gtk.Button() icon = Gio.ThemedIcon(name="help-browser-symbolic") image = Gtk.Image() image.props.margin = 3 btn.add(image) btn.set_tooltip_text(extract_text("_Help")) image.set_from_gicon(icon, Gtk.IconSize.BUTTON) minitoolbar_box.add(btn) minitoolbar_box.child_set_property(btn, "non-homogeneous", True) btn.connect('clicked', self._help_button_clicked) self._help_button = btn item = Gtk.SeparatorToolItem.new() item.props.draw = False toolbar.insert(item, 1) toolbar.child_set_property(item, "expand", True) item = Gtk.ToolItem.new() item.add(minitoolbar_box) toolbar.insert(item, 2) contentbox = Gtk.Box() contentbox.set_orientation(Gtk.Orientation.VERTICAL) scrollwindow = Gtk.ScrolledWindow.new(None, None) scrollwindow.add(listbox) scrollwindow.props.hexpand = True scrollwindow.props.vexpand = True contentbox.pack_start(scrollwindow, True, True, 0) contentbox.pack_start(toolbar, False, False, 1) self.props.title = _("Configure Plugins") if not self._has_headerbar: self.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE) else: headerbar = self.get_header_bar() headerbar.set_show_close_button(True) contentbox.show_all() area = self.get_content_area() area.add(contentbox) listbox.connect('row-selected', self._listbox_row_selected)
def __init__(self, parent_container, parent_button, *args, **kwargs): super(RepeatPopContainer, self).__init__(*args, **kwargs) self.set_orientation(Gtk.Orientation.HORIZONTAL) self.set_layout(Gtk.ButtonBoxStyle.START) self.props.margin = 5 context = self.get_style_context() context.add_class('linked') icon_size = 4 toggle1 = Gtk.RadioButton.new(None) toggle1.set_mode(False) icon = Gio.ThemedIcon.new_with_default_fallbacks( 'media-playlist-repeat-symbolic') image = Gtk.Image() image.set_from_gicon(icon, icon_size) image.props.margin = 5 toggle1.set_image(image) toggle1.connect('leave-notify-event', self._on_popover_mouse_over) toggle1.connect('enter-notify-event', self._on_popover_mouse_over) toggle1.connect('toggled', self._on_popover_button_toggled) # locale stuff cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) if parent_button.get_has_tooltip(): toggle1.set_tooltip_text(_("Repeat all tracks")) self._repeat_button = toggle1 self.add(toggle1) self.child_set_property(toggle1, "non-homogeneous", True) toggle1.show_all() self._repeat_image = Gtk.Image() self._repeat_image.set_from_gicon(icon, icon_size) self._repeat_image.props.margin = 5 toggle2 = Gtk.RadioButton.new_from_widget(toggle1) toggle2.set_mode(False) icon2 = Gio.ThemedIcon.new_with_default_fallbacks( 'media-playlist-repeat-song-symbolic') image2 = Gtk.Image() image2.set_from_gicon(icon2, icon_size) image2.props.margin = 5 toggle2.set_image(image2) if parent_button.get_has_tooltip(): toggle2.set_tooltip_text(_("Repeat the current track")) self._repeat_song_image = Gtk.Image() self._repeat_song_image.set_from_gicon(icon2, icon_size) self._repeat_song_image.props.margin = 5 toggle2.connect('leave-notify-event', self._on_popover_mouse_over) toggle2.connect('enter-notify-event', self._on_popover_mouse_over) toggle2.connect('toggled', self._on_popover_button_toggled) toggle2.show_all() self._repeat_song_button = toggle2 self.add(toggle2) self.child_set_property(toggle2, "non-homogeneous", True) self._popover_inprogress = 0 parent_container.connect('leave-notify-event', self._on_popover_mouse_over) parent_container.connect('enter-notify-event', self._on_popover_mouse_over) parent_button.connect('leave-notify-event', self._on_popover_mouse_over) parent_button.connect('enter-notify-event', self._on_popover_mouse_over) gicon_name = image.props.gicon parent_button.set_image(self._repeat_image) self._parent_container = parent_container self._parent_button = parent_button # now get the repeat-type saved in gsettings # get values from gsettings self.gs = GSetting() self.plugin_settings = self.gs.get_setting(self.gs.Path.PLUGIN) repeat_type = self.plugin_settings[self.gs.PluginKey.REPEAT_TYPE] if repeat_type == RepeatPopContainer.ONE_SONG: self._repeat_song_button.set_active(True)
def __init__(self, toolbar, rbtree): """ Initialises the object. """ super(AltToolbarSidebar, self).__init__() self.shell = toolbar.shell self.toolbar = toolbar self.plugin = toolbar.plugin self.rbtree = rbtree self._drag_dest_source = None self._drag_motion_counter = -1 # locale stuff cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) self.set_name("AltToolbarSideBar") self._category = {} self._last_click_source = None self._user_clicked = False gs = GSetting() plugin_settings = gs.get_setting(gs.Path.PLUGIN) plugin_settings.bind(gs.PluginKey.EXPANDERS, self, 'expanders', Gio.SettingsBindFlags.DEFAULT) # title, source, visible self.treestore = Gtk.TreeStore.new([str, GObject.Object, bool]) self.treestore_filter = self.treestore.filter_new(root=None) self.treestore_filter.set_visible_column(2) self.set_model(self.treestore_filter) context = self.get_style_context() context.add_class(Gtk.STYLE_CLASS_SIDEBAR) self.set_headers_visible(False) # define the headers - not visible by default def define_category(text, category): local = self.treestore.append(None) self.treestore[local] = [text, None, False] self._category[category] = local define_category(_("Local collection"), AltControllerCategory.LOCAL) define_category(_("Online sources"), AltControllerCategory.ONLINE) define_category(_("Other sources"), AltControllerCategory.OTHER) define_category(_("Playlists"), AltControllerCategory.PLAYLIST) def delayed(*args): model = self.shell.props.display_page_model rootiter = model.get_iter_first() depth = 0 self._traverse_rows(model, rootiter, None, depth) # switch on/off headers depending upon what's in the model self._refresh_headers() # tidy up syncing by connecting signals self._connect_signals() # now expand or collapse each expander that we have saved from a # previous session expanders = eval(self.expanders) print(expanders) print(self.expanders) for category in expanders: print(category) path = self.treestore.get_path(self._category[category]) if path and expanders[category]: # self._user_clicked = True self.expand_row(path, False) # expanders[category]) return False GLib.timeout_add_seconds(1, delayed) column = Gtk.TreeViewColumn.new() column.set_fixed_width(5) column.set_sizing(Gtk.TreeViewColumnSizing.FIXED) self.append_column(column) column = Gtk.TreeViewColumn.new() pixbuf_renderer = Gtk.CellRendererPixbuf() column.pack_start(pixbuf_renderer, False) renderer = Gtk.CellRendererText() renderer.connect('edited', self.on_renderertext_edited) self.text_renderer = renderer column.pack_start(renderer, False) column.set_cell_data_func(pixbuf_renderer, self._set_pixbuf) column.set_cell_data_func(renderer, self._set_text) self.tree_column = column self.append_column(column) self.set_expander_column(column) self.show_all() self.set_can_focus(True) cl = CoverLocale() cl.switch_locale(cl.Locale.RB)
def __init__(self, parent_window, has_headerbar): if has_headerbar: super(PluginDialog, self).__init__(use_header_bar=True, parent=parent_window, flags=Gtk.DialogFlags.MODAL) else: super(PluginDialog, self).__init__(parent=parent_window, flags=Gtk.DialogFlags.MODAL) self._has_headerbar = has_headerbar self._parent_window = parent_window listbox = Gtk.ListBox.new() listbox.set_sort_func(self._listbox_sort, None) self._listbox = listbox self._items = {} self._peas = Peas.Engine.get_default() plugins = self._peas.get_plugin_list() self._peas.connect_after('unload-plugin', self._on_load_unload_plugin) self._peas.connect_after('load-plugin', self._on_load_unload_plugin) for plugin in plugins: if not plugin.is_builtin() and not plugin.is_hidden(): row = PluginListRow(plugin, self._switch_callback) self._items[plugin.get_module_name()] = row listbox.add(row) # locale stuff cl = CoverLocale() cl.switch_locale(cl.Locale.RB) def extract_text(str): # remove _ and (_A) type expressions translation = gettext.gettext(str) translation = re.sub('\(..\)', '', translation, flags=re.DOTALL) translation = translation.replace('_', '') return translation toolbar = Gtk.Toolbar.new() context = toolbar.get_style_context() context.add_class(Gtk.STYLE_CLASS_INLINE_TOOLBAR) item = Gtk.ToolItem.new() btn = Gtk.Button() icon = Gio.ThemedIcon(name="preferences-system-symbolic") image = Gtk.Image() image.props.margin = 3 btn.add(image) btn.set_tooltip_text(extract_text("_Preferences")) image.set_from_gicon(icon, Gtk.IconSize.BUTTON) box = Gtk.Box() box.pack_start(btn, False, False, 0) item.add(box) toolbar.insert(item, 0) btn.connect('clicked', self._preferences_button_clicked) self._preferences_button = btn minitoolbar_box = Gtk.ButtonBox() context = minitoolbar_box.get_style_context() context.add_class('linked') minitoolbar_box.set_layout(Gtk.ButtonBoxStyle.START) btn = Gtk.Button() icon = Gio.ThemedIcon(name="preferences-system-details-symbolic") image = Gtk.Image() image.props.margin = 3 btn.add(image) btn.set_tooltip_text(extract_text("_About")) image.set_from_gicon(icon, Gtk.IconSize.BUTTON) minitoolbar_box.add(btn) minitoolbar_box.child_set_property(btn, "non-homogeneous", True) btn.connect('clicked', self._info_button_clicked) self._info_button = btn btn = Gtk.Button() icon = Gio.ThemedIcon(name="help-contents-symbolic") image = Gtk.Image() image.props.margin = 3 btn.add(image) btn.set_tooltip_text(extract_text("_Help")) image.set_from_gicon(icon, Gtk.IconSize.BUTTON) minitoolbar_box.add(btn) minitoolbar_box.child_set_property(btn, "non-homogeneous", True) btn.connect('clicked', self._help_button_clicked) self._help_button = btn item = Gtk.SeparatorToolItem.new() item.props.draw = False toolbar.insert(item, 1) toolbar.child_set_property(item, "expand", True) item = Gtk.ToolItem.new() item.add(minitoolbar_box) toolbar.insert(item, 2) contentbox = Gtk.Box() contentbox.set_orientation(Gtk.Orientation.VERTICAL) scrollwindow = Gtk.ScrolledWindow.new(None, None) scrollwindow.add(listbox) scrollwindow.props.hexpand = True scrollwindow.props.vexpand = True contentbox.pack_start(scrollwindow, True, True, 0) contentbox.pack_start(toolbar, False, False, 1) self.props.title = _("Configure Plugins") if not self._has_headerbar: self.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE) else: headerbar = self.get_header_bar() headerbar.set_show_close_button(True) contentbox.show_all() area = self.get_content_area() area.add(contentbox) listbox.connect('row-selected', self._listbox_row_selected)
def do_activate(self): """ Called by Rhythmbox when the plugin is activated. It creates the plugin's source and connects signals to manage the plugin's preferences. """ self.shell = self.object self.db = self.shell.props.db self.shell_player = self.shell.props.shell_player # Prepare internal variables self.song_duration = 0 self.entry = None self._plugin_dialog_width = 760 self._plugin_dialog_height = 550 # locale stuff cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) # for custom icons ensure we start looking in the plugin img folder # as a fallback theme = Gtk.IconTheme.get_default() theme.append_search_path(rb.find_plugin_file(self, 'img')) # Find the Rhythmbox Toolbar self.rb_toolbar = AltToolbarPlugin.find(self.shell.props.window, 'main-toolbar', 'by_id') # get values from gsettings self.gs = GSetting() self.plugin_settings = self.gs.get_setting(self.gs.Path.PLUGIN) display_type = self.plugin_settings[self.gs.PluginKey.DISPLAY_TYPE] self.volume_control = self.plugin_settings[ self.gs.PluginKey.VOLUME_CONTROL] self.show_compact_toolbar = self.plugin_settings[ self.gs.PluginKey.SHOW_COMPACT] self.start_hidden = self.plugin_settings[ self.gs.PluginKey.START_HIDDEN] self.inline_label = self.plugin_settings[ self.gs.PluginKey.INLINE_LABEL] self.enhanced_sidebar = self.plugin_settings[ self.gs.PluginKey.ENHANCED_SIDEBAR] self.show_tooltips = self.plugin_settings[ self.gs.PluginKey.SHOW_TOOLTIPS] self.enhanced_plugins = self.plugin_settings[ self.gs.PluginKey.ENHANCED_PLUGINS] self.horiz_categories = self.plugin_settings[ self.gs.PluginKey.HORIZ_CATEGORIES] self.app_menu = self.plugin_settings[self.gs.PluginKey.APP_MENU] self.prefer_dark_theme = \ self.plugin_settings[self.gs.PluginKey.DARK_THEME] # Add the various application view menus self.appshell = ApplicationShell(self.shell) self._add_menu_options() # Determine what type of toolbar is to be displayed default = Gtk.Settings.get_default() if display_type == 0: if ( not default.props.gtk_shell_shows_app_menu) or \ default.props.gtk_shell_shows_menubar: display_type = 2 else: display_type = 1 self.toolbar_type = None if display_type == 1: self.toolbar_type = AltToolbarHeaderBar() elif self.show_compact_toolbar: self.toolbar_type = AltToolbarCompact() else: self.toolbar_type = AltToolbarStandard() self.toolbar_type.initialise(self) self.toolbar_type.post_initialise() if self.enhanced_plugins: # redirect plugins action to our implementation action = Gio.SimpleAction.new('plugins', None) action.connect('activate', self._display_plugins) self.shell.props.application.add_action(action) self._connect_signals() self._connect_properties() # allow other plugins access to this toolbar self.shell.alternative_toolbar = self cl.switch_locale(cl.Locale.RB)
def set_library_labels(self): # locale stuff cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) self.header.set_library_labels(song_label=_('Podcasts'))
def do_activate(self): """ Called by Rhythmbox when the plugin is activated. It creates the plugin's source and connects signals to manage the plugin's preferences. """ self.shell = self.object self.db = self.shell.props.db self.shell_player = self.shell.props.shell_player # Prepare internal variables self.song_duration = 0 self.entry = None self._plugin_dialog_width = 760 self._plugin_dialog_height = 550 # locale stuff cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) # for custom icons ensure we start looking in the plugin img folder # as a fallback theme = Gtk.IconTheme.get_default() theme.append_search_path(rb.find_plugin_file(self, 'img')) # Find the Rhythmbox Toolbar self.rb_toolbar = AltToolbarPlugin.find(self.shell.props.window, 'main-toolbar', 'by_id') # get values from gsettings self.gs = GSetting() self.plugin_settings = self.gs.get_setting(self.gs.Path.PLUGIN) display_type = self.plugin_settings[self.gs.PluginKey.DISPLAY_TYPE] self.volume_control = self.plugin_settings[ self.gs.PluginKey.VOLUME_CONTROL] self.show_compact_toolbar = self.plugin_settings[ self.gs.PluginKey.SHOW_COMPACT] self.start_hidden = self.plugin_settings[ self.gs.PluginKey.START_HIDDEN] self.inline_label = self.plugin_settings[ self.gs.PluginKey.INLINE_LABEL] self.compact_progressbar = self.plugin_settings[ self.gs.PluginKey.COMPACT_PROGRESSBAR] self.enhanced_sidebar = self.plugin_settings[ self.gs.PluginKey.ENHANCED_SIDEBAR] self.show_tooltips = self.plugin_settings[ self.gs.PluginKey.SHOW_TOOLTIPS] self.enhanced_plugins = self.plugin_settings[ self.gs.PluginKey.ENHANCED_PLUGINS] # Add the various application view menus self.appshell = ApplicationShell(self.shell) self._add_menu_options() # Determine what type of toolbar is to be displayed default = Gtk.Settings.get_default() if display_type == 0: if ( not default.props.gtk_shell_shows_app_menu) or \ default.props.gtk_shell_shows_menubar: display_type = 2 else: display_type = 1 self.toolbar_type = None if display_type == 1: self.toolbar_type = AltToolbarHeaderBar() elif self.show_compact_toolbar: self.toolbar_type = AltToolbarCompact() else: self.toolbar_type = AltToolbarStandard() self.toolbar_type.initialise(self) self.toolbar_type.post_initialise() if self.enhanced_plugins: # redirect plugins action to our implementation action = Gio.SimpleAction.new('plugins', None) action.connect('activate', self._display_plugins) self.shell.props.application.add_action(action) self._connect_signals() self._connect_properties() # allow other plugins access to this toolbar self.shell.alternative_toolbar = self cl.switch_locale(cl.Locale.RB)
def do_activate(self): """ Called by Rhythmbox when the plugin is activated. It creates the plugin's source and connects signals to manage the plugin's preferences. """ self.shell = self.object self.db = self.shell.props.db self.shell_player = self.shell.props.shell_player # Prepare internal variables self.song_duration = 0 self.entry = None self._plugin_dialog_width = 760 self._plugin_dialog_height = 550 # locale stuff cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) # for custom icons ensure we start looking in the plugin img folder # as a fallback theme = Gtk.IconTheme.get_default() theme.append_search_path(rb.find_plugin_file(self, 'img')) # Find the Rhythmbox Toolbar self.rb_toolbar = AltToolbarPlugin.find(self.shell.props.window, 'main-toolbar', 'by_id') # get values from gsettings self.gs = GSetting() self.plugin_settings = self.gs.get_setting(self.gs.Path.PLUGIN) display_type = self.plugin_settings[self.gs.PluginKey.DISPLAY_TYPE] self.volume_control = self.plugin_settings[ self.gs.PluginKey.VOLUME_CONTROL] self.show_compact_toolbar = self.plugin_settings[ self.gs.PluginKey.SHOW_COMPACT] self.start_hidden = self.plugin_settings[ self.gs.PluginKey.START_HIDDEN] self.inline_label = self.plugin_settings[ self.gs.PluginKey.INLINE_LABEL] self.enhanced_sidebar = self.plugin_settings[ self.gs.PluginKey.ENHANCED_SIDEBAR] self.show_tooltips = self.plugin_settings[ self.gs.PluginKey.SHOW_TOOLTIPS] self.enhanced_plugins = self.plugin_settings[ self.gs.PluginKey.ENHANCED_PLUGINS] self.horiz_categories = self.plugin_settings[ self.gs.PluginKey.HORIZ_CATEGORIES] self.app_menu = self.plugin_settings[ self.gs.PluginKey.APP_MENU] self.prefer_dark_theme = \ self.plugin_settings[self.gs.PluginKey.DARK_THEME] # Add the various application view menus self.appshell = ApplicationShell(self.shell) self._add_menu_options() # Determine what type of toolbar is to be displayed if display_type == 0: if 'gnome' in os.environ['XDG_CURRENT_DESKTOP'].lower(): display_type = 1 else: display_type = 2 self.plugin_settings[self.gs.PluginKey.DISPLAY_TYPE] = display_type self.toolbar_type = None if display_type == 1: self.toolbar_type = AltToolbarHeaderBar() elif self.show_compact_toolbar: self.toolbar_type = AltToolbarCompact() else: self.toolbar_type = AltToolbarStandard() self.toolbar_type.initialise(self) self.toolbar_type.post_initialise() try: process = Gio.Subprocess.new(['rhythmbox', '--version'], Gio.SubprocessFlags.STDOUT_PIPE) passval, buf, err = process.communicate_utf8(None) if passval: buf = buf[:-1] ver = buf.split(' ')[1] except: ver = "999.99.99" if self.enhanced_plugins and ver <= "3.4.3": # redirect plugins action to our implementation # after v3.4.3 plugins has been moved into # preferences so no need to activate our own # implementation action = Gio.SimpleAction.new('plugins', None) action.connect('activate', self._display_plugins) self.shell.props.application.add_action(action) self._connect_signals() self._connect_properties() # allow other plugins access to this toolbar self.shell.alternative_toolbar = self cl.switch_locale(cl.Locale.RB)
def set_library_labels(self): # locale stuff cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) self.header.set_library_labels(song_label=_('Podcasts'))
def __init__(self, toolbar, rbtree): """ Initialises the object. """ super(AltToolbarSidebar, self).__init__() self.shell = toolbar.shell self.toolbar = toolbar self.plugin = toolbar.plugin self.rbtree = rbtree self._drag_dest_source = None self._drag_motion_counter = -1 # locale stuff cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) self.set_name("AltToolbarSideBar") self._category = {} self._last_click_source = None self._user_clicked = False gs = GSetting() plugin_settings = gs.get_setting(gs.Path.PLUGIN) plugin_settings.bind(gs.PluginKey.EXPANDERS, self, 'expanders', Gio.SettingsBindFlags.DEFAULT) # title, source, visible self.treestore = Gtk.TreeStore.new([str, GObject.Object, bool]) self.treestore_filter = self.treestore.filter_new(root=None) self.treestore_filter.set_visible_column(2) self.set_model(self.treestore_filter) context = self.get_style_context() context.add_class(Gtk.STYLE_CLASS_SIDEBAR) self.set_headers_visible(False) # define the headers - not visible by default def define_category(text, category): local = self.treestore.append(None) self.treestore[local] = [text, None, False] self._category[category] = local define_category(_("Local collection"), AltControllerCategory.LOCAL) define_category(_("Online sources"), AltControllerCategory.ONLINE) define_category(_("Other sources"), AltControllerCategory.OTHER) define_category(_("Playlists"), AltControllerCategory.PLAYLIST) def delayed(*args): model = self.shell.props.display_page_model rootiter = model.get_iter_first() depth = 0 self._traverse_rows(model, rootiter, None, depth) # switch on/off headers depending upon what's in the model self._refresh_headers() # tidy up syncing by connecting signals self._connect_signals() # now expand or collapse each expander that we have saved from a # previous session expanders = eval(self.expanders) print(expanders) print(self.expanders) for category in expanders: print(category) path = self.treestore.get_path(self._category[category]) if path and expanders[category]: # self._user_clicked = True self.expand_row(path, False) # expanders[category]) return False GLib.timeout_add_seconds(1, delayed) column = Gtk.TreeViewColumn.new() column.set_fixed_width(5) column.set_sizing(Gtk.TreeViewColumnSizing.FIXED) self.append_column(column) column = Gtk.TreeViewColumn.new() pixbuf_renderer = Gtk.CellRendererPixbuf() column.pack_start(pixbuf_renderer, False) renderer = Gtk.CellRendererText() renderer.connect('edited', self.on_renderertext_edited) self.text_renderer = renderer column.pack_start(renderer, False) column.set_cell_data_func(pixbuf_renderer, self._set_pixbuf) column.set_cell_data_func(renderer, self._set_text) self.tree_column = column self.append_column(column) self.set_expander_column(column) self.show_all() self.set_can_focus(True) cl = CoverLocale() cl.switch_locale(cl.Locale.RB)