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. ''' print("CoverArtBrowser DEBUG - do_activate") self.shell = self.object self.db = self.shell.props.db try: entry_type = CoverArtBrowserEntryType() self.db.register_entry_type(entry_type) except NotImplementedError: entry_type = self.db.entry_register_type( 'CoverArtBrowserEntryType') cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) entry_type.category = RB.RhythmDBEntryCategory.NORMAL group = RB.DisplayPageGroup.get_by_id('library') # load plugin icon theme = Gtk.IconTheme.get_default() rb.append_plugin_source_path(theme, '/icons') # lets assume that python3 versions of RB only has the new icon attribute in the source if rb3compat.PYVER >=3: iconfile = Gio.File.new_for_path( rb.find_plugin_file(self, 'img/' + Theme(self).current\ + '/covermgr.png')) self.source = CoverArtBrowserSource( shell=self.shell, name=_("CoverArt"), entry_type=entry_type, plugin=self, icon=Gio.FileIcon.new(iconfile), query_model=self.shell.props.library_source.props.base_query_model) else: what, width, height = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR) pxbf = GdkPixbuf.Pixbuf.new_from_file_at_size( rb.find_plugin_file(self, 'img/' + Theme(self).current\ + '/covermgr.png'), width, height) self.source = CoverArtBrowserSource( shell=self.shell, name=_("CoverArt"), entry_type=entry_type, plugin=self, pixbuf=pxbf, query_model=self.shell.props.library_source.props.base_query_model) self.shell.register_entry_type_for_source(self.source, entry_type) self.shell.append_display_page(self.source, group) self.source.props.query_model.connect('complete', self.load_complete) print("CoverArtBrowser DEBUG - end do_activate")
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. ''' # define .plugin text strings used for translation plugin = _('CoverArt Browser') desc = _('Browse and play your albums through their covers') print "CoverArtBrowser DEBUG - do_activate" self.shell = self.object self.db = self.shell.props.db try: entry_type = CoverArtBrowserEntryType() self.db.register_entry_type(entry_type) except NotImplementedError: entry_type = self.db.entry_register_type( 'CoverArtBrowserEntryType') cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) entry_type.category = RB.RhythmDBEntryCategory.NORMAL # load plugin icon theme = Gtk.IconTheme.get_default() rb.append_plugin_source_path(theme, '/icons') what, width, height = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR) pxbf = GdkPixbuf.Pixbuf.new_from_file_at_size( rb.find_plugin_file(self, 'img/' + Theme(self).current\ + '/covermgr.png'), width, height) group = RB.DisplayPageGroup.get_by_id('library') self.source = CoverArtBrowserSource( shell=self.shell, name=_("CoverArt"), entry_type=entry_type, plugin=self, pixbuf=pxbf, query_model=self.shell.props.library_source.props.base_query_model) self.shell.register_entry_type_for_source(self.source, entry_type) self.shell.append_display_page(self.source, group) self.source.props.query_model.connect('complete', self.load_complete) print "CoverArtBrowser DEBUG - end do_activate"
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. ''' # define .plugin text strings used for translation plugin = _('CoverArt Browser') desc = _('Browse and play your albums through their covers') print("CoverArtBrowser DEBUG - do_activate") self.shell = self.object self.db = self.shell.props.db try: entry_type = CoverArtBrowserEntryType() self.db.register_entry_type(entry_type) except NotImplementedError: entry_type = self.db.entry_register_type( 'CoverArtBrowserEntryType') cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) entry_type.category = RB.RhythmDBEntryCategory.NORMAL # load plugin icon theme = Gtk.IconTheme.get_default() rb.append_plugin_source_path(theme, '/icons') what, width, height = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR) pxbf = GdkPixbuf.Pixbuf.new_from_file_at_size( rb.find_plugin_file(self, 'img/' + Theme(self).current\ + '/covermgr.png'), width, height) group = RB.DisplayPageGroup.get_by_id('library') self.source = CoverArtBrowserSource(shell=self.shell, name=_("CoverArt"), entry_type=entry_type, plugin=self, pixbuf=pxbf, query_model=self.shell.props.library_source.props.base_query_model) self.shell.register_entry_type_for_source(self.source, entry_type) self.shell.append_display_page(self.source, group) self.source.props.query_model.connect('complete', self.load_complete) print("CoverArtBrowser DEBUG - end do_activate")
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. ''' print("CoverArtBrowser DEBUG - do_activate") self.shell = self.object self.db = self.shell.props.db self.entry_type = CoverArtBrowserEntryType() self.db.register_entry_type(self.entry_type) cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) self.entry_type.category = RB.RhythmDBEntryCategory.NORMAL group = RB.DisplayPageGroup.get_by_id('library') # load plugin icon theme = Gtk.IconTheme.get_default() rb.append_plugin_source_path(theme, '/icons') iconfile = Gio.File.new_for_path( rb.find_plugin_file(self, 'img/covermgr_rb3.png')) self.source = CoverArtBrowserSource( shell=self.shell, name=_("CoverArt"), entry_type=self.entry_type, plugin=self, icon=Gio.FileIcon.new(iconfile), query_model=self.shell.props.library_source.props.base_query_model) self.shell.register_entry_type_for_source(self.source, self.entry_type) self.shell.append_display_page(self.source, group) self.source.props.query_model.connect('complete', self.load_complete) self._externalmenu = ExternalPluginMenu(self) cl.switch_locale(cl.Locale.RB) print("CoverArtBrowser DEBUG - end do_activate")
class CoverArtBrowserPlugin(GObject.Object, Peas.Activatable): ''' Main class of the plugin. Manages the activation and deactivation of the plugin. ''' __gtype_name = 'CoverArtBrowserPlugin' object = GObject.property(type=GObject.Object) def __init__(self): ''' Initialises the plugin object. ''' GObject.Object.__init__(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. ''' print("CoverArtBrowser DEBUG - do_activate") self.shell = self.object self.db = self.shell.props.db entry_type = CoverArtBrowserEntryType() self.db.register_entry_type(entry_type) cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) entry_type.category = RB.RhythmDBEntryCategory.NORMAL group = RB.DisplayPageGroup.get_by_id('library') # load plugin icon theme = Gtk.IconTheme.get_default() rb.append_plugin_source_path(theme, '/icons') iconfile = Gio.File.new_for_path( rb.find_plugin_file(self, 'img/covermgr_rb3.png')) self.source = CoverArtBrowserSource( shell=self.shell, name=_("CoverArt"), entry_type=entry_type, plugin=self, icon=Gio.FileIcon.new(iconfile), query_model=self.shell.props.library_source.props.base_query_model) self.shell.register_entry_type_for_source(self.source, entry_type) self.shell.append_display_page(self.source, group) self.source.props.query_model.connect('complete', self.load_complete) self._externalmenu = ExternalPluginMenu(self) cl.switch_locale(cl.Locale.RB) print("CoverArtBrowser DEBUG - end do_activate") def do_deactivate(self): ''' Called by Rhythmbox when the plugin is deactivated. It makes sure to free all the resources used by the plugin. ''' print("CoverArtBrowser DEBUG - do_deactivate") self.source.delete_thyself() if self._externalmenu: self._externalmenu.cleanup() del self.shell del self.db del self.source print("CoverArtBrowser DEBUG - end do_deactivate") def load_complete(self, *args, **kwargs): ''' Called by Rhythmbox when it has completed loading all data Used to automatically switch to the browser if the user has set in the preferences ''' gs = GSetting() setting = gs.get_setting(gs.Path.PLUGIN) if setting[gs.PluginKey.AUTOSTART]: GLib.idle_add(self.shell.props.display_page_tree.select, self.source) def _translation_helper(self): ''' a method just to help out with translation strings it is not meant to be called by itself ''' # define .plugin text strings used for translation plugin = _('CoverArt Browser') desc = _('Browse and play your albums through their covers') #. TRANSLATORS: This is the icon-grid view that the user sees tile = _('Tiles') #. TRANSLATORS: This is the cover-flow view the user sees - they can swipe album covers from side-to-side artist = _('Flow') #. TRANSLATORS: percentage size that the image will be expanded scale = _('Scale by %:') # stop PyCharm removing the Preference import on optimisation pref = Preferences()
class CoverArtBrowserPlugin(GObject.Object, Peas.Activatable): ''' Main class of the plugin. Manages the activation and deactivation of the plugin. ''' __gtype_name = 'CoverArtBrowserPlugin' object = GObject.property(type=GObject.Object) def __init__(self): ''' Initialises the plugin object. ''' GObject.Object.__init__(self) GObject.threads_init() 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. ''' # define .plugin text strings used for translation plugin = _('CoverArt Browser') desc = _('Browse and play your albums through their covers') print("CoverArtBrowser DEBUG - do_activate") self.shell = self.object self.db = self.shell.props.db try: entry_type = CoverArtBrowserEntryType() self.db.register_entry_type(entry_type) except NotImplementedError: entry_type = self.db.entry_register_type( 'CoverArtBrowserEntryType') cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) entry_type.category = RB.RhythmDBEntryCategory.NORMAL # load plugin icon theme = Gtk.IconTheme.get_default() rb.append_plugin_source_path(theme, '/icons') what, width, height = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR) pxbf = GdkPixbuf.Pixbuf.new_from_file_at_size( rb.find_plugin_file(self, 'img/' + Theme(self).current\ + '/covermgr.png'), width, height) group = RB.DisplayPageGroup.get_by_id('library') self.source = CoverArtBrowserSource(shell=self.shell, name=_("CoverArt"), entry_type=entry_type, plugin=self, pixbuf=pxbf, query_model=self.shell.props.library_source.props.base_query_model) self.shell.register_entry_type_for_source(self.source, entry_type) self.shell.append_display_page(self.source, group) self.source.props.query_model.connect('complete', self.load_complete) print("CoverArtBrowser DEBUG - end do_activate") def do_deactivate(self): ''' Called by Rhythmbox when the plugin is deactivated. It makes sure to free all the resources used by the plugin. ''' print("CoverArtBrowser DEBUG - do_deactivate") self.source.delete_thyself() del self.shell del self.db del self.source print("CoverArtBrowser DEBUG - end do_deactivate") def load_complete(self, *args, **kwargs): ''' Called by Rhythmbox when it has completed loading all data Used to automatically switch to the browser if the user has set in the preferences ''' gs = GSetting() setting = gs.get_setting(gs.Path.PLUGIN) if setting[gs.PluginKey.AUTOSTART]: GObject.idle_add(self.shell.props.display_page_tree.select, self.source)
class CoverArtBrowserPlugin(GObject.Object, Peas.Activatable): ''' Main class of the plugin. Manages the activation and deactivation of the plugin. ''' __gtype_name = 'CoverArtBrowserPlugin' object = GObject.property(type=GObject.Object) def __init__(self): ''' Initialises the plugin object. ''' GObject.Object.__init__(self) if rb3compat.pygobject_version() < 3.9: GObject.threads_init() 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. ''' print("CoverArtBrowser DEBUG - do_activate") self.shell = self.object self.db = self.shell.props.db try: entry_type = CoverArtBrowserEntryType() self.db.register_entry_type(entry_type) except NotImplementedError: entry_type = self.db.entry_register_type( 'CoverArtBrowserEntryType') cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) entry_type.category = RB.RhythmDBEntryCategory.NORMAL group = RB.DisplayPageGroup.get_by_id('library') # load plugin icon theme = Gtk.IconTheme.get_default() rb.append_plugin_source_path(theme, '/icons') # lets assume that python3 versions of RB only has the new icon attribute in the source if rb3compat.PYVER >=3: iconfile = Gio.File.new_for_path( rb.find_plugin_file(self, 'img/' + Theme(self).current\ + '/covermgr.png')) self.source = CoverArtBrowserSource( shell=self.shell, name=_("CoverArt"), entry_type=entry_type, plugin=self, icon=Gio.FileIcon.new(iconfile), query_model=self.shell.props.library_source.props.base_query_model) else: what, width, height = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR) pxbf = GdkPixbuf.Pixbuf.new_from_file_at_size( rb.find_plugin_file(self, 'img/' + Theme(self).current\ + '/covermgr.png'), width, height) self.source = CoverArtBrowserSource( shell=self.shell, name=_("CoverArt"), entry_type=entry_type, plugin=self, pixbuf=pxbf, query_model=self.shell.props.library_source.props.base_query_model) self.shell.register_entry_type_for_source(self.source, entry_type) self.shell.append_display_page(self.source, group) self.source.props.query_model.connect('complete', self.load_complete) print("CoverArtBrowser DEBUG - end do_activate") def do_deactivate(self): ''' Called by Rhythmbox when the plugin is deactivated. It makes sure to free all the resources used by the plugin. ''' print("CoverArtBrowser DEBUG - do_deactivate") self.source.delete_thyself() del self.shell del self.db del self.source print("CoverArtBrowser DEBUG - end do_deactivate") def load_complete(self, *args, **kwargs): ''' Called by Rhythmbox when it has completed loading all data Used to automatically switch to the browser if the user has set in the preferences ''' gs = GSetting() setting = gs.get_setting(gs.Path.PLUGIN) if setting[gs.PluginKey.AUTOSTART]: GObject.idle_add(self.shell.props.display_page_tree.select, self.source) def _translation_helper(self): ''' a method just to help out with translation strings it is not meant to be called by itself ''' # define .plugin text strings used for translation plugin = _('CoverArt Browser') desc = _('Browse and play your albums through their covers') #. TRANSLATORS: This is the icon-grid view that the user sees #. TRANSLATORS: Please try to keep the translation to less than 8 characters tile = _('Tiles') #. TRANSLATORS: This is the cover-flow view the user sees - they can swipe album covers from side-to-side #. TRANSLATORS: Please try to keep the translation to less than 8 characters artist = _('Flow') #. TRANSLATORS: percentage size that the image will be expanded scale = _('Scale by %:')
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. ''' print("CoverArtBrowser DEBUG - do_activate") self.shell = self.object self.db = self.shell.props.db self.entry_type = CoverArtBrowserEntryType() self.db.register_entry_type(self.entry_type) # we do some specific functionality when working with alternative toolbar # variables defined by the externalpluginmenu self.using_alternative_toolbar = False self.using_headerbar = False cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) self.entry_type.category = RB.RhythmDBEntryCategory.NORMAL group = RB.DisplayPageGroup.get_by_id('library') theme = Gtk.IconTheme.get_default() theme.append_search_path(rb.find_plugin_file(self, 'img')) iconfile = Gio.ThemedIcon(name='coverart-icon-symbolic') # our plugin model shared between sources self.source_query_model = RB.RhythmDBQueryModel.new_empty( self.shell.props.db) self.source = CoverArtBrowserSource( shell=self.shell, name=_("CoverArt"), entry_type=self.entry_type, plugin=self, icon=iconfile, query_model=self.shell.props.library_source.props.base_query_model) self.shell.register_entry_type_for_source(self.source, self.entry_type) self.source.props.visibility = False self.shell.append_display_page(self.source, group) self.playlist_source = GObject.new(CoverArtPlaySource, name=_("CoverArt Playlist"), shell=self.shell, plugin=self, entry_type=self.entry_type) self.shell.append_display_page(self.playlist_source, self.source) self.shell.props.db.connect('load-complete', self.load_complete) # GLib.timeout_add_seconds(3, self.load_complete) # kludge - if plugin activated after RB has loaded then do stuff def delayed(*args): if self.shell.props.selected_page: self._externalmenu = ExternalPluginMenu(self) return False else: return True GLib.timeout_add(100, delayed) cl.switch_locale(cl.Locale.RB) print("CoverArtBrowser DEBUG - end do_activate")
class CoverArtBrowserPlugin(GObject.Object, Peas.Activatable): ''' Main class of the plugin. Manages the activation and deactivation of the plugin. ''' __gtype_name = 'CoverArtBrowserPlugin' object = GObject.property(type=GObject.Object) def __init__(self): ''' Initialises the plugin object. ''' GObject.Object.__init__(self) self._externalmenu = None 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. ''' print("CoverArtBrowser DEBUG - do_activate") self.shell = self.object self.db = self.shell.props.db self.entry_type = CoverArtBrowserEntryType() self.db.register_entry_type(self.entry_type) # we do some specific functionality when working with alternative toolbar # variables defined by the externalpluginmenu self.using_alternative_toolbar = False self.using_headerbar = False cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) self.entry_type.category = RB.RhythmDBEntryCategory.NORMAL group = RB.DisplayPageGroup.get_by_id('library') theme = Gtk.IconTheme.get_default() theme.append_search_path(rb.find_plugin_file(self, 'img')) iconfile = Gio.ThemedIcon(name='coverart-icon-symbolic') # our plugin model shared between sources self.source_query_model = RB.RhythmDBQueryModel.new_empty( self.shell.props.db) self.source = CoverArtBrowserSource( shell=self.shell, name=_("CoverArt"), entry_type=self.entry_type, plugin=self, icon=iconfile, query_model=self.shell.props.library_source.props.base_query_model) self.shell.register_entry_type_for_source(self.source, self.entry_type) self.source.props.visibility = False self.shell.append_display_page(self.source, group) self.playlist_source = GObject.new(CoverArtPlaySource, name=_("CoverArt Playlist"), shell=self.shell, plugin=self, entry_type=self.entry_type) self.shell.append_display_page(self.playlist_source, self.source) self.shell.props.db.connect('load-complete', self.load_complete) # GLib.timeout_add_seconds(3, self.load_complete) # kludge - if plugin activated after RB has loaded then do stuff def delayed(*args): if self.shell.props.selected_page: self._externalmenu = ExternalPluginMenu(self) return False else: return True GLib.timeout_add(100, delayed) cl.switch_locale(cl.Locale.RB) print("CoverArtBrowser DEBUG - end do_activate") def do_deactivate(self): ''' Called by Rhythmbox when the plugin is deactivated. It makes sure to free all the resources used by the plugin. ''' print("CoverArtBrowser DEBUG - do_deactivate") self.source.delete_thyself() if self._externalmenu: self._externalmenu.cleanup(full_cleanup=True) del self.shell del self.db del self.source print("CoverArtBrowser DEBUG - end do_deactivate") def load_complete(self, *args, **kwargs): ''' Called by Rhythmbox when it has completed loading all data Used to automatically switch to the browser if the user has set in the preferences ''' gs = GSetting() setting = gs.get_setting(gs.Path.PLUGIN) if setting[gs.PluginKey.AUTOSTART]: self._externalmenu.autostart_source() def _translation_helper(self): ''' a method just to help out with translation strings it is not meant to be called by itself ''' # define .plugin text strings used for translation plugin = _('CoverArt Browser') desc = _('Browse and play your albums through their covers') # . TRANSLATORS: This is the icon-grid view that the user sees tile = _('Tiles') #. TRANSLATORS: This is the cover-flow view the user sees - they can swipe album covers from side-to-side artist = _('Flow') #. TRANSLATORS: percentage size that the image will be expanded scale = _('Scale by %:') # stop PyCharm removing the Preference import on optimisation pref = Preferences()
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. ''' print("CoverArtBrowser DEBUG - do_activate") self.shell = self.object self.db = self.shell.props.db try: entry_type = CoverArtBrowserEntryType() self.db.register_entry_type(entry_type) except NotImplementedError: entry_type = self.db.entry_register_type( 'CoverArtBrowserEntryType') cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) entry_type.category = RB.RhythmDBEntryCategory.NORMAL group = RB.DisplayPageGroup.get_by_id('library') # load plugin icon theme = Gtk.IconTheme.get_default() rb.append_plugin_source_path(theme, '/icons') # lets assume that python3 versions of RB only has the new icon attribute in the source if rb3compat.PYVER >=3: iconfile = Gio.File.new_for_path( rb.find_plugin_file(self, 'img/covermgr_rb3.png')) self.source = CoverArtBrowserSource( shell=self.shell, name=_("CoverArt"), entry_type=entry_type, plugin=self, icon=Gio.FileIcon.new(iconfile), query_model=self.shell.props.library_source.props.base_query_model) else: what, width, height = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR) pxbf = GdkPixbuf.Pixbuf.new_from_file_at_size( rb.find_plugin_file(self, 'img/covermgr.png'), width, height) self.source = CoverArtBrowserSource( shell=self.shell, name=_("CoverArt"), entry_type=entry_type, plugin=self, pixbuf=pxbf, query_model=self.shell.props.library_source.props.base_query_model) self.shell.register_entry_type_for_source(self.source, entry_type) self.shell.append_display_page(self.source, group) self.source.props.query_model.connect('complete', self.load_complete) if rb3compat.PYVER >=3: self._externalmenu = ExternalPluginMenu(self) else: self._externalmenu = None cl.switch_locale(cl.Locale.RB) print("CoverArtBrowser DEBUG - end do_activate")
class CoverArtBrowserPlugin(GObject.Object, Peas.Activatable): ''' Main class of the plugin. Manages the activation and deactivation of the plugin. ''' __gtype_name = 'CoverArtBrowserPlugin' object = GObject.property(type=GObject.Object) def __init__(self): ''' Initialises the plugin object. ''' GObject.Object.__init__(self) if not rb3compat.compare_pygobject_version('3.9'): GObject.threads_init() 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. ''' print("CoverArtBrowser DEBUG - do_activate") self.shell = self.object self.db = self.shell.props.db try: entry_type = CoverArtBrowserEntryType() self.db.register_entry_type(entry_type) except NotImplementedError: entry_type = self.db.entry_register_type( 'CoverArtBrowserEntryType') cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) entry_type.category = RB.RhythmDBEntryCategory.NORMAL group = RB.DisplayPageGroup.get_by_id('library') # load plugin icon theme = Gtk.IconTheme.get_default() rb.append_plugin_source_path(theme, '/icons') # lets assume that python3 versions of RB only has the new icon attribute in the source if rb3compat.PYVER >=3: iconfile = Gio.File.new_for_path( rb.find_plugin_file(self, 'img/covermgr_rb3.png')) self.source = CoverArtBrowserSource( shell=self.shell, name=_("CoverArt"), entry_type=entry_type, plugin=self, icon=Gio.FileIcon.new(iconfile), query_model=self.shell.props.library_source.props.base_query_model) else: what, width, height = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR) pxbf = GdkPixbuf.Pixbuf.new_from_file_at_size( rb.find_plugin_file(self, 'img/covermgr.png'), width, height) self.source = CoverArtBrowserSource( shell=self.shell, name=_("CoverArt"), entry_type=entry_type, plugin=self, pixbuf=pxbf, query_model=self.shell.props.library_source.props.base_query_model) self.shell.register_entry_type_for_source(self.source, entry_type) self.shell.append_display_page(self.source, group) self.source.props.query_model.connect('complete', self.load_complete) if rb3compat.PYVER >=3: self._externalmenu = ExternalPluginMenu(self) else: self._externalmenu = None cl.switch_locale(cl.Locale.RB) print("CoverArtBrowser DEBUG - end do_activate") def do_deactivate(self): ''' Called by Rhythmbox when the plugin is deactivated. It makes sure to free all the resources used by the plugin. ''' print("CoverArtBrowser DEBUG - do_deactivate") self.source.delete_thyself() if self._externalmenu: self._externalmenu.cleanup() del self.shell del self.db del self.source print("CoverArtBrowser DEBUG - end do_deactivate") def load_complete(self, *args, **kwargs): ''' Called by Rhythmbox when it has completed loading all data Used to automatically switch to the browser if the user has set in the preferences ''' gs = GSetting() setting = gs.get_setting(gs.Path.PLUGIN) if setting[gs.PluginKey.AUTOSTART]: GLib.idle_add(self.shell.props.display_page_tree.select, self.source) def _translation_helper(self): ''' a method just to help out with translation strings it is not meant to be called by itself ''' # define .plugin text strings used for translation plugin = _('CoverArt Browser') desc = _('Browse and play your albums through their covers') #. TRANSLATORS: This is the icon-grid view that the user sees tile = _('Tiles') #. TRANSLATORS: This is the cover-flow view the user sees - they can swipe album covers from side-to-side artist = _('Flow') #. TRANSLATORS: percentage size that the image will be expanded scale = _('Scale by %:')
class CoverArtBrowserPlugin(GObject.Object, Peas.Activatable): ''' Main class of the plugin. Manages the activation and deactivation of the plugin. ''' __gtype_name = 'CoverArtBrowserPlugin' object = GObject.property(type=GObject.Object) def __init__(self): ''' Initialises the plugin object. ''' GObject.Object.__init__(self) GObject.threads_init() 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. ''' # define .plugin text strings used for translation plugin = _('CoverArt Browser') desc = _('Browse and play your albums through their covers') print "CoverArtBrowser DEBUG - do_activate" self.shell = self.object self.db = self.shell.props.db try: entry_type = CoverArtBrowserEntryType() self.db.register_entry_type(entry_type) except NotImplementedError: entry_type = self.db.entry_register_type( 'CoverArtBrowserEntryType') cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) entry_type.category = RB.RhythmDBEntryCategory.NORMAL # load plugin icon theme = Gtk.IconTheme.get_default() rb.append_plugin_source_path(theme, '/icons') what, width, height = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR) pxbf = GdkPixbuf.Pixbuf.new_from_file_at_size( rb.find_plugin_file(self, 'img/' + Theme(self).current\ + '/covermgr.png'), width, height) group = RB.DisplayPageGroup.get_by_id('library') self.source = CoverArtBrowserSource( shell=self.shell, name=_("CoverArt"), entry_type=entry_type, plugin=self, pixbuf=pxbf, query_model=self.shell.props.library_source.props.base_query_model) self.shell.register_entry_type_for_source(self.source, entry_type) self.shell.append_display_page(self.source, group) self.source.props.query_model.connect('complete', self.load_complete) print "CoverArtBrowser DEBUG - end do_activate" def do_deactivate(self): ''' Called by Rhythmbox when the plugin is deactivated. It makes sure to free all the resources used by the plugin. ''' print "CoverArtBrowser DEBUG - do_deactivate" self.source.delete_thyself() del self.shell del self.db del self.source print "CoverArtBrowser DEBUG - end do_deactivate" def load_complete(self, *args, **kwargs): ''' Called by Rhythmbox when it has completed loading all data Used to automatically switch to the browser if the user has set in the preferences ''' gs = GSetting() setting = gs.get_setting(gs.Path.PLUGIN) if setting[gs.PluginKey.AUTOSTART]: GObject.idle_add(self.shell.props.display_page_tree.select, self.source)
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. ''' print("CoverArtBrowser DEBUG - do_activate") self.shell = self.object self.db = self.shell.props.db self.entry_type = CoverArtBrowserEntryType() self.db.register_entry_type(self.entry_type) # we do some specific functionality when working with alternative toolbar # variables defined by the externalpluginmenu self.using_alternative_toolbar = False self.using_headerbar = False cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) self.entry_type.category = RB.RhythmDBEntryCategory.NORMAL group = RB.DisplayPageGroup.get_by_id('library') theme = Gtk.IconTheme.get_default() theme.append_search_path(rb.find_plugin_file(self, 'img')) iconfile = Gio.ThemedIcon(name = 'coverart-icon-symbolic') # our plugin model shared between sources self.source_query_model = RB.RhythmDBQueryModel.new_empty(self.shell.props.db) self.source = CoverArtBrowserSource( shell=self.shell, name=_("CoverArt"), entry_type=self.entry_type, plugin=self, icon=iconfile, query_model=self.shell.props.library_source.props.base_query_model) self.shell.register_entry_type_for_source(self.source, self.entry_type) self.source.props.visibility = False self.shell.append_display_page(self.source, group) self.playlist_source = GObject.new( CoverArtPlaySource, name=_("CoverArt Playlist"), shell=self.shell, plugin=self, entry_type=self.entry_type) self.shell.append_display_page(self.playlist_source, self.source) self.shell.props.db.connect('load-complete', self.load_complete) # GLib.timeout_add_seconds(3, self.load_complete) # kludge - if plugin activated after RB has loaded then do stuff def delayed(*args): if self.shell.props.selected_page: self._externalmenu = ExternalPluginMenu(self) return False else: return True GLib.timeout_add(100, delayed) cl.switch_locale(cl.Locale.RB) print("CoverArtBrowser DEBUG - end do_activate")
class CoverArtBrowserPlugin(GObject.Object, Peas.Activatable): ''' Main class of the plugin. Manages the activation and deactivation of the plugin. ''' __gtype_name = 'CoverArtBrowserPlugin' object = GObject.property(type=GObject.Object) def __init__(self): ''' Initialises the plugin object. ''' GObject.Object.__init__(self) self._externalmenu = None 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. ''' print("CoverArtBrowser DEBUG - do_activate") self.shell = self.object self.db = self.shell.props.db self.entry_type = CoverArtBrowserEntryType() self.db.register_entry_type(self.entry_type) # we do some specific functionality when working with alternative toolbar # variables defined by the externalpluginmenu self.using_alternative_toolbar = False self.using_headerbar = False cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) self.entry_type.category = RB.RhythmDBEntryCategory.NORMAL group = RB.DisplayPageGroup.get_by_id('library') theme = Gtk.IconTheme.get_default() theme.append_search_path(rb.find_plugin_file(self, 'img')) iconfile = Gio.ThemedIcon(name = 'coverart-icon-symbolic') # our plugin model shared between sources self.source_query_model = RB.RhythmDBQueryModel.new_empty(self.shell.props.db) self.source = CoverArtBrowserSource( shell=self.shell, name=_("CoverArt"), entry_type=self.entry_type, plugin=self, icon=iconfile, query_model=self.shell.props.library_source.props.base_query_model) self.shell.register_entry_type_for_source(self.source, self.entry_type) self.source.props.visibility = False self.shell.append_display_page(self.source, group) self.playlist_source = GObject.new( CoverArtPlaySource, name=_("CoverArt Playlist"), shell=self.shell, plugin=self, entry_type=self.entry_type) self.shell.append_display_page(self.playlist_source, self.source) self.shell.props.db.connect('load-complete', self.load_complete) # GLib.timeout_add_seconds(3, self.load_complete) # kludge - if plugin activated after RB has loaded then do stuff def delayed(*args): if self.shell.props.selected_page: self._externalmenu = ExternalPluginMenu(self) return False else: return True GLib.timeout_add(100, delayed) cl.switch_locale(cl.Locale.RB) print("CoverArtBrowser DEBUG - end do_activate") def do_deactivate(self): ''' Called by Rhythmbox when the plugin is deactivated. It makes sure to free all the resources used by the plugin. ''' print("CoverArtBrowser DEBUG - do_deactivate") self.source.delete_thyself() if self._externalmenu: self._externalmenu.cleanup(full_cleanup=True) del self.shell del self.db del self.source print("CoverArtBrowser DEBUG - end do_deactivate") def load_complete(self, *args, **kwargs): ''' Called by Rhythmbox when it has completed loading all data Used to automatically switch to the browser if the user has set in the preferences ''' gs = GSetting() setting = gs.get_setting(gs.Path.PLUGIN) if setting[gs.PluginKey.AUTOSTART]: self._externalmenu.autostart_source() def _translation_helper(self): ''' a method just to help out with translation strings it is not meant to be called by itself ''' # define .plugin text strings used for translation plugin = _('CoverArt Browser') desc = _('Browse and play your albums through their covers') # . TRANSLATORS: This is the icon-grid view that the user sees tile = _('Tiles') #. TRANSLATORS: This is the cover-flow view the user sees - they can swipe album covers from side-to-side artist = _('Flow') #. TRANSLATORS: percentage size that the image will be expanded scale = _('Scale by %:') # stop PyCharm removing the Preference import on optimisation pref = Preferences()