Guest User

Untitled

a guest
Sep 6th, 2013
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.43 KB | None | 0 0
  1. from gi.repository import GObject, Gtk, Gedit
  2.  
  3. class ExamplePlugin03(GObject.Object, Gedit.WindowActivatable):
  4.     __gtype_name__ = "ExamplePlugin03"
  5.     window = GObject.property(type=Gedit.Window)
  6.    
  7.     def __init__(self):
  8.         GObject.Object.__init__(self)
  9.    
  10.     def do_activate(self):
  11.         print "Activating plugin..."
  12.         handlers = []
  13.         handler_id = self.window.connect("tab-added", self.on_tab_added)
  14.         handlers.append(handler_id)
  15.         print "Connected handler %s" % handler_id
  16.        
  17.         handler_id = self.window.connect("tab-removed", self.on_tab_removed)
  18.         handlers.append(handler_id)
  19.         print "Connected handler %s" % handler_id
  20.        
  21.         self.window.set_data("ExamplePlugin03Handlers", handlers)
  22.  
  23.     def do_deactivate(self):
  24.         print "Deactivating plugin..."
  25.         handlers = self.window.get_data("ExamplePlugin03Handlers")
  26.         for handler_id in handlers:
  27.             self.window.disconnect(handler_id)
  28.             print "Disconnected handler %s" % handler_id
  29.  
  30.     def do_update_state(self):
  31.         pass    
  32.     def on_tab_added(self, window, tab, data=None):
  33.         document = tab.get_document()
  34.         print "'%s' has been added." % document.get_short_name_for_display()
  35.    
  36.     def on_tab_removed(self, window, tab, data=None):
  37.         document = tab.get_document()
  38.         print "'%s' has been removed." % document.get_short_name_for_display()
Advertisement
Add Comment
Please, Sign In to add comment