]> Pileus Git - ~andy/gtk/blob - docs/reference/gtk/tmpl/gtkbindings.sgml
Small additions and corrections
[~andy/gtk] / docs / reference / gtk / tmpl / gtkbindings.sgml
1 <!-- ##### SECTION Title ##### -->
2 Bindings
3
4 <!-- ##### SECTION Short_Description ##### -->
5 Key bindings for individual widgets
6
7 <!-- ##### SECTION Long_Description ##### -->
8 <para>
9 GtkBinding provides a mechanism for configuring GTK+ key bindings through 
10 RC files. This eases key binding adjustments for application developers as 
11 well as users and provides GTK+ users or administrators with high key 
12 binding configurability which requires no application or toolkit side changes.
13 </para>
14
15 <refsect2>
16 <anchor id="gtk-bindings-install"/>
17 <title>Installing a key binding</title>
18
19 <para>
20 A resource file binding consists of a 'binding' definition and a match 
21 statement to apply the binding to specific widget types. Details on the 
22 matching mechanism are described under 
23 <link linkend="gtkrc-pathnames-and-patterns">Pathnames and patterns</link>.
24 Inside the binding definition, key combinations are bound to specific signal 
25 emissions on the target widget. Key combinations are strings consisting of 
26 an optional #GdkModifierType name and 
27 <link linkend="gdk-Keyboard-Handling">key names</link> such as those defined 
28 in <filename>&lt;gdk/gdkkeysyms.h&gt;</filename> or returned from 
29 gdk_keyval_name(), they have to be parsable by gtk_accelerator_parse().
30 Specifications of signal emissions consist of a string identifying the signal 
31 name, and a list of signal specific arguments in parenthesis.
32 </para>
33 <para>
34 For example for binding Control and the left or right cursor keys of a 
35 #GtkEntry widget to the #GtkEntry::move-cursor signal, so movement occurs 
36 in 3 letter steps, the following binding can be used:
37
38 <informalexample><programlisting>
39 binding "MoveCursor3" {
40   bind "&lt;Control&gt;Right" {
41     "move-cursor" (visual-positions, 3, 0)
42   }
43   bind "&lt;Control&gt;Left" {
44     "move-cursor" (visual-positions, -3, 0)
45   }
46 }
47 class "GtkEntry" binding "MoveCursor3"
48 </programlisting></informalexample>
49 </para>
50
51
52 <anchor id="gtk-bindings-unbind"/>
53 <title>Unbinding existing key bindings</title>
54 <para>
55 GTK+ already defines a number of useful bindings for the widgets it provides.
56 Because custom bindings set up in RC files take precedence over the default 
57 bindings shipped with GTK+, overriding existing bindings as demonstrated in 
58 <link linkend="gtk-bindings-install">Installing a key binding</link>
59 works as expected. The same mechanism can not be used to "unbind" existing 
60 bindings, however.
61
62 <informalexample><programlisting>
63 binding "MoveCursor3" {
64   bind "&lt;Control&gt;Right" { }
65   bind "&lt;Control&gt;Left" { }
66 }
67 class "GtkEntry" binding "MoveCursor3"
68 </programlisting></informalexample>
69
70 The above example will not have the desired effect of causing 
71 "&lt;Control&gt;Right" and "&lt;Control&gt;Left" key presses to be ignored 
72 by GTK+. Instead, it just causes any existing bindings from the bindings 
73 set "MoveCursor3" to be deleted, so when "&lt;Control&gt;Right" or 
74 "&lt;Control&gt;Left" are pressed, no binding for these keys is found in 
75 binding set "MoveCursor3". GTK+ will thus continue to search for matching
76 key bindings, and will eventually lookup and find the default GTK+ bindings 
77 for entries which implement word movement. To keep GTK+ from activating its 
78 default bindings, the "unbind" keyword can be used like this:
79
80 <informalexample><programlisting>
81 binding "MoveCursor3" {
82   unbind "&lt;Control&gt;Right"
83   unbind "&lt;Control&gt;Left"
84 }
85 class "GtkEntry" binding "MoveCursor3"
86 </programlisting></informalexample>
87
88 Now, GTK+ will find a match when looking up "&lt;Control&gt;Right" and 
89 "&lt;Control&gt;Left" key presses before it resorts to its default 
90 bindings, and the match instructs it to abort ("unbind") the search, so 
91 the key presses are not consumed by this widget. As usual, further processing 
92 of the key presses, e.g. by an entry's parent widget, is now possible.
93 </para>
94
95 <para>
96 The "unbind" functionality has been introduced in GTK+ 2.12.
97 </para>
98
99 </refsect2>
100
101 <!-- ##### SECTION See_Also ##### -->
102 <para>
103 <variablelist>
104
105 <varlistentry>
106 <term><link linkend="gtk-keyboard-accelerators">Keyboard Accelerators</link>
107 </term>
108 <listitem><para>installing and using keyboard short-cuts.</para></listitem>
109 </varlistentry>
110
111 <varlistentry>
112 <term><link linkend="Resource-Files">Resource Files</link>
113 </term>
114 <listitem><para>GTK+ Resource Files - behavior and style definitions.</para></listitem>
115 </varlistentry>
116
117 </variablelist>
118 </para>
119
120 <!-- ##### SECTION Stability_Level ##### -->
121
122
123 <!-- ##### STRUCT GtkBindingSet ##### -->
124 <para>
125 A binding set maintains a list of activatable key bindings.
126 A single binding set can match multiple types of widgets.
127 Similar to styles, widgets can be mapped by widget name paths, widget 
128 class paths or widget class types.  When a binding within a set is 
129 matched upon activation, an action signal is emitted on the target 
130 widget to carry out the actual activation.
131 </para>
132
133 @set_name:              unique binding set name
134 @priority:              unused
135 @widget_path_pspecs:    widgets matched by path that this binding set applies to
136 @widget_class_pspecs:   widgets matched by class path that this binding set applies to
137 @class_branch_pspecs:   widgets matched by class that this binding set applies to
138 @entries:               the key binding entries in this binding set
139 @current:               implementation detail
140 @parsed:                whether this binding set stems from an RC file and is reset upon theme changes
141
142 <!-- ##### STRUCT GtkBindingEntry ##### -->
143 <para>
144 Each key binding element of a binding sets binding list is represented by 
145 a #GtkBindingEntry.
146 </para>
147
148 @keyval:        key value to match
149 @modifiers:     key modifier to match
150 @binding_set:   binding set this entry belongs to
151 @destroyed:     implementation detail
152 @in_emission:   implementation detail
153 @marks_unbound: implementation detail
154 @set_next:      linked list of entries maintained by binding set
155 @hash_next:     implementation detail
156 @signals:       action signals of this entry
157
158 <!-- ##### STRUCT GtkBindingSignal ##### -->
159 <para>
160 A #GtkBindingSignal stores the necessary information to activate a widget
161 in response to a key press via a signal emission.
162 </para>
163
164 @next:          implementation detail
165 @signal_name:   the action signal to be emitted
166 @n_args:        number of arguments specified for the signal
167 @args:          the arguments specified for the signal
168
169 <!-- ##### STRUCT GtkBindingArg ##### -->
170 <para>
171 A #GtkBindingArg holds the data associated with an argument for a
172 key binding signal emission as stored in #GtkBindingSignal.
173 </para>
174
175 @arg_type: implementation detail
176
177 <!-- ##### MACRO gtk_binding_entry_add ##### -->
178 <para>
179 Deprecated.
180 </para>
181
182
183
184 <!-- ##### FUNCTION gtk_binding_entry_add_signall ##### -->
185 <para>
186
187 </para>
188
189 @binding_set: 
190 @keyval: 
191 @modifiers: 
192 @signal_name: 
193 @binding_args: 
194
195
196 <!-- ##### FUNCTION gtk_binding_entry_clear ##### -->
197 <para>
198
199 </para>
200
201 @binding_set: 
202 @keyval: 
203 @modifiers: 
204
205
206 <!-- ##### FUNCTION gtk_binding_parse_binding ##### -->
207 <para>
208
209 </para>
210
211 @scanner: 
212 @Returns: 
213
214
215 <!-- ##### FUNCTION gtk_binding_set_new ##### -->
216 <para>
217
218 </para>
219
220 @set_name: 
221 @Returns: 
222
223
224 <!-- ##### FUNCTION gtk_binding_set_by_class ##### -->
225 <para>
226
227 </para>
228
229 @object_class: 
230 @Returns: 
231
232
233 <!-- ##### FUNCTION gtk_binding_set_find ##### -->
234 <para>
235
236 </para>
237
238 @set_name: 
239 @Returns: 
240
241
242 <!-- ##### FUNCTION gtk_bindings_activate ##### -->
243 <para>
244
245 </para>
246
247 @object: 
248 @keyval: 
249 @modifiers: 
250 @Returns: 
251
252
253 <!-- ##### FUNCTION gtk_bindings_activate_event ##### -->
254 <para>
255
256 </para>
257
258 @object: 
259 @event: 
260 @Returns: 
261
262
263 <!-- ##### FUNCTION gtk_binding_set_activate ##### -->
264 <para>
265
266 </para>
267
268 @binding_set: 
269 @keyval: 
270 @modifiers: 
271 @object: 
272 @Returns: 
273
274
275 <!-- ##### FUNCTION gtk_binding_entry_add_signal ##### -->
276 <para>
277
278 </para>
279
280 @binding_set: 
281 @keyval: 
282 @modifiers: 
283 @signal_name: 
284 @n_args: 
285 @Varargs: 
286
287
288 <!-- ##### FUNCTION gtk_binding_entry_skip ##### -->
289 <para>
290
291 </para>
292
293 @binding_set: 
294 @keyval: 
295 @modifiers: 
296
297
298 <!-- ##### FUNCTION gtk_binding_entry_remove ##### -->
299 <para>
300
301 </para>
302
303 @binding_set: 
304 @keyval: 
305 @modifiers: 
306
307
308 <!-- ##### FUNCTION gtk_binding_set_add_path ##### -->
309 <para>
310
311 </para>
312
313 @binding_set: 
314 @path_type: 
315 @path_pattern: 
316 @priority: 
317
318