]> Pileus Git - ~andy/gtk/blob - gtk/gtkaccelgroup.h
Merge branch 'master' into broadway2
[~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_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 _GtkAccelGroupPrivate      GtkAccelGroupPrivate;
63 typedef struct _GtkAccelKey               GtkAccelKey;
64 typedef struct _GtkAccelGroupEntry        GtkAccelGroupEntry;
65 typedef gboolean (*GtkAccelGroupActivate) (GtkAccelGroup  *accel_group,
66                                            GObject        *acceleratable,
67                                            guint           keyval,
68                                            GdkModifierType modifier);
69
70 /**
71  * GtkAccelGroupFindFunc:
72  * @key: 
73  * @closure: 
74  * @data: (closure):
75  * 
76  * Since: 2.2
77  */
78 typedef gboolean (*GtkAccelGroupFindFunc) (GtkAccelKey    *key,
79                                            GClosure       *closure,
80                                            gpointer        data);
81
82 /**
83  * GtkAccelGroup:
84  * 
85  * An object representing and maintaining a group of accelerators.
86  */
87 struct _GtkAccelGroup
88 {
89   GObject               parent;
90   GtkAccelGroupPrivate *priv;
91 };
92
93 struct _GtkAccelGroupClass
94 {
95   GObjectClass parent_class;
96
97   void  (*accel_changed)        (GtkAccelGroup  *accel_group,
98                                  guint           keyval,
99                                  GdkModifierType modifier,
100                                  GClosure       *accel_closure);
101   
102   /* Padding for future expansion */
103   void (*_gtk_reserved1) (void);
104   void (*_gtk_reserved2) (void);
105   void (*_gtk_reserved3) (void);
106   void (*_gtk_reserved4) (void);
107 };
108
109 struct _GtkAccelKey
110 {
111   guint           accel_key;
112   GdkModifierType accel_mods;
113   guint           accel_flags : 16;
114 };
115
116
117 /* -- Accelerator Groups --- */
118 GType          gtk_accel_group_get_type           (void) G_GNUC_CONST;
119 GtkAccelGroup* gtk_accel_group_new                (void);
120 gboolean       gtk_accel_group_get_is_locked      (GtkAccelGroup  *accel_group);
121 GdkModifierType 
122                gtk_accel_group_get_modifier_mask  (GtkAccelGroup  *accel_group);
123 void           gtk_accel_group_lock               (GtkAccelGroup  *accel_group);
124 void           gtk_accel_group_unlock             (GtkAccelGroup  *accel_group);
125 void           gtk_accel_group_connect            (GtkAccelGroup  *accel_group,
126                                                    guint           accel_key,
127                                                    GdkModifierType accel_mods,
128                                                    GtkAccelFlags   accel_flags,
129                                                    GClosure       *closure);
130 void           gtk_accel_group_connect_by_path    (GtkAccelGroup  *accel_group,
131                                                    const gchar    *accel_path,
132                                                    GClosure       *closure);
133 gboolean       gtk_accel_group_disconnect         (GtkAccelGroup  *accel_group,
134                                                    GClosure       *closure);
135 gboolean       gtk_accel_group_disconnect_key     (GtkAccelGroup  *accel_group,
136                                                    guint           accel_key,
137                                                    GdkModifierType accel_mods);
138 gboolean       gtk_accel_group_activate           (GtkAccelGroup   *accel_group,
139                                                    GQuark          accel_quark,
140                                                    GObject        *acceleratable,
141                                                    guint           accel_key,
142                                                    GdkModifierType accel_mods);
143
144
145 /* --- GtkActivatable glue --- */
146 void            _gtk_accel_group_attach         (GtkAccelGroup  *accel_group,
147                                                  GObject        *object);
148 void            _gtk_accel_group_detach         (GtkAccelGroup  *accel_group,
149                                                  GObject        *object);
150 gboolean        gtk_accel_groups_activate       (GObject        *object,
151                                                  guint           accel_key,
152                                                  GdkModifierType accel_mods);
153 GSList*         gtk_accel_groups_from_object    (GObject        *object);
154 GtkAccelKey*    gtk_accel_group_find            (GtkAccelGroup        *accel_group,
155                                                  GtkAccelGroupFindFunc find_func,
156                                                  gpointer              data);
157 GtkAccelGroup*  gtk_accel_group_from_accel_closure (GClosure    *closure);
158
159
160 /* --- Accelerators--- */
161 gboolean gtk_accelerator_valid                (guint            keyval,
162                                                GdkModifierType  modifiers) G_GNUC_CONST;
163 void     gtk_accelerator_parse                (const gchar     *accelerator,
164                                                guint           *accelerator_key,
165                                                GdkModifierType *accelerator_mods);
166 gchar*   gtk_accelerator_name                 (guint            accelerator_key,
167                                                GdkModifierType  accelerator_mods);
168 gchar*   gtk_accelerator_get_label            (guint           accelerator_key,
169                                                GdkModifierType accelerator_mods);
170 void     gtk_accelerator_set_default_mod_mask (GdkModifierType  default_mod_mask);
171 GdkModifierType
172          gtk_accelerator_get_default_mod_mask (void);
173
174
175 /* --- internal --- */
176 GtkAccelGroupEntry*     gtk_accel_group_query   (GtkAccelGroup  *accel_group,
177                                                  guint           accel_key,
178                                                  GdkModifierType accel_mods,
179                                                  guint          *n_entries);
180
181 void                 _gtk_accel_group_reconnect (GtkAccelGroup *accel_group,
182                                                  GQuark         accel_path_quark);
183 GSList*       _gtk_accel_group_get_accelerables (GtkAccelGroup *accel_group);
184
185 struct _GtkAccelGroupEntry
186 {
187   GtkAccelKey  key;
188   GClosure    *closure;
189   GQuark       accel_path_quark;
190 };
191
192
193 G_END_DECLS
194
195
196 #endif /* __GTK_ACCEL_GROUP_H__ */