]> Pileus Git - ~andy/gtk/blob - gtk/gtkactiongroup.h
stylecontext: Do invalidation on first resize container
[~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 this library. If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 /*
21  * Author: James Henstridge <james@daa.com.au>
22  *
23  * Modified by the GTK+ Team and others 2003.  See the AUTHORS
24  * file for a list of people on the GTK+ Team.  See the ChangeLog
25  * files for a list of changes.  These files are distributed with
26  * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
27  */
28
29 #ifndef __GTK_ACTION_GROUP_H__
30 #define __GTK_ACTION_GROUP_H__
31
32 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
33 #error "Only <gtk/gtk.h> can be included directly."
34 #endif
35
36 #include <gtk/gtkaction.h>
37 #include <gtk/gtkstock.h>
38
39 G_BEGIN_DECLS
40
41 #define GTK_TYPE_ACTION_GROUP              (gtk_action_group_get_type ())
42 #define GTK_ACTION_GROUP(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ACTION_GROUP, GtkActionGroup))
43 #define GTK_ACTION_GROUP_CLASS(vtable)     (G_TYPE_CHECK_CLASS_CAST ((vtable), GTK_TYPE_ACTION_GROUP, GtkActionGroupClass))
44 #define GTK_IS_ACTION_GROUP(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ACTION_GROUP))
45 #define GTK_IS_ACTION_GROUP_CLASS(vtable)  (G_TYPE_CHECK_CLASS_TYPE ((vtable), GTK_TYPE_ACTION_GROUP))
46 #define GTK_ACTION_GROUP_GET_CLASS(inst)   (G_TYPE_INSTANCE_GET_CLASS ((inst), GTK_TYPE_ACTION_GROUP, GtkActionGroupClass))
47
48 typedef struct _GtkActionGroup        GtkActionGroup;
49 typedef struct _GtkActionGroupPrivate GtkActionGroupPrivate;
50 typedef struct _GtkActionGroupClass   GtkActionGroupClass;
51 typedef struct _GtkActionEntry        GtkActionEntry;
52 typedef struct _GtkToggleActionEntry  GtkToggleActionEntry;
53 typedef struct _GtkRadioActionEntry   GtkRadioActionEntry;
54
55 struct _GtkActionGroup
56 {
57   GObject parent;
58
59   /*< private >*/
60   GtkActionGroupPrivate *priv;
61 };
62
63 struct _GtkActionGroupClass
64 {
65   GObjectClass parent_class;
66
67   GtkAction *(* get_action) (GtkActionGroup *action_group,
68                              const gchar    *action_name);
69
70   /* Padding for future expansion */
71   void (*_gtk_reserved1) (void);
72   void (*_gtk_reserved2) (void);
73   void (*_gtk_reserved3) (void);
74   void (*_gtk_reserved4) (void);
75 };
76
77 /**
78  * GtkActionEntry:
79  * @name: The name of the action.
80  * @stock_id: The stock id for the action, or the name of an icon from the
81  *  icon theme.
82  * @label: The label for the action. This field should typically be marked
83  *  for translation, see gtk_action_group_set_translation_domain(). If
84  *  @label is %NULL, the label of the stock item with id @stock_id is used.
85  * @accelerator: The accelerator for the action, in the format understood by
86  *  gtk_accelerator_parse().
87  * @tooltip: The tooltip for the action. This field should typically be
88  *  marked for translation, see gtk_action_group_set_translation_domain().
89  * @callback: The function to call when the action is activated.
90  *
91  * #GtkActionEntry structs are used with gtk_action_group_add_actions() to
92  * construct actions.
93  */
94 struct _GtkActionEntry 
95 {
96   const gchar     *name;
97   const gchar     *stock_id;
98   const gchar     *label;
99   const gchar     *accelerator;
100   const gchar     *tooltip;
101   GCallback  callback;
102 };
103
104 /**
105  * GtkToggleActionEntry:
106  * @name: The name of the action.
107  * @stock_id: The stock id for the action, or the name of an icon from the
108  *  icon theme.
109  * @label: The label for the action. This field should typically be marked
110  *  for translation, see gtk_action_group_set_translation_domain().
111  * @accelerator: The accelerator for the action, in the format understood by
112  *  gtk_accelerator_parse().
113  * @tooltip: The tooltip for the action. This field should typically be
114  *  marked for translation, see gtk_action_group_set_translation_domain().
115  * @callback: The function to call when the action is activated.
116  * @is_active: The initial state of the toggle action.
117  *
118  * #GtkToggleActionEntry structs are used with
119  * gtk_action_group_add_toggle_actions() to construct toggle actions.
120  */
121 struct _GtkToggleActionEntry 
122 {
123   const gchar     *name;
124   const gchar     *stock_id;
125   const gchar     *label;
126   const gchar     *accelerator;
127   const gchar     *tooltip;
128   GCallback  callback;
129   gboolean   is_active;
130 };
131
132 /**
133  * GtkRadioActionEntry:
134  * @name: The name of the action.
135  * @stock_id: The stock id for the action, or the name of an icon from the
136  *  icon theme.
137  * @label: The label for the action. This field should typically be marked
138  *  for translation, see gtk_action_group_set_translation_domain().
139  * @accelerator: The accelerator for the action, in the format understood by
140  *  gtk_accelerator_parse().
141  * @tooltip: The tooltip for the action. This field should typically be
142  *  marked for translation, see gtk_action_group_set_translation_domain().
143  * @value: The value to set on the radio action. See
144  *  gtk_radio_action_get_current_value().
145  *
146  * #GtkRadioActionEntry structs are used with
147  * gtk_action_group_add_radio_actions() to construct groups of radio actions.
148  */
149 struct _GtkRadioActionEntry 
150 {
151   const gchar *name;
152   const gchar *stock_id;
153   const gchar *label;
154   const gchar *accelerator;
155   const gchar *tooltip;
156   gint   value; 
157 };
158
159 GType           gtk_action_group_get_type                (void) G_GNUC_CONST;
160 GtkActionGroup *gtk_action_group_new                     (const gchar                *name);
161 const gchar    *gtk_action_group_get_name                (GtkActionGroup             *action_group);
162 gboolean        gtk_action_group_get_sensitive           (GtkActionGroup             *action_group);
163 void            gtk_action_group_set_sensitive           (GtkActionGroup             *action_group,
164                                                           gboolean                    sensitive);
165 gboolean        gtk_action_group_get_visible             (GtkActionGroup             *action_group);
166 void            gtk_action_group_set_visible             (GtkActionGroup             *action_group,
167                                                           gboolean                    visible);
168 GDK_AVAILABLE_IN_3_6
169 GtkAccelGroup  *gtk_action_group_get_accel_group         (GtkActionGroup             *action_group);
170 GDK_AVAILABLE_IN_3_6
171 void            gtk_action_group_set_accel_group         (GtkActionGroup             *action_group,
172                                                           GtkAccelGroup              *accel_group);
173
174 GtkAction      *gtk_action_group_get_action              (GtkActionGroup             *action_group,
175                                                           const gchar                *action_name);
176 GList          *gtk_action_group_list_actions            (GtkActionGroup             *action_group);
177 void            gtk_action_group_add_action              (GtkActionGroup             *action_group,
178                                                           GtkAction                  *action);
179 void            gtk_action_group_add_action_with_accel   (GtkActionGroup             *action_group,
180                                                           GtkAction                  *action,
181                                                           const gchar                *accelerator);
182 void            gtk_action_group_remove_action           (GtkActionGroup             *action_group,
183                                                           GtkAction                  *action);
184 void            gtk_action_group_add_actions             (GtkActionGroup             *action_group,
185                                                           const GtkActionEntry       *entries,
186                                                           guint                       n_entries,
187                                                           gpointer                    user_data);
188 void            gtk_action_group_add_toggle_actions      (GtkActionGroup             *action_group,
189                                                           const GtkToggleActionEntry *entries,
190                                                           guint                       n_entries,
191                                                           gpointer                    user_data);
192 void            gtk_action_group_add_radio_actions       (GtkActionGroup             *action_group,
193                                                           const GtkRadioActionEntry  *entries,
194                                                           guint                       n_entries,
195                                                           gint                        value,
196                                                           GCallback                   on_change,
197                                                           gpointer                    user_data);
198 void            gtk_action_group_add_actions_full        (GtkActionGroup             *action_group,
199                                                           const GtkActionEntry       *entries,
200                                                           guint                       n_entries,
201                                                           gpointer                    user_data,
202                                                           GDestroyNotify              destroy);
203 void            gtk_action_group_add_toggle_actions_full (GtkActionGroup             *action_group,
204                                                           const GtkToggleActionEntry *entries,
205                                                           guint                       n_entries,
206                                                           gpointer                    user_data,
207                                                           GDestroyNotify              destroy);
208 void            gtk_action_group_add_radio_actions_full  (GtkActionGroup             *action_group,
209                                                           const GtkRadioActionEntry  *entries,
210                                                           guint                       n_entries,
211                                                           gint                        value,
212                                                           GCallback                   on_change,
213                                                           gpointer                    user_data,
214                                                           GDestroyNotify              destroy);
215 void            gtk_action_group_set_translate_func      (GtkActionGroup             *action_group,
216                                                           GtkTranslateFunc            func,
217                                                           gpointer                    data,
218                                                           GDestroyNotify              notify);
219 void            gtk_action_group_set_translation_domain  (GtkActionGroup             *action_group,
220                                                           const gchar                *domain);
221 const gchar *   gtk_action_group_translate_string        (GtkActionGroup             *action_group,
222                                                           const gchar                *string);
223
224 /* Protected for use by GtkAction */
225 void _gtk_action_group_emit_connect_proxy    (GtkActionGroup *action_group,
226                                               GtkAction      *action,
227                                               GtkWidget      *proxy);
228 void _gtk_action_group_emit_disconnect_proxy (GtkActionGroup *action_group,
229                                               GtkAction      *action,
230                                               GtkWidget      *proxy);
231 void _gtk_action_group_emit_pre_activate     (GtkActionGroup *action_group,
232                                               GtkAction      *action);
233 void _gtk_action_group_emit_post_activate    (GtkActionGroup *action_group,
234                                               GtkAction      *action);
235
236 G_END_DECLS
237
238 #endif  /* __GTK_ACTION_GROUP_H__ */