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 # 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] # 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() self._connect_signals() self._connect_properties() # allow other plugins access to this toolbar self.shell.alternative_toolbar = self
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)