

_plugin = None 13 14 def update_ui( self): 15 # Called whenever the window has been updated (active tab 16 # changed, etc.) 17 print " Plugin update for ", self. _plugin = plugin 8 9 def deactivate( self): 10 print " Plugin stopped for ", self. At the most minimal level, it just defines one class derived from gedit.Plugin defining activate, deactivate and update_ui:ġ import gedit 2 3 class ExamplePyWindowHelper: 4 def _init_( self, plugin, window): 5 print " Plugin created for ", window 6 self. The plugin is called examplepy, so we create examplepy.py. Website: optionally, the plugins website.

This will show up in the about dialog of the plugin (plugins list in the preference dialog)

The approach I find easy to implement (also implemented in the example) is to create a new class. On the other hand, when a window is destroyed the deactivate function is called. Whenever a new window is created the activate function on your plugin will be called with one argument (the window). This is what the activate and deactivate are for. However, plugins usually apply to windows. Plugins are therefore only instantiated once (during load) of the master Gedit application. When Gedit starts it looks for an existing Gedit instance, hands over control to that instance and exits. Now, Gedit is an application which usually only runs one instance, even if you launch it multiple times. A Python plugin is derived from the gedit.Plugin base class which defines the following functions (which you can override): It's important to read this section carefully. Most plugin writers find the way Gedit plugins work counterintuitive at first glance. Both of these files need to be placed in either the system-wide plugins directory /usr/lib/gedit-2/plugins/, or in the user plugins directory, which may need to be created, ~/.gnome2/gedit/plugins/. The second file is the actual Python code. One file ( pluginname.gedit-plugin) is to tell Gedit where the plugin can be found, what it's called, a short description, who's the author, etc. Adding a configure dialog for your pluginĮvery Python plugin needs at least two files.
