# The following code is taken from
# http://libre2.adacore.com/viewvc/trunk/gps/share/plug-ins/text_utils.py?view=markup&pathrev=131464
# and shows how to override key bindings.
SPACE=32
BACKSPACE=65288
def override (key, modifier, movement, step, select):
gtk.binding_entry_remove (gtk.TextView, key, modifier)
gtk.binding_entry_add_signal (gtk.TextView, key, modifier,
"move_cursor",
gobject.TYPE_ENUM, movement,
gobject.TYPE_INT, step,
gobject.TYPE_BOOLEAN, select)
def override_key_bindings (select):
"""Override the default TextView keybinding to either always force
the extension the selection, or not"""
override (SPACE, 0, gtk.MOVEMENT_PAGES, 1, select)
override (BACKSPACE, 0, gtk.MOVEMENT_PAGES, -1, select)
:
tv = gtk.TextView()
tv.set_editable(False)
tv.set_cursor_visible(False)
override_key_bindings(select=False)