本文整理汇总了Python中GTG.core.plugins.engine.PluginEngine.onTaskLoad方法的典型用法代码示例。如果您正苦于以下问题:Python PluginEngine.onTaskLoad方法的具体用法?Python PluginEngine.onTaskLoad怎么用?Python PluginEngine.onTaskLoad使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GTG.core.plugins.engine.PluginEngine
的用法示例。
在下文中一共展示了PluginEngine.onTaskLoad方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TaskEditor
# 需要导入模块: from GTG.core.plugins.engine import PluginEngine [as 别名]
# 或者: from GTG.core.plugins.engine.PluginEngine import onTaskLoad [as 别名]
#.........这里部分代码省略.........
self.textview.set_remove_tag_callback(task.remove_tag)
self.textview.save_task_callback(self.light_save)
texte = self.task.get_text()
title = self.task.get_title()
# the first line is the title
self.textview.set_text("%s\n" % title)
# we insert the rest of the task
if texte:
self.textview.insert("%s" % texte)
else:
# If not text, we insert tags
if tags:
for t in tags:
self.textview.insert_text("%s, " % t.get_name())
self.textview.insert_text("\n")
# If we don't have text, we still need to insert subtasks if any
subtasks = task.get_children()
if subtasks:
self.textview.insert_subtasks(subtasks)
# We select the title if it's a new task
if thisisnew:
self.textview.select_title()
else:
self.task.set_to_keep()
self.textview.modified(full=True)
self.window.connect("destroy", self.destruction)
self.calendar.connect("date-changed", self.on_date_changed)
# plugins
self.pengine = PluginEngine()
self.plugin_api = PluginAPI(self.req, self.vmanager, self)
self.pengine.register_api(self.plugin_api)
self.pengine.onTaskLoad(self.plugin_api)
# Putting the refresh callback at the end make the start a lot faster
self.textview.refresh_callback(self.refresh_editor)
self.refresh_editor()
self.textview.grab_focus()
# restoring size and position, spatial tasks
if self.config is not None:
tid = self.task.get_id()
if self.config.has_section(tid):
if self.config.has_option(tid, "position"):
pos_x, pos_y = self.config.get(tid, "position")
self.move(int(pos_x), int(pos_y))
if self.config.has_option(tid, "size"):
width, height = self.config.get(tid, "size")
self.window.resize(int(width), int(height))
self.textview.set_editable(True)
self.window.show()
# Define accelerator-keys for this dialog
# TODO: undo/redo
def init_accelerators(self):
agr = Gtk.AccelGroup()
self.window.add_accel_group(agr)
# Escape and Ctrl-W close the dialog. It's faster to call close
# directly, rather than use the close button widget
key, modifier = Gtk.accelerator_parse('Escape')
agr.connect(key, modifier, Gtk.AccelFlags.VISIBLE, self.close)
key, modifier = Gtk.accelerator_parse('<Control>w')
示例2: __init__
# 需要导入模块: from GTG.core.plugins.engine import PluginEngine [as 别名]
# 或者: from GTG.core.plugins.engine.PluginEngine import onTaskLoad [as 别名]
#.........这里部分代码省略.........
self.textview.set_remove_tag_callback(task.remove_tag)
self.textview.save_task_callback(self.light_save)
texte = self.task.get_text()
title = self.task.get_title()
#the first line is the title
self.textview.set_text("%s\n"%title)
#we insert the rest of the task
if texte :
self.textview.insert("%s"%texte)
else :
#If not text, we insert tags
if tags :
for t in tags :
self.textview.insert_text("%s, "%t.get_name())
self.textview.insert_text("\n")
#If we don't have text, we still need to insert subtasks if any
subtasks = task.get_children()
if subtasks :
self.textview.insert_subtasks(subtasks)
#We select the title if it's a new task
if thisisnew :
self.textview.select_title()
else :
self.task.set_to_keep()
self.textview.modified(full=True)
self.window.connect("destroy", self.destruction)
self.calendar.connect("date-changed", self.on_date_changed)
# plugins
self.pengine = PluginEngine()
self.plugin_api = PluginAPI(self.req, self.vmanager, self)
self.pengine.register_api(self.plugin_api)
self.pengine.onTaskLoad(self.plugin_api)
#Putting the refresh callback at the end make the start a lot faster
self.textview.refresh_callback(self.refresh_editor)
self.refresh_editor()
self.textview.grab_focus()
#restoring size and position, spatial tasks
if self.config :
tid = self.task.get_id()
if tid in self.config:
if "position" in self.config[tid]:
pos = self.config[tid]["position"]
self.move(pos[0],pos[1])
#print "restoring position %s %s" %(pos[0],pos[1])
if "size" in self.config[tid]:
size = self.config[tid]["size"]
#print "size %s - %s" %(str(size[0]),str(size[1]))
#this eval(str()) is a ugly (!) hack to accept both int and str
#FIXME: Fix this!
self.window.resize(eval(str(size[0])),eval(str(size[1])))
self.textview.set_editable(True)
#Connection for the update
self.req.connect('task-modified',self.task_modified)
self.window.show()
#FIXME: avoid to update to many time when we modify from the editor itself
def task_modified(self,sender,tid):
self.refresh_editor(refreshtext=True)
# Define accelerator-keys for this dialog