Is there an easy way to convert a gedit plugin from the gnome2 version to the gnome3 version?

Go To


I'd like to transfer my plugins to the new gedit in Gnome 3 (coming from Gnome 2 Gedit), but they don't all work.

I've changed their location from ~/,gnome2/gedit to ~/.local/share/gedit, and I've renamed all from *.gedit-plugin to *.plugin and I've changed the header in those files from [Gedit Plugin] to [Plugin]. I can see them now in the plugins tabs of the preferences, but enabling them results in an error.

Are there any simple fixes?

2012-04-04 02:28
by trusktr


It is actually not that hard if you use python. You already converted the .plugin files. In the python files, this is a typical diff:

-import gtk
-import gedit
-import gobject
-import pango
+from gi.repository import Gtk, GObject, Gedit


-class PluginName(gedit.Plugin):
+class PluginName(GObject.Object, Gedit.WindowActivatable):
+    window =
     def __init__(self):
-        gedit.Plugin.__init__(self)
+        GObject.Object.__init__(self)
         self._instances = {}

-    def activate(self, window):
-        self._instances[window] = PluginNameWindowHelper(self, window)
+    def do_activate(self):
+        self._instances[self.window] = PluginNameWindowHelper(self, self.window)
+    def do_deactivate(self):
+        self._instances[self.window].deactivate()
+        del self._instances[self.window]

-    def deactivate(self, window):
-        self._instances[window].deactivate()
-        del self._instances[window]
+    def do_update_state(self):
+        self._instances[self.window].update_ui()

-    def update_ui(self, window):
-        self._instances[window].update_ui()


-        self._action_group = gtk.ActionGroup("PluginNameActions")
+        self._action_group = Gtk.ActionGroup("PluginNameActions")


-             line = document.get_text(line_start, line_end)
+             line = document.get_text(line_start, line_end, False)

I converted 6 plugins some time ago, and these were the only changes I needed.

2012-04-04 06:05
by Jens Nyman
Nice. The plugin I'm working with seems a little tricky though: And that's only one file - trusktr 2012-04-04 10:09
You mostly need to use GObject Instrospection and adjust the methods as it was suggested by Jens - gpoo 2012-05-04 06:15
Thanks. I'll give it a try. By the way jens or @gpoo, can you guys send me your converted plugins to see if any of them happen to be ones that I wanted to convert? My gmail: trusktr. Thanks - trusktr 2012-06-06 05:33
you can find mine at - Jens Nyman 2012-06-10 07:46