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()
Example #2
0
    def activate(self, shell):
        self.shell = shell  # so the source can update the progress bar
        self.db = shell.get_property("db")

        self.entry_type = self.db.entry_register_type("MagnatuneEntryType")
        # 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()
        rb.append_plugin_source_path(theme, "/icons")

        width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR)
        icon = rb.try_load_icon(theme, "magnatune", width, 0)

        group = rb.rb_source_group_get_by_name("stores")
        self.source = gobject.new(MagnatuneSource,
                                  shell=shell,
                                  entry_type=self.entry_type,
                                  source_group=group,
                                  icon=icon,
                                  plugin=self)

        shell.register_entry_type_for_source(self.source, self.entry_type)
        shell.append_source(self.source, None)  # Add the source to the list

        manager = shell.get_player().get_property('ui-manager')
        # Add the popup menu actions
        self.action_group = gtk.ActionGroup('MagnatunePluginActions')

        action = gtk.Action('MagnatuneDownloadAlbum', _('Download Album'),
                            _("Download this album from Magnatune"),
                            'gtk-save')
        action.connect(
            'activate', lambda a: self.shell.get_property("selected-source").
            download_album())
        self.action_group.add_action(action)
        action = gtk.Action('MagnatuneArtistInfo', _('Artist Information'),
                            _("Get information about this artist"), 'gtk-info')
        action.connect(
            'activate', lambda a: self.shell.get_property("selected-source").
            display_artist_info())
        self.action_group.add_action(action)
        action = gtk.Action('MagnatuneCancelDownload', _('Cancel Downloads'),
                            _("Stop downloading purchased albums"), 'gtk-stop')
        action.connect(
            'activate', lambda a: self.shell.get_property("selected-source").
            cancel_downloads())
        action.set_sensitive(False)
        self.action_group.add_action(action)

        manager.insert_action_group(self.action_group, 0)
        self.ui_id = manager.add_ui_from_string(popup_ui)

        self.pec_id = shell.get_player().connect('playing-song-changed',
                                                 self.playing_entry_changed)
        manager.ensure_update()
Example #3
0
	def activate(self, shell):
		self.shell = shell # so the source can update the progress bar
		self.db = shell.get_property("db")

		self.entry_type = self.db.entry_register_type("MagnatuneEntryType")
		# 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()
		rb.append_plugin_source_path(theme, "/icons")

		width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR)
		icon = rb.try_load_icon(theme, "magnatune", width, 0)

		group = rb.rb_source_group_get_by_name("stores")
		self.source = gobject.new(MagnatuneSource,
					  shell=shell,
					  entry_type=self.entry_type,
					  source_group=group,
					  icon=icon,
					  plugin=self)

		shell.register_entry_type_for_source(self.source, self.entry_type)
		shell.append_source(self.source, None) # Add the source to the list

		manager = shell.get_player().get_property('ui-manager')
		# Add the popup menu actions
		self.action_group = gtk.ActionGroup('MagnatunePluginActions')

		action = gtk.Action('MagnatuneDownloadAlbum', _('Download Album'),
				_("Download this album from Magnatune"),
				'gtk-save')
		action.connect('activate', lambda a: self.shell.get_property("selected-source").download_album())
		self.action_group.add_action(action)
		action = gtk.Action('MagnatuneArtistInfo', _('Artist Information'),
				_("Get information about this artist"),
				'gtk-info')
		action.connect('activate', lambda a: self.shell.get_property("selected-source").display_artist_info())
		self.action_group.add_action(action)
		action = gtk.Action('MagnatuneCancelDownload', _('Cancel Downloads'),
				_("Stop downloading purchased albums"),
				'gtk-stop')
		action.connect('activate', lambda a: self.shell.get_property("selected-source").cancel_downloads())
		action.set_sensitive(False)
		self.action_group.add_action(action)

		manager.insert_action_group(self.action_group, 0)
		self.ui_id = manager.add_ui_from_string(popup_ui)

		self.pec_id = shell.get_player().connect('playing-song-changed', self.playing_entry_changed)
		manager.ensure_update()
    def activate(self, shell):
    # First lets see if we can add to the context menu
        self.db = shell.props.db
        self.entry_type = self.db.entry_register_type("VkontakteMyEntryType")
        group = rb.rb_source_group_get_by_name ("vkontakte")
        if not group:
            group = rb.rb_source_group_register ("vkontakte",
 							     _("Vkontakte"),
 							     rb.SOURCE_GROUP_CATEGORY_FIXED)

        self.vksource = gobject.new (MySource, shell=shell, name=_("My Music"), entry_type=self.entry_type,source_group=group)
        shell.register_entry_type_for_source(self.vksource, self.entry_type)
        shell.append_source(self.vksource, None)
	def activate(self, shell):
		self.db = shell.get_property("db")

		self.entry_type = self.db.entry_register_type("JamendoEntryType")
		# allow changes which don't do anything
		self.entry_type.can_sync_metadata = True
		self.entry_type.sync_metadata = None

		group = rb.rb_source_group_get_by_name ("stores")
 		if not group:
 			group = rb.rb_source_group_register ("stores",
 							     _("Stores"),
 							     rb.SOURCE_GROUP_CATEGORY_FIXED)

		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, "jamendo", width, 0)

		self.source = gobject.new (JamendoSource,
					   shell=shell,
					   entry_type=self.entry_type,
					   plugin=self,
					   icon=icon,
					   source_group=group)
		shell.register_entry_type_for_source(self.source, self.entry_type)
		shell.append_source(self.source, None) # Add the source to the list

		# Add button
		manager = shell.get_player().get_property('ui-manager')
		action = gtk.Action('JamendoDownloadAlbum', _('_Download Album'),
				_("Download this album using BitTorrent"),
				'gtk-save')
		action.connect('activate', lambda a: shell.get_property("selected-source").download_album())
		self.action_group = gtk.ActionGroup('JamendoPluginActions')
		self.action_group.add_action(action)
		
		# Add Button for Donate
		action = gtk.Action('JamendoDonateArtist', _('_Donate to Artist'),
				_("Donate Money to this Artist"),
				'gtk-jump-to')
		action.connect('activate', lambda a: shell.get_property("selected-source").launch_donate())
		self.action_group.add_action(action)

		manager.insert_action_group(self.action_group, 0)
		self.ui_id = manager.add_ui_from_string(popup_ui)
		manager.ensure_update()

		self.pec_id = shell.get_player().connect('playing-song-changed', self.playing_entry_changed)
Example #6
0
	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")
		self.source =gobject.new(DoubanFMSource,
						   shell=shell,
						   entry_type=self.entry_type,
						   plugin=self,
						   icon=icon,
						   source_group=group)
		shell.register_entry_type_for_source(self.source, self.entry_type)
		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"))
		#生成界面
		
		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)
Example #7
0
    def activate(self, shell):
        self.db = shell.get_property("db")

        self.entry_type = self.db.entry_register_type("JamendoEntryType")
        # 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()
        rb.append_plugin_source_path(theme, "/icons/")

        width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR)
        icon = rb.try_load_icon(theme, "jamendo", width, 0)

        group = rb.rb_source_group_get_by_name("stores")
        self.source = gobject.new(JamendoSource,
                                  shell=shell,
                                  entry_type=self.entry_type,
                                  plugin=self,
                                  icon=icon,
                                  source_group=group)
        shell.register_entry_type_for_source(self.source, self.entry_type)
        shell.append_source(self.source, None)  # Add the source to the list

        # Add button
        manager = shell.get_player().get_property('ui-manager')
        action = gtk.Action('JamendoDownloadAlbum', _('_Download Album'),
                            _("Download this album using BitTorrent"),
                            'gtk-save')
        action.connect(
            'activate',
            lambda a: shell.get_property("selected-source").download_album())
        self.action_group = gtk.ActionGroup('JamendoPluginActions')
        self.action_group.add_action(action)

        # Add Button for Donate
        action = gtk.Action('JamendoDonateArtist', _('_Donate to Artist'),
                            _("Donate Money to this Artist"), 'gtk-jump-to')
        action.connect(
            'activate',
            lambda a: shell.get_property("selected-source").launch_donate())
        self.action_group.add_action(action)

        manager.insert_action_group(self.action_group, 0)
        self.ui_id = manager.add_ui_from_string(popup_ui)
        manager.ensure_update()

        self.pec_id = shell.get_player().connect('playing-song-changed',
                                                 self.playing_entry_changed)
Example #8
0
  def activate(self, shell):
    self.db = shell.props.db

    group = rb.rb_source_group_get_by_name ("online")
    if not group:
        group = rb.rb_source_group_register ("online",
                             _("Online"),
                             rb.SOURCE_GROUP_CATEGORY_FIXED)

    self.entry_type = self.db.entry_register_type("GoogleMusic")
    self.entry_type.get_playback_uri=self.get_playback_uri
    theme = gtk.icon_theme_get_default()
    theme.append_search_path(os.path.join(self.__get_plugins_dir(), "icons"))
    rb.append_plugin_source_path(theme, "/icons")

    width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR)
    icon = rb.try_load_icon(theme, "googlemusic", width, 0)

    self.source = gobject.new (OnlineMusicSource,
                   shell=shell,
                   entry_type=self.entry_type,
                   source_group=group,
                   name = _("Google Music"),
                   icon=icon,
                   plugin=self)

    shell.register_entry_type_for_source(self.source, self.entry_type)
    shell.append_source(self.source, None)

    # First lets see if we can add to the context menu
    ui = shell.get_ui_manager()

    # Group and it's actions
    self.action_group = gtk.ActionGroup ('TestActions')

    # Create Actions for the plugin
    action = gtk.Action ('ReloadMusic', _('Reload music'),
                         _('Reload music'),
                         'gtk-refresh')
    activate_id = action.connect ('activate', lambda a: self.source.onlineMusic.reloadMusic())#self.source.onlineMusic.activate()
    self.action_group.add_action (action)
    action = gtk.Action ('SwitchList', _('Switch List'),
                         _('Switch List'),
                         'gtk-properties')#gtk-preferences
    activate_id = action.connect ('activate', lambda a: self.switch_list())
    self.action_group.add_action (action)

    ui.insert_action_group(self.action_group, -1)
	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

		group = rb.rb_source_group_get_by_name(self.config.get("group"))
		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,
			source_group=group,
 			name=self.config.get("name"),
 			shell=shell,
		)

		self.config.set("icon_filename", self.find_file(self.config.get("icon")))
		self.source.activate(self.config)

		shell.register_entry_type_for_source(self.source, self.entry_type)
		shell.append_source(self.source, None)

		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()
Example #10
0
    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_source_group_get_by_name("shared")

        from UpnpSource import UpnpSource
        source = gobject.new (UpnpSource,
                    shell=self.shell,
                    entry_type=self.entry_type,
                    source_group=group,
                    plugin=self,
                    client=client,
                    udn=udn)

        self.sources[udn] = source

        self.shell.append_source (source, None)
Example #11
0
    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()
Example #12
0
    def activate(self, shell):
        self.db = shell.get_property("db")

        self.entry_type = JamendoEntryType()
        self.db.register_entry_type(self.entry_type)

        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, "jamendo", width, 0)

        group = rb.rb_source_group_get_by_name("stores")
        self.source = gobject.new(
            JamendoSource, shell=shell, entry_type=self.entry_type, plugin=self, icon=icon, source_group=group
        )
        shell.register_entry_type_for_source(self.source, self.entry_type)
        shell.append_source(self.source, None)  # Add the source to the list

        # Add button
        manager = shell.get_player().get_property("ui-manager")
        action = gtk.Action(
            "JamendoDownloadAlbum", _("_Download Album"), _("Download this album using BitTorrent"), "gtk-save"
        )
        action.connect("activate", lambda a: shell.get_property("selected-source").download_album())
        self.action_group = gtk.ActionGroup("JamendoPluginActions")
        self.action_group.add_action(action)

        # Add Button for Donate
        action = gtk.Action(
            "JamendoDonateArtist", _("_Donate to Artist"), _("Donate Money to this Artist"), "gtk-jump-to"
        )
        action.connect("activate", lambda a: shell.get_property("selected-source").launch_donate())
        self.action_group.add_action(action)

        manager.insert_action_group(self.action_group, 0)
        self.ui_id = manager.add_ui_from_string(popup_ui)
        manager.ensure_update()

        self.pec_id = shell.get_player().connect("playing-song-changed", self.playing_entry_changed)
Example #13
0
	def run(self,rbshell,rbplugin):
		print "Avahi THINGS !!!!!!!!!!!!!!"
		self.shell=rbshell
		self.rbplugin=rbplugin

		#GUI allgemein vorbereiten
		self.db = self.shell.get_property("db")
		self.entry_type = self.db.entry_register_type("RemoteEntryType")
		self.entry_type.can_sync_metadata = True
                self.entry_type.sync_metadata = None
                theme = gtk.icon_theme_get_default()
                rb.append_plugin_source_path(theme, "/icons/")
                width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR)
                self.icon = rb.try_load_icon(theme, "jamendo", width, 0)
                self.group = rb.rb_source_group_get_by_name ("stores")

		#DBUS lauschen auf remotes
		bus=dbus.SystemBus()#mainloop=loop)
		self.server = dbus.Interface(bus.get_object('org.freedesktop.Avahi','/'),"org.freedesktop.Avahi.Server")
		b = dbus.Interface(bus.get_object(avahi.DBUS_NAME,self.server.ServiceBrowserNew(avahi.IF_UNSPEC,avahi.PROTO_UNSPEC,"_touch-remote._tcp", 'local', dbus.UInt32(0))),avahi.DBUS_INTERFACE_SERVICE_BROWSER)
		b.connect_to_signal("ItemNew",self.newRemote)
		b.connect_to_signal("ItemRemove",self.RemoteRemoved)
Example #14
0
    def activate(self, shell):
        self.shell = shell

        group = rb.rb_source_group_get_by_name ("library")
        self.db = shell.get_property("db")
        try:
            self.entry_type = FolderViewEntryType()
            self.db.register_entry_type(self.entry_type)
        except NotImplementedError:
            self.entry_type = self.db.entry_register_type("FolderViewEntryType")
        self.entry_type.can_sync_metadata = True
        self.entry_type.save_to_disk = True
        self.entry_type.category = rhythmdb.ENTRY_STREAM
        self.source = gobject.new (FolderViewSource,
                                    shell=self.shell,
                                    name="Folder View",
                                    entry_type=self.entry_type,
                                    plugin=self,
                                    source_group=group
                                    )
        self.source.set_property( "icon", self.get_folder_closed_icon()) 
        shell.append_source(self.source, None)
        shell.register_entry_type_for_source(self.source, self.entry_type)
Example #15
0
    def detected_media_server(self, client, udn):
        print "found upnp server %s (%s)"  %  (client.device.get_friendly_name(), udn)
        self.warning("found upnp server %s (%s)"  %  (client.device.get_friendly_name(), udn))
        if client.device.get_id() == self.uuid:
            """ don't react on our own MediaServer"""
            return

        db = self.shell.props.db
        group = rb.rb_source_group_get_by_name ("shared")
        entry_type = db.entry_register_type("CoherenceUpnp:" + client.device.get_id()[5:])

        from UpnpSource import UpnpSource
        source = gobject.new (UpnpSource,
                    shell=self.shell,
                    entry_type=entry_type,
                    source_group=group,
                    plugin=self,
                    client=client,
                    udn=udn)

        self.sources[udn] = source

        self.shell.append_source (source, None)
Example #16
0
    def activate(self, shell):
        self.db = shell.get_property("db")
        self.entry_type = BlofeldEntryType()
        self.db.register_entry_type(self.entry_type)
        model = self.db.query_model_new_empty()
        group = rb.rb_source_group_get_by_name ("library")
        if not group:
            group = rb.rb_source_group_register ("library",
                _("Library"),
                rb.SOURCE_GROUP_CATEGORY_FIXED)
        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, "network-server", width, 0)
        self.source = gobject.new (BlofeldSource,
                        shell=shell,
                        entry_type=self.entry_type,
                        source_group=group,
                        icon=icon,
                        plugin=self)
        shell.register_entry_type_for_source(self.source, self.entry_type)
        shell.append_source(self.source, None) # Add the source to the list
        self.pec_id = shell.get_player().connect('playing-song-changed', self.playing_entry_changed)
Example #17
0
    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_source_group_get_by_name("shared")
        entry_type = db.entry_register_type("CoherenceUpnp:%s" %
                                            client.device.get_id()[5:])

        from UpnpSource import UpnpSource
        source = gobject.new(UpnpSource,
                             shell=self.shell,
                             entry_type=entry_type,
                             source_group=group,
                             plugin=self,
                             client=client,
                             udn=udn)

        self.sources[udn] = source

        self.shell.append_source(source, None)
Example #18
0
    def activate(self, shell):

        self.shell = shell
        print "activating Hora python plugin"
        self.db = shell.get_property("db")

        print "register entry type"

        if hasattr(self.db, 'entry_register_type'):
            self.entry_type = self.db.entry_register_type("HoraEntryType")
        else:
            self.entry_type = HoraEntryType()
            self.db.register_entry_type(self.entry_type)

        group = rb.rb_source_group_get_by_name("shared")
        self.source = gobject.new(HoraSource,
                                  shell=self.shell,
                                  entry_type=self.entry_type,
                                  source_group=group,
                                  plugin=self,
                                  name=_("Hora"))

        self.shell.register_entry_type_for_source(self.source, self.entry_type)
        self.shell.append_source(self.source, None)
        self.entry_type.get_playback_uri = self.hora_get_playback_uri

        print "loading icon and button"
        icon_file_name = self.find_file("hora.svg")
        iconsource = gtk.IconSource()
        iconsource.set_filename(icon_file_name)
        iconset = gtk.IconSet()
        iconset.add_source(iconsource)
        iconfactory = gtk.IconFactory()
        iconfactory.add("hora-button", iconset)
        iconfactory.add_default()

        hora_action = gtk.Action('Hora', _('Hora'), _('Que hora Es?'),
                                 "hora-button")

        #action.connect('activate', self.hora, shell)
        hora_action.connect('activate', self.hora, shell)

        self.action_group = gtk.ActionGroup('HoraActionGroup')
        self.action_group.add_action_with_accel(hora_action, '<Control>h')
        self.action_group.add_toggle_actions([
            ('Cron', None, '_Cron', '<Control>c', 'Activar Cron', self.cron)
        ])

        ui_manager = shell.get_ui_manager()
        ui_manager.insert_action_group(self.action_group, 0)
        self.UI_ID = ui_manager.add_ui_from_string(ui_str)
        ui_manager.ensure_update()

        # add hora.spx
        fpath = self.find_file(audio_file)
        self.uri = fpath
        gconf.client_get_default().set_string(gconf_keys['button'],
                                              "Agregar a la Cola")
        gconf.client_get_default().set_string(gconf_keys['offset'], "0")
        gconf.client_get_default().set_string(gconf_keys['crontab'],
                                              "Disactivado")

        #self.gconf.set_string(gconf_keys['button'], "not queue")
        load_uri = "file://" + self.uri

        entry = self.db.entry_lookup_by_location(self.uri)
        if entry == None:
            print "add entry: " + load_uri
            entry = self.db.entry_new(self.entry_type, load_uri)

            self.db.set(entry, rhythmdb.PROP_TITLE, "Didza Lube")
            self.db.set(entry, rhythmdb.PROP_ALBUM, "HORA")
            self.db.set(entry, rhythmdb.PROP_ARTIST, "Radio Yaxhil")
Example #19
0
	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)
Example #20
0
	def activate(self, shell):

		self.shell = shell    
		print "activating Hora python plugin"
	        self.db = shell.get_property("db")
		
		
		print "register entry type"
		
		if hasattr(self.db, 'entry_register_type'):
			self.entry_type = self.db.entry_register_type("HoraEntryType")
		else:
			self.entry_type = HoraEntryType()
			self.db.register_entry_type(self.entry_type)
			 
		group = rb.rb_source_group_get_by_name("shared")
		self.source = gobject.new (HoraSource,
                    shell=self.shell,
                    entry_type=self.entry_type,
                    source_group=group,
                    plugin=self,
                    name=_("Hora"))
		
		self.shell.register_entry_type_for_source(self.source, self.entry_type)
        	self.shell.append_source (self.source, None)
		self.entry_type.get_playback_uri = self.hora_get_playback_uri
	        
		print "loading icon and button"
       		icon_file_name = self.find_file("hora.svg")
        	iconsource = gtk.IconSource()
        	iconsource.set_filename(icon_file_name)
        	iconset = gtk.IconSet()
        	iconset.add_source(iconsource)
        	iconfactory = gtk.IconFactory()
        	iconfactory.add("hora-button", iconset)
        	iconfactory.add_default()

		hora_action = gtk.Action ('Hora',
                     _('Hora'), 
                     _('Que hora Es?'),
                     "hora-button")

		#action.connect('activate', self.hora, shell)
		hora_action.connect('activate', self.hora, shell)

		self.action_group = gtk.ActionGroup('HoraActionGroup')
		self.action_group.add_action_with_accel(hora_action, '<Control>h')
		self.action_group.add_toggle_actions([('Cron', None, '_Cron', '<Control>c',
                                         'Activar Cron', self.cron)])

		ui_manager = shell.get_ui_manager()
		ui_manager.insert_action_group(self.action_group, 0)
		self.UI_ID = ui_manager.add_ui_from_string(ui_str)
		ui_manager.ensure_update()

		# add hora.spx
		fpath =  self.find_file(audio_file)
		self.uri = fpath
		gconf.client_get_default().set_string(gconf_keys['button'], "Agregar a la Cola")
		gconf.client_get_default().set_string(gconf_keys['offset'], "0")
		gconf.client_get_default().set_string(gconf_keys['crontab'], "Disactivado")

		#self.gconf.set_string(gconf_keys['button'], "not queue")
		load_uri = "file://"+ self.uri

		entry = self.db.entry_lookup_by_location(self.uri)
         	if entry == None:
			print "add entry: "+ load_uri				
                	entry = self.db.entry_new(self.entry_type, load_uri)
			
			self.db.set(entry, rhythmdb.PROP_TITLE, "Didza Lube")
			self.db.set(entry, rhythmdb.PROP_ALBUM, "HORA")
		        self.db.set(entry, rhythmdb.PROP_ARTIST, "Radio Yaxhil")
	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_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)
		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( "icon",  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)