]> Pileus Git - ~andy/gtk/blob - gtk/gtkaccelgroup.h
Mark as const.
[~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 #ifndef __GTK_ACCEL_GROUP_H__
28 #define __GTK_ACCEL_GROUP_H__
29
30
31 #include <gdk/gdk.h>
32 #include <gtk/gtkenums.h>
33
34 G_BEGIN_DECLS
35
36
37 /* --- type macros --- */
38 #define GTK_TYPE_ACCEL_GROUP              (gtk_accel_group_get_type ())
39 #define GTK_ACCEL_GROUP(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GTK_TYPE_ACCEL_GROUP, GtkAccelGroup))
40 #define GTK_ACCEL_GROUP_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ACCEL_GROUP, GtkAccelGroupClass))
41 #define GTK_IS_ACCEL_GROUP(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GTK_TYPE_ACCEL_GROUP))
42 #define GTK_IS_ACCEL_GROUP_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ACCEL_GROUP))
43 #define GTK_ACCEL_GROUP_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ACCEL_GROUP, GtkAccelGroupClass))
44
45
46 /* --- accel flags --- */
47 typedef enum
48 {
49   GTK_ACCEL_VISIBLE        = 1 << 0,    /* display in GtkAccelLabel? */
50   GTK_ACCEL_LOCKED         = 1 << 1,    /* is it removable? */
51   GTK_ACCEL_MASK           = 0x07
52 } GtkAccelFlags;
53
54
55 /* --- typedefs & structures --- */
56 typedef struct _GtkAccelGroup      GtkAccelGroup;
57 typedef struct _GtkAccelGroupClass GtkAccelGroupClass;
58 typedef struct _GtkAccelKey        GtkAccelKey;
59 typedef struct _GtkAccelGroupEntry GtkAccelGroupEntry;
60 typedef gboolean (*GtkAccelGroupActivate) (GtkAccelGroup  *accel_group,
61                                            GObject        *acceleratable,
62                                            guint           keyval,
63                                            GdkModifierType modifier);
64
65 typedef gboolean (*GtkAccelGroupFindFunc) (GtkAccelKey    *key,
66                                            GClosure       *closure,
67                                            gpointer        data);
68
69 struct _GtkAccelGroup
70 {
71   GObject             parent;
72   guint               lock_count;
73   GdkModifierType     modifier_mask;
74   GSList             *acceleratables;
75   guint               n_accels;
76   GtkAccelGroupEntry *priv_accels;
77 };
78
79 struct _GtkAccelGroupClass
80 {
81   GObjectClass parent_class;
82
83   void  (*accel_changed)        (GtkAccelGroup  *accel_group,
84                                  guint           keyval,
85                                  GdkModifierType modifier,
86                                  GClosure       *accel_closure);
87   
88   /* Padding for future expansion */
89   void (*_gtk_reserved1) (void);
90   void (*_gtk_reserved2) (void);
91   void (*_gtk_reserved3) (void);
92   void (*_gtk_reserved4) (void);
93 };
94
95 struct _GtkAccelKey
96 {
97   guint           accel_key;
98   GdkModifierType accel_mods;
99   guint           accel_flags : 16;
100 };
101
102
103 /* -- Accelerator Groups --- */
104 GType          gtk_accel_group_get_type           (void) G_GNUC_CONST;
105 GtkAccelGroup* gtk_accel_group_new                (void);
106 void           gtk_accel_group_lock               (GtkAccelGroup  *accel_group);
107 void           gtk_accel_group_unlock             (GtkAccelGroup  *accel_group);
108 void           gtk_accel_group_connect            (GtkAccelGroup  *accel_group,
109                                                    guint           accel_key,
110                                                    GdkModifierType accel_mods,
111                                                    GtkAccelFlags   accel_flags,
112                                                    GClosure       *closure);
113 void           gtk_accel_group_connect_by_path    (GtkAccelGroup  *accel_group,
114                                                    const gchar    *accel_path,
115                                                    GClosure       *closure);
116 gboolean       gtk_accel_group_disconnect         (GtkAccelGroup  *accel_group,
117                                                    GClosure       *closure);
118 gboolean       gtk_accel_group_disconnect_key     (GtkAccelGroup  *accel_group,
119                                                    guint           accel_key,
120                                                    GdkModifierType accel_mods);
121 gboolean       gtk_accel_group_activate           (GtkAccelGroup   *accel_group,
122                                                    GQuark          accel_quark,
123                                                    GObject        *acceleratable,
124                                                    guint           accel_key,
125                                                    GdkModifierType accel_mods);
126
127
128 /* --- GtkActivatable glue --- */
129 void            _gtk_accel_group_attach         (GtkAccelGroup  *accel_group,
130                                                  GObject        *object);
131 void            _gtk_accel_group_detach         (GtkAccelGroup  *accel_group,
132                                                  GObject        *object);
133 gboolean        gtk_accel_groups_activate       (GObject        *object,
134                                                  guint           accel_key,
135                                                  GdkModifierType accel_mods);
136 GSList*         gtk_accel_groups_from_object    (GObject        *object);
137 GtkAccelKey*    gtk_accel_group_find            (GtkAccelGroup        *accel_group,
138                                                  GtkAccelGroupFindFunc find_func,
139                                                  gpointer              data);
140 GtkAccelGroup*  gtk_accel_group_from_accel_closure (GClosure    *closure);
141
142
143 /* --- Accelerators--- */
144 gboolean gtk_accelerator_valid                (guint            keyval,
145                                                GdkModifierType  modifiers) G_GNUC_CONST;
146 void     gtk_accelerator_parse                (const gchar     *accelerator,
147                                                guint           *accelerator_key,
148                                                GdkModifierType *accelerator_mods);
149 gchar*   gtk_accelerator_name                 (guint            accelerator_key,
150                                                GdkModifierType  accelerator_mods);
151 gchar*   gtk_accelerator_get_label            (guint           accelerator_key,
152                                                GdkModifierType accelerator_mods);
153 void     gtk_accelerator_set_default_mod_mask (GdkModifierType  default_mod_mask);
154 guint    gtk_accelerator_get_default_mod_mask (void);
155
156
157 /* --- internal --- */
158 GtkAccelGroupEntry*     gtk_accel_group_query   (GtkAccelGroup  *accel_group,
159                                                  guint           accel_key,
160                                                  GdkModifierType accel_mods,
161                                                  guint          *n_entries);
162
163 void                 _gtk_accel_group_reconnect (GtkAccelGroup *accel_group,
164                                                  GQuark         accel_path_quark);
165
166 struct _GtkAccelGroupEntry
167 {
168   GtkAccelKey  key;
169   GClosure    *closure;
170   GQuark       accel_path_quark;
171 };
172
173
174 #ifndef GTK_DISABLE_DEPRECATED
175 #define gtk_accel_group_ref     g_object_ref
176 #define gtk_accel_group_unref   g_object_unref
177 #endif /* GTK_DISABLE_DEPRECATED */
178
179 G_END_DECLS
180
181
182 #endif /* __GTK_ACCEL_GROUP_H__ */