def activate(self, shell): try: entry_type = VkontakteEntryType() shell.props.db.register_entry_type(entry_type) except NotImplementedError: # backward compatibility with 0.12 version entry_type = shell.props.db.entry_register_type("VkontakteEntryType") # Set the source's icon width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR) icon = gtk.gdk.pixbuf_new_from_file_at_size(DATA_DIR+"/vk_small.png", width, height) # rhythmbox api break up (0.13.2 - 0.13.3) if hasattr(rb, 'rb_source_group_get_by_name'): source_group = rb.rb_source_group_get_by_name("library") self.source = gobject.new(VkontakteSource, name=_("Vkontakte"), shell=shell, icon=icon, plugin=self, entry_type=entry_type, source_group=source_group) shell.register_entry_type_for_source(self.source, entry_type) shell.append_source(self.source, None) else: source_group = rb.rb_display_page_group_get_by_id ("library") self.source = gobject.new(VkontakteSource, name=_("Vkontakte"), shell=shell, plugin=self, pixbuf=icon, entry_type=entry_type) shell.register_entry_type_for_source(self.source, entry_type) shell.append_display_page(self.source, source_group) ui = shell.get_ui_manager() self.uid = ui.add_ui_from_string(popup_ui) ui.ensure_update() self.source.initialise()
def detected_media_server(self, client, udn): self.info("found upnp server %s (%s)" % (client.device.get_friendly_name(), udn)) """ don't react on our own MediaServer""" if hasattr(self, 'server') and client.device.get_id() == str( self.server.uuid): return db = self.shell.props.db group = rb.rb_display_page_group_get_by_id("shared") entry_type = CoherenceDBEntryType(client.device.get_id()[5:]) db.register_entry_type(entry_type) from UpnpSource import UpnpSource source = gobject.new(UpnpSource, shell=self.shell, entry_type=entry_type, plugin=self, client=client, udn=udn) self.sources[udn] = source self.shell.append_display_page(source, group)
def activate(self, shell): self.db = shell.props.db self.entry_type = AmpacheEntryType() self.entry_type.can_sync_metadata = True self.entry_type.sync_metadata = None self.entry_type.category = rhythmdb.ENTRY_STREAM theme = gtk.icon_theme_get_default() rb.append_plugin_source_path(theme, "/icons/") width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR) #icon = rb.try_load_icon(theme, "ampache", width, 0) group = rb.rb_display_page_group_get_by_id ("shared") if not group: group = rb.rb_source_group_register ( "ampache", self.config.get("group"), rb.SOURCE_GROUP_CATEGORY_FIXED, ) self.source = gobject.new ( AmpacheBrowser, entry_type=self.entry_type, plugin=self, name=self.config.get("name"), shell=shell, ) self.config.set("icon_filename", self.find_file(self.config.get("icon"))) #icon = rb.try_load_icon(theme, "ampache", width, 0) icon = gtk.gdk.pixbuf_new_from_file_at_size(self.config.get("icon_filename"), width, height) self.source = gobject.new (AmpacheBrowser, shell=shell, entry_type=self.entry_type, plugin=self, name=self.config.get("name"), pixbuf=icon) self.source.activate(self.config) shell.register_entry_type_for_source(self.source, self.entry_type) shell.append_display_page(self.source, group) ui_manager = shell.get_ui_manager() action = gtk.Action('RefetchAmpache', _('_Re-fetch Ampache Library'), _('Update the local ampache library'), "") action.connect ('activate', self.refetch_ampache, shell) action_group = gtk.ActionGroup ('RefetchAmpacheGroup') action_group.add_action(action) ui_manager.insert_action_group(action_group, -1) self.uid = ui_manager.add_ui_from_string(ui_str) ui_manager.ensure_update()
def activate(self, shell): #logging log.setLevel(logging.DEBUG) console_handler = logging.StreamHandler() console_handler.setLevel(logging.DEBUG) console_handler.setFormatter(logging.Formatter('%(name)s %(levelname)-8s %(module)s::%(funcName)s - %(message)s')) log.addHandler(console_handler) self._shell=shell self._handler = [ shell.props.shell_player.connect('playing-song-changed', self._on_playing_song_changed)] self._ui=UI.UI(); self.build_actions() self._setup=Setup.SetupBox() self.db = shell.get_property("db") try: self.entry_type = DoubanFMEntryType() self.db.register_entry_type(self.entry_type) except NotImplementedError: self.entry_type = self.db.entry_register_type("DoubanFMEntryType") # allow changes which don't do anything self.entry_type.can_sync_metadata = True self.entry_type.sync_metadata = None theme = gtk.icon_theme_get_default() width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR) icon = rb.try_load_icon(theme, "doubanFM", width, 0) #group = rb.rb_source_group_get_by_name ("stores") group = rb.rb_display_page_group_get_by_id ("stores") self.source =gobject.new(DoubanFMSource, shell=shell, entry_type=self.entry_type, pixbuf=icon, plugin=self) shell.register_entry_type_for_source(self.source, self.entry_type) shell.append_display_page(self.source, group) #shell.append_source(self.source, None) self._uiManager=shell.props.ui_manager self._uiManager.insert_action_group(self.actionGroup) # self.uiMergeid=self._uiManager.add_ui_from_file(self.find_file("UI.xml")) #生成界面 log.info(self._ui.buildUIString()) self.uiMergeid=self._uiManager.add_ui_from_string(self._ui.buildUIString()) self._uiManager.ensure_update() if gconf.client_get_default().get_without_default(Setup.ENABLE_INDICATOR).get_bool(): doubanIndicator=DoubanIndicator.DoubanIndicator() doubanIndicator.indicator(shell,self)
def create_source(self, playlist_name, playlist): entry_type = SampleEntryType() self.db.register_entry_type(entry_type) mysource = gobject.new(SampleSource, shell=self.shell, name=_(playlist_name), entry_type=entry_type) width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR) icon = gtk.gdk.pixbuf_new_from_file_at_size(self.find_file("echo_logo_64a.png"), width, height) mysource.set_property("pixbuf", icon) group = rb.rb_display_page_group_get_by_id("playlists") self.shell.append_display_page (mysource, group) self.shell.register_entry_type_for_source(mysource, entry_type) for songobj in playlist: # don't put two same URIs in db... new_entry = self.db.entry_lookup_by_location(uri=songobj['uri']) or self.db.entry_new(entry_type, songobj['uri'] ) self.db.set(new_entry, rhythmdb.PROP_ARTIST, songobj['artist']) self.db.set(new_entry, rhythmdb.PROP_TITLE, songobj['title']) self.db.commit()
def detected_media_server(self, client, udn): self.info("found upnp server %s (%s)" % (client.device.get_friendly_name(), udn)) if self.server and client.device.get_id() == str(self.server.uuid): """ don't react on our own MediaServer""" return db = self.shell.props.db group = rb.rb_display_page_group_get_by_id ("shared") from UpnpSource import UpnpSource source = gobject.new (UpnpSource, shell=self.shell, entry_type=self.entry_type, plugin=self, client=client, udn=udn) self.sources[udn] = source self.shell.append_display_page (source, group)
def detected_media_server(self, client, udn): self.info("found upnp server %s (%s)" % (client.device.get_friendly_name(), udn)) if self.server and client.device.get_id() == str(self.server.uuid): """ don't react on our own MediaServer""" return db = self.shell.props.db group = rb.rb_display_page_group_get_by_id("shared") from UpnpSource import UpnpSource source = gobject.new(UpnpSource, shell=self.shell, entry_type=self.entry_type, plugin=self, client=client, udn=udn) self.sources[udn] = source self.shell.append_display_page(source, group)
def activate(self, shell): try: entry_type = VkontakteEntryType() shell.props.db.register_entry_type(entry_type) except NotImplementedError: # backward compatibility with 0.12 version entry_type = shell.props.db.entry_register_type( "VkontakteEntryType") # Set the source's icon width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR) icon = gtk.gdk.pixbuf_new_from_file_at_size(self.find_file("icon.ico"), width, height) # rhythmbox api break up (0.13.2 - 0.13.3) if hasattr(rb, 'rb_source_group_get_by_name'): source_group = rb.rb_source_group_get_by_name("library") self.source = gobject.new(VkontakteSource, name=_("Vkontakte"), shell=shell, icon=icon, plugin=self, entry_type=entry_type, source_group=source_group) shell.register_entry_type_for_source(self.source, entry_type) shell.append_source(self.source, None) else: source_group = rb.rb_display_page_group_get_by_id("library") self.source = gobject.new(VkontakteSource, name=_("Vkontakte"), shell=shell, plugin=self, pixbuf=icon, entry_type=entry_type) shell.register_entry_type_for_source(self.source, entry_type) shell.append_display_page(self.source, source_group) ui = shell.get_ui_manager() self.uid = ui.add_ui_from_string(popup_ui) ui.ensure_update() self.source.initialise()
def create_source(self, playlist_name, playlist): entry_type = SampleEntryType() self.db.register_entry_type(entry_type) mysource = gobject.new(SampleSource, shell=self.shell, name=_(playlist_name), entry_type=entry_type) width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR) icon = gtk.gdk.pixbuf_new_from_file_at_size( self.find_file("echo_logo_64a.png"), width, height) mysource.set_property("pixbuf", icon) group = rb.rb_display_page_group_get_by_id("playlists") self.shell.append_display_page(mysource, group) self.shell.register_entry_type_for_source(mysource, entry_type) for songobj in playlist: # don't put two same URIs in db... new_entry = self.db.entry_lookup_by_location( uri=songobj['uri']) or self.db.entry_new( entry_type, songobj['uri']) self.db.set(new_entry, rhythmdb.PROP_ARTIST, songobj['artist']) self.db.set(new_entry, rhythmdb.PROP_TITLE, songobj['title']) self.db.commit()
def activate(self, shell): print "activating pandora plugin" db = shell.props.db try: entry_type = db.entry_register_type("PandoraEntryType") except AttributeError: entry_type = rhythmdb.EntryType() width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR) icon = gtk.gdk.pixbuf_new_from_file_at_size(self.find_file("pandora.png"), width, height) # rhythmbox api break up (0.13.2 - 0.13.3) if hasattr(shell, 'append_source'): self.source = gobject.new (PandoraSource, shell=shell, plugin=self, name=_("Pandora"), icon=icon, entry_type=entry_type) shell.append_source(self.source, None) else: group = rb.rb_display_page_group_get_by_id ("library") self.source = gobject.new (PandoraSource, shell=shell, plugin=self, name=_("Pandora"), pixbuf=icon, entry_type=entry_type) shell.append_display_page(self.source, group) shell.register_entry_type_for_source(self.source, entry_type) # hack, should be done within gobject constructor self.source.init() self.pec_id = shell.get_player().connect_after('playing-song-changed', self.playing_entry_changed) self.psc_id = shell.get_player().connect_after('playing-source-changed', self.playing_source_changed)
def detected_media_server(self, client, udn): self.info("found upnp server %s (%s)" % (client.device.get_friendly_name(), udn)) """ don't react on our own MediaServer""" if hasattr(self, 'server') and client.device.get_id() == str(self.server.uuid): return db = self.shell.props.db group = rb.rb_display_page_group_get_by_id ("shared") entry_type = CoherenceDBEntryType(client.device.get_id()[5:]) db.register_entry_type(entry_type) from UpnpSource import UpnpSource source = gobject.new (UpnpSource, shell=self.shell, entry_type=entry_type, plugin=self, client=client, udn=udn) self.sources[udn] = source self.shell.append_display_page (source, group)
def activate(self, shell): # Get the translation file install('radio-browser') # register this source in rhythmbox db = shell.props.db try: entry_type = RadioBrowserEntryType() db.register_entry_type(entry_type) except NotImplementedError: entry_type = db.entry_register_type("RadioBrowserEntryType") entry_type.category = rhythmdb.ENTRY_STREAM group = rb.rb_display_page_group_get_by_id("library") self.source = gobject.new (RadioBrowserSource, shell=shell, name=_("Radio browser"), entry_type=entry_type,plugin=self) shell.append_display_page(self.source, group) shell.register_entry_type_for_source(self.source, entry_type) gobject.type_register(RadioBrowserSource) # load plugin icon width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR) filepath = self.find_file("radio-browser.png") if filepath: icon = gtk.gdk.pixbuf_new_from_file_at_size(filepath, width, height) self.source.set_property( "pixbuf", icon) self.actiongroup = gtk.ActionGroup('RadioBrowserActionGroup') # add "update-all" action to the toolbar action = gtk.Action('UpdateList', None, _("Update radio station list"), gtk.STOCK_GO_DOWN) action.connect('activate', lambda a: shell.get_property("selected-source").update_button_clicked()) self.actiongroup.add_action(action) action = gtk.Action('ClearIconCache', None, _("Clear icon cache"), gtk.STOCK_CLEAR) action.connect('activate', lambda a: shell.get_property("selected-source").clear_iconcache_button_clicked()) self.actiongroup.add_action(action) uim = shell.get_ui_manager () uim.insert_action_group (self.actiongroup) uim.ensure_update() # try reading gconf entries and set default values if not readable self.download_trys = gconf.client_get_default().get_string(gconf_keys['download_trys']) if not self.download_trys: self.download_trys = "3" gconf.client_get_default().set_string(gconf_keys['download_trys'], self.download_trys) self.recently_played_purge_days = gconf.client_get_default().get_string(gconf_keys['recently_played_purge_days']) if not self.recently_played_purge_days: self.recently_played_purge_days = "3" gconf.client_get_default().set_string(gconf_keys['recently_played_purge_days'], self.recently_played_purge_days) # set the output path of recorded music to xdg standard directory for music self.outputpath = gconf.client_get_default().get_string(gconf_keys['outputpath']) if not self.outputpath: self.outputpath = os.path.expanduser("~") # try to read xdg music dir try: f = open(self.outputpath+"/.config/user-dirs.dirs","r") except IOError: print "xdg user dir file not found" else: for line in f: if line.startswith("XDG_MUSIC_DIR"): self.outputpath = os.path.expandvars(line.split("=")[1].strip().strip('"')) print self.outputpath f.close() gconf.client_get_default().set_string(gconf_keys['outputpath'], self.outputpath)
def activate(self, shell): def action_update_list(): try: shell.get_property("selected-source").update_button_clicked() except: # 0.13.3 shell.get_property("selected-page").update_button_clicked() def action_remove_images(): try: shell.get_property("selected-source").clear_iconcache_button_clicked() except: # 0.13.3 shell.get_property("selected-page").clear_iconcache_button_clicked() # Get the translation file install('radio-browser') # register this source in rhythmbox db = shell.props.db try: entry_type = RadioBrowserEntryType() db.register_entry_type(entry_type) except NotImplementedError: entry_type = db.entry_register_type("RadioBrowserEntryType") entry_type.category = rhythmdb.ENTRY_STREAM # load plugin icon width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR) filepath = self.find_file("radio-browser.png") if filepath: icon = gtk.gdk.pixbuf_new_from_file_at_size(filepath, width, height) # self.source.set_property( "icon", icon) try: group = rb.rb_source_group_get_by_name ("library") self.source = gobject.new (RadioBrowserSource, shell=shell, name=_("Radio browser"), entry_type=entry_type,source_group=group,plugin=self) shell.append_source(self.source, None) if filepath: self.source.set_property( "icon", icon) except: group = rb.rb_display_page_group_get_by_id ("library") self.source = gobject.new (RadioBrowserSource, shell=shell, name=_("Radio browser"), entry_type=entry_type,plugin=self,pixbuf=icon) shell.append_display_page(self.source, group) shell.register_entry_type_for_source(self.source, entry_type) gobject.type_register(RadioBrowserSource) self.actiongroup = gtk.ActionGroup('RadioBrowserActionGroup') # add "update-all" action to the toolbar action = gtk.Action('UpdateList', None, _("Update radio station list"), gtk.STOCK_GO_DOWN) action.connect('activate', lambda a: action_update_list()) self.actiongroup.add_action(action) action = gtk.Action('ClearIconCache', None, _("Clear icon cache"), gtk.STOCK_CLEAR) action.connect('activate', lambda a: action_remove_images()) self.actiongroup.add_action(action) uim = shell.get_ui_manager () uim.insert_action_group (self.actiongroup) uim.ensure_update() # try reading gconf entries and set default values if not readable self.download_trys = gconf.client_get_default().get_string(gconf_keys['download_trys']) if not self.download_trys: self.download_trys = "3" gconf.client_get_default().set_string(gconf_keys['download_trys'], self.download_trys) self.recently_played_purge_days = gconf.client_get_default().get_string(gconf_keys['recently_played_purge_days']) if not self.recently_played_purge_days: self.recently_played_purge_days = "3" gconf.client_get_default().set_string(gconf_keys['recently_played_purge_days'], self.recently_played_purge_days) # set the output path of recorded music to xdg standard directory for music self.outputpath = gconf.client_get_default().get_string(gconf_keys['outputpath']) if not self.outputpath: self.outputpath = os.path.expanduser("~") # try to read xdg music dir try: f = open(self.outputpath+"/.config/user-dirs.dirs","r") except IOError: print "xdg user dir file not found" else: for line in f: if line.startswith("XDG_MUSIC_DIR"): self.outputpath = os.path.expandvars(line.split("=")[1].strip().strip('"')) print self.outputpath f.close() gconf.client_get_default().set_string(gconf_keys['outputpath'], self.outputpath)