I'm writing a gedit 3 plugin, something similar to phsilva's PyLint plugin, which calls out to an external lint program and highlights lines of code in the current document. My question is, if my plugin has a run_lint
action is it possible to bind that to the OnSave
event in gedit? The list of available signals in the documentation I've linked above still has a FIXME
notice against it and I'm struggling to figure out where in the soup of API documentation the full list can be found.
问问题
268 次
1 回答
2
好吧,没有人回答这个问题,但我最终想通了。这有两个步骤,当在该选项卡包含文档的窗口中创建一个新选项卡时。该文档具有可以连接到操作的信号loaded
。saved
重要的是要记住每个选项卡都有一个单独的文档,每个文档都需要自己的一组信号和处理程序。
这是一个大纲解决方案,以防对其他人有用:
class FooPlugin(GObject.Object, Gedit.WindowActivatable):
__gtype_name__ = 'Foo'
...
def do_activate(self):
self._add_ui()
self.window.connect('tab-added', self.on_tab_added)
...
return
def on_tab_added(self, window, tab, data=None):
doc = tab.get_document()
doc.connect('saved', self.on_document_saved)
doc.connect('loaded', self.on_document_loaded)
return
def on_document_loaded(self, document, data=None):
# do something here...
return
def on_document_saved(self, document, data=None):
# do something here...
return
于 2012-02-18T21:39:26.957 回答