You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
310 lines
10 KiB
310 lines
10 KiB
Description: Fix the gedit plugin for Gedit3
|
|
From: Adam Plumb <adamplumb@gmail.com>
|
|
Origin: upstream, http://code.google.com/p/rabbitvcs/source/detail?r=3022
|
|
Bug: http://code.google.com/p/rabbitvcs/issues/detail?id=622
|
|
Bug-Debian: http://bugs.debian.org/635123
|
|
|
|
--- a/rabbitvcs/util/contextmenuitems.py
|
|
+++ b/rabbitvcs/util/contextmenuitems.py
|
|
@@ -204,7 +204,7 @@
|
|
)
|
|
|
|
return action
|
|
-
|
|
+
|
|
def make_gtk_menu_item(self, id_magic = None):
|
|
action = self.make_action(id_magic)
|
|
|
|
@@ -217,6 +217,17 @@
|
|
else:
|
|
menuitem = action.create_menu_item()
|
|
|
|
+ return menuitem
|
|
+
|
|
+ def make_gtk3_menu_item(self, id_magic = None):
|
|
+ action = self.make_action(id_magic)
|
|
+
|
|
+ if self.icon:
|
|
+ menuitem = action.create_menu_item()
|
|
+ menuitem.set_image(gtk.Image.new_from_icon_name(self.icon, gtk.IconSize.MENU))
|
|
+ else:
|
|
+ menuitem = action.create_menu_item()
|
|
+
|
|
return menuitem
|
|
|
|
def make_nautilus_menu_item(self, id_magic = None):
|
|
--- a/clients/gedit/rabbitvcs.gedit-plugin
|
|
+++ /dev/null
|
|
@@ -1,10 +0,0 @@
|
|
-[Gedit Plugin]
|
|
-Loader=python
|
|
-Module=rabbitvcs-plugin
|
|
-IAge=2
|
|
-Name=RabbitVCS
|
|
-Description=RabbitVCS plugin for Gedit
|
|
-Authors=Adam Plumb <adamplumb@gmail.com>
|
|
-Copyright=Copyright © 2009 Adam Plumb
|
|
-Website=http://www.rabbitvcs.org
|
|
-
|
|
--- /dev/null
|
|
+++ b/clients/gedit/rabbitvcs-gedit2.gedit-plugin
|
|
@@ -0,0 +1,10 @@
|
|
+[Gedit Plugin]
|
|
+Loader=python
|
|
+Module=rabbitvcs-plugin
|
|
+IAge=2
|
|
+Name=RabbitVCS
|
|
+Description=RabbitVCS plugin for Gedit
|
|
+Authors=Adam Plumb <adamplumb@gmail.com>
|
|
+Copyright=Copyright © 2011 Adam Plumb
|
|
+Website=http://www.rabbitvcs.org
|
|
+
|
|
--- a/clients/gedit/rabbitvcs-plugin.py
|
|
+++ b/clients/gedit/rabbitvcs-plugin.py
|
|
@@ -2,7 +2,7 @@
|
|
# This is a Gedit plugin to allow for RabbitVCS integration in the Gedit
|
|
# text editor.
|
|
#
|
|
-# Copyright (C) 2008-2008 by Adam Plumb <adamplumb@gmail.com>
|
|
+# Copyright (C) 2008-2011 by Adam Plumb <adamplumb@gmail.com>
|
|
#
|
|
# RabbitVCS is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
@@ -21,8 +21,17 @@
|
|
from gettext import gettext as _
|
|
|
|
import os
|
|
-import gtk
|
|
-import gedit
|
|
+
|
|
+try:
|
|
+ from gi.repository import Gedit
|
|
+ os.environ["NAUTILUS_PYTHON_REQUIRE_GTK3"] = "1"
|
|
+ GTK3 = True
|
|
+except ImportError:
|
|
+ import gedit
|
|
+ GTK3 = False
|
|
+
|
|
+from gi.repository import GObject
|
|
+from gi.repository import Gtk as gtk
|
|
|
|
import rabbitvcs.util.helper
|
|
from rabbitvcs.vcs import create_vcs_instance
|
|
@@ -327,8 +336,15 @@
|
|
|
|
manager = self._window.get_ui_manager()
|
|
for menu_path in self._menu_paths:
|
|
- widget = manager.get_widget(menu_path)
|
|
- self._menubar_menu.update_action(widget.get_action())
|
|
+ # Gtk3 changes how we access a widget's action. Get it from the
|
|
+ # UI Manager instead of the widget directly
|
|
+ if hasattr(manager, "get_action"):
|
|
+ action = manager.get_action(menu_path)
|
|
+ else:
|
|
+ widget = manager.get_widget(menu_path)
|
|
+ action = widget.get_action()
|
|
+
|
|
+ self._menubar_menu.update_action(action)
|
|
|
|
# Menu activate handlers
|
|
def reload_settings(self, proc):
|
|
@@ -337,49 +353,100 @@
|
|
def on_context_menu_command_finished(self):
|
|
self.update_ui()
|
|
|
|
-class RabbitVCSPlugin(gedit.Plugin):
|
|
- def __init__(self):
|
|
- gedit.Plugin.__init__(self)
|
|
- self._instances = {}
|
|
- self.id_name = "RabbitVCSContextMenuID"
|
|
-
|
|
- def activate(self, window):
|
|
- self._instances[window] = RabbitVCSWindowHelper(self, window)
|
|
-
|
|
- handler_ids = []
|
|
- for signal in ('tab-added', 'tab-removed'):
|
|
- method = getattr(self, 'on_window_' + signal.replace('-', '_'))
|
|
- handler_ids.append(window.connect(signal, method))
|
|
-
|
|
- window.set_data(self.id_name, handler_ids)
|
|
- if window in self._instances:
|
|
- for view in window.get_views():
|
|
- self._instances[window].connect_view(view, self.id_name)
|
|
-
|
|
- def deactivate(self, window):
|
|
- widgets = [window] + window.get_views()
|
|
- for widget in widgets:
|
|
- handler_ids = widget.get_data(self.id_name)
|
|
- if handler_ids is not None:
|
|
- for handler_id in handler_ids:
|
|
- widget.disconnect(handler_id)
|
|
- widget.set_data(self.id_name, None)
|
|
-
|
|
- if window in self._instances:
|
|
- self._instances[window].deactivate()
|
|
- del self._instances[window]
|
|
-
|
|
- def update_ui(self, window):
|
|
- if window in self._instances:
|
|
- self._instances[window].update_ui()
|
|
-
|
|
- def on_window_tab_added(self, window, tab):
|
|
- if window in self._instances:
|
|
- self._instances[window].connect_view(tab.get_view(), self.id_name)
|
|
-
|
|
- def on_window_tab_removed(self, window, tab):
|
|
- if window in self._instances:
|
|
- self._instances[window].disconnect_view(tab.get_view(), self.id_name)
|
|
+if GTK3:
|
|
+ class RabbitVCSGedit3Plugin(GObject.Object, Gedit.WindowActivatable):
|
|
+ __gtype_name__ = "RabbitVCSGedit3Plugin"
|
|
+ window = GObject.property(type=Gedit.Window)
|
|
+
|
|
+ def __init__(self):
|
|
+ GObject.Object.__init__(self)
|
|
+ self._instances = {}
|
|
+ self.id_name = "RabbitVCSContextMenuID"
|
|
+
|
|
+ def do_activate(self):
|
|
+ self._instances[self.window] = RabbitVCSWindowHelper(self, self.window)
|
|
+
|
|
+ handler_ids = []
|
|
+ for signal in ('tab-added', 'tab-removed'):
|
|
+ method = getattr(self, 'on_window_' + signal.replace('-', '_'))
|
|
+ handler_ids.append(self.window.connect(signal, method))
|
|
+
|
|
+ self.window.set_data(self.id_name, handler_ids)
|
|
+ if self.window in self._instances:
|
|
+ for view in self.window.get_views():
|
|
+ self._instances[self.window].connect_view(view, self.id_name)
|
|
+
|
|
+ def do_deactivate(self):
|
|
+ widgets = [self.window] + self.window.get_views()
|
|
+ for widget in widgets:
|
|
+ handler_ids = widget.get_data(self.id_name)
|
|
+ if handler_ids is not None:
|
|
+ for handler_id in handler_ids:
|
|
+ widget.disconnect(handler_id)
|
|
+ widget.set_data(self.id_name, None)
|
|
+
|
|
+ if self.window in self._instances:
|
|
+ self._instances[self.window].deactivate()
|
|
+ del self._instances[self.window]
|
|
+
|
|
+ def do_update_state(self):
|
|
+ self.update_ui()
|
|
+
|
|
+ def update_ui(self):
|
|
+ if self.window in self._instances:
|
|
+ self._instances[self.window].update_ui()
|
|
+
|
|
+ def on_window_tab_added(self, window, tab):
|
|
+ if self.window in self._instances:
|
|
+ self._instances[self.window].connect_view(tab.get_view(), self.id_name)
|
|
+
|
|
+ def on_window_tab_removed(self, window, tab):
|
|
+ if window in self._instances:
|
|
+ self._instances[self.window].disconnect_view(tab.get_view(), self.id_name)
|
|
+else:
|
|
+ class RabbitVCSGedit2Plugin(gedit.Plugin):
|
|
+ def __init__(self):
|
|
+ gedit.Plugin.__init__(self)
|
|
+ self._instances = {}
|
|
+ self.id_name = "RabbitVCSContextMenuID"
|
|
+
|
|
+ def activate(self, window):
|
|
+ self._instances[window] = RabbitVCSWindowHelper(self, window)
|
|
+
|
|
+ handler_ids = []
|
|
+ for signal in ('tab-added', 'tab-removed'):
|
|
+ method = getattr(self, 'on_window_' + signal.replace('-', '_'))
|
|
+ handler_ids.append(window.connect(signal, method))
|
|
+
|
|
+ window.set_data(self.id_name, handler_ids)
|
|
+ if window in self._instances:
|
|
+ for view in window.get_views():
|
|
+ self._instances[window].connect_view(view, self.id_name)
|
|
+
|
|
+ def deactivate(self, window):
|
|
+ widgets = [window] + window.get_views()
|
|
+ for widget in widgets:
|
|
+ handler_ids = widget.get_data(self.id_name)
|
|
+ if handler_ids is not None:
|
|
+ for handler_id in handler_ids:
|
|
+ widget.disconnect(handler_id)
|
|
+ widget.set_data(self.id_name, None)
|
|
+
|
|
+ if window in self._instances:
|
|
+ self._instances[window].deactivate()
|
|
+ del self._instances[window]
|
|
+
|
|
+ def update_ui(self, window):
|
|
+ if window in self._instances:
|
|
+ self._instances[window].update_ui()
|
|
+
|
|
+ def on_window_tab_added(self, window, tab):
|
|
+ if window in self._instances:
|
|
+ self._instances[window].connect_view(tab.get_view(), self.id_name)
|
|
+
|
|
+ def on_window_tab_removed(self, window, tab):
|
|
+ if window in self._instances:
|
|
+ self._instances[window].disconnect_view(tab.get_view(), self.id_name)
|
|
|
|
class MenuIgnoreByFilename(MenuItem):
|
|
identifier = "RabbitVCS::Ignore_By_Filename"
|
|
@@ -593,7 +660,10 @@
|
|
signal = "activate"
|
|
|
|
def make_menu_item(self, item, id_magic):
|
|
- return item.make_gtk_menu_item(id_magic)
|
|
+ if GTK3:
|
|
+ return item.make_gtk3_menu_item(id_magic)
|
|
+ else:
|
|
+ return item.make_gtk_menu_item(id_magic)
|
|
|
|
def attach_submenu(self, menu_node, submenu_list):
|
|
submenu = gtk.Menu()
|
|
--- /dev/null
|
|
+++ b/clients/gedit/rabbitvcs-gedit3.plugin
|
|
@@ -0,0 +1,9 @@
|
|
+[Plugin]
|
|
+Loader=python
|
|
+Module=rabbitvcs-plugin
|
|
+IAge=3
|
|
+Name=RabbitVCS
|
|
+Description=RabbitVCS plugin for Gedit
|
|
+Authors=Adam Plumb <adamplumb@gmail.com>
|
|
+Copyright=Copyright © 2011 Adam Plumb
|
|
+Website=http://www.rabbitvcs.org
|
|
--- a/clients/gedit/README
|
|
+++ b/clients/gedit/README
|
|
@@ -8,14 +8,24 @@
|
|
* gedit
|
|
* (all other RabbitVCS requirements)
|
|
|
|
-To install:
|
|
+To install for Gedit 3:
|
|
To install for all users, copy rabbitvcs-plugin.py and
|
|
- rabbitvcs.gedit-plugin to:
|
|
+ rabbitvcs-gedit3.plugin to:
|
|
+ /usr/share/gedit/plugins
|
|
+
|
|
+ To install for a single user, copy rabbitvcs-plugin.py and
|
|
+ rabbitvcs-gedit3.plugin to:
|
|
+ ~/.local/share/gedit/plugins
|
|
+
|
|
+To install for Gedit 2:
|
|
+ To install for all users, copy rabbitvcs-plugin.py and
|
|
+ rabbitvcs-gedit2.gedit-plugin to:
|
|
/usr/lib/gedit-2/plugins
|
|
|
|
To install for a single user, copy rabbitvcs-plugin.py and
|
|
- rabbitvcs.gedit-plugin to:
|
|
- ~/.gnome2/gedit/plugins
|
|
+ rabbitvcs-gedit2.gedit-plugin to:
|
|
+ ~/.gnome2/gedit/plugins
|
|
+
|
|
|
|
Troubleshooting:
|
|
|