Blob Blame History Raw
diff -up beesu-2.7/gedit-beesu-plugin-0.4/beesu/__init__.py.geditfix beesu-2.7/gedit-beesu-plugin-0.4/beesu/__init__.py
--- beesu-2.7/gedit-beesu-plugin-0.4/beesu/__init__.py.geditfix	2015-09-15 11:18:41.101760031 -0400
+++ beesu-2.7/gedit-beesu-plugin-0.4/beesu/__init__.py	2015-09-15 11:23:00.775034004 -0400
@@ -1 +1,131 @@
-from .beesu import beesuPlugin
+# 2010 - Copyright by Bee <http://www.honeybeenet.altervista.org>.
+# 2012 - Rewritten to work with modern Gedit by Tom Callaway <spot@fedoraproject.org>
+# 2013 - Rewritten slightly for compatibility with Gedit 3.8 by D. Charles Pyle <dcharlespyle@msn.com>.
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+import os
+
+import gi
+gi.require_version('Gedit', '3.0')
+gi.require_version('Gtk', '3.0')
+from gi.repository import GObject, Gio, Gtk, Gedit
+from gettext import gettext as _
+
+import tempfile
+import time
+import sys
+import traceback
+import subprocess
+import pickle
+
+class beesuAppActivatable(GObject.Object, Gedit.AppActivatable):
+    app = GObject.Property(type=Gedit.App)
+
+    def __init__(self):
+        GObject.Object.__init__(self)
+
+    def do_activate(self):
+        self.app.add_accelerator("<Primary><Alt>B", "win.beesu", None)
+        self.menu_ext = self.extend_menu("file-section")
+        item = Gio.MenuItem.new(_("Open as root..."), "win.beesu")
+        self.menu_ext.prepend_menu_item(item)
+
+    def do_deactivate(self):
+        self.app.remove_accelerator("win.beesu", None)
+
+class beesuPlugin(GObject.Object, Gedit.WindowActivatable):
+    __gtype_name__ = "beesuPlugin"
+
+    window = GObject.Property(type=Gedit.Window)
+
+    def __init__(self):
+        GObject.Object.__init__(self)
+
+    def do_activate(self):
+        action = Gio.SimpleAction(name="beesu")
+        action.connect('activate', self.beesu)
+        self.window.add_action(action)
+
+    def do_deactivate(self):
+        self.window.remove_action("beesu")
+
+    def error_message(message):
+        def msg_on_close_destroy(button,response_id,dialog):
+            if response_id == Gtk.ResponseType.CLOSE:
+                dialog.destroy()
+
+        msg_dialog = Gtk.MessageDialog(self, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, message)
+        msg_dialog.connect('response', msg_on_close_destroy, msg_dialog)
+        msg_dialog.run()
+
+
+    def beesu(self, action, parameter):
+        tab = self.window.get_active_tab()
+        doc = self.window.get_active_document()
+
+        filename = None
+        if doc:
+            location = doc.get_location()
+            if location:
+               uri = location.get_uri()
+               if uri is not None:
+                   if uri[:7] == "file://":
+                       filename = location.get_parse_name()
+
+        if not self.beesu_exec(filename):
+            return
+
+        if tab:
+            if doc == tab.get_document():
+                if doc.get_readonly() or doc.is_untouched():
+                    self.window.close_tab(tab)
+                    if self.window.get_active_document() == None and self.window.get_active_tab() == None:
+                        self.window.destroy()
+
+    def beesu_exec(self, filename):
+        tmp = tempfile.NamedTemporaryFile(delete = False)
+        lockfile = tmp.name
+        tmp.close()
+        #shell_args = [SED_BEESU_COMMAND_LINE_SU,'/usr/libexec/gedit-beesu-plugin','gedit-beesu-plugin','gedit','gedit',lockfile]
+        if filename != None and filename != '':
+            # shell_args = ['beesu', '-l', '-c', '\"/usr/bin/gedit %s\"' % filename]
+            shell_args = ['beesu','-l','-c','unset','XDG_RUNTIME_DIR',';','/usr/libexec/gedit-beesu-plugin','gedit-beesu-plugin','/usr/bin/gedit','gedit',lockfile,'\"%s\"' %filename]
+            # shell_args = ['/usr/libexec/gedit-beesu-plugin','gedit-beesu-plugin','gedit','gedit', lockfile, filename]
+        else:
+           return False
+        print(str(shell_args))
+        try:
+            subprocess.Popen(shell_args, stderr=open(os.devnull)).wait()
+        except:
+            etype = sys.exc_info()[0]
+            evalue = sys.exc_info()[1]
+            etb = traceback.extract_tb(sys.exc_info()[2])
+            myerror = 'Error running SED_BEESU_COMMAND_LINE_NAME: ' + '\n' + 'Error Type: ' + str(etype) + '\n' + 'Error Value: ' + str(evalue) + '\n' + 'Traceback: ' + str(etb)
+            self.error_message(_(myerror))
+            return False
+
+        print('Hey, it says the Popen succeeded.')
+        # Added for additional debugging information.
+        #
+        print("The file worked on by beesu was: " + filename)
+        print("The shell_args passed to execvp() were: " + str(shell_args))
+
+        if os.path.isfile(lockfile):
+            os.remove(lockfile)
+            return False
+
+        return True
+
+# ex:ts=4:et:
diff -up beesu-2.7/gedit-beesu-plugin-0.4/beesu.py.geditfix beesu-2.7/gedit-beesu-plugin-0.4/beesu.py
--- beesu-2.7/gedit-beesu-plugin-0.4/beesu.py.geditfix	2015-09-15 11:18:41.101760031 -0400
+++ beesu-2.7/gedit-beesu-plugin-0.4/beesu.py	2015-09-15 11:18:41.107759992 -0400
@@ -1,146 +0,0 @@
-# 2010 - Copyright by Bee <http://www.honeybeenet.altervista.org>.
-# 2012 - Rewritten to work with modern Gedit by Tom Callaway <spot@fedoraproject.org>
-# 2013 - Rewritten slightly for compatibility with Gedit 3.8 by D. Charles Pyle <dcharlespyle@msn.com>.
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-from gi.repository import GObject, Gtk, Gedit
-# import gedit
-# import pygtk
-# pygtk.require('2.0')
-# import gtk
-from gettext import gettext as _
-import os
-import tempfile
-import time
-import sys
-import traceback
-import subprocess
-import pickle
-
-ui_str = """
-<ui>
-  <menubar name="MenuBar">
-    <menu name="ToolsMenu" action="Tools">
-      <placeholder name="ToolsOps_2">
-        <menuitem name="beesuPlugin" action="beesuPlugin"/>
-      </placeholder>
-    </menu>
-  </menubar>
-</ui>
-"""
-
-class beesuPlugin(GObject.Object, Gedit.WindowActivatable):
-    __gtype_name__ = "BeesuPlugin"
-
-    window = GObject.property(type=Gedit.Window)
-
-    def __init__(self):
-        GObject.Object.__init__(self)
-
-    def do_activate(self):
-        self._insert_menu()
-
-    def do_deactivate(self):
-        self._remove_menu()
-
-    def _remove_menu(self):
-        manager = self.window.get_ui_manager()
-        manager.remove_ui(self._ui_id)
-        manager.remove_action_group(self._action_group)
-        self._action_group = None
-        manager.ensure_update()
-
-    def _insert_menu(self):
-        manager = self.window.get_ui_manager()
-
-        self._action_group = Gtk.ActionGroup(name="beesuPluginActions")
-        self._action_group.add_actions([("beesuPlugin", None,
-                                        _("Open as \"root\""),
-                                         None,
-                                        _("Open this document as \"root\" in gedit with SED_BEESU_COMMAND_LINE_NAME"),
-                                         self.beesu)])
-
-        manager.insert_action_group(self._action_group, -1)
-        self._ui_id = manager.add_ui_from_string(ui_str)
-
-    def is_configurable(self):
-        return False  
-
-    def error_message(message):
-        def msg_on_close_destroy(button,response_id,dialog):
-            if response_id == Gtk.ResponseType.CLOSE:
-                dialog.destroy()
-
-        msg_dialog = Gtk.MessageDialog(self, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, message)
-        msg_dialog.connect('response', msg_on_close_destroy, msg_dialog)
-        msg_dialog.run()
-
-
-    def beesu(self, action):
-        tab = self.window.get_active_tab()
-        doc = self.window.get_active_document()
-
-        filename = None
-        if doc:
-            location = doc.get_location()
-            if location:
-               uri = location.get_uri()
-               if uri is not None:
-                   if uri[:7] == "file://":
-                       filename = location.get_parse_name()
-
-        if not self.beesu_exec(filename):
-            return
-
-        if tab:
-            if doc == tab.get_document():
-                if doc.get_readonly() or doc.is_untouched():
-                    self.window.close_tab(tab)
-                    if self.window.get_active_document() == None and self.window.get_active_tab() == None:
-                        self.window.destroy()
-
-    def beesu_exec(self, filename):
-        tmp = tempfile.NamedTemporaryFile(delete = False)
-        lockfile = tmp.name
-        tmp.close()
-        #shell_args = [SED_BEESU_COMMAND_LINE_SU,'/usr/libexec/gedit-beesu-plugin','gedit-beesu-plugin','gedit','gedit',lockfile]
-        if filename != None and filename != '':
-            # shell_args = ['beesu', '-l', '-c', '\"/usr/bin/gedit %s\"' % filename]
-            shell_args = ['beesu','-l','-c','unset','XDG_RUNTIME_DIR',';','/usr/libexec/gedit-beesu-plugin','gedit-beesu-plugin','/usr/bin/gedit','gedit',lockfile,'\"%s\"' %filename]
-            # shell_args = ['/usr/libexec/gedit-beesu-plugin','gedit-beesu-plugin','gedit','gedit', lockfile, filename]
-        else:
-           return False
-        print(str(shell_args))
-        try:
-            subprocess.Popen(shell_args, stderr=open(os.devnull)).wait()
-        except:
-            etype = sys.exc_info()[0]
-            evalue = sys.exc_info()[1]
-            etb = traceback.extract_tb(sys.exc_info()[2])
-            myerror = 'Error running SED_BEESU_COMMAND_LINE_NAME: ' + '\n' + 'Error Type: ' + str(etype) + '\n' + 'Error Value: ' + str(evalue) + '\n' + 'Traceback: ' + str(etb)
-            self.error_message(_(myerror))
-            return False
-
-        print('Hey, it says the Popen succeeded.')
-        # Added for additional debugging information.
-        #
-        print("The file worked on by beesu was: " + filename)
-        print("The shell_args passed to execvp() were: " + str(shell_args))
-
-        if os.path.isfile(lockfile):
-            os.remove(lockfile)
-            return False
-
-        return True
diff -up beesu-2.7/gedit-beesu-plugin-0.4/Makefile.in.geditfix beesu-2.7/gedit-beesu-plugin-0.4/Makefile.in
--- beesu-2.7/gedit-beesu-plugin-0.4/Makefile.in.geditfix	2015-09-15 11:18:41.100760038 -0400
+++ beesu-2.7/gedit-beesu-plugin-0.4/Makefile.in	2015-09-15 11:18:41.107759992 -0400
@@ -17,14 +17,12 @@ install:
 	$(INSTALL) -p -m 644 beesu.gedit-plugin $(LIBDIR)/gedit/plugins/beesu.plugin
 	$(MKDIR) -v -p $(LIBDIR)/gedit/plugins/beesu
 	$(INSTALL) -p -m 644 beesu/__init__.py $(LIBDIR)/gedit/plugins/beesu
-	$(INSTALL) -p -m 644 beesu/beesu.py $(LIBDIR)/gedit/plugins/beesu
 	$(MKDIR) -v -p $(LIBEXECDIR)
 	$(INSTALL) -p -m 755 libexec/gedit-beesu-plugin $(LIBEXECDIR)/
 
 # uninstall
 uninstall:
 	$(RM) $(LIBEXECDIR)/gedit-beesu-plugin
-	$(RM) $(LIBDIR)/gedit/plugins/beesu/beesu.py
 	$(RM) $(LIBDIR)/gedit/plugins/beesu/__init__.py
 	$(RM) $(LIBDIR)/gedit/plugins/beesu.plugin
 	$(RMDIR) $(LIBDIR)/gedit/plugins/beesu