def __init__(self): """ Initialises the object. """ super(AltToolbarBase, self).__init__() gs = GSetting() plugin_settings = gs.get_setting(gs.Path.PLUGIN) plugin_settings.bind(gs.PluginKey.SOURCE_TOOLBAR, self, 'source_toolbar_visible', Gio.SettingsBindFlags.DEFAULT) self._async_functions = [ ] # array of functions to callback once the toolbar has been setup self.connect('notify::setup-completed', self._on_setup_completed)
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 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 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)