]> Pileus Git - ~andy/gtk/blob - gtk/gtkactiongroup.h
gtkactiongroup: Unseal private pointer
[~andy/gtk] / gtk / gtkactiongroup.h
1 /*
2  * GTK - The GIMP Toolkit
3  * Copyright (C) 1998, 1999 Red Hat, Inc.
4  * All rights reserved.
5  *
6  * This Library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public License as
8  * published by the Free Software Foundation; either version 2 of the
9  * License, or (at your option) any later version.
10  *
11  * This Library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with the Gnome Library; see the file COPYING.LIB.  If not,
18  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21
22 /*
23  * Author: James Henstridge <james@daa.com.au>
24  *
25  * Modified by the GTK+ Team and others 2003.  See the AUTHORS
26  * file for a list of people on the GTK+ Team.  See the ChangeLog
27  * files for a list of changes.  These files are distributed with
28  * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
29  */
30
31 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
32 #error "Only <gtk/gtk.h> can be included directly."
33 #endif
34
35 #ifndef __GTK_ACTION_GROUP_H__
36 #define __GTK_ACTION_GROUP_H__
37
38 #include <gtk/gtkaction.h>
39 #include <gtk/gtktypeutils.h> /* for GtkTranslateFunc */
40
41 G_BEGIN_DECLS
42
43 #define GTK_TYPE_ACTION_GROUP              (gtk_action_group_get_type ())
44 #define GTK_ACTION_GROUP(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ACTION_GROUP, GtkActionGroup))
45 #define GTK_ACTION_GROUP_CLASS(vtable)     (G_TYPE_CHECK_CLASS_CAST ((vtable), GTK_TYPE_ACTION_GROUP, GtkActionGroupClass))
46 #define GTK_IS_ACTION_GROUP(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ACTION_GROUP))
47 #define GTK_IS_ACTION_GROUP_CLASS(vtable)  (G_TYPE_CHECK_CLASS_TYPE ((vtable), GTK_TYPE_ACTION_GROUP))
48 #define GTK_ACTION_GROUP_GET_CLASS(inst)   (G_TYPE_INSTANCE_GET_CLASS ((inst), GTK_TYPE_ACTION_GROUP, GtkActionGroupClass))
49
50 typedef struct _GtkActionGroup        GtkActionGroup;
51 typedef struct _GtkActionGroupPrivate GtkActionGroupPrivate;
52 typedef struct _GtkActionGroupClass   GtkActionGroupClass;
53 typedef struct _GtkActionEntry        GtkActionEntry;
54 typedef struct _GtkToggleActionEntry  GtkToggleActionEntry;
55 typedef struct _GtkRadioActionEntry   GtkRadioActionEntry;
56
57 struct _GtkActionGroup
58 {
59   GObject parent;
60
61   /*< private >*/
62   GtkActionGroupPrivate *priv;
63 };
64
65 struct _GtkActionGroupClass
66 {
67   GObjectClass parent_class;
68
69   GtkAction *(* get_action) (GtkActionGroup *action_group,
70                              const gchar    *action_name);
71
72   /* Padding for future expansion */
73   void (*_gtk_reserved1) (void);
74   void (*_gtk_reserved2) (void);
75   void (*_gtk_reserved3) (void);
76   void (*_gtk_reserved4) (void);
77 };
78
79 /**
80  * GtkActionEntry:
81  * @name: The name of the action.
82  * @stock_id: The stock id for the action, or the name of an icon from the
83  *  icon theme.
84  * @label: The label for the action. This field should typically be marked
85  *  for translation, see gtk_action_group_set_translation_domain(). If
86  *  @label is %NULL, the label of the stock item with id @stock_id is used.
87  * @accelerator: The accelerator for the action, in the format understood by
88  *  gtk_accelerator_parse().
89  * @tooltip: The tooltip for the action. This field should typically be
90  *  marked for translation, see gtk_action_group_set_translation_domain().
91  * @callback: The function to call when the action is activated.
92  *
93  * #GtkActionEntry structs are used with gtk_action_group_add_actions() to
94  * construct actions.
95  */
96 struct _GtkActionEntry 
97 {
98   const gchar     *name;
99   const gchar     *stock_id;
100   const gchar     *label;
101   const gchar     *accelerator;
102   const gchar     *tooltip;
103   GCallback  callback;
104 };
105
106 /**
107  * GtkToggleActionEntry:
108  * @name: The name of the action.
109  * @stock_id: The stock id for the action, or the name of an icon from the
110  *  icon theme.
111  * @label: The label for the action. This field should typically be marked
112  *  for translation, see gtk_action_group_set_translation_domain().
113  * @accelerator: The accelerator for the action, in the format understood by
114  *  gtk_accelerator_parse().
115  * @tooltip: The tooltip for the action. This field should typically be
116  *  marked for translation, see gtk_action_group_set_translation_domain().
117  * @callback: The function to call when the action is activated.
118  * @is_active: The initial state of the toggle action.
119  *
120  * #GtkToggleActionEntry structs are used with
121  * gtk_action_group_add_toggle_actions() to construct toggle actions.
122  */
123 struct _GtkToggleActionEntry 
124 {
125   const gchar     *name;
126   const gchar     *stock_id;
127   const gchar     *label;
128   const gchar     *accelerator;
129   const gchar     *tooltip;
130   GCallback  callback;
131   gboolean   is_active;
132 };
133
134 /**
135  * GtkRadioActionEntry:
136  * @name: The name of the action.
137  * @stock_id: The stock id for the action, or the name of an icon from the
138  *  icon theme.
139  * @label: The label for the action. This field should typically be marked
140  *  for translation, see gtk_action_group_set_translation_domain().
141  * @accelerator: The accelerator for the action, in the format understood by
142  *  gtk_accelerator_parse().
143  * @tooltip: The tooltip for the action. This field should typically be
144  *  marked for translation, see gtk_action_group_set_translation_domain().
145  * @value: The value to set on the radio action. See
146  *  gtk_radio_action_get_current_value().
147  *
148  * #GtkRadioActionEntry structs are used with
149  * gtk_action_group_add_radio_actions() to construct groups of radio actions.
150  */
151 struct _GtkRadioActionEntry 
152 {
153   const gchar *name;
154   const gchar *stock_id;
155   const gchar *label;
156   const gchar *accelerator;
157   const gchar *tooltip;
158   gint   value; 
159 };
160
161 GType           gtk_action_group_get_type                (void) G_GNUC_CONST;
162 GtkActionGroup *gtk_action_group_new                     (const gchar                *name);
163 G_CONST_RETURN gchar *gtk_action_group_get_name          (GtkActionGroup             *action_group);
164 gboolean        gtk_action_group_get_sensitive           (GtkActionGroup             *action_group);
165 void            gtk_action_group_set_sensitive           (GtkActionGroup             *action_group,
166                                                           gboolean                    sensitive);
167 gboolean        gtk_action_group_get_visible             (GtkActionGroup             *action_group);
168 void            gtk_action_group_set_visible             (GtkActionGroup             *action_group,
169                                                           gboolean                    visible);
170 GtkAction      *gtk_action_group_get_action              (GtkActionGroup             *action_group,
171                                                           const gchar                *action_name);
172 GList          *gtk_action_group_list_actions            (GtkActionGroup             *action_group);
173 void            gtk_action_group_add_action              (GtkActionGroup             *action_group,
174                                                           GtkAction                  *action);
175 void            gtk_action_group_add_action_with_accel   (GtkActionGroup             *action_group,
176                                                           GtkAction                  *action,
177                                                           const gchar                *accelerator);
178 void            gtk_action_group_remove_action           (GtkActionGroup             *action_group,
179                                                           GtkAction                  *action);
180 void            gtk_action_group_add_actions             (GtkActionGroup             *action_group,
181                                                           const GtkActionEntry       *entries,
182                                                           guint                       n_entries,
183                                                           gpointer                    user_data);
184 void            gtk_action_group_add_toggle_actions      (GtkActionGroup             *action_group,
185                                                           const GtkToggleActionEntry *entries,
186                                                           guint                       n_entries,
187                                                           gpointer                    user_data);
188 void            gtk_action_group_add_radio_actions       (GtkActionGroup             *action_group,
189                                                           const GtkRadioActionEntry  *entries,
190                                                           guint                       n_entries,
191                                                           gint                        value,
192                                                           GCallback                   on_change,
193                                                           gpointer                    user_data);
194 void            gtk_action_group_add_actions_full        (GtkActionGroup             *action_group,
195                                                           const GtkActionEntry       *entries,
196                                                           guint                       n_entries,
197                                                           gpointer                    user_data,
198                                                           GDestroyNotify              destroy);
199 void            gtk_action_group_add_toggle_actions_full (GtkActionGroup             *action_group,
200                                                           const GtkToggleActionEntry *entries,
201                                                           guint                       n_entries,
202                                                           gpointer                    user_data,
203                                                           GDestroyNotify              destroy);
204 void            gtk_action_group_add_radio_actions_full  (GtkActionGroup             *action_group,
205                                                           const GtkRadioActionEntry  *entries,
206                                                           guint                       n_entries,
207                                                           gint                        value,
208                                                           GCallback                   on_change,
209                                                           gpointer                    user_data,
210                                                           GDestroyNotify              destroy);
211 void            gtk_action_group_set_translate_func      (GtkActionGroup             *action_group,
212                                                           GtkTranslateFunc            func,
213                                                           gpointer                    data,
214                                                           GDestroyNotify              notify);
215 void            gtk_action_group_set_translation_domain  (GtkActionGroup             *action_group,
216                                                           const gchar                *domain);
217 G_CONST_RETURN gchar *gtk_action_group_translate_string  (GtkActionGroup             *action_group,
218                                                           const gchar                *string);
219
220 /* Protected for use by GtkAction */
221 void _gtk_action_group_emit_connect_proxy    (GtkActionGroup *action_group,
222                                               GtkAction      *action,
223                                               GtkWidget      *proxy);
224 void _gtk_action_group_emit_disconnect_proxy (GtkActionGroup *action_group,
225                                               GtkAction      *action,
226                                               GtkWidget      *proxy);
227 void _gtk_action_group_emit_pre_activate     (GtkActionGroup *action_group,
228                                               GtkAction      *action);
229 void _gtk_action_group_emit_post_activate    (GtkActionGroup *action_group,
230                                               GtkAction      *action);
231
232 G_END_DECLS
233
234 #endif  /* __GTK_ACTION_GROUP_H__ */