[totem] pythonconsole: Fix key event handling
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem] pythonconsole: Fix key event handling
- Date: Sun, 27 Mar 2011 04:19:51 +0000 (UTC)
commit 9cc3129e8f432543a513c4977a453176d191f05b
Author: Philip Withnall <philip tecnocode co uk>
Date: Sat Mar 26 17:37:55 2011 +0000
pythonconsole: Fix key event handling
Port fixes to key event handling from
gedit's pythonconsole
Fix the event handling for key events so that typing
in the console works as expected.
Based on:
http://git.gnome.org/browse/gedit/commit/plugins/pythonconsole/pythonconsole/console.py?id=da49b588a394717b5ea0a3f9e6a823a86e62feae
http://git.gnome.org/browse/gedit/commit/plugins/pythonconsole/pythonconsole/console.py?id=ba74278347888e4a16f3a0fee2a359b7f2bcde8b
Closes: bgo#645762
src/plugins/pythonconsole/console.py | 21 +++++++++++----------
1 files changed, 11 insertions(+), 10 deletions(-)
---
diff --git a/src/plugins/pythonconsole/console.py b/src/plugins/pythonconsole/console.py
index f1e6bdd..6a71183 100644
--- a/src/plugins/pythonconsole/console.py
+++ b/src/plugins/pythonconsole/console.py
@@ -88,12 +88,13 @@ class PythonConsole(Gtk.ScrolledWindow):
def __key_press_event_cb(self, view, event):
- (_, state) = event.get_state ()
+ modifier_mask = Gtk.accelerator_get_default_mod_mask()
+ event_state = event.state & modifier_mask
- if event.key.keyval == Gdk.KEY_d and state & Gdk.ModifierType.CONTROL_MASK:
+ if event.keyval == Gdk.KEY_d and event_state == Gdk.ModifierType.CONTROL_MASK:
self.destroy()
- elif event.key.keyval == Gdk.KEY_Return and state & Gdk.ModifierType.CONTROL_MASK:
+ elif event.keyval == Gdk.KEY_Return and event_state == Gdk.ModifierType.CONTROL_MASK:
# Get the command
buffer = view.get_buffer()
inp_mark = buffer.get_mark("input")
@@ -119,7 +120,7 @@ class PythonConsole(Gtk.ScrolledWindow):
gobject.idle_add(self.scroll_to_end)
return True
- elif event.key.keyval == Gdk.KEY_Return:
+ elif event.keyval == Gdk.KEY_Return:
# Get the marks
buffer = view.get_buffer()
lin_mark = buffer.get_mark("input-line")
@@ -163,32 +164,32 @@ class PythonConsole(Gtk.ScrolledWindow):
gobject.idle_add(self.scroll_to_end)
return True
- elif event.key.keyval == Gdk.KEY_KP_Down or event.key.keyval == Gdk.KEY_Down:
+ elif event.keyval == Gdk.KEY_KP_Down or event.keyval == Gdk.KEY_Down:
# Next entry from history
view.emit_stop_by_name("key_press_event")
self.history_down()
gobject.idle_add(self.scroll_to_end)
return True
- elif event.key.keyval == Gdk.KEY_KP_Up or event.key.keyval == Gdk.KEY_Up:
+ elif event.keyval == Gdk.KEY_KP_Up or event.keyval == Gdk.KEY_Up:
# Previous entry from history
view.emit_stop_by_name("key_press_event")
self.history_up()
gobject.idle_add(self.scroll_to_end)
return True
- elif event.key.keyval == Gdk.KEY_KP_Left or event.key.keyval == Gdk.KEY_Left or \
- event.key.keyval == Gdk.KEY_BackSpace:
+ elif event.keyval == Gdk.KEY_KP_Left or event.keyval == Gdk.KEY_Left or \
+ event.keyval == Gdk.KEY_BackSpace:
buffer = view.get_buffer()
inp = buffer.get_iter_at_mark(buffer.get_mark("input"))
cur = buffer.get_iter_at_mark(buffer.get_insert())
return inp.compare(cur) == 0
- elif event.key.keyval == Gdk.KEY_Home:
+ elif event.keyval == Gdk.KEY_Home:
# Go to the begin of the command instead of the begin of the line
buffer = view.get_buffer()
inp = buffer.get_iter_at_mark(buffer.get_mark("input"))
- if state & Gdk.ModifierType.SHIFT_MASK:
+ if event_state == Gdk.ModifierType.SHIFT_MASK:
buffer.move_mark_by_name("insert", inp)
else:
buffer.place_cursor(inp)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]