[meld] Use Alt+Up/Down for Previous/Next diff (closes bgo#626183, bgo#613849)
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Use Alt+Up/Down for Previous/Next diff (closes bgo#626183, bgo#613849)
- Date: Sat, 2 Oct 2010 01:14:02 +0000 (UTC)
commit 0bcbab20550741cff80d57970303877735274a60
Author: Kai Willadsen <kai willadsen gmail com>
Date: Fri May 7 08:15:06 2010 +1000
Use Alt+Up/Down for Previous/Next diff (closes bgo#626183, bgo#613849)
GtkSourceView uses two different binding mechanisms; blatant
interception pre-2.10, and a nice binding post-2.10. We need to deal
with both.
meld/meldapp.py | 4 ++--
meld/util/sourceviewer.py | 45 ++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 46 insertions(+), 3 deletions(-)
---
diff --git a/meld/meldapp.py b/meld/meldapp.py
index 39bb9a1..040eb9b 100644
--- a/meld/meldapp.py
+++ b/meld/meldapp.py
@@ -154,8 +154,8 @@ class MeldApp(gnomeglade.Component):
("Preferences", gtk.STOCK_PREFERENCES, _("Prefere_nces"), None, _("Configure the application"), self.on_menu_preferences_activate),
("ChangesMenu", None, _("_Changes")),
- ("NextChange", gtk.STOCK_GO_DOWN, _("Next change"), "<control>D", _("Go to the next change"), self.on_menu_edit_down_activate),
- ("PrevChange", gtk.STOCK_GO_UP, _("Previous change"), "<control>E", _("Go to the previous change"), self.on_menu_edit_up_activate),
+ ("NextChange", gtk.STOCK_GO_DOWN, _("Next change"), "<Alt>Down", _("Go to the next change"), self.on_menu_edit_down_activate),
+ ("PrevChange", gtk.STOCK_GO_UP, _("Previous change"), "<Alt>Up", _("Go to the previous change"), self.on_menu_edit_up_activate),
("ViewMenu", None, _("_View")),
("FileStatus", None, _("File status")),
diff --git a/meld/util/sourceviewer.py b/meld/util/sourceviewer.py
index f1be1fc..ec97378 100644
--- a/meld/util/sourceviewer.py
+++ b/meld/util/sourceviewer.py
@@ -19,6 +19,9 @@
import os
+import gtk
+
+
class _srcviewer(object):
# Module name to be imported for the sourceviewer class
srcviewer_module = None
@@ -152,9 +155,48 @@ class gtksourceview24(_gtksourceview2):
if self.gsv.pygtksourceview2_version[1] < 4:
raise ImportError
+ def overrides(self):
+ _gtksourceview2.overrides(self)
+ viewClass = self.gsv.View
+
+ class SourceView(viewClass):
+
+ __gsignals__ = {
+ 'key-press-event': 'override'
+ }
+
+ def do_key_press_event(self, event):
+ if event.keyval in (gtk.keysyms.KP_Up, gtk.keysyms.KP_Down,
+ gtk.keysyms.Up, gtk.keysyms.Down) and \
+ (event.state & gtk.gdk.MOD1_MASK) != 0 and \
+ (event.state & gtk.gdk.SHIFT_MASK) == 0:
+ return True
+ return viewClass.do_key_press_event(self, event)
+
+ self.GtkTextView = SourceView
+
def get_language_from_file(self, filename):
return self.get_language_manager().guess_language(filename)
+
+class gtksourceview210(gtksourceview24):
+
+ def version_check(self):
+ if self.gsv.pygtksourceview2_version[1] < 10:
+ raise ImportError
+
+ def overrides(self):
+ _gtksourceview2.overrides(self)
+ gtk.binding_entry_remove(self.GtkTextView, gtk.keysyms.Up,
+ gtk.gdk.MOD1_MASK)
+ gtk.binding_entry_remove(self.GtkTextView, gtk.keysyms.KP_Up,
+ gtk.gdk.MOD1_MASK)
+ gtk.binding_entry_remove(self.GtkTextView, gtk.keysyms.Down,
+ gtk.gdk.MOD1_MASK)
+ gtk.binding_entry_remove(self.GtkTextView, gtk.keysyms.KP_Down,
+ gtk.gdk.MOD1_MASK)
+
+
class nullsourceview(_srcviewer):
"""Implement the sourceviewer API when no real one is available
"""
@@ -181,7 +223,8 @@ class nullsourceview(_srcviewer):
pass
def _get_srcviewer():
- for srcv in (gtksourceview24, gtksourceview22, gtksourceview, sourceview):
+ for srcv in (gtksourceview210, gtksourceview24, gtksourceview22,
+ gtksourceview, sourceview):
try:
return srcv()
except ImportError:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]