1/* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 *
4 * GtkBindingSet: Keybinding manager for GObjects.
5 * Copyright (C) 1998 Tim Janik
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21/*
22 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
23 * file for a list of people on the GTK+ Team. See the ChangeLog
24 * files for a list of changes. These files are distributed with
25 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
26 */
27
28#ifndef __GTK_BINDINGS_H__
29#define __GTK_BINDINGS_H__
30
31
32#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
33#error "Only <gtk/gtk.h> can be included directly."
34#endif
35
36#include <gdk/gdk.h>
37#include <gtk/gtkenums.h>
38
39G_BEGIN_DECLS
40
41typedef struct _GtkBindingSet GtkBindingSet;
42typedef struct _GtkBindingEntry GtkBindingEntry;
43typedef struct _GtkBindingSignal GtkBindingSignal;
44typedef struct _GtkBindingArg GtkBindingArg;
45
46/**
47 * GtkBindingSet:
48 * @set_name: unique name of this binding set
49 * @priority: unused
50 * @widget_path_pspecs: unused
51 * @widget_class_pspecs: unused
52 * @class_branch_pspecs: unused
53 * @entries: the key binding entries in this binding set
54 * @current: implementation detail
55 * @parsed: whether this binding set stems from a CSS file and is reset upon theme changes
56 *
57 * A binding set maintains a list of activatable key bindings.
58 * A single binding set can match multiple types of widgets.
59 * Similar to style contexts, can be matched by any information contained
60 * in a widgets #GtkWidgetPath. When a binding within a set is matched upon
61 * activation, an action signal is emitted on the target widget to carry out
62 * the actual activation.
63 */
64struct _GtkBindingSet
65{
66 gchar *set_name;
67 gint priority;
68 GSList *widget_path_pspecs;
69 GSList *widget_class_pspecs;
70 GSList *class_branch_pspecs;
71 GtkBindingEntry *entries;
72 GtkBindingEntry *current;
73 guint parsed : 1;
74};
75
76/**
77 * GtkBindingEntry:
78 * @keyval: key value to match
79 * @modifiers: key modifiers to match
80 * @binding_set: binding set this entry belongs to
81 * @destroyed: implementation detail
82 * @in_emission: implementation detail
83 * @marks_unbound: implementation detail
84 * @set_next: linked list of entries maintained by binding set
85 * @hash_next: implementation detail
86 * @signals: action signals of this entry
87 *
88 * Each key binding element of a binding sets binding list is
89 * represented by a GtkBindingEntry.
90 */
91struct _GtkBindingEntry
92{
93 /* key portion */
94 guint keyval;
95 GdkModifierType modifiers;
96
97 GtkBindingSet *binding_set;
98 guint destroyed : 1;
99 guint in_emission : 1;
100 guint marks_unbound : 1;
101 GtkBindingEntry *set_next;
102 GtkBindingEntry *hash_next;
103 GtkBindingSignal *signals;
104};
105
106/**
107 * GtkBindingArg:
108 * @arg_type: implementation detail
109 *
110 * A #GtkBindingArg holds the data associated with
111 * an argument for a key binding signal emission as
112 * stored in #GtkBindingSignal.
113 */
114struct _GtkBindingArg
115{
116 GType arg_type;
117 union {
118 glong long_data;
119 gdouble double_data;
120 gchar *string_data;
121 } d;
122};
123
124/**
125 * GtkBindingSignal:
126 * @next: implementation detail
127 * @signal_name: the action signal to be emitted
128 * @n_args: number of arguments specified for the signal
129 * @args: (array length=n_args): the arguments specified for the signal
130 *
131 * A GtkBindingSignal stores the necessary information to
132 * activate a widget in response to a key press via a signal
133 * emission.
134 */
135struct _GtkBindingSignal
136{
137 GtkBindingSignal *next;
138 gchar *signal_name;
139 guint n_args;
140 GtkBindingArg *args;
141};
142
143GDK_AVAILABLE_IN_ALL
144GtkBindingSet *gtk_binding_set_new (const gchar *set_name);
145GDK_AVAILABLE_IN_ALL
146GtkBindingSet *gtk_binding_set_by_class (gpointer object_class);
147GDK_AVAILABLE_IN_ALL
148GtkBindingSet *gtk_binding_set_find (const gchar *set_name);
149
150GDK_AVAILABLE_IN_ALL
151gboolean gtk_bindings_activate (GObject *object,
152 guint keyval,
153 GdkModifierType modifiers);
154GDK_AVAILABLE_IN_ALL
155gboolean gtk_bindings_activate_event (GObject *object,
156 GdkEventKey *event);
157GDK_AVAILABLE_IN_ALL
158gboolean gtk_binding_set_activate (GtkBindingSet *binding_set,
159 guint keyval,
160 GdkModifierType modifiers,
161 GObject *object);
162
163GDK_AVAILABLE_IN_ALL
164void gtk_binding_entry_skip (GtkBindingSet *binding_set,
165 guint keyval,
166 GdkModifierType modifiers);
167GDK_AVAILABLE_IN_ALL
168void gtk_binding_entry_add_signal (GtkBindingSet *binding_set,
169 guint keyval,
170 GdkModifierType modifiers,
171 const gchar *signal_name,
172 guint n_args,
173 ...);
174GDK_AVAILABLE_IN_ALL
175void gtk_binding_entry_add_signall (GtkBindingSet *binding_set,
176 guint keyval,
177 GdkModifierType modifiers,
178 const gchar *signal_name,
179 GSList *binding_args);
180
181GDK_AVAILABLE_IN_ALL
182GTokenType gtk_binding_entry_add_signal_from_string
183 (GtkBindingSet *binding_set,
184 const gchar *signal_desc);
185
186GDK_AVAILABLE_IN_ALL
187void gtk_binding_entry_remove (GtkBindingSet *binding_set,
188 guint keyval,
189 GdkModifierType modifiers);
190
191G_END_DECLS
192
193#endif /* __GTK_BINDINGS_H__ */
194

source code of include/gtk-3.0/gtk/gtkbindings.h