]> Pileus Git - ~andy/gtk/blob - gtk/gtkbindings.h
a21455c88306810419d56ab91bfa9a596277da33
[~andy/gtk] / gtk / gtkbindings.h
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, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 /*
24  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
25  * file for a list of people on the GTK+ Team.  See the ChangeLog
26  * files for a list of changes.  These files are distributed with
27  * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
28  */
29
30 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
31 #error "Only <gtk/gtk.h> can be included directly."
32 #endif
33
34 #ifndef __GTK_BINDINGS_H__
35 #define __GTK_BINDINGS_H__
36
37
38 #include <gdk/gdk.h>
39 #include <gtk/gtkenums.h>
40
41 G_BEGIN_DECLS
42
43 typedef struct _GtkBindingSet    GtkBindingSet;
44 typedef struct _GtkBindingEntry  GtkBindingEntry;
45 typedef struct _GtkBindingSignal GtkBindingSignal;
46 typedef struct _GtkBindingArg    GtkBindingArg;
47
48 /**
49  * GtkBindingSet:
50  * @set_name: unique name of this binding set
51  * @priority: unused
52  * @widget_path_pspecs: unused
53  * @widget_class_pspecs: unused
54  * @class_branch_pspecs: unused
55  * @entries: the key binding entries in this binding set
56  * @current: implementation detail
57  * @parsed: whether this binding set stems from a CSS file and is reset upon theme changes
58  *
59  * A binding set maintains a list of activatable key bindings.
60  * A single binding set can match multiple types of widgets.
61  * Similar to style contexts, can be matched by any information contained
62  * in a widgets #GtkWidgetPath. When a binding within a set is matched upon
63  * activation, an action signal is emitted on the target widget to carry out
64  * the actual activation.
65  */
66 struct _GtkBindingSet
67 {
68   gchar           *set_name;
69   gint             priority;
70   GSList          *widget_path_pspecs;
71   GSList          *widget_class_pspecs;
72   GSList          *class_branch_pspecs;
73   GtkBindingEntry *entries;
74   GtkBindingEntry *current;
75   guint            parsed : 1;
76 };
77
78 /**
79  * GtkBindingEntry:
80  * @keyval: key value to match
81  * @modifiers: key modifiers to match
82  * @binding_set: binding set this entry belongs to
83  * @destroyed: implementation detail
84  * @in_emission: implementation detail
85  * @marks_unbound: implementation detail
86  * @set_next: linked list of entries maintained by binding set
87  * @hash_next: implementation detail
88  * @signals: action signals of this entry
89  *
90  * Each key binding element of a binding sets binding list is
91  * represented by a GtkBindingEntry.
92  */
93 struct _GtkBindingEntry
94 {
95   /* key portion */
96   guint             keyval;
97   GdkModifierType   modifiers;
98
99   GtkBindingSet    *binding_set;
100   guint             destroyed     : 1;
101   guint             in_emission   : 1;
102   guint             marks_unbound : 1;
103   GtkBindingEntry  *set_next;
104   GtkBindingEntry  *hash_next;
105   GtkBindingSignal *signals;
106 };
107
108 /**
109  * GtkBindingArg:
110  * @arg_type: implementation detail
111  *
112  * A #GtkBindingArg holds the data associated with
113  * an argument for a key binding signal emission as
114  * stored in #GtkBindingSignal.
115  */
116 struct _GtkBindingArg
117 {
118   GType      arg_type;
119   union {
120     glong    long_data;
121     gdouble  double_data;
122     gchar   *string_data;
123   } d;
124 };
125
126 /**
127  * GtkBindingSignal:
128  * @next: implementation detail
129  * @signal_name: the action signal to be emitted
130  * @n_args: number of arguments specified for the signal
131  * @args: the arguments specified for the signal
132  *
133  * <anchor id="keybinding-signals"/>
134  * A GtkBindingSignal stores the necessary information to
135  * activate a widget in response to a key press via a signal
136  * emission.
137  */
138 struct _GtkBindingSignal
139 {
140   GtkBindingSignal *next;
141   gchar            *signal_name;
142   guint             n_args;
143   GtkBindingArg    *args;
144 };
145
146 GtkBindingSet *gtk_binding_set_new           (const gchar         *set_name);
147 GtkBindingSet *gtk_binding_set_by_class      (gpointer             object_class);
148 GtkBindingSet *gtk_binding_set_find          (const gchar         *set_name);
149
150 gboolean       gtk_bindings_activate         (GObject             *object,
151                                               guint                keyval,
152                                               GdkModifierType      modifiers);
153 gboolean       gtk_bindings_activate_event   (GObject             *object,
154                                               GdkEventKey         *event);
155 gboolean       gtk_binding_set_activate      (GtkBindingSet       *binding_set,
156                                               guint                keyval,
157                                               GdkModifierType      modifiers,
158                                               GObject             *object);
159
160 void           gtk_binding_entry_skip        (GtkBindingSet       *binding_set,
161                                               guint                keyval,
162                                               GdkModifierType      modifiers);
163 void           gtk_binding_entry_add_signal  (GtkBindingSet       *binding_set,
164                                               guint                keyval,
165                                               GdkModifierType      modifiers,
166                                               const gchar         *signal_name,
167                                               guint                n_args,
168                                               ...);
169 void           gtk_binding_entry_add_signall (GtkBindingSet       *binding_set,
170                                               guint                keyval,
171                                               GdkModifierType      modifiers,
172                                               const gchar         *signal_name,
173                                               GSList              *binding_args);
174
175 GTokenType     gtk_binding_entry_add_signal_from_string
176                                              (GtkBindingSet       *binding_set,
177                                               const gchar         *signal_desc);
178
179 void           gtk_binding_entry_remove      (GtkBindingSet       *binding_set,
180                                               guint                keyval,
181                                               GdkModifierType      modifiers);
182
183 GDK_DEPRECATED_IN_3_0
184 void           gtk_binding_set_add_path      (GtkBindingSet       *binding_set,
185                                               GtkPathType          path_type,
186                                               const gchar         *path_pattern,
187                                               GtkPathPriorityType  priority);
188
189 G_END_DECLS
190
191 #endif /* __GTK_BINDINGS_H__ */