1
-----------------------------------------------------------------------
2
-- GtkAda - Ada95 binding for Gtk+/Gnome --
4
-- Copyright (C) 2006, AdaCore --
6
-- This library is free software; you can redistribute it and/or --
7
-- modify it under the terms of the GNU General Public --
8
-- License as published by the Free Software Foundation; either --
9
-- version 2 of the License, or (at your option) any later version. --
11
-- This library is distributed in the hope that it will be useful, --
12
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
13
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
14
-- General Public License for more details. --
16
-- You should have received a copy of the GNU General Public --
17
-- License along with this library; if not, write to the --
18
-- Free Software Foundation, Inc., 59 Temple Place - Suite 330, --
19
-- Boston, MA 02111-1307, USA. --
21
-----------------------------------------------------------------------
24
-- Gtk_Bindings provides a mechanism for configuring Gtk+ key bindings through
25
-- RC files. This eases key binding adjustments for application developers as
26
-- well as users and provides Gtk+ users or administrators with high key
27
-- binding configurability which requires no application or toolkit side
30
-- Installing a key binding
31
-- ========================
33
-- A resource file binding consists of a 'binding' definition and a match
34
-- statement to apply the binding to specific widget types. Details on the
35
-- matching mechanism are described under Pathnames and patterns. Inside the
36
-- binding definition, key combinations are bound to specific signal emissions
37
-- on the target widget. Key combinations are strings consisting of an
38
-- optional Gdk_Modifier_Type name and key names such as those defined in
39
-- Gdk.Types.Keysyms or returned from gdk_keyval_name(), they have to be
40
-- parsable by gtk_accelerator_parse(). Specifications of signal emissions
41
-- consist of a string identifying the signal name, and a list of signal
42
-- specific arguments in parenthesis. For example for binding Control and the
43
-- left or right cursor keys of a Gtk_Entry widget to the
44
-- Gtk_Entry::move-cursor signal, so movement occurs in 3 letter steps, the
45
-- following binding can be used:
47
-- binding "MoveCursor3" {
48
-- bind "<Control>Right" {
49
-- "move-cursor" (visual-positions, 3, 0)
51
-- bind "<Control>Left" {
52
-- "move-cursor" (visual-positions, -3, 0)
55
-- class "GtkEntry" binding "MoveCursor3"
57
-- Unbinding existing key bindings
58
-- ===============================
60
-- Gtk+ already defines a number of useful bindings for the widgets it
61
-- provides. Because custom bindings set up in RC files take precedence over
62
-- the default bindings shipped with Gtk+, overriding existing bindings as
63
-- demonstrated in Installing a key binding works as expected. The same
64
-- mechanism can not be used to "unbind" existing bindings, however.
66
-- binding "MoveCursor3" {
67
-- bind "<Control>Right" { }
68
-- bind "<Control>Left" { }
70
-- class "GtkEntry" binding "MoveCursor3"
72
-- The above example will not have the desired effect of causing
73
-- "<Control>Right" and "<Control>Left" key presses to be ignored by Gtk+.
74
-- Instead, it just causes any existing bindings from the bindings set
75
-- "MoveCursor3" to be deleted, so when "<Control>Right" or "<Control>Left"
76
-- are pressed, no binding for these keys is found in binding set
77
-- "MoveCursor3". Gtk+ will thus continue to search for matching key bindings,
78
-- and will eventually lookup and find the default Gtk+ bindings for entries
79
-- which implement word movement. To keep Gtk+ from activating its default
80
-- bindings, the "unbind" keyword can be used like this:
82
-- binding "MoveCursor3" {
83
-- unbind "<Control>Right"
84
-- unbind "<Control>Left"
86
-- class "GtkEntry" binding "MoveCursor3"
88
-- Now, Gtk+ will find a match when looking up "<Control>Right" and
89
-- "<Control>Left" key presses before it resorts to its default bindings, and
90
-- the match instructs it to abort ("unbind") the search, so the key presses
91
-- are not consumed by this widget. As usual, further processing of the key
92
-- presses, e.g. by an entries parent widget, is now possible.
94
-- <c_version>2.8.17</c_version>
95
-- <group>Configuration and Themes</group>
102
package Gtk.Bindings is
104
type Gtk_Binding_Set is new Glib.C_Proxy;
105
-- A binding set maintains a list of activatable key bindings. A single
106
-- binding set can match multiple types of widgets. Similar to styles,
107
-- widgets can be mapped by widget name paths, widget class paths or widget
108
-- class types. When a binding within a set is matched upon activation, an
109
-- action signal is emitted on the target widget to carry out the actual
112
function Binding_Set_New (Set_Name : String) return Gtk_Binding_Set;
113
-- Gtk+ maintains a global list of binding sets. Each binding set has a
114
-- unique name which needs to be specified upon creation.
116
function Binding_Set_By_Class
117
(Object_Class : Glib.Object.GObject_Class) return Gtk_Binding_Set;
118
-- This function returns the binding set named after the type name of the
119
-- passed in class structure. New binding sets are created on demand by
122
function Binding_Set_Find (Set_Name : String) return Gtk_Binding_Set;
123
-- Find a binding set by its globally unique name. The set_name can either
124
-- be a name used for Binding_Set_New or the type name of a class
125
-- used in Binding_Set_By_Class.
128
(Object : access Gtk.Object.Gtk_Object_Record'Class;
130
Modifiers : Gdk.Types.Gdk_Modifier_Type)
132
-- Find a key binding matching keyval and modifiers and activate the
133
-- binding on object.
135
function Activate_Event
136
(Object : access Gtk.Object.Gtk_Object_Record;
137
Event : Gdk.Event.Gdk_Event_Key)
139
-- Looks up key bindings for Object to find one matching
140
-- Event, and if one was found, activate it.
141
-- Return value: True if a matching key binding was found
143
function Binding_Set_Activate
144
(Binding_Set : Gtk_Binding_Set;
146
Modifiers : Gdk.Types.Gdk_Modifier_Type;
147
Object : access Gtk.Object.Gtk_Object_Record'Class)
149
-- Find a key binding matching keyval and modifiers within binding_set and
150
-- activate the binding on object.
153
(Binding_Set : Gtk_Binding_Set;
155
Modifiers : Gdk.Types.Gdk_Modifier_Type;
156
Signal_Name : String);
158
(Binding_Set : Gtk_Binding_Set;
160
Modifiers : Gdk.Types.Gdk_Modifier_Type;
161
Signal_Name : String;
164
(Binding_Set : Gtk_Binding_Set;
166
Modifiers : Gdk.Types.Gdk_Modifier_Type;
167
Signal_Name : String;
170
(Binding_Set : Gtk_Binding_Set;
172
Modifiers : Gdk.Types.Gdk_Modifier_Type;
173
Signal_Name : String;
176
-- Override or install a new key binding for keyval with modifiers on
177
-- binding_set. When the binding is activated, signal_name will be emitted
178
-- on the target widget, with the given arguments as argument.
181
pragma Import (C, Binding_Set_By_Class, "gtk_binding_set_by_class");
184
-- These are bound through our own C wrappers:
185
-- No binding: gtk_binding_entry_add_signal
187
-- These are internal gtk+ functions
188
-- No binding: gtk_binding_entry_add_signall
189
-- No binding: gtk_binding_entry_clear
190
-- No binding: gtk_binding_entry_remove
191
-- No binding: gtk_binding_parse_binding
192
-- No binding: gtk_binding_set_add_path