1 /* GIMP - The GNU Image Manipulation Program
2  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3  *
4  * gimpactiongroup.h
5  * Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program 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
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef __GIMP_ACTION_GROUP_H__
22 #define __GIMP_ACTION_GROUP_H__
23 
24 
25 #define GIMP_TYPE_ACTION_GROUP              (gimp_action_group_get_type ())
26 #define GIMP_ACTION_GROUP(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_ACTION_GROUP, GimpActionGroup))
27 #define GIMP_ACTION_GROUP_CLASS(vtable)     (G_TYPE_CHECK_CLASS_CAST ((vtable), GIMP_TYPE_ACTION_GROUP, GimpActionGroupClass))
28 #define GIMP_IS_ACTION_GROUP(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_ACTION_GROUP))
29 #define GIMP_IS_ACTION_GROUP_CLASS(vtable)  (G_TYPE_CHECK_CLASS_TYPE ((vtable), GIMP_TYPE_ACTION_GROUP))
30 #define GIMP_ACTION_GROUP_GET_CLASS(inst)   (G_TYPE_INSTANCE_GET_CLASS ((inst), GIMP_TYPE_ACTION_GROUP, GimpActionGroupClass))
31 
32 
33 typedef struct _GimpActionGroupClass GimpActionGroupClass;
34 
35 struct _GimpActionGroup
36 {
37   GtkActionGroup             parent_instance;
38 
39   Gimp                      *gimp;
40   gchar                     *label;
41   gchar                     *icon_name;
42 
43   gpointer                   user_data;
44 
45   GimpActionGroupUpdateFunc  update_func;
46 };
47 
48 struct _GimpActionGroupClass
49 {
50   GtkActionGroupClass  parent_class;
51 
52   GHashTable          *groups;
53 
54   /* signals */
55   void (* action_added) (GimpActionGroup *group,
56                          GimpAction      *action);
57 };
58 
59 
60 typedef void (* GimpActionCallback) (GimpAction *action,
61                                      GVariant   *value,
62                                      gpointer    data);
63 
64 struct _GimpActionEntry
65 {
66   const gchar        *name;
67   const gchar        *icon_name;
68   const gchar        *label;
69   const gchar        *accelerator;
70   const gchar        *tooltip;
71   GimpActionCallback  callback;
72 
73   const gchar        *help_id;
74 };
75 
76 struct _GimpToggleActionEntry
77 {
78   const gchar        *name;
79   const gchar        *icon_name;
80   const gchar        *label;
81   const gchar        *accelerator;
82   const gchar        *tooltip;
83   GimpActionCallback  callback;
84   gboolean            is_active;
85 
86   const gchar *help_id;
87 };
88 
89 struct _GimpRadioActionEntry
90 {
91   const gchar *name;
92   const gchar *icon_name;
93   const gchar *label;
94   const gchar *accelerator;
95   const gchar *tooltip;
96   gint         value;
97 
98   const gchar *help_id;
99 };
100 
101 struct _GimpEnumActionEntry
102 {
103   const gchar *name;
104   const gchar *icon_name;
105   const gchar *label;
106   const gchar *accelerator;
107   const gchar *tooltip;
108   gint         value;
109   gboolean     value_variable;
110 
111   const gchar *help_id;
112 };
113 
114 struct _GimpStringActionEntry
115 {
116   const gchar *name;
117   const gchar *icon_name;
118   const gchar *label;
119   const gchar *accelerator;
120   const gchar *tooltip;
121   const gchar *value;
122 
123   const gchar *help_id;
124 };
125 
126 struct _GimpProcedureActionEntry
127 {
128   const gchar   *name;
129   const gchar   *icon_name;
130   const gchar   *label;
131   const gchar   *accelerator;
132   const gchar   *tooltip;
133   GimpProcedure *procedure;
134 
135   const gchar   *help_id;
136 };
137 
138 
139 GType            gimp_action_group_get_type   (void) G_GNUC_CONST;
140 
141 GimpActionGroup *gimp_action_group_new        (Gimp                  *gimp,
142                                                const gchar           *name,
143                                                const gchar           *label,
144                                                const gchar           *icon_name,
145                                                gpointer               user_data,
146                                                GimpActionGroupUpdateFunc update_func);
147 
148 GList *gimp_action_groups_from_name           (const gchar           *name);
149 
150 const gchar * gimp_action_group_get_name       (GimpActionGroup       *group);
151 
152 void  gimp_action_group_add_action            (GimpActionGroup *action_group,
153                                                GimpAction      *action);
154 void  gimp_action_group_add_action_with_accel (GimpActionGroup *action_group,
155                                                GimpAction      *action,
156                                                const gchar     *accelerator);
157 void  gimp_action_group_remove_action         (GimpActionGroup *action_group,
158                                                GimpAction      *action);
159 
160 GimpAction  * gimp_action_group_get_action     (GimpActionGroup       *group,
161                                                 const gchar           *action_name);
162 GList       * gimp_action_group_list_actions   (GimpActionGroup       *group);
163 
164 void   gimp_action_group_update               (GimpActionGroup       *group,
165                                                gpointer               update_data);
166 
167 void   gimp_action_group_add_actions          (GimpActionGroup             *group,
168                                                const gchar                 *msg_context,
169                                                const GimpActionEntry       *entries,
170                                                guint                        n_entries);
171 void   gimp_action_group_add_toggle_actions   (GimpActionGroup             *group,
172                                                const gchar                 *msg_context,
173                                                const GimpToggleActionEntry *entries,
174                                                guint                        n_entries);
175 GSList *gimp_action_group_add_radio_actions   (GimpActionGroup             *group,
176                                                const gchar                 *msg_context,
177                                                const GimpRadioActionEntry  *entries,
178                                                guint                        n_entries,
179                                                GSList                      *radio_group,
180                                                gint                         value,
181                                                GimpActionCallback           callback);
182 void   gimp_action_group_add_enum_actions     (GimpActionGroup             *group,
183                                                const gchar                 *msg_context,
184                                                const GimpEnumActionEntry   *entries,
185                                                guint                        n_entries,
186                                                GimpActionCallback           callback);
187 void   gimp_action_group_add_string_actions   (GimpActionGroup             *group,
188                                                const gchar                 *msg_context,
189                                                const GimpStringActionEntry *entries,
190                                                guint                        n_entries,
191                                                GimpActionCallback           callback);
192 void   gimp_action_group_add_procedure_actions(GimpActionGroup             *group,
193                                                const GimpProcedureActionEntry *entries,
194                                                guint                        n_entries,
195                                                GimpActionCallback           callback);
196 
197 void   gimp_action_group_remove_action_and_accel (GimpActionGroup          *group,
198                                                   GimpAction               *action);
199 
200 void          gimp_action_group_activate_action       (GimpActionGroup *group,
201                                                        const gchar     *action_name);
202 void          gimp_action_group_set_action_visible    (GimpActionGroup *group,
203                                                        const gchar     *action_name,
204                                                        gboolean         visible);
205 void          gimp_action_group_set_action_sensitive  (GimpActionGroup *group,
206                                                        const gchar     *action_name,
207                                                        gboolean         sensitive);
208 void          gimp_action_group_set_action_active     (GimpActionGroup *group,
209                                                        const gchar     *action_name,
210                                                        gboolean         active);
211 void          gimp_action_group_set_action_label      (GimpActionGroup *group,
212                                                        const gchar     *action_name,
213                                                        const gchar     *label);
214 void          gimp_action_group_set_action_pixbuf     (GimpActionGroup *group,
215                                                        const gchar     *action_name,
216                                                        GdkPixbuf       *pixbuf);
217 void          gimp_action_group_set_action_tooltip    (GimpActionGroup *group,
218                                                        const gchar     *action_name,
219                                                        const gchar     *tooltip);
220 const gchar * gimp_action_group_get_action_tooltip    (GimpActionGroup *group,
221                                                        const gchar     *action_name);
222 void          gimp_action_group_set_action_context    (GimpActionGroup *group,
223                                                        const gchar     *action_name,
224                                                        GimpContext     *context);
225 void          gimp_action_group_set_action_color      (GimpActionGroup *group,
226                                                        const gchar     *action_name,
227                                                        const GimpRGB   *color,
228                                                        gboolean         set_label);
229 void          gimp_action_group_set_action_viewable   (GimpActionGroup *group,
230                                                        const gchar     *action_name,
231                                                        GimpViewable    *viewable);
232 void          gimp_action_group_set_action_hide_empty (GimpActionGroup *group,
233                                                        const gchar     *action_name,
234                                                        gboolean         hide_empty);
235 void   gimp_action_group_set_action_always_show_image (GimpActionGroup *group,
236                                                        const gchar     *action_name,
237                                                        gboolean         always_show_image);
238 
239 
240 
241 #endif  /* __GIMP_ACTION_GROUP_H__ */
242