1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
From 0372583cc0af915e84558caa515429bbb372358d Mon Sep 17 00:00:00 2001
From: Jesse van den Kieboom <jesse@icecrew.nl>
Date: Thu, 29 Apr 2010 17:05:40 +0000
Subject: Add Ctrl+Shift+C/V copy paste accelerators to terminal
---
diff --git a/plugins/terminal/terminal.py b/plugins/terminal/terminal.py
index 902b424..28ee996 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)
--
cgit v0.8.3.1
|