コード例 #1
0
class Ampache(rb.Plugin):
	def __init__(self):
		self.config = AmpacheConfig()

		rb.Plugin.__init__(self)

	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 deactivate(self, shell):
		self.db.entry_delete_by_type(self.entry_type)
                self.db.commit()
                del self.db
                self.db = None

                self.entry_type = None

                self.source.delete_thyself()
                del self.source
                self.source = None

		# clean up the UI
		ui_manager = shell.get_ui_manager()
		ui_manager.remove_ui(self.uid)

	def create_configure_dialog(self):
		glade_file = self.find_file("ampache-prefs.glade")

		if glade_file:
			dialog = AmpacheConfigDialog(glade_file, self.config).get_dialog()

		if dialog:
			return dialog
		else:
			print "couldn't create configure dialog"
			return None

       	def refetch_ampache(self, widget, shell):
		self.source.download_db()
コード例 #2
0
	def __init__(self):
		self.config = AmpacheConfig()

		rb.Plugin.__init__(self)
コード例 #3
0
class Ampache(rb.Plugin):
	def __init__(self):
		self.config = AmpacheConfig()

		rb.Plugin.__init__(self)

	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()

	def deactivate(self, shell):
		self.db.entry_delete_by_type(self.entry_type)
                self.db.commit()
                del self.db
                self.db = None

                self.entry_type = None

                self.source.delete_thyself()
                del self.source
                self.source = None

		# clean up the UI
		ui_manager = shell.get_ui_manager()
		ui_manager.remove_ui(self.uid)

	def create_configure_dialog(self):
		glade_file = self.find_file("ampache-prefs.glade")

		if glade_file:
			dialog = AmpacheConfigDialog(glade_file, self.config).get_dialog()

		if dialog:
			return dialog
		else:
			print "couldn't create configure dialog"
			return None

       	def refetch_ampache(self, widget, shell):
		self.source.download_db()