]> Pileus Git - ~andy/gtk/blob - gtk/gtkactiongroup.c
add visible_horizontal, visible_vertical. (gtk_action_class_init) : here.
[~andy/gtk] / gtk / gtkactiongroup.c
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 #include <config.h>
32
33 #include "gtkactiongroup.h"
34 #include "gtkstock.h"
35 #include "gtktoggleaction.h"
36 #include "gtkradioaction.h"
37 #include "gtkaccelmap.h"
38 #include "gtkintl.h"
39
40 #define GTK_ACTION_GROUP_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ACTION_GROUP, GtkActionGroupPrivate))
41
42 struct _GtkActionGroupPrivate 
43 {
44   gchar           *name;
45   GHashTable      *actions;
46
47   GtkTranslateFunc translate_func;
48   gpointer         translate_data;
49   GtkDestroyNotify translate_notify;   
50 };
51
52 enum 
53 {
54   PROP_0,
55   PROP_NAME
56 };
57
58 static void       gtk_action_group_init            (GtkActionGroup      *self);
59 static void       gtk_action_group_class_init      (GtkActionGroupClass *class);
60 static void       gtk_action_group_finalize        (GObject             *object);
61 static void       gtk_action_group_set_property    (GObject             *object,
62                                                     guint                prop_id,
63                                                     const GValue        *value,
64                                                     GParamSpec          *pspec);
65 static void       gtk_action_group_get_property    (GObject             *object,
66                                                     guint                prop_id,
67                                                     GValue              *value,
68                                                     GParamSpec          *pspec);
69 static GtkAction *gtk_action_group_real_get_action (GtkActionGroup      *self,
70                                                     const gchar         *name);
71
72
73 GType
74 gtk_action_group_get_type (void)
75 {
76   static GType type = 0;
77
78   if (!type)
79     {
80       static const GTypeInfo type_info =
81       {
82         sizeof (GtkActionGroupClass),
83         NULL,           /* base_init */
84         NULL,           /* base_finalize */
85         (GClassInitFunc) gtk_action_group_class_init,
86         NULL,           /* class_finalize */
87         NULL,           /* class_data */
88         sizeof (GtkActionGroup),
89         0, /* n_preallocs */
90         (GInstanceInitFunc) gtk_action_group_init,
91       };
92
93       type = g_type_register_static (G_TYPE_OBJECT, "GtkActionGroup",
94                                      &type_info, 0);
95     }
96
97   return type;
98 }
99
100 static GObjectClass *parent_class = NULL;
101
102 static void
103 gtk_action_group_class_init (GtkActionGroupClass *klass)
104 {
105   GObjectClass *gobject_class;
106
107   gobject_class = G_OBJECT_CLASS (klass);
108   parent_class = g_type_class_peek_parent (klass);
109
110   gobject_class->finalize = gtk_action_group_finalize;
111   gobject_class->set_property = gtk_action_group_set_property;
112   gobject_class->get_property = gtk_action_group_get_property;
113   klass->get_action = gtk_action_group_real_get_action;
114
115   g_object_class_install_property (gobject_class,
116                                    PROP_NAME,
117                                    g_param_spec_string ("name",
118                                                         _("Name"),
119                                                         _("A name for the action group."),
120                                                         NULL,
121                                                         G_PARAM_READWRITE |
122                                                         G_PARAM_CONSTRUCT_ONLY));
123   g_type_class_add_private (gobject_class, sizeof (GtkActionGroupPrivate));
124 }
125
126 static void
127 gtk_action_group_init (GtkActionGroup *self)
128 {
129   self->private_data = GTK_ACTION_GROUP_GET_PRIVATE (self);
130   self->private_data->name = NULL;
131   self->private_data->actions = g_hash_table_new_full (g_str_hash, g_str_equal,
132                                                        (GDestroyNotify) g_free,
133                                                        (GDestroyNotify) g_object_unref);
134   self->private_data->translate_func = NULL;
135   self->private_data->translate_data = NULL;
136   self->private_data->translate_notify = NULL;
137 }
138
139 /**
140  * gtk_action_group_new:
141  * @name: the name of the action group.
142  *
143  * Creates a new #GtkActionGroup object. The name of the action group
144  * is used when associating <link linkend="Action-Accel">keybindings</link> 
145  * with the actions.
146  *
147  * Returns: the new #GtkActionGroup
148  *
149  * Since: 2.4
150  */
151 GtkActionGroup *
152 gtk_action_group_new (const gchar *name)
153 {
154   GtkActionGroup *self;
155
156   self = g_object_new (GTK_TYPE_ACTION_GROUP, NULL);
157   self->private_data->name = g_strdup (name);
158
159   return self;
160 }
161
162 static void
163 gtk_action_group_finalize (GObject *object)
164 {
165   GtkActionGroup *self;
166
167   self = GTK_ACTION_GROUP (object);
168
169   g_free (self->private_data->name);
170   self->private_data->name = NULL;
171
172   g_hash_table_destroy (self->private_data->actions);
173   self->private_data->actions = NULL;
174
175   if (self->private_data->translate_notify)
176     self->private_data->translate_notify (self->private_data->translate_data);
177
178   if (parent_class->finalize)
179     (* parent_class->finalize) (object);
180 }
181
182 static void
183 gtk_action_group_set_property (GObject         *object,
184                                guint            prop_id,
185                                const GValue    *value,
186                                GParamSpec      *pspec)
187 {
188   GtkActionGroup *self;
189   gchar *tmp;
190   
191   self = GTK_ACTION_GROUP (object);
192
193   switch (prop_id)
194     {
195     case PROP_NAME:
196       tmp = self->private_data->name;
197       self->private_data->name = g_value_dup_string (value);
198       g_free (tmp);
199       break;
200     default:
201       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
202       break;
203     }
204 }
205
206 static void
207 gtk_action_group_get_property (GObject    *object,
208                                guint       prop_id,
209                                GValue     *value,
210                                GParamSpec *pspec)
211 {
212   GtkActionGroup *self;
213   
214   self = GTK_ACTION_GROUP (object);
215
216   switch (prop_id)
217     {
218     case PROP_NAME:
219       g_value_set_string (value, self->private_data->name);
220       break;
221     default:
222       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
223       break;
224     }
225 }
226
227 static GtkAction *
228 gtk_action_group_real_get_action (GtkActionGroup *self,
229                                   const gchar    *action_name)
230 {
231   return g_hash_table_lookup (self->private_data->actions, action_name);
232 }
233
234 /**
235  * gtk_action_group_get_name:
236  * @action_group: the action group
237  *
238  * Gets the name of the action group.
239  *
240  * Returns: the name of the action group.
241  * 
242  * Since: 2.4
243  */
244 const gchar *
245 gtk_action_group_get_name (GtkActionGroup *action_group)
246 {
247   g_return_val_if_fail (GTK_IS_ACTION_GROUP (action_group), NULL);
248
249   return action_group->private_data->name;
250 }
251
252 /**
253  * gtk_action_group_get_action:
254  * @action_group: the action group
255  * @action_name: the name of the action
256  *
257  * Looks up an action in the action group by name.
258  *
259  * Returns: the action, or %NULL if no action by that name exists
260  *
261  * Since: 2.4
262  */
263 GtkAction *
264 gtk_action_group_get_action (GtkActionGroup *action_group,
265                              const gchar    *action_name)
266 {
267   g_return_val_if_fail (GTK_IS_ACTION_GROUP (action_group), NULL);
268   g_return_val_if_fail (GTK_ACTION_GROUP_GET_CLASS (action_group)->get_action != NULL, NULL);
269
270   return (* GTK_ACTION_GROUP_GET_CLASS (action_group)->get_action)
271     (action_group, action_name);
272 }
273
274 /**
275  * gtk_action_group_add_action:
276  * @action_group: the action group
277  * @action: an action
278  *
279  * Adds an action object to the action group. 
280  *
281  * Since: 2.4
282  */
283 void
284 gtk_action_group_add_action (GtkActionGroup *action_group,
285                              GtkAction      *action)
286 {
287   g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
288   g_return_if_fail (GTK_IS_ACTION (action));
289   g_return_if_fail (gtk_action_get_name (action) != NULL);
290
291   g_hash_table_insert (action_group->private_data->actions, 
292                        g_strdup (gtk_action_get_name (action)),
293                        g_object_ref (action));
294 }
295
296 /**
297  * gtk_action_group_add_action_with_accel:
298  * @action_group: the action group (#GtkActionGroup)
299  * @action : the action to add (#GtkAction)
300  * @name :
301  * @accelerator :
302  * @stock_id :
303  *
304  * Adds an action object to the action group and sets up the accelerator.
305  *
306  * If @accelerator is NULL, attempt to use the accelerator associated with
307  * @stock_id.
308  *
309  * accel paths are set to 
310  * <literal>&lt;Actions&gt;/<replaceable>group-name</replaceable>/<replaceable>action-name</replaceable></literal>.  
311  * 
312  * Since: 2.4
313  */
314 void
315 gtk_action_group_add_action_with_accel (GtkActionGroup *action_group,
316                                         GtkAction *action,
317                                         const char *name,
318                                         const char *accelerator,
319                                         const char *stock_id)
320 {
321   gchar *accel_path;
322   guint  accel_key = 0;
323   GdkModifierType accel_mods;
324   GtkStockItem stock_item;
325
326   accel_path = g_strconcat ("<Actions>/",
327                             action_group->private_data->name, "/", name, NULL);
328
329   if (accelerator)
330     gtk_accelerator_parse (accelerator, &accel_key, &accel_mods);
331   else if (stock_id && gtk_stock_lookup (stock_id, &stock_item))
332     {
333       accel_key = stock_item.keyval;
334       accel_mods = stock_item.modifier;
335     }
336
337   if (accel_key)
338     gtk_accel_map_add_entry (accel_path, accel_key, accel_mods);
339
340   gtk_action_set_accel_path (action, accel_path);
341   g_free (accel_path);
342
343   gtk_action_group_add_action (action_group, action);
344 }
345
346 /**
347  * gtk_action_group_remove_action:
348  * @action_group: the action group
349  * @action: an action
350  *
351  * Removes an action object from the action group.
352  *
353  * Since: 2.4
354  */
355 void
356 gtk_action_group_remove_action (GtkActionGroup *action_group,
357                                 GtkAction      *action)
358 {
359   g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
360   g_return_if_fail (GTK_IS_ACTION (action));
361   g_return_if_fail (gtk_action_get_name (action) != NULL);
362
363   /* extra protection to make sure action->name is valid */
364   g_object_ref (action);
365   g_hash_table_remove (action_group->private_data->actions, gtk_action_get_name (action));
366   g_object_unref (action);
367 }
368
369 static void
370 add_single_action (gpointer key, 
371                    gpointer value, 
372                    gpointer user_data)
373 {
374   GList **list = user_data;
375
376   *list = g_list_prepend (*list, value);
377 }
378
379 /**
380  * gtk_action_group_list_actions:
381  * @action_group: the action group
382  *
383  * Lists the actions in the action group.
384  *
385  * Returns: an allocated list of the action objects in the action group
386  * 
387  * Since: 2.4
388  */
389 GList *
390 gtk_action_group_list_actions (GtkActionGroup *action_group)
391 {
392   GList *actions = NULL;
393   g_return_val_if_fail (GTK_IS_ACTION_GROUP (action_group), NULL);
394   
395   g_hash_table_foreach (action_group->private_data->actions, add_single_action, &actions);
396
397   return g_list_reverse (actions);
398 }
399
400
401 /**
402  * gtk_action_group_add_actions:
403  * @action_group: the action group
404  * @entries: an array of action descriptions
405  * @n_entries: the number of entries
406  * @user_data: data to pass to the action callbacks
407  *
408  * This is a convenience function to create a number of actions and add them 
409  * to the action group.
410  *
411  * The "activate" signals of the actions are connected to the callbacks and 
412  * their accel paths are set to 
413  * <literal>&lt;Actions&gt;/<replaceable>group-name</replaceable>/<replaceable>action-name</replaceable></literal>.  
414  * 
415  * Since: 2.4
416  */
417 void
418 gtk_action_group_add_actions (GtkActionGroup *action_group,
419                               GtkActionEntry *entries,
420                               guint           n_entries,
421                               gpointer        user_data)
422 {
423   gtk_action_group_add_actions_full (action_group, 
424                                      entries, n_entries, 
425                                      user_data, NULL);
426 }
427
428
429 /**
430  * gtk_action_group_add_actions_full:
431  * @action_group: the action group
432  * @entries: an array of action descriptions
433  * @n_entries: the number of entries
434  * @user_data: data to pass to the action callbacks
435  * @destroy: destroy notification callback for @user_data
436  *
437  * This variant of gtk_action_group_add_actions() adds a #GDestroyNotify
438  * callback for @user_data. 
439  * 
440  * Since: 2.4
441  */
442 void
443 gtk_action_group_add_actions_full (GtkActionGroup *action_group,
444                                    GtkActionEntry *entries,
445                                    guint           n_entries,
446                                    gpointer        user_data,
447                                    GDestroyNotify  destroy)
448 {
449
450   /* Keep this in sync with the other 
451    * gtk_action_group_add_..._actions_full() functions.
452    */
453   guint i;
454   GtkTranslateFunc translate_func;
455   gpointer translate_data;
456
457   g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
458
459   translate_func = action_group->private_data->translate_func;
460   translate_data = action_group->private_data->translate_data;
461
462   for (i = 0; i < n_entries; i++)
463     {
464       GtkAction *action;
465       const gchar *label;
466       const gchar *tooltip;
467
468       if (translate_func)
469         {
470           label = translate_func (entries[i].label, translate_data);
471           tooltip = translate_func (entries[i].tooltip, translate_data);
472         }
473       else
474         {
475           label = entries[i].label;
476           tooltip = entries[i].tooltip;
477         }
478
479       action = g_object_new (GTK_TYPE_ACTION,
480                              "name", entries[i].name,
481                              "label", label,
482                              "tooltip", tooltip,
483                              "stock_id", entries[i].stock_id,
484                              NULL);
485
486       if (entries[i].callback)
487         g_signal_connect_data (action, "activate",
488                                entries[i].callback, 
489                                user_data, (GClosureNotify)destroy, 0);
490
491       gtk_action_group_add_action_with_accel (action_group, action,
492                                               entries[i].name,
493                                               entries[i].accelerator,
494                                               entries[i].stock_id);
495       g_object_unref (action);
496     }
497 }
498
499 /**
500  * gtk_action_group_add_toggle_actions:
501  * @action_group: the action group
502  * @entries: an array of toggle action descriptions
503  * @n_entries: the number of entries
504  * @user_data: data to pass to the action callbacks
505  *
506  * This is a convenience function to create a number of toggle actions and add them 
507  * to the action group.
508  *
509  * The "activate" signals of the actions are connected to the callbacks and 
510  * their accel paths are set to 
511  * <literal>&lt;Actions&gt;/<replaceable>group-name</replaceable>/<replaceable>action-name</replaceable></literal>.  
512  * 
513  * Since: 2.4
514  */
515 void
516 gtk_action_group_add_toggle_actions (GtkActionGroup       *action_group,
517                                      GtkToggleActionEntry *entries,
518                                      guint                 n_entries,
519                                      gpointer              user_data)
520 {
521   gtk_action_group_add_toggle_actions_full (action_group, 
522                                             entries, n_entries, 
523                                             user_data, NULL);
524 }
525
526
527 /**
528  * gtk_action_group_add_toggle_actions_full:
529  * @action_group: the action group
530  * @entries: an array of toggle action descriptions
531  * @n_entries: the number of entries
532  * @user_data: data to pass to the action callbacks
533  * @destroy: destroy notification callback for @user_data
534  *
535  * This variant of gtk_action_group_add_toggle_actions() adds a 
536  * #GDestroyNotify callback for @user_data. 
537  * 
538  * Since: 2.4
539  */
540 void
541 gtk_action_group_add_toggle_actions_full (GtkActionGroup       *action_group,
542                                           GtkToggleActionEntry *entries,
543                                           guint                 n_entries,
544                                           gpointer              user_data,
545                                           GDestroyNotify        destroy)
546 {
547   /* Keep this in sync with the other 
548    * gtk_action_group_add_..._actions_full() functions.
549    */
550   guint i;
551   GtkTranslateFunc translate_func;
552   gpointer translate_data;
553
554   g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
555
556   translate_func = action_group->private_data->translate_func;
557   translate_data = action_group->private_data->translate_data;
558
559   for (i = 0; i < n_entries; i++)
560     {
561       GtkAction *action;
562       const gchar *label;
563       const gchar *tooltip;
564
565       if (translate_func)
566         {
567           label = translate_func (entries[i].label, translate_data);
568           tooltip = translate_func (entries[i].tooltip, translate_data);
569         }
570       else
571         {
572           label = entries[i].label;
573           tooltip = entries[i].tooltip;
574         }
575
576       action = g_object_new (GTK_TYPE_TOGGLE_ACTION,
577                              "name", entries[i].name,
578                              "label", label,
579                              "tooltip", tooltip,
580                              "stock_id", entries[i].stock_id,
581                              NULL);
582
583       gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), 
584                                     entries[i].is_active);
585
586       if (entries[i].callback)
587         g_signal_connect_data (action, "activate",
588                                entries[i].callback, 
589                                user_data, (GClosureNotify)destroy, 0);
590
591       gtk_action_group_add_action_with_accel (action_group, action,
592                                               entries[i].name,
593                                               entries[i].accelerator,
594                                               entries[i].stock_id);
595       g_object_unref (action);
596     }
597 }
598
599 /**
600  * gtk_action_group_add_radio_actions:
601  * @action_group: the action group
602  * @entries: an array of radio action descriptions
603  * @n_entries: the number of entries
604  * @value: the value of the action to activate initially, or -1 if
605  *   no action should be activated
606  * @on_change: the callback to connect to the changed signal
607  * @user_data: data to pass to the action callbacks
608  * 
609  * This is a convenience routine to create a group of radio actions and
610  * add them to the action group. 
611  *
612  * The "changed" signal of the first radio action is connected to the 
613  * @on_change callback and the accel paths of the actions are set to 
614  * <literal>&lt;Actions&gt;/<replaceable>group-name</replaceable>/<replaceable>action-name</replaceable></literal>.  
615  * 
616  * Since: 2.4
617  **/
618 void            
619 gtk_action_group_add_radio_actions (GtkActionGroup      *action_group,
620                                     GtkRadioActionEntry *entries,
621                                     guint                n_entries,
622                                     gint                 value,
623                                     GCallback            on_change,
624                                     gpointer             user_data)
625 {
626   gtk_action_group_add_radio_actions_full (action_group, 
627                                            entries, n_entries, 
628                                            value,
629                                            on_change, user_data, NULL);
630 }
631
632 /**
633  * gtk_action_group_add_radio_actions_full:
634  * @action_group: the action group
635  * @entries: an array of radio action descriptions
636  * @n_entries: the number of entries
637  * @value: the value of the action to activate initially, or -1 if
638  *   no action should be activated
639  * @on_change: the callback to connect to the changed signal
640  * @user_data: data to pass to the action callbacks
641  * @destroy: destroy notification callback for @user_data
642  *
643  * This variant of gtk_action_group_add_radio_actions() adds a 
644  * #GDestroyNotify callback for @user_data. 
645  * 
646  * Since: 2.4
647  **/
648 void            
649 gtk_action_group_add_radio_actions_full (GtkActionGroup      *action_group,
650                                          GtkRadioActionEntry *entries,
651                                          guint                n_entries,
652                                          gint                 value,
653                                          GCallback            on_change,
654                                          gpointer             user_data,
655                                          GDestroyNotify       destroy)
656 {
657   /* Keep this in sync with the other 
658    * gtk_action_group_add_..._actions_full() functions.
659    */
660   guint i;
661   GtkTranslateFunc translate_func;
662   gpointer translate_data;
663   GSList *group = NULL;
664   GtkAction *first_action = NULL;
665
666   g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
667
668   translate_func = action_group->private_data->translate_func;
669   translate_data = action_group->private_data->translate_data;
670
671   for (i = 0; i < n_entries; i++)
672     {
673       GtkAction *action;
674       const gchar *label;
675       const gchar *tooltip; 
676
677       if (translate_func)
678         {
679           label = translate_func (entries[i].label, translate_data);
680           tooltip = translate_func (entries[i].tooltip, translate_data);
681         }
682       else
683         {
684           label = entries[i].label;
685           tooltip = entries[i].tooltip;
686         }
687
688       action = g_object_new (GTK_TYPE_RADIO_ACTION,
689                              "name", entries[i].name,
690                              "label", label,
691                              "tooltip", tooltip,
692                              "stock_id", entries[i].stock_id,
693                              "value", entries[i].value,
694                              NULL);
695
696       if (i == 0) 
697         first_action = action;
698
699       gtk_radio_action_set_group (GTK_RADIO_ACTION (action), group);
700       group = gtk_radio_action_get_group (GTK_RADIO_ACTION (action));
701
702       if (value == entries[i].value)
703         gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
704
705       gtk_action_group_add_action_with_accel (action_group, action,
706                                               entries[i].name,
707                                               entries[i].accelerator,
708                                               entries[i].stock_id);
709       g_object_unref (action);
710     }
711
712   if (on_change && first_action)
713     g_signal_connect_data (first_action, "changed",
714                            on_change, user_data, 
715                            (GClosureNotify)destroy, 0);
716 }
717
718 /**
719  * gtk_action_group_set_translate_func:
720  * @action_group: a #GtkActionGroup
721  * @func: a #GtkTranslateFunc
722  * @data: data to be passed to @func and @notify
723  * @notify: a #GtkDestroyNotify function to be called when @action_group is 
724  *   destroyed and when the translation function is changed again
725  * 
726  * Sets a function to be used for translating the @label and @tooltip of 
727  * #GtkActionGroupEntry<!-- -->s added by gtk_action_group_add_actions().
728  *
729  * If you're using gettext(), it is enough to set the translation domain
730  * with gtk_action_group_set_translation_domain().
731  *
732  * Since: 2.4 
733  **/
734 void
735 gtk_action_group_set_translate_func (GtkActionGroup      *action_group,
736                                      GtkTranslateFunc     func,
737                                      gpointer             data,
738                                      GtkDestroyNotify     notify)
739 {
740   g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
741   
742   if (action_group->private_data->translate_notify)
743     action_group->private_data->translate_notify (action_group->private_data->translate_data);
744       
745   action_group->private_data->translate_func = func;
746   action_group->private_data->translate_data = data;
747   action_group->private_data->translate_notify = notify;
748 }
749
750 static gchar *
751 dgettext_swapped (const gchar *msgid, 
752                   const gchar *domainname)
753 {
754   return dgettext (domainname, msgid);
755 }
756
757 /**
758  * gtk_action_group_set_translation_domain:
759  * @action_group: a #GtkActionGroup
760  * @domain: the translation domain to use for dgettext() calls
761  * 
762  * Sets the translation domain and uses dgettext() for translating the 
763  * @label and @tooltip of #GtkActionEntry<!-- -->s added by 
764  * gtk_action_group_add_actions().
765  *
766  * If you're not using gettext() for localization, see 
767  * gtk_action_group_set_translate_func().
768  *
769  * Since: 2.4
770  **/
771 void 
772 gtk_action_group_set_translation_domain (GtkActionGroup *action_group,
773                                          const gchar    *domain)
774 {
775   g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
776
777   gtk_action_group_set_translate_func (action_group, 
778                                        (GtkTranslateFunc)dgettext_swapped,
779                                        g_strdup (domain),
780                                        g_free);
781