Reinstate the accidentally lost addition of

2004-10-09  Matthias Clasen  <mclasen@redhat.com>

	* gtk/gtkactiongroup.h:
	* gtk/gtkactiongroup.c: Reinstate the accidentally lost addition
	of gtk_action_group_translate_string().
This commit is contained in:
Matthias Clasen 2004-10-09 04:26:11 +00:00 committed by Matthias Clasen
parent 4ef4bd0c27
commit 6b7f5ada66
6 changed files with 55 additions and 46 deletions

View File

@ -1,5 +1,9 @@
2004-10-09 Matthias Clasen <mclasen@redhat.com> 2004-10-09 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkactiongroup.h:
* gtk/gtkactiongroup.c: Reinstate the accidentally lost addition
of gtk_action_group_translate_string().
* gtk/gtkaccelgroup.h: Declare gtk_accelerator_get_label. * gtk/gtkaccelgroup.h: Declare gtk_accelerator_get_label.
2004-10-08 Matthias Clasen <mclasen@redhat.com> 2004-10-08 Matthias Clasen <mclasen@redhat.com>

View File

@ -1,5 +1,9 @@
2004-10-09 Matthias Clasen <mclasen@redhat.com> 2004-10-09 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkactiongroup.h:
* gtk/gtkactiongroup.c: Reinstate the accidentally lost addition
of gtk_action_group_translate_string().
* gtk/gtkaccelgroup.h: Declare gtk_accelerator_get_label. * gtk/gtkaccelgroup.h: Declare gtk_accelerator_get_label.
2004-10-08 Matthias Clasen <mclasen@redhat.com> 2004-10-08 Matthias Clasen <mclasen@redhat.com>

View File

@ -1,5 +1,9 @@
2004-10-09 Matthias Clasen <mclasen@redhat.com> 2004-10-09 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkactiongroup.h:
* gtk/gtkactiongroup.c: Reinstate the accidentally lost addition
of gtk_action_group_translate_string().
* gtk/gtkaccelgroup.h: Declare gtk_accelerator_get_label. * gtk/gtkaccelgroup.h: Declare gtk_accelerator_get_label.
2004-10-08 Matthias Clasen <mclasen@redhat.com> 2004-10-08 Matthias Clasen <mclasen@redhat.com>

View File

@ -1,5 +1,9 @@
2004-10-09 Matthias Clasen <mclasen@redhat.com> 2004-10-09 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkactiongroup.h:
* gtk/gtkactiongroup.c: Reinstate the accidentally lost addition
of gtk_action_group_translate_string().
* gtk/gtkaccelgroup.h: Declare gtk_accelerator_get_label. * gtk/gtkaccelgroup.h: Declare gtk_accelerator_get_label.
2004-10-08 Matthias Clasen <mclasen@redhat.com> 2004-10-08 Matthias Clasen <mclasen@redhat.com>

View File

@ -744,15 +744,10 @@ gtk_action_group_add_actions_full (GtkActionGroup *action_group,
* gtk_action_group_add_..._actions_full() functions. * gtk_action_group_add_..._actions_full() functions.
*/ */
guint i; guint i;
GtkTranslateFunc translate_func;
gpointer translate_data;
SharedData *shared_data; SharedData *shared_data;
g_return_if_fail (GTK_IS_ACTION_GROUP (action_group)); g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
translate_func = action_group->private_data->translate_func;
translate_data = action_group->private_data->translate_data;
shared_data = g_new0 (SharedData, 1); shared_data = g_new0 (SharedData, 1);
shared_data->ref_count = 1; shared_data->ref_count = 1;
shared_data->data = user_data; shared_data->data = user_data;
@ -764,16 +759,8 @@ gtk_action_group_add_actions_full (GtkActionGroup *action_group,
const gchar *label; const gchar *label;
const gchar *tooltip; const gchar *tooltip;
if (translate_func) label = gtk_action_group_translate_string (action_group, entries[i].label);
{ tooltip = gtk_action_group_translate_string (action_group, entries[i].tooltip);
label = translate_func (entries[i].label, translate_data);
tooltip = translate_func (entries[i].tooltip, translate_data);
}
else
{
label = entries[i].label;
tooltip = entries[i].tooltip;
}
action = gtk_action_new (entries[i].name, action = gtk_action_new (entries[i].name,
label, label,
@ -853,15 +840,10 @@ gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_gro
* gtk_action_group_add_..._actions_full() functions. * gtk_action_group_add_..._actions_full() functions.
*/ */
guint i; guint i;
GtkTranslateFunc translate_func;
gpointer translate_data;
SharedData *shared_data; SharedData *shared_data;
g_return_if_fail (GTK_IS_ACTION_GROUP (action_group)); g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
translate_func = action_group->private_data->translate_func;
translate_data = action_group->private_data->translate_data;
shared_data = g_new0 (SharedData, 1); shared_data = g_new0 (SharedData, 1);
shared_data->ref_count = 1; shared_data->ref_count = 1;
shared_data->data = user_data; shared_data->data = user_data;
@ -873,16 +855,8 @@ gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_gro
const gchar *label; const gchar *label;
const gchar *tooltip; const gchar *tooltip;
if (translate_func) label = gtk_action_group_translate_string (action_group, entries[i].label);
{ tooltip = gtk_action_group_translate_string (action_group, entries[i].tooltip);
label = translate_func (entries[i].label, translate_data);
tooltip = translate_func (entries[i].tooltip, translate_data);
}
else
{
label = entries[i].label;
tooltip = entries[i].tooltip;
}
action = gtk_toggle_action_new (entries[i].name, action = gtk_toggle_action_new (entries[i].name,
label, label,
@ -974,32 +948,19 @@ gtk_action_group_add_radio_actions_full (GtkActionGroup *action_group
* gtk_action_group_add_..._actions_full() functions. * gtk_action_group_add_..._actions_full() functions.
*/ */
guint i; guint i;
GtkTranslateFunc translate_func;
gpointer translate_data;
GSList *group = NULL; GSList *group = NULL;
GtkRadioAction *first_action = NULL; GtkRadioAction *first_action = NULL;
g_return_if_fail (GTK_IS_ACTION_GROUP (action_group)); g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
translate_func = action_group->private_data->translate_func;
translate_data = action_group->private_data->translate_data;
for (i = 0; i < n_entries; i++) for (i = 0; i < n_entries; i++)
{ {
GtkRadioAction *action; GtkRadioAction *action;
const gchar *label; const gchar *label;
const gchar *tooltip; const gchar *tooltip;
if (translate_func) label = gtk_action_group_translate_string (action_group, entries[i].label);
{ tooltip = gtk_action_group_translate_string (action_group, entries[i].tooltip);
label = translate_func (entries[i].label, translate_data);
tooltip = translate_func (entries[i].tooltip, translate_data);
}
else
{
label = entries[i].label;
tooltip = entries[i].tooltip;
}
action = gtk_radio_action_new (entries[i].name, action = gtk_radio_action_new (entries[i].name,
label, label,
@ -1093,6 +1054,37 @@ gtk_action_group_set_translation_domain (GtkActionGroup *action_group,
g_free); g_free);
} }
/**
* gtk_action_group_translate_string:
* @action_group: a #GtkActionGroup
* @string: a string
*
* Translates a string using the specified translate_func(). This
* is mainly intended for language bindings.
*
* Returns: the translation of @string
*
* Since: 2.6
**/
G_CONST_RETURN gchar *
gtk_action_group_translate_string (GtkActionGroup *action_group,
const gchar *string)
{
GtkTranslateFunc translate_func;
gpointer translate_data;
g_return_val_if_fail (GTK_IS_ACTION_GROUP (action_group), string);
translate_func = action_group->private_data->translate_func;
translate_data = action_group->private_data->translate_data;
if (translate_func)
return translate_func (string, translate_data);
else
return string;
}
/* Protected for use by GtkAction */ /* Protected for use by GtkAction */
void void
_gtk_action_group_emit_connect_proxy (GtkActionGroup *action_group, _gtk_action_group_emit_connect_proxy (GtkActionGroup *action_group,

View File

@ -159,7 +159,8 @@ void gtk_action_group_set_translate_func (GtkActionGroup
GtkDestroyNotify notify); GtkDestroyNotify notify);
void gtk_action_group_set_translation_domain (GtkActionGroup *action_group, void gtk_action_group_set_translation_domain (GtkActionGroup *action_group,
const gchar *domain); const gchar *domain);
G_CONST_RETURN gchar *gtk_action_group_translate_string (GtkActionGroup *action_group,
const gchar *string);
/* Protected for use by GtkAction */ /* Protected for use by GtkAction */
void _gtk_action_group_emit_connect_proxy (GtkActionGroup *action_group, void _gtk_action_group_emit_connect_proxy (GtkActionGroup *action_group,