Commit fa72dfce authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen

Make the the GtkAction{Toggle,Radio,}Entry* arguments to the

Tue Aug  3 20:16:26 2004  Matthias Clasen  <maclas@gmx.de>

	* gtk/gtkactiongroup.[hc]: Make the the GtkAction{Toggle,Radio,}Entry*
	arguments to the gtk_action_group_add_..._actions() functions const,
	since the most common use case is to use a static array.  (142334,
	Mariano Suarez-Alvarez)
parent f2f361cb
Tue Aug 3 20:16:26 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkactiongroup.[hc]: Make the the GtkAction{Toggle,Radio,}Entry*
arguments to the gtk_action_group_add_..._actions() functions const,
since the most common use case is to use a static array. (142334,
Mariano Suarez-Alvarez)
Tue Aug 3 20:03:33 2004 Matthias Clasen <maclas@gmx.de> Tue Aug 3 20:03:33 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c (get_node): Make gtk_ui_manager_add_ui() * gtk/gtkuimanager.c (get_node): Make gtk_ui_manager_add_ui()
......
Tue Aug 3 20:16:26 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkactiongroup.[hc]: Make the the GtkAction{Toggle,Radio,}Entry*
arguments to the gtk_action_group_add_..._actions() functions const,
since the most common use case is to use a static array. (142334,
Mariano Suarez-Alvarez)
Tue Aug 3 20:03:33 2004 Matthias Clasen <maclas@gmx.de> Tue Aug 3 20:03:33 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c (get_node): Make gtk_ui_manager_add_ui() * gtk/gtkuimanager.c (get_node): Make gtk_ui_manager_add_ui()
......
Tue Aug 3 20:16:26 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkactiongroup.[hc]: Make the the GtkAction{Toggle,Radio,}Entry*
arguments to the gtk_action_group_add_..._actions() functions const,
since the most common use case is to use a static array. (142334,
Mariano Suarez-Alvarez)
Tue Aug 3 20:03:33 2004 Matthias Clasen <maclas@gmx.de> Tue Aug 3 20:03:33 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c (get_node): Make gtk_ui_manager_add_ui() * gtk/gtkuimanager.c (get_node): Make gtk_ui_manager_add_ui()
......
Tue Aug 3 20:16:26 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkactiongroup.[hc]: Make the the GtkAction{Toggle,Radio,}Entry*
arguments to the gtk_action_group_add_..._actions() functions const,
since the most common use case is to use a static array. (142334,
Mariano Suarez-Alvarez)
Tue Aug 3 20:03:33 2004 Matthias Clasen <maclas@gmx.de> Tue Aug 3 20:03:33 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c (get_node): Make gtk_ui_manager_add_ui() * gtk/gtkuimanager.c (get_node): Make gtk_ui_manager_add_ui()
......
...@@ -308,7 +308,8 @@ gtk_action_group_finalize (GObject *object) ...@@ -308,7 +308,8 @@ gtk_action_group_finalize (GObject *object)
if (self->private_data->translate_notify) if (self->private_data->translate_notify)
self->private_data->translate_notify (self->private_data->translate_data); self->private_data->translate_notify (self->private_data->translate_data);
(* parent_class->finalize) (object); if (parent_class->finalize)
(* parent_class->finalize) (object);
} }
static void static void
...@@ -683,10 +684,10 @@ gtk_action_group_list_actions (GtkActionGroup *action_group) ...@@ -683,10 +684,10 @@ gtk_action_group_list_actions (GtkActionGroup *action_group)
* Since: 2.4 * Since: 2.4
*/ */
void void
gtk_action_group_add_actions (GtkActionGroup *action_group, gtk_action_group_add_actions (GtkActionGroup *action_group,
GtkActionEntry *entries, const GtkActionEntry *entries,
guint n_entries, guint n_entries,
gpointer user_data) gpointer user_data)
{ {
gtk_action_group_add_actions_full (action_group, gtk_action_group_add_actions_full (action_group,
entries, n_entries, entries, n_entries,
...@@ -731,21 +732,26 @@ shared_data_unref (gpointer data) ...@@ -731,21 +732,26 @@ shared_data_unref (gpointer data)
* Since: 2.4 * Since: 2.4
*/ */
void void
gtk_action_group_add_actions_full (GtkActionGroup *action_group, gtk_action_group_add_actions_full (GtkActionGroup *action_group,
GtkActionEntry *entries, const GtkActionEntry *entries,
guint n_entries, guint n_entries,
gpointer user_data, gpointer user_data,
GDestroyNotify destroy) GDestroyNotify destroy)
{ {
/* Keep this in sync with the other /* Keep this in sync with the other
* 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;
...@@ -757,8 +763,16 @@ gtk_action_group_add_actions_full (GtkActionGroup *action_group, ...@@ -757,8 +763,16 @@ gtk_action_group_add_actions_full (GtkActionGroup *action_group,
const gchar *label; const gchar *label;
const gchar *tooltip; const gchar *tooltip;
label = gtk_action_group_translate_string (action_group, entries[i].label); if (translate_func)
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,
...@@ -803,10 +817,10 @@ gtk_action_group_add_actions_full (GtkActionGroup *action_group, ...@@ -803,10 +817,10 @@ gtk_action_group_add_actions_full (GtkActionGroup *action_group,
* Since: 2.4 * Since: 2.4
*/ */
void void
gtk_action_group_add_toggle_actions (GtkActionGroup *action_group, gtk_action_group_add_toggle_actions (GtkActionGroup *action_group,
GtkToggleActionEntry *entries, const GtkToggleActionEntry *entries,
guint n_entries, guint n_entries,
gpointer user_data) gpointer user_data)
{ {
gtk_action_group_add_toggle_actions_full (action_group, gtk_action_group_add_toggle_actions_full (action_group,
entries, n_entries, entries, n_entries,
...@@ -828,20 +842,25 @@ gtk_action_group_add_toggle_actions (GtkActionGroup *action_group, ...@@ -828,20 +842,25 @@ gtk_action_group_add_toggle_actions (GtkActionGroup *action_group,
* Since: 2.4 * Since: 2.4
*/ */
void void
gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_group, gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_group,
GtkToggleActionEntry *entries, const GtkToggleActionEntry *entries,
guint n_entries, guint n_entries,
gpointer user_data, gpointer user_data,
GDestroyNotify destroy) GDestroyNotify destroy)
{ {
/* Keep this in sync with the other /* Keep this in sync with the other
* 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;
...@@ -853,8 +872,16 @@ gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_group, ...@@ -853,8 +872,16 @@ gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_group,
const gchar *label; const gchar *label;
const gchar *tooltip; const gchar *tooltip;
label = gtk_action_group_translate_string (action_group, entries[i].label); if (translate_func)
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,
...@@ -904,12 +931,12 @@ gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_group, ...@@ -904,12 +931,12 @@ gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_group,
* Since: 2.4 * Since: 2.4
**/ **/
void void
gtk_action_group_add_radio_actions (GtkActionGroup *action_group, gtk_action_group_add_radio_actions (GtkActionGroup *action_group,
GtkRadioActionEntry *entries, const GtkRadioActionEntry *entries,
guint n_entries, guint n_entries,
gint value, gint value,
GCallback on_change, GCallback on_change,
gpointer user_data) gpointer user_data)
{ {
gtk_action_group_add_radio_actions_full (action_group, gtk_action_group_add_radio_actions_full (action_group,
entries, n_entries, entries, n_entries,
...@@ -934,31 +961,44 @@ gtk_action_group_add_radio_actions (GtkActionGroup *action_group, ...@@ -934,31 +961,44 @@ gtk_action_group_add_radio_actions (GtkActionGroup *action_group,
* Since: 2.4 * Since: 2.4
**/ **/
void void
gtk_action_group_add_radio_actions_full (GtkActionGroup *action_group, gtk_action_group_add_radio_actions_full (GtkActionGroup *action_group,
GtkRadioActionEntry *entries, const GtkRadioActionEntry *entries,
guint n_entries, guint n_entries,
gint value, gint value,
GCallback on_change, GCallback on_change,
gpointer user_data, gpointer user_data,
GDestroyNotify destroy) GDestroyNotify destroy)
{ {
/* Keep this in sync with the other /* Keep this in sync with the other
* 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;
label = gtk_action_group_translate_string (action_group, entries[i].label); if (translate_func)
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,
...@@ -1033,10 +1073,7 @@ dgettext_swapped (const gchar *msgid, ...@@ -1033,10 +1073,7 @@ dgettext_swapped (const gchar *msgid,
* *
* Sets the translation domain and uses dgettext() for translating the * Sets the translation domain and uses dgettext() for translating the
* @label and @tooltip of #GtkActionEntry<!-- -->s added by * @label and @tooltip of #GtkActionEntry<!-- -->s added by
* gtk_action_group_add_actions(). Note that GTK+ expects all strings * gtk_action_group_add_actions().
* to be encoded in UTF-8, therefore the translation domain must have
* its codeset set to UTF-8, see bind_textdomain_codeset() in the
* gettext() documentation.
* *
* If you're not using gettext() for localization, see * If you're not using gettext() for localization, see
* gtk_action_group_set_translate_func(). * gtk_action_group_set_translate_func().
...@@ -1055,36 +1092,6 @@ gtk_action_group_set_translation_domain (GtkActionGroup *action_group, ...@@ -1055,36 +1092,6 @@ 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
**/
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,
......
...@@ -104,64 +104,62 @@ struct _GtkRadioActionEntry ...@@ -104,64 +104,62 @@ struct _GtkRadioActionEntry
}; };
GType gtk_action_group_get_type (void); GType gtk_action_group_get_type (void);
GtkActionGroup *gtk_action_group_new (const gchar *name); GtkActionGroup *gtk_action_group_new (const gchar *name);
const gchar *gtk_action_group_get_name (GtkActionGroup *action_group); const gchar *gtk_action_group_get_name (GtkActionGroup *action_group);
gboolean gtk_action_group_get_sensitive (GtkActionGroup *action_group); gboolean gtk_action_group_get_sensitive (GtkActionGroup *action_group);
void gtk_action_group_set_sensitive (GtkActionGroup *action_group, void gtk_action_group_set_sensitive (GtkActionGroup *action_group,
gboolean sensitive); gboolean sensitive);
gboolean gtk_action_group_get_visible (GtkActionGroup *action_group); gboolean gtk_action_group_get_visible (GtkActionGroup *action_group);
void gtk_action_group_set_visible (GtkActionGroup *action_group, void gtk_action_group_set_visible (GtkActionGroup *action_group,
gboolean visible); gboolean visible);
GtkAction *gtk_action_group_get_action (GtkActionGroup *action_group, GtkAction *gtk_action_group_get_action (GtkActionGroup *action_group,
const gchar *action_name); const gchar *action_name);
GList *gtk_action_group_list_actions (GtkActionGroup *action_group); GList *gtk_action_group_list_actions (GtkActionGroup *action_group);
void gtk_action_group_add_action (GtkActionGroup *action_group, void gtk_action_group_add_action (GtkActionGroup *action_group,
GtkAction *action); GtkAction *action);
void gtk_action_group_add_action_with_accel (GtkActionGroup *action_group, void gtk_action_group_add_action_with_accel (GtkActionGroup *action_group,
GtkAction *action, GtkAction *action,
const gchar *accelerator); const gchar *accelerator);
void gtk_action_group_remove_action (GtkActionGroup *action_group,
void gtk_action_group_remove_action (GtkActionGroup *action_group, GtkAction *action);
GtkAction *action); void gtk_action_group_add_actions (GtkActionGroup *action_group,
void gtk_action_group_add_actions (GtkActionGroup *action_group, const GtkActionEntry *entries,
GtkActionEntry *entries, guint n_entries,
guint n_entries, gpointer user_data);
gpointer user_data); void gtk_action_group_add_toggle_actions (GtkActionGroup *action_group,
void gtk_action_group_add_toggle_actions (GtkActionGroup *action_group, const GtkToggleActionEntry *entries,
GtkToggleActionEntry *entries, guint n_entries,
guint n_entries, gpointer user_data);
gpointer user_data); void gtk_action_group_add_radio_actions (GtkActionGroup *action_group,
void gtk_action_group_add_radio_actions (GtkActionGroup *action_group, const GtkRadioActionEntry *entries,
GtkRadioActionEntry *entries, guint n_entries,
guint n_entries, gint value,
gint value, GCallback on_change,
GCallback on_change, gpointer user_data);
gpointer user_data); void gtk_action_group_add_actions_full (GtkActionGroup *action_group,
void gtk_action_group_add_actions_full (GtkActionGroup *action_group, const GtkActionEntry *entries,
GtkActionEntry *entries, guint n_entries,
guint n_entries, gpointer user_data,
gpointer user_data, GDestroyNotify destroy);
GDestroyNotify destroy); void gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_group,
void gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_group, const GtkToggleActionEntry *entries,
GtkToggleActionEntry *entries, guint n_entries,
guint n_entries, gpointer user_data,
gpointer user_data, GDestroyNotify destroy);
GDestroyNotify destroy); void gtk_action_group_add_radio_actions_full (GtkActionGroup *action_group,
void gtk_action_group_add_radio_actions_full (GtkActionGroup *action_group, const GtkRadioActionEntry *entries,
GtkRadioActionEntry *entries, guint n_entries,
guint n_entries, gint value,
gint value, GCallback on_change,
GCallback on_change, gpointer user_data,
gpointer user_data, GDestroyNotify destroy);
GDestroyNotify destroy); void gtk_action_group_set_translate_func (GtkActionGroup *action_group,
void gtk_action_group_set_translate_func (GtkActionGroup *action_group, GtkTranslateFunc func,
GtkTranslateFunc func, gpointer data,
gpointer data, 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);
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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment