]> Pileus Git - ~andy/gtk/blob - gtk/gtkbindings.h
stylecontext: Do invalidation on first resize container
[~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, 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
39 G_BEGIN_DECLS
40
41 typedef struct _GtkBindingSet    GtkBindingSet;
42 typedef struct _GtkBindingEntry  GtkBindingEntry;
43 typedef struct _GtkBindingSignal GtkBindingSignal;
44 typedef 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  */
64 struct _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  */
91 struct _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  */
114 struct _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: the arguments specified for the signal
130  *
131  * <anchor id="keybinding-signals"/>
132  * A GtkBindingSignal stores the necessary information to
133  * activate a widget in response to a key press via a signal
134  * emission.
135  */
136 struct _GtkBindingSignal
137 {
138   GtkBindingSignal *next;
139   gchar            *signal_name;
140   guint             n_args;
141   GtkBindingArg    *args;
142 };
143
144 GtkBindingSet *gtk_binding_set_new           (const gchar         *set_name);
145 GtkBindingSet *gtk_binding_set_by_class      (gpointer             object_class);
146 GtkBindingSet *gtk_binding_set_find          (const gchar         *set_name);
147
148 gboolean       gtk_bindings_activate         (GObject             *object,
149                                               guint                keyval,
150                                               GdkModifierType      modifiers);
151 gboolean       gtk_bindings_activate_event   (GObject             *object,
152                                               GdkEventKey         *event);
153 gboolean       gtk_binding_set_activate      (GtkBindingSet       *binding_set,
154                                               guint                keyval,
155                                               GdkModifierType      modifiers,
156                                               GObject             *object);
157
158 void           gtk_binding_entry_skip        (GtkBindingSet       *binding_set,
159                                               guint                keyval,
160                                               GdkModifierType      modifiers);
161 void           gtk_binding_entry_add_signal  (GtkBindingSet       *binding_set,
162                                               guint                keyval,
163                                               GdkModifierType      modifiers,
164                                               const gchar         *signal_name,
165                                               guint                n_args,
166                                               ...);
167 void           gtk_binding_entry_add_signall (GtkBindingSet       *binding_set,
168                                               guint                keyval,
169                                               GdkModifierType      modifiers,
170                                               const gchar         *signal_name,
171                                               GSList              *binding_args);
172
173 GTokenType     gtk_binding_entry_add_signal_from_string
174                                              (GtkBindingSet       *binding_set,
175                                               const gchar         *signal_desc);
176
177 void           gtk_binding_entry_remove      (GtkBindingSet       *binding_set,
178                                               guint                keyval,
179                                               GdkModifierType      modifiers);
180
181 GDK_DEPRECATED_IN_3_0
182 void           gtk_binding_set_add_path      (GtkBindingSet       *binding_set,
183                                               GtkPathType          path_type,
184                                               const gchar         *path_pattern,
185                                               GtkPathPriorityType  priority);
186
187 G_END_DECLS
188
189 #endif /* __GTK_BINDINGS_H__ */