Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from gi.repository import GObject, Gtk, Gedit
- class ExamplePlugin03(GObject.Object, Gedit.WindowActivatable):
- __gtype_name__ = "ExamplePlugin03"
- window = GObject.property(type=Gedit.Window)
- def __init__(self):
- GObject.Object.__init__(self)
- def do_activate(self):
- print "Activating plugin..."
- handlers = []
- handler_id = self.window.connect("tab-added", self.on_tab_added)
- handlers.append(handler_id)
- print "Connected handler %s" % handler_id
- handler_id = self.window.connect("tab-removed", self.on_tab_removed)
- handlers.append(handler_id)
- print "Connected handler %s" % handler_id
- self.window.set_data("ExamplePlugin03Handlers", handlers)
- def do_deactivate(self):
- print "Deactivating plugin..."
- handlers = self.window.get_data("ExamplePlugin03Handlers")
- for handler_id in handlers:
- self.window.disconnect(handler_id)
- print "Disconnected handler %s" % handler_id
- def do_update_state(self):
- pass
- def on_tab_added(self, window, tab, data=None):
- document = tab.get_document()
- print "'%s' has been added." % document.get_short_name_for_display()
- def on_tab_removed(self, window, tab, data=None):
- document = tab.get_document()
- print "'%s' has been removed." % document.get_short_name_for_display()
Advertisement
Add Comment
Please, Sign In to add comment