rendered paste bodyimport rb
import rhythmdb
class MyPlugin(rb.Plugin):
sources = []
def __init__(self):
rb.Plugin.__init__(self)
def activate(self, shell):
self.cs_id = shell.props.removable_media_manager.connect("create-source", self.create_source)
self.shell = shell
def deactivate(self, shell):
shell.props.removable_media_manager.disconnect(self.cs_id)
del self.cs_id
del self.shell
for s in self.sources:
s.delete_thyself()
sources = []
def create_source(self, manager, volume):
# determine whether this is something we can handle
is_valid_device = True
if is_valid_device:
entry_type = self.shell.db.entry_register_type("MyRemovableDevice:" + volume.get_device_path())
source = gobject.new (MyRemovableSource, shell=self.shell, volume=volume, source_group=rb.SOURCE_GROUP_DEVICES, entry_type=entry_type)
self.sources.append(source)
return source
else:
return None
class MyRemovableSource(rb.RemovableMediaSource):
def __init__(self, *args, **kwargs):
rb.RemovableMediaSource(self, *args, **kwargs)
gobject.type_register(MyRemovableSource)