]> Pileus Git - ~andy/gtk/blob - gtk/gtkaccelgroup.h
Added notice to look in AUTHORS and ChangeLog files for a list of changes.
[~andy/gtk] / gtk / gtkaccelgroup.h
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * GtkAccelGroup: Accelerator manager for GtkObjects.
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 Library 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  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 /*
24  * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
25  * file for a list of people on the GTK+ Team.  See the ChangeLog
26  * files for a list of changes.  These files are distributed with
27  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
28  */
29
30 #ifndef __GTK_ACCEL_GROUP_H__
31 #define __GTK_ACCEL_GROUP_H__
32
33
34 #include <gdk/gdk.h>
35 #include <gtk/gtkobject.h>
36 #include <gtk/gtkenums.h>
37
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif /* __cplusplus */
42
43
44 typedef struct _GtkAccelGroup   GtkAccelGroup;
45 typedef struct _GtkAccelEntry   GtkAccelEntry;
46
47 typedef enum
48 {
49   /* should the accelerator appear in
50    * the widget's display?
51    */
52   GTK_ACCEL_VISIBLE        = 1 << 0,
53   /* should the signal associated with
54    * this accelerator be also visible?
55    */
56   GTK_ACCEL_SIGNAL_VISIBLE = 1 << 1,
57   /* may the accelerator be removed
58    * again?
59    */
60   GTK_ACCEL_LOCKED         = 1 << 2,
61   GTK_ACCEL_MASK           = 0x07
62 } GtkAccelFlags;
63
64 struct _GtkAccelGroup
65 {
66   guint           ref_count;
67   guint           lock_count;
68   GdkModifierType modifier_mask;
69   GSList         *attach_objects;
70 };
71
72 struct _GtkAccelEntry
73 {
74   /* key portion
75    */
76   GtkAccelGroup         *accel_group;
77   guint                  accelerator_key;
78   GdkModifierType        accelerator_mods;
79   
80   GtkAccelFlags          accel_flags;
81   GtkObject             *object;
82   guint                  signal_id;
83 };
84
85
86 /* Accelerator Groups
87  */
88 GtkAccelGroup*  gtk_accel_group_new             (void);
89 GtkAccelGroup*  gtk_accel_group_get_default     (void);
90 GtkAccelGroup*  gtk_accel_group_ref             (GtkAccelGroup  *accel_group);
91 void            gtk_accel_group_unref           (GtkAccelGroup  *accel_group);
92 gboolean        gtk_accel_group_activate        (GtkAccelGroup  *accel_group,
93                                                  guint           accel_key,
94                                                  GdkModifierType accel_mods);
95 gboolean        gtk_accel_groups_activate       (GtkObject      *object,
96                                                  guint           accel_key,
97                                                  GdkModifierType accel_mods);
98 void            gtk_accel_group_attach          (GtkAccelGroup  *accel_group,
99                                                  GtkObject      *object);
100 void            gtk_accel_group_detach          (GtkAccelGroup  *accel_group,
101                                                  GtkObject      *object);
102 void            gtk_accel_group_lock            (GtkAccelGroup  *accel_group);
103 void            gtk_accel_group_unlock          (GtkAccelGroup  *accel_group);
104
105 /* Accelerator Group Entries
106  */
107 GtkAccelEntry*  gtk_accel_group_get_entry       (GtkAccelGroup  *accel_group,
108                                                  guint           accel_key,
109                                                  GdkModifierType accel_mods);
110 void            gtk_accel_group_lock_entry      (GtkAccelGroup  *accel_group,
111                                                  guint           accel_key,
112                                                  GdkModifierType accel_mods);
113 void            gtk_accel_group_unlock_entry    (GtkAccelGroup  *accel_group,
114                                                  guint           accel_key,
115                                                  GdkModifierType accel_mods);
116 void            gtk_accel_group_add             (GtkAccelGroup  *accel_group,
117                                                  guint           accel_key,
118                                                  GdkModifierType accel_mods,
119                                                  GtkAccelFlags   accel_flags,
120                                                  GtkObject      *object,
121                                                  const gchar    *accel_signal);
122 void            gtk_accel_group_remove          (GtkAccelGroup  *accel_group,
123                                                  guint           accel_key,
124                                                  GdkModifierType accel_mods,
125                                                  GtkObject      *object);
126
127 /* Accelerator Signals
128  */
129 void            gtk_accel_group_handle_add      (GtkObject      *object,
130                                                  guint           accel_signal_id,
131                                                  GtkAccelGroup  *accel_group,
132                                                  guint           accel_key,
133                                                  GdkModifierType accel_mods,
134                                                  GtkAccelFlags   accel_flags);
135 void            gtk_accel_group_handle_remove   (GtkObject      *object,
136                                                  GtkAccelGroup  *accel_group,
137                                                  guint           accel_key,
138                                                  GdkModifierType accel_mods);
139 guint           gtk_accel_group_create_add      (GtkType         class_type,
140                                                  GtkSignalRunType signal_flags,
141                                                  guint           handler_offset);
142 guint           gtk_accel_group_create_remove   (GtkType         class_type,
143                                                  GtkSignalRunType signal_flags,
144                                                  guint           handler_offset);
145 void            gtk_accel_group_marshal_add     (GtkObject      *object,
146                                                  GtkSignalFunc   func,
147                                                  gpointer        func_data,
148                                                  GtkArg         *args);
149 void            gtk_accel_group_marshal_remove  (GtkObject      *object,
150                                                  GtkSignalFunc   func,
151                                                  gpointer        func_data,
152                                                  GtkArg         *args);
153
154 /* Miscellaneous
155  */
156 GSList* gtk_accel_groups_from_object            (GtkObject      *object);
157 GSList* gtk_accel_group_entries_from_object     (GtkObject      *object);
158
159
160 /* Accelerators
161  */
162 gboolean gtk_accelerator_valid                (guint            keyval,
163                                                GdkModifierType  modifiers);
164 void     gtk_accelerator_parse                (const gchar     *accelerator,
165                                                guint           *accelerator_key,
166                                                GdkModifierType *accelerator_mods);
167 gchar*   gtk_accelerator_name                 (guint            accelerator_key,
168                                                GdkModifierType  accelerator_mods);
169 void     gtk_accelerator_set_default_mod_mask (GdkModifierType  default_mod_mask);
170 guint    gtk_accelerator_get_default_mod_mask (void);
171
172
173
174 #ifdef __cplusplus
175 }
176 #endif /* __cplusplus */
177
178
179 #endif /* __GTK_ACCEL_GROUP_H__ */