[gedit-plugins] Add Ctrl+Shift+C/V copy paste accelerators to terminal



commit 2378aab5fdf321e5856291891dc8cf1d4f3e94ed
Author: Jesse van den Kieboom <jesse icecrew nl>
Date:   Thu Apr 29 19:05:40 2010 +0200

    Add Ctrl+Shift+C/V copy paste accelerators to terminal

 plugins/terminal/terminal.py |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/plugins/terminal/terminal.py b/plugins/terminal/terminal.py
index 75e2fcb..229a766 100644
--- a/plugins/terminal/terminal.py
+++ b/plugins/terminal/terminal.py
@@ -94,6 +94,19 @@ class GeditTerminal(gtk.HBox):
         self._vte.connect("popup-menu", self.on_vte_popup_menu)
         self._vte.connect("child-exited", lambda term: term.fork_command())
 
+        self._accel_base = '<gedit>/plugins/terminal'
+        self._accels = {
+            'copy-clipboard': [gtk.keysyms.C, gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK, self.copy_clipboard],
+            'paste-clipboard': [gtk.keysyms.V, gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK, self.paste_clipboard]
+        }
+
+        for name in self._accels:
+            path = self._accel_base + '/' + name
+            accel = gtk.accel_map_lookup_entry(path)
+
+            if accel == None:
+                 gtk.accel_map_add_entry(path, self._accels[name][0], self._accels[name][1])
+
         self._vte.fork_command()
 
     def do_grab_focus(self):
@@ -196,6 +209,15 @@ class GeditTerminal(gtk.HBox):
             elif modifiers == gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK:
                 self.get_toplevel().child_focus(gtk.DIR_TAB_BACKWARD)
                 return True
+
+        for name in self._accels:
+            path = self._accel_base + '/' + name
+            entry = gtk.accel_map_lookup_entry(path)
+
+            if entry and entry[0] == event.keyval and entry[1] == modifiers:
+                self._accels[name][2]()
+                return True
+
         return False
 
     def on_vte_button_press(self, term, event):
@@ -212,11 +234,13 @@ class GeditTerminal(gtk.HBox):
 
         item = gtk.ImageMenuItem(gtk.STOCK_COPY)
         item.connect("activate", lambda menu_item: self.copy_clipboard())
+        item.set_accel_path(self._accel_base + '/copy-clipboard')
         item.set_sensitive(self._vte.get_has_selection())
         menu.append(item)
 
         item = gtk.ImageMenuItem(gtk.STOCK_PASTE)
         item.connect("activate", lambda menu_item: self.paste_clipboard())
+        item.set_accel_path(self._accel_base + '/paste-clipboard')
         menu.append(item)
 
         self.emit("populate-popup", menu)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]