]> Pileus Git - ~andy/gtk/blob - gtk/gtkaccelgroup.h
Seal GtkAccelGroup - fixed some issues with the initial attempt thanks to comments...
[~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, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
21  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
25  */
26
27 #if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
28 #error "Only <gtk/gtk.h> can be included directly."
29 #endif
30
31 #ifndef __GTK_ACCEL_GROUP_H__
32 #define __GTK_ACCEL_GROUP_H__
33
34
35 #include <gdk/gdk.h>
36 #include <gtk/gtkenums.h>
37
38 G_BEGIN_DECLS
39
40
41 /* --- type macros --- */
42 #define GTK_TYPE_ACCEL_GROUP              (gtk_accel_group_get_type ())
43 #define GTK_ACCEL_GROUP(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GTK_TYPE_ACCEL_GROUP, GtkAccelGroup))
44 #define GTK_ACCEL_GROUP_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ACCEL_GROUP, GtkAccelGroupClass))
45 #define GTK_IS_ACCEL_GROUP(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GTK_TYPE_ACCEL_GROUP))
46 #define GTK_IS_ACCEL_GROUP_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ACCEL_GROUP))
47 #define GTK_ACCEL_GROUP_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ACCEL_GROUP, GtkAccelGroupClass))
48
49
50 /* --- accel flags --- */
51 typedef enum
52 {
53   GTK_ACCEL_VISIBLE        = 1 << 0,    /* display in GtkAccelLabel? */
54   GTK_ACCEL_LOCKED         = 1 << 1,    /* is it removable? */
55   GTK_ACCEL_MASK           = 0x07
56 } GtkAccelFlags;
57
58
59 /* --- typedefs & structures --- */
60 typedef struct _GtkAccelGroup      GtkAccelGroup;
61 typedef struct _GtkAccelGroupClass GtkAccelGroupClass;
62 typedef struct _GtkAccelKey        GtkAccelKey;
63 typedef struct _GtkAccelGroupEntry GtkAccelGroupEntry;
64 typedef gboolean (*GtkAccelGroupActivate) (GtkAccelGroup  *accel_group,
65                                            GObject        *acceleratable,
66                                            guint           keyval,
67                                            GdkModifierType modifier);
68
69 typedef gboolean (*GtkAccelGroupFindFunc) (GtkAccelKey    *key,
70                                            GClosure       *closure,
71                                            gpointer        data);
72
73 struct _GtkAccelGroup
74 {
75   GObject             parent;
76   guint               GSEAL (lock_count);
77   GdkModifierType     GSEAL (modifier_mask);
78   GSList             *GSEAL (acceleratables);
79   guint               GSEAL (n_accels);
80   GtkAccelGroupEntry *GSEAL (priv_accels);
81 };
82
83 struct _GtkAccelGroupClass
84 {
85   GObjectClass parent_class;
86
87   void  (*accel_changed)        (GtkAccelGroup  *accel_group,
88                                  guint           keyval,
89                                  GdkModifierType modifier,
90                                  GClosure       *accel_closure);
91   
92   /* Padding for future expansion */
93   void (*_gtk_reserved1) (void);
94   void (*_gtk_reserved2) (void);
95   void (*_gtk_reserved3) (void);
96   void (*_gtk_reserved4) (void);
97 };
98
99 struct _GtkAccelKey
100 {
101   guint           accel_key;
102   GdkModifierType accel_mods;
103   guint           accel_flags : 16;
104 };
105
106
107 /* -- Accelerator Groups --- */
108 GType          gtk_accel_group_get_type           (void) G_GNUC_CONST;
109 GtkAccelGroup* gtk_accel_group_new                (void);
110 gboolean       gtk_accel_group_get_is_locked      (GtkAccelGroup  *accel_group);
111 GdkModifierType 
112                gtk_accel_group_get_modifier_mask  (GtkAccelGroup  *accel_group);
113 void           gtk_accel_group_lock               (GtkAccelGroup  *accel_group);
114 void           gtk_accel_group_unlock             (GtkAccelGroup  *accel_group);
115 void           gtk_accel_group_connect            (GtkAccelGroup  *accel_group,
116                                                    guint           accel_key,
117                                                    GdkModifierType accel_mods,
118                                                    GtkAccelFlags   accel_flags,
119                                                    GClosure       *closure);
120 void           gtk_accel_group_connect_by_path    (GtkAccelGroup  *accel_group,
121                                                    const gchar    *accel_path,
122                                                    GClosure       *closure);
123 gboolean       gtk_accel_group_disconnect         (GtkAccelGroup  *accel_group,
124                                                    GClosure       *closure);
125 gboolean       gtk_accel_group_disconnect_key     (GtkAccelGroup  *accel_group,
126                                                    guint           accel_key,
127                                                    GdkModifierType accel_mods);
128 gboolean       gtk_accel_group_activate           (GtkAccelGroup   *accel_group,
129                                                    GQuark          accel_quark,
130                                                    GObject        *acceleratable,
131                                                    guint           accel_key,
132                                                    GdkModifierType accel_mods);
133
134
135 /* --- GtkActivatable glue --- */
136 void            _gtk_accel_group_attach         (GtkAccelGroup  *accel_group,
137                                                  GObject        *object);
138 void            _gtk_accel_group_detach         (GtkAccelGroup  *accel_group,
139                                                  GObject        *object);
140 gboolean        gtk_accel_groups_activate       (GObject        *object,
141                                                  guint           accel_key,
142                                                  GdkModifierType accel_mods);
143 GSList*         gtk_accel_groups_from_object    (GObject        *object);
144 GtkAccelKey*    gtk_accel_group_find            (GtkAccelGroup        *accel_group,
145                                                  GtkAccelGroupFindFunc find_func,
146                                                  gpointer              data);
147 GtkAccelGroup*  gtk_accel_group_from_accel_closure (GClosure    *closure);
148
149
150 /* --- Accelerators--- */
151 gboolean gtk_accelerator_valid                (guint            keyval,
152                                                GdkModifierType  modifiers) G_GNUC_CONST;
153 void     gtk_accelerator_parse                (const gchar     *accelerator,
154                                                guint           *accelerator_key,
155                                                GdkModifierType *accelerator_mods);
156 gchar*   gtk_accelerator_name                 (guint            accelerator_key,
157                                                GdkModifierType  accelerator_mods);
158 gchar*   gtk_accelerator_get_label            (guint           accelerator_key,
159                                                GdkModifierType accelerator_mods);
160 void     gtk_accelerator_set_default_mod_mask (GdkModifierType  default_mod_mask);
161 guint    gtk_accelerator_get_default_mod_mask (void);
162
163
164 /* --- internal --- */
165 GtkAccelGroupEntry*     gtk_accel_group_query   (GtkAccelGroup  *accel_group,
166                                                  guint           accel_key,
167                                                  GdkModifierType accel_mods,
168                                                  guint          *n_entries);
169
170 void                 _gtk_accel_group_reconnect (GtkAccelGroup *accel_group,
171                                                  GQuark         accel_path_quark);
172
173 struct _GtkAccelGroupEntry
174 {
175   GtkAccelKey  key;
176   GClosure    *closure;
177   GQuark       accel_path_quark;
178 };
179
180
181 #ifndef GTK_DISABLE_DEPRECATED
182 #define gtk_accel_group_ref     g_object_ref
183 #define gtk_accel_group_unref   g_object_unref
184 #endif /* GTK_DISABLE_DEPRECATED */
185
186 G_END_DECLS
187
188
189 #endif /* __GTK_ACCEL_GROUP_H__ */