Reload store plugins when they are enabled and disabled.

This commit is contained in:
John Schember 2011-03-05 21:16:06 -05:00
parent baf16af89f
commit 1ec3860ee6
3 changed files with 30 additions and 18 deletions

View File

@ -18,6 +18,10 @@ class StoreAction(InterfaceAction):
def genesis(self):
self.qaction.triggered.connect(self.search)
self.store_menu = QMenu()
self.load_menu()
def load_menu(self):
self.store_menu.clear()
self.store_menu.addAction(_('Search'), self.search)
self.store_menu.addSeparator()
for n, p in self.gui.istores.items():

View File

@ -217,6 +217,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
self.search.search.connect(self.find)
self.next_button.clicked.connect(self.find_next)
self.previous_button.clicked.connect(self.find_previous)
self.changed_signal.connect(self.reload_store_plugins)
def find(self, query):
idx = self._plugin_model.find(query)
@ -342,6 +343,11 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
plugin.name + _(' cannot be removed. It is a '
'builtin plugin. Try disabling it instead.')).exec_()
def reload_store_plugins(self):
self.gui.load_store_plugins()
if self.gui.iactions.has_key('Store'):
self.gui.iactions['Store'].load_menu()
if __name__ == '__main__':
from PyQt4.Qt import QApplication

View File

@ -118,10 +118,27 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
ac.plugin_path = action.plugin_path
ac.interface_action_base_plugin = action
self.add_iaction(ac)
# Stores
self.load_store_plugins()
def init_iaction(self, action):
ac = action.load_actual_plugin(self)
ac.plugin_path = action.plugin_path
ac.interface_action_base_plugin = action
action.actual_iaction_plugin_loaded = True
return ac
def add_iaction(self, ac):
acmap = self.iactions
if ac.name in acmap:
if ac.priority >= acmap[ac.name].priority:
acmap[ac.name] = ac
else:
acmap[ac.name] = ac
def load_store_plugins(self):
self.istores = OrderedDict()
for store in store_plugins():
if opts.ignore_plugins and store.plugin_path is not None:
if self.opts.ignore_plugins and store.plugin_path is not None:
continue
try:
st = self.init_istore(store)
@ -134,13 +151,6 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
raise
continue
def init_iaction(self, action):
ac = action.load_actual_plugin(self)
ac.plugin_path = action.plugin_path
ac.interface_action_base_plugin = action
action.actual_iaction_plugin_loaded = True
return ac
def init_istore(self, store):
st = store.load_actual_plugin(self)
st.plugin_path = store.plugin_path
@ -148,14 +158,6 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
store.actual_istore_plugin_loaded = True
return st
def add_iaction(self, ac):
acmap = self.iactions
if ac.name in acmap:
if ac.priority >= acmap[ac.name].priority:
acmap[ac.name] = ac
else:
acmap[ac.name] = ac
def add_istore(self, st):
stmap = self.istores
if st.name in stmap: