1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
from gi.repository import GObject, Peas
from gi.repository import RB
import gettext
gettext.install('rhythmbox', RB.locale_dir())
class SamplePython(GObject.Object, Peas.Activatable):
__gtype_name = 'SamplePythonPlugin'
object = GObject.property(type=GObject.GObject)
def __init__(self):
GObject.Object.__init__(self)
def do_activate(self):
print "activating sample python plugin"
shell = self.object
db = shell.props.db
model = RB.RhythmDBQueryModel.new_empty(db)
self.source = GObject.new (PythonSource, shell=shell, name=_("Python Source"), query_model=model)
self.source.setup()
group = RB.DisplayPageGroup.get_by_id ("library")
shell.append_display_page(self.source, group)
def do_deactivate(self):
print "deactivating sample python plugin"
self.source.delete_thyself()
self.source = None
class PythonSource(RB.Source):
def __init__(self, **kwargs):
super(PythonSource, self).__init__(kwargs)
def setup(self):
shell = self.props.shell
songs = RB.EntryView(db=shell.props.db, shell_player=shell.props.shell_player, is_drag_source=False, is_drag_dest=False)
songs.append_column(RB.EntryViewColumn.TITLE, True)
songs.set_model(self.props.query_model)
songs.show_all()
self.pack_start(songs, expand=True, fill=True, padding=0)
GObject.type_register(PythonSource)
|