本文整理汇总了Python中GTG.core.plugins.engine.PluginEngine.deactivate_plugins方法的典型用法代码示例。如果您正苦于以下问题:Python PluginEngine.deactivate_plugins方法的具体用法?Python PluginEngine.deactivate_plugins怎么用?Python PluginEngine.deactivate_plugins使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GTG.core.plugins.engine.PluginEngine
的用法示例。
在下文中一共展示了PluginEngine.deactivate_plugins方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Manager
# 需要导入模块: from GTG.core.plugins.engine import PluginEngine [as 别名]
# 或者: from GTG.core.plugins.engine.PluginEngine import deactivate_plugins [as 别名]
#.........这里部分代码省略.........
# When an editor is closed, it should de-register itself.
if tid in self.opened_task:
#the following line has the side effect of removing the
# tid key in the opened_task dictionary.
editor = self.opened_task[tid]
if editor:
del self.opened_task[tid]
#we have to remove the tid from opened_task first
#else, it close_task would be called once again
#by editor.close
editor.close()
self.check_quit_condition()
def check_quit_condition(self):
'''
checking if we need to shut down the whole GTG (if no window is open)
'''
if not self.is_browser_visible() and not self.opened_task:
#no need to live
print "AAAAAAAAAAA"
self.quit()
print self.opened_task
################ Others dialog ############################################
def open_edit_backends(self, sender = None, backend_id = None):
if not self.edit_backends_dialog:
self.edit_backends_dialog = BackendsDialog(self.req)
self.edit_backends_dialog.activate()
if backend_id != None:
self.edit_backends_dialog.show_config_for_backend(backend_id)
def configure_backend(self, backend_id):
self.open_edit_backends(None, backend_id)
def open_preferences(self, config_priv, sender=None):
if not hasattr(self, "preferences"):
self.preferences = PreferencesDialog(self.config_obj)
self.preferences.activate(config_priv)
def ask_delete_tasks(self, tids):
if not self.delete_dialog:
self.delete_dialog = DeletionUI(self.req)
if self.delete_dialog.delete_tasks(tids):
for t in tids:
if t in self.opened_task:
self.close_task(t)
### URIS ###################################################################
def open_uri_list(self, unused, uri_list):
'''
Open the Editor windows of the tasks associated with the uris given.
Uris are of the form gtg://<taskid>
'''
print self.req.get_all_tasks_list()
for uri in uri_list:
if uri.startswith("gtg://"):
self.open_task(uri[6:])
#if no window was opened, we just quit
self.check_quit_condition()
### MAIN ###################################################################
def main(self, once_thru = False, uri_list = []):
if uri_list:
#before opening the requested tasks, we make sure that all of them
#are loaded.
BackendSignals().connect('default-backend-loaded',
self.open_uri_list,
uri_list)
else:
self.open_browser()
gobject.threads_init()
if not self.gtk_terminate:
if once_thru:
gtk.main_iteration()
else:
gtk.main()
return 0
def quit(self,sender=None):
gtk.main_quit()
#save opened tasks and their positions.
open_task = []
for otid in self.opened_task.keys():
open_task.append(otid)
self.opened_task[otid].close()
self.config["browser"]["opened_tasks"] = open_task
# adds the plugin settings to the conf
#FIXME: this code is replicated in the preference window.
if len(self.pengine.plugins) > 0:
self.config["plugins"] = {}
self.config["plugins"]["disabled"] = \
[p.module_name for p in self.pengine.get_plugins("disabled")]
self.config["plugins"]["enabled"] = \
[p.module_name for p in self.pengine.get_plugins("enabled")]
# plugins are deactivated
self.pengine.deactivate_plugins()
示例2: __init__
# 需要导入模块: from GTG.core.plugins.engine import PluginEngine [as 别名]
# 或者: from GTG.core.plugins.engine.PluginEngine import deactivate_plugins [as 别名]
#.........这里部分代码省略.........
""" Refresh status of plugins and show the dialog """
if len(self.plugin_tree.get_columns()) == 0:
self._init_plugin_tree()
else:
self._refresh_plugin_store()
self.dialog.show_all()
def on_close(self, widget, data=None):
""" Close the plugins dialog."""
self.dialog.hide()
return True
@classmethod
def on_help(cls, widget):
""" Open help for plugins """
help.show_help("plugins")
return True
def on_plugin_toggle(self, widget, path):
"""Toggle a plugin enabled/disabled."""
iterator = self.plugin_store.get_iter(path)
plugin_id = self.plugin_store.get_value(iterator, PLUGINS_COL_ID)
plugin = self.pengine.get_plugin(plugin_id)
plugin.enabled = not self.plugin_store.get_value(iterator,
PLUGINS_COL_ENABLED)
plugins_enabled = self.config.get("enabled")
plugins_disabled = self.config.get("disabled")
if plugin.enabled:
self.pengine.activate_plugins([plugin])
plugins_enabled.append(plugin.module_name)
if plugin.module_name in plugins_disabled:
plugins_disabled.remove(plugin.module_name)
else:
self.pengine.deactivate_plugins([plugin])
plugins_disabled.append(plugin.module_name)
if plugin.module_name in plugins_enabled:
plugins_enabled.remove(plugin.module_name)
self.config.set("enabled", plugins_enabled)
self.config.set("disabled", plugins_disabled)
self.plugin_store.set_value(iterator, PLUGINS_COL_ENABLED,
plugin.enabled)
self._update_plugin_configure(plugin)
self.config_obj.save()
def on_plugin_select(self, plugin_tree):
""" Callback when user select/unselect a plugin
Update the button "Configure plugin" sensitivity """
model, iterator = plugin_tree.get_selection().get_selected()
if iterator is not None:
plugin_id = model.get_value(iterator, PLUGINS_COL_ID)
plugin = self.pengine.get_plugin(plugin_id)
self._update_plugin_configure(plugin)
def _update_plugin_configure(self, plugin):
""" Enable the button "Configure Plugin" appropriate. """
configurable = plugin.active and plugin.is_configurable()
self.plugin_configure.set_property('sensitive', configurable)
def on_plugin_configure(self, widget):
""" Show the dialog for plugin configuration """
_, iterator = self.plugin_tree.get_selection().get_selected()
if iterator is None:
return
plugin_id = self.plugin_store.get_value(iterator, PLUGINS_COL_ID)
示例3: Manager
# 需要导入模块: from GTG.core.plugins.engine import PluginEngine [as 别名]
# 或者: from GTG.core.plugins.engine.PluginEngine import deactivate_plugins [as 别名]
#.........这里部分代码省略.........
def open_edit_backends(self, sender=None, backend_id=None):
if not self.edit_backends_dialog:
self.edit_backends_dialog = BackendsDialog(self.req)
self.edit_backends_dialog.activate()
if backend_id is not None:
self.edit_backends_dialog.show_config_for_backend(backend_id)
def configure_backend(self, backend_id):
self.open_edit_backends(None, backend_id)
def open_preferences(self, config_priv):
self.preferences.activate()
def configure_plugins(self):
self.plugins.activate()
def ask_delete_tasks(self, tids):
if not self.delete_dialog:
self.delete_dialog = DeletionUI(self.req)
finallist = self.delete_dialog.delete_tasks(tids)
for t in finallist:
if t.get_id() in self.opened_task:
self.close_task(t.get_id())
GObject.idle_add(self.emit, "tasks-deleted", finallist)
return finallist
def open_tag_editor(self, tag):
if not self.tag_editor_dialog:
self.tag_editor_dialog = TagEditor(self.req, self, tag)
else:
self.tag_editor_dialog.set_tag(tag)
self.tag_editor_dialog.show()
self.tag_editor_dialog.present()
def close_tag_editor(self):
self.tag_editor_dialog.hide()
# STATUS #####################################################################
def ask_set_task_status(self, task, new_status):
'''
Both browser and editor have to use this central method to set
task status. It also emits a signal with the task instance as first
and the new status as second parameter
'''
task.set_status(new_status)
GObject.idle_add(self.emit, "task-status-changed", task, new_status)
# URIS #####################################################################
def open_uri_list(self, unused, uri_list):
'''
Open the Editor windows of the tasks associated with the uris given.
Uris are of the form gtg://<taskid>
'''
for uri in uri_list:
if uri.startswith("gtg://"):
self.open_task(uri[6:])
# if no window was opened, we just quit
self.check_quit_condition()
# MAIN #####################################################################
def main(self, once_thru=False, uri_list=[]):
if uri_list:
# before opening the requested tasks, we make sure that all of them
# are loaded.
BackendSignals().connect('default-backend-loaded',
self.open_uri_list,
uri_list)
else:
self.open_browser()
GObject.threads_init()
if not self.gtk_terminate:
if once_thru:
Gtk.main_iteration()
else:
Gtk.main()
return 0
def quit(self, sender=None):
Gtk.main_quit()
# save opened tasks and their positions.
open_task = []
for otid in list(self.opened_task.keys()):
open_task.append(otid)
self.opened_task[otid].close()
self.browser_config.set("opened_tasks", open_task)
# adds the plugin settings to the conf
# FIXME: this code is replicated in the preference window.
if len(self.pengine.plugins) > 0:
self.plugins_config.clear()
self.plugins_config.set(
"disabled",
[p.module_name for p in self.pengine.get_plugins("disabled")],
)
self.plugins_config.set(
"enabled",
[p.module_name for p in self.pengine.get_plugins("enabled")],
)
# plugins are deactivated
self.pengine.deactivate_plugins()
示例4: __init__
# 需要导入模块: from GTG.core.plugins.engine import PluginEngine [as 别名]
# 或者: from GTG.core.plugins.engine.PluginEngine import deactivate_plugins [as 别名]
#.........这里部分代码省略.........
plugin_id = self.plugin_store.get_value(iter, PLUGINS_COL_ID)
p = self.pengine.get_plugin(plugin_id)
pad = self.plugin_about_dialog
pad.set_name(p.full_name)
pad.set_version(p.version)
authors = p.authors
if isinstance(authors, str):
authors = [authors, ]
pad.set_authors(authors)
pad.set_comments(p.description.replace(r'\n', "\n"))
self.plugin_depends.set_label(plugin_error_text(p))
pad.show_all()
def on_plugin_about_close(self, widget, *args):
"""Close the PluginAboutDialog."""
self.plugin_about_dialog.hide()
def on_plugin_configure(self, widget):
"""Configure a plugin."""
(junk, iter) = self.plugin_tree.get_selection().get_selected()
plugin_id = self.plugin_store.get_value(iter, PLUGINS_COL_ID)
# TODO: load plugin's configuration UI and insert into pc-vbox1 in
# position 0. Something like...
#pcd = self.plugin_config_dialog
#pcd.show_all()
# ...for now, use existing code.
self.pengine.get_plugin(plugin_id).instance.configure_dialog(self.dialog)
def on_plugin_config_close(self, widget):
"""Close the PluginConfigDialog."""
self.plugin_config_dialog.hide()
def on_plugin_select(self, plugin_tree):
(model, iter) = plugin_tree.get_selection().get_selected()
if iter is not None:
plugin_id = model.get_value(iter, PLUGINS_COL_ID)
self._update_plugin_configure(self.pengine.get_plugin(plugin_id))
def on_plugin_toggle(self, widget, path):
"""Toggle a plugin enabled/disabled."""
iter = self.plugin_store.get_iter(path)
plugin_id = self.plugin_store.get_value(iter, PLUGINS_COL_ID)
p = self.pengine.get_plugin(plugin_id)
p.enabled = not self.plugin_store.get_value(iter, PLUGINS_COL_ENABLED)
if p.enabled:
self.pengine.activate_plugins([p])
else:
self.pengine.deactivate_plugins([p])
self.plugin_store.set_value(iter, PLUGINS_COL_ENABLED, p.enabled)
self._update_plugin_configure(p)
def toggle_preview(self, widget):
"""Toggle previews in the task view on or off."""
self.config_priv.set("contents_preview_enable",widget.get_active())
def toggle_spellcheck(self, widget):
"""Toggle spell checking on or off."""
print __name__
def _update_plugin_configure(self, plugin):
"""Enable the "Configure Plugin" button if appropriate."""
configurable = plugin.active and plugin.is_configurable()
self.plugin_configure.set_property('sensitive', configurable)
def on_autostart_toggled(self, widget):
"""Toggle GTG autostarting with the GNOME desktop"""
autostart_path = os.path.join(self.__AUTOSTART_DIRECTORY, \
self.__AUTOSTART_FILE)
if widget.get_active() == False:
#Disable autostart, removing the file in autostart_path
if os.path.isfile(autostart_path):
os.remove(autostart_path)
else:
#Enable autostart
#We look for the desktop file
desktop_file_path = None
desktop_file_directories = ["../..",
"../../../applications",
"../../../../../share/applications"]
this_directory = os.path.dirname(os.path.abspath(__file__))
for path in desktop_file_directories:
fullpath = os.path.normpath(os.path.join(this_directory, path, \
self.__AUTOSTART_FILE))
if os.path.isfile(fullpath):
desktop_file_path = fullpath
break
#If we have found the desktop file, we make a link to in in
# autostart_path. If symbolic linking is not possible
# (that is, if we are running on Windows), then copy the file
if desktop_file_path:
if not os.path.exists(self.__AUTOSTART_DIRECTORY):
os.mkdir(self.__AUTOSTART_DIRECTORY)
if os.path.isdir(self.__AUTOSTART_DIRECTORY) and \
not os.path.exists(autostart_path):
if hasattr(os, "symlink"):
os.symlink(desktop_file_path, \
autostart_path)
else:
shutil.copyfile(desktop_file_path, \
autostart_path)