]> Pileus Git - ~andy/gtk/blob - gtk/gtkaccelgroup.h
stylecontext: Do invalidation on first resize container
[~andy/gtk] / gtk / gtkaccelgroup.h
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 1998, 2001 Tim Janik
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 /*
19  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
20  * file for a list of people on the GTK+ Team.  See the ChangeLog
21  * files for a list of changes.  These files are distributed with
22  * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
23  */
24
25 #ifndef __GTK_ACCEL_GROUP_H__
26 #define __GTK_ACCEL_GROUP_H__
27
28
29 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
30 #error "Only <gtk/gtk.h> can be included directly."
31 #endif
32
33 #include <gdk/gdk.h>
34 #include <gtk/gtkenums.h>
35
36 G_BEGIN_DECLS
37
38
39 /* --- type macros --- */
40 #define GTK_TYPE_ACCEL_GROUP              (gtk_accel_group_get_type ())
41 #define GTK_ACCEL_GROUP(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GTK_TYPE_ACCEL_GROUP, GtkAccelGroup))
42 #define GTK_ACCEL_GROUP_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ACCEL_GROUP, GtkAccelGroupClass))
43 #define GTK_IS_ACCEL_GROUP(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GTK_TYPE_ACCEL_GROUP))
44 #define GTK_IS_ACCEL_GROUP_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ACCEL_GROUP))
45 #define GTK_ACCEL_GROUP_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ACCEL_GROUP, GtkAccelGroupClass))
46
47
48 /* --- accel flags --- */
49 typedef enum
50 {
51   GTK_ACCEL_VISIBLE        = 1 << 0,    /* display in GtkAccelLabel? */
52   GTK_ACCEL_LOCKED         = 1 << 1,    /* is it removable? */
53   GTK_ACCEL_MASK           = 0x07
54 } GtkAccelFlags;
55
56
57 /* --- typedefs & structures --- */
58 typedef struct _GtkAccelGroup             GtkAccelGroup;
59 typedef struct _GtkAccelGroupClass        GtkAccelGroupClass;
60 typedef struct _GtkAccelGroupPrivate      GtkAccelGroupPrivate;
61 typedef struct _GtkAccelKey               GtkAccelKey;
62 typedef struct _GtkAccelGroupEntry        GtkAccelGroupEntry;
63 typedef gboolean (*GtkAccelGroupActivate) (GtkAccelGroup  *accel_group,
64                                            GObject        *acceleratable,
65                                            guint           keyval,
66                                            GdkModifierType modifier);
67
68 /**
69  * GtkAccelGroupFindFunc:
70  * @key: 
71  * @closure: 
72  * @data: (closure):
73  * 
74  * Since: 2.2
75  */
76 typedef gboolean (*GtkAccelGroupFindFunc) (GtkAccelKey    *key,
77                                            GClosure       *closure,
78                                            gpointer        data);
79
80 /**
81  * GtkAccelGroup:
82  * 
83  * An object representing and maintaining a group of accelerators.
84  */
85 struct _GtkAccelGroup
86 {
87   GObject               parent;
88   GtkAccelGroupPrivate *priv;
89 };
90
91 struct _GtkAccelGroupClass
92 {
93   GObjectClass parent_class;
94
95   void  (*accel_changed)        (GtkAccelGroup  *accel_group,
96                                  guint           keyval,
97                                  GdkModifierType modifier,
98                                  GClosure       *accel_closure);
99   
100   /* Padding for future expansion */
101   void (*_gtk_reserved1) (void);
102   void (*_gtk_reserved2) (void);
103   void (*_gtk_reserved3) (void);
104   void (*_gtk_reserved4) (void);
105 };
106
107 struct _GtkAccelKey
108 {
109   guint           accel_key;
110   GdkModifierType accel_mods;
111   guint           accel_flags : 16;
112 };
113
114
115 /* -- Accelerator Groups --- */
116 GType          gtk_accel_group_get_type           (void) G_GNUC_CONST;
117 GtkAccelGroup* gtk_accel_group_new                (void);
118 gboolean       gtk_accel_group_get_is_locked      (GtkAccelGroup  *accel_group);
119 GdkModifierType 
120                gtk_accel_group_get_modifier_mask  (GtkAccelGroup  *accel_group);
121 void           gtk_accel_group_lock               (GtkAccelGroup  *accel_group);
122 void           gtk_accel_group_unlock             (GtkAccelGroup  *accel_group);
123 void           gtk_accel_group_connect            (GtkAccelGroup  *accel_group,
124                                                    guint           accel_key,
125                                                    GdkModifierType accel_mods,
126                                                    GtkAccelFlags   accel_flags,
127                                                    GClosure       *closure);
128 void           gtk_accel_group_connect_by_path    (GtkAccelGroup  *accel_group,
129                                                    const gchar    *accel_path,
130                                                    GClosure       *closure);
131 gboolean       gtk_accel_group_disconnect         (GtkAccelGroup  *accel_group,
132                                                    GClosure       *closure);
133 gboolean       gtk_accel_group_disconnect_key     (GtkAccelGroup  *accel_group,
134                                                    guint           accel_key,
135                                                    GdkModifierType accel_mods);
136 gboolean       gtk_accel_group_activate           (GtkAccelGroup   *accel_group,
137                                                    GQuark          accel_quark,
138                                                    GObject        *acceleratable,
139                                                    guint           accel_key,
140                                                    GdkModifierType accel_mods);
141
142
143 /* --- GtkActivatable glue --- */
144 void            _gtk_accel_group_attach         (GtkAccelGroup  *accel_group,
145                                                  GObject        *object);
146 void            _gtk_accel_group_detach         (GtkAccelGroup  *accel_group,
147                                                  GObject        *object);
148 gboolean        gtk_accel_groups_activate       (GObject        *object,
149                                                  guint           accel_key,
150                                                  GdkModifierType accel_mods);
151 GSList*         gtk_accel_groups_from_object    (GObject        *object);
152 GtkAccelKey*    gtk_accel_group_find            (GtkAccelGroup        *accel_group,
153                                                  GtkAccelGroupFindFunc find_func,
154                                                  gpointer              data);
155 GtkAccelGroup*  gtk_accel_group_from_accel_closure (GClosure    *closure);
156
157
158 /* --- Accelerators--- */
159 gboolean gtk_accelerator_valid                (guint            keyval,
160                                                GdkModifierType  modifiers) G_GNUC_CONST;
161 void     gtk_accelerator_parse                (const gchar     *accelerator,
162                                                guint           *accelerator_key,
163                                                GdkModifierType *accelerator_mods);
164 GDK_AVAILABLE_IN_3_4
165 void gtk_accelerator_parse_with_keycode       (const gchar     *accelerator,
166                                                guint           *accelerator_key,
167                                                guint          **accelerator_codes,
168                                                GdkModifierType *accelerator_mods);
169 gchar*   gtk_accelerator_name                 (guint            accelerator_key,
170                                                GdkModifierType  accelerator_mods);
171 GDK_AVAILABLE_IN_3_4
172 gchar*   gtk_accelerator_name_with_keycode    (GdkDisplay      *display,
173                                                guint            accelerator_key,
174                                                guint            keycode,
175                                                GdkModifierType  accelerator_mods);
176 gchar*   gtk_accelerator_get_label            (guint           accelerator_key,
177                                                GdkModifierType accelerator_mods);
178 GDK_AVAILABLE_IN_3_4
179 gchar*   gtk_accelerator_get_label_with_keycode (GdkDisplay      *display,
180                                                  guint            accelerator_key,
181                                                  guint            keycode,
182                                                  GdkModifierType  accelerator_mods);
183 void     gtk_accelerator_set_default_mod_mask (GdkModifierType  default_mod_mask);
184 GdkModifierType
185          gtk_accelerator_get_default_mod_mask (void);
186
187
188 /* --- internal --- */
189 GtkAccelGroupEntry*     gtk_accel_group_query   (GtkAccelGroup  *accel_group,
190                                                  guint           accel_key,
191                                                  GdkModifierType accel_mods,
192                                                  guint          *n_entries);
193
194 void                 _gtk_accel_group_reconnect (GtkAccelGroup *accel_group,
195                                                  GQuark         accel_path_quark);
196 GSList*       _gtk_accel_group_get_accelerables (GtkAccelGroup *accel_group);
197
198 struct _GtkAccelGroupEntry
199 {
200   GtkAccelKey  key;
201   GClosure    *closure;
202   GQuark       accel_path_quark;
203 };
204
205
206 G_END_DECLS
207
208
209 #endif /* __GTK_ACCEL_GROUP_H__ */