Description
Gtk_Bindings provides a mechanism for configuring
Gtk+ key bindings through
RC files. This eases key binding adjustments for application developers as
well as users and provides
Gtk+ users or administrators with high key
binding configurability which requires no application or toolkit side
changes.
Installing a key binding
========================
A resource file binding consists of a 'binding' definition and a match
statement to apply the binding to specific widget types. Details on the
matching mechanism are described under Pathnames and patterns. Inside the
binding definition, key combinations are bound to specific signal emissions
on the target widget. Key combinations are strings consisting of an
optional Gdk_Modifier_Type name and key names such as those defined in
Gdk.Types.Keysyms or returned from gdk_keyval_name(), they have to be
parsable by gtk_accelerator_parse(). Specifications of signal emissions
consist of a string identifying the signal name, and a list of signal
specific arguments in parenthesis. For example for binding Control and the
left or right cursor keys of a Gtk_Entry widget to the
Gtk_Entry::move-cursor signal, so movement occurs in 3 letter steps, the
following binding can be used:
binding "MoveCursor3" {
bind "Right" {
"move-cursor" (visual-positions, 3, 0)
}
bind "Left" {
"move-cursor" (visual-positions, -3, 0)
}
}
class "GtkEntry" binding "MoveCursor3"
Unbinding existing key bindings
===============================
Gtk+ already defines a number of useful bindings for the widgets it
provides. Because custom bindings set up in RC files take precedence over
the default bindings shipped with Gtk+, overriding existing bindings as
demonstrated in Installing a key binding works as expected. The same
mechanism can not be used to "unbind" existing bindings, however.
binding "MoveCursor3" {
bind "Right" { }
bind "Left" { }
}
class "GtkEntry" binding "MoveCursor3"
The above example will not have the desired effect of causing
"Right" and "Left" key presses to be ignored by Gtk+.
Instead, it just causes any existing bindings from the bindings set
"MoveCursor3" to be deleted, so when "Right" or "Left"
are pressed, no binding for these keys is found in binding set
"MoveCursor3". Gtk+ will thus continue to search for matching key bindings,
and will eventually lookup and find the default Gtk+ bindings for entries
which implement word movement. To keep Gtk+ from activating its default
bindings, the "unbind" keyword can be used like this:
binding "MoveCursor3" {
unbind "Right"
unbind "Left"
}
class "GtkEntry" binding "MoveCursor3"
Now, Gtk+ will find a match when looking up "Right" and
"Left" key presses before it resorts to its default bindings, and
the match instructs it to abort ("unbind") the search, so the key presses
are not consumed by this widget. As usual, further processing of the key
presses, e.g. by an entries parent widget, is now possible.
Subprograms
-
function Binding_Set_New (Set_Name : String) return Gtk_Binding_Set;
-
-
function Binding_Set_Find (Set_Name : String) return Gtk_Binding_Set;
-
function Activate
(Object :
access Gtk.Object.Gtk_Object_Record'Class;
Keyval : Guint;
Modifiers : Gdk.Types.Gdk_Modifier_Type)
return Boolean;
-
-
function Binding_Set_Activate
(Binding_Set : Gtk_Binding_Set;
Keyval : Guint;
Modifiers : Gdk.Types.Gdk_Modifier_Type;
Object :
access Gtk.Object.Gtk_Object_Record'Class)
return Boolean;
-
procedure Add_Signal
(Binding_Set : Gtk_Binding_Set;
Keyval : Guint;
Modifiers : Gdk.Types.Gdk_Modifier_Type;
Signal_Name : String);
procedure Add_Signal
(Binding_Set : Gtk_Binding_Set;
Keyval : Guint;
Modifiers : Gdk.Types.Gdk_Modifier_Type;
Signal_Name : String;
Arg1 : Gint);
procedure Add_Signal
(Binding_Set : Gtk_Binding_Set;
Keyval : Guint;
Modifiers : Gdk.Types.Gdk_Modifier_Type;
Signal_Name : String;
Arg1 : Boolean);
procedure Add_Signal
(Binding_Set : Gtk_Binding_Set;
Keyval : Guint;
Modifiers : Gdk.Types.Gdk_Modifier_Type;
Signal_Name : String;
Arg1 : Gint;
Arg2 : Gint);