1
# -*- Mode: python; coding: utf-8; tab-width: 8; indent-tabs-mode: t; -*-
7
from AmpacheConfig import AmpacheConfig
8
from AmpacheConfigDialog import AmpacheConfigDialog
9
from AmpacheBrowser import AmpacheBrowser
13
<menubar name="MenuBar">
14
<menu name="ToolsMenu" action="Tools">
15
<placeholder name="ToolsOps_5">
16
<menuitem name="Re-fetch Ampache Library" action="RefetchAmpache"/>
23
class AmpacheEntryType(rhythmdb.EntryType):
25
rhythmdb.EntryType.__init__(self, name='AmpacheEntryType')
27
class Ampache(rb.Plugin):
29
self.config = AmpacheConfig()
31
rb.Plugin.__init__(self)
33
def activate(self, shell):
34
self.db = shell.props.db
36
self.entry_type = AmpacheEntryType()
37
self.entry_type.can_sync_metadata = True
38
self.entry_type.sync_metadata = None
39
self.entry_type.category = rhythmdb.ENTRY_STREAM
41
group = rb.rb_source_group_get_by_name(self.config.get("group"))
43
group = rb.rb_source_group_register (
45
self.config.get("group"),
46
rb.SOURCE_GROUP_CATEGORY_FIXED,
50
self.source = gobject.new (
52
entry_type=self.entry_type,
54
name=self.config.get("name"),
58
self.config.set("icon_filename", self.find_file(self.config.get("icon")))
59
self.source.activate(self.config)
61
shell.register_entry_type_for_source(self.source, self.entry_type)
62
shell.append_source(self.source, None)
64
ui_manager = shell.get_ui_manager()
65
action = gtk.Action('RefetchAmpache',
66
_('_Re-fetch Ampache Library'),
67
_('Update the local ampache library'), "")
68
action.connect ('activate', self.refetch_ampache, shell)
69
action_group = gtk.ActionGroup ('RefetchAmpacheGroup')
70
action_group.add_action(action)
71
ui_manager.insert_action_group(action_group, -1)
72
self.uid = ui_manager.add_ui_from_string(ui_str)
73
ui_manager.ensure_update()
75
def deactivate(self, shell):
76
self.db.entry_delete_by_type(self.entry_type)
81
self.entry_type = None
83
self.source.delete_thyself()
88
ui_manager = shell.get_ui_manager()
89
ui_manager.remove_ui(self.uid)
91
def create_configure_dialog(self):
92
glade_file = self.find_file("ampache-prefs.glade")
95
dialog = AmpacheConfigDialog(glade_file, self.config).get_dialog()
100
print "couldn't create configure dialog"
103
def refetch_ampache(self, widget, shell):
104
self.source.download_db()