[evolution] Bug #667185 - Menu items from plugins not translated



commit 5aa4790e47a1cea8a94b0142922c7e6914d43694
Author: Milan Crha <mcrha redhat com>
Date:   Wed Jan 4 17:19:28 2012 +0100

    Bug #667185 - Menu items from plugins not translated

 e-util/e-util.c |   61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 e-util/e-util.h |    6 +++++
 2 files changed, 67 insertions(+), 0 deletions(-)
---
diff --git a/e-util/e-util.c b/e-util/e-util.c
index f21693b..681ce78 100644
--- a/e-util/e-util.c
+++ b/e-util/e-util.c
@@ -640,6 +640,67 @@ e_radio_action_get_current_action (GtkRadioAction *radio_action)
 	return NULL;
 }
 
+/**
+ * e_action_group_add_actions_localized:
+ * @action_group: a #GtkActionGroup to add @entries to
+ * @translation_domain: a translation domain to use
+ *    to translate label and tooltip strings in @entries
+ * @entries: (array length=n_entries): an array of action descriptions
+ * @n_entries: the number of entries
+ * @user_data: data to pass to the action callbacks
+ *
+ * Adds #GtkAction-s defined by @entries to @action_group, with action's
+ * label and tooltip localized in the given translation domain, instead
+ * of the domain set on the @action_group.
+ *
+ * Since: 3.4
+ **/
+void
+e_action_group_add_actions_localized (GtkActionGroup *action_group,
+				      const gchar *translation_domain,
+				      const GtkActionEntry *entries,
+				      guint n_entries,
+				      gpointer user_data)
+{
+	gint ii;
+	GtkAction *action;
+	GList *actions, *iter;
+	GtkActionGroup *tmp_group;
+
+	g_return_if_fail (action_group != NULL);
+	g_return_if_fail (entries != NULL);
+	g_return_if_fail (n_entries > 0);
+	g_return_if_fail (translation_domain != NULL);
+	g_return_if_fail (*translation_domain);
+
+	tmp_group = gtk_action_group_new ("temporary-group");
+	gtk_action_group_set_translation_domain (tmp_group, translation_domain);
+	gtk_action_group_add_actions (tmp_group, entries, n_entries, user_data);
+
+	actions = gtk_action_group_list_actions (tmp_group);
+	for (iter = actions; iter != NULL; iter = iter->next) {
+		action = iter->data;
+
+		if (!action)
+			continue;
+
+		g_object_ref (action);
+
+		for (ii = 0; ii < n_entries; ii++) {
+			if (g_strcmp0 (entries[ii].name, gtk_action_get_name (action)) == 0) {
+				gtk_action_group_remove_action (tmp_group, action);
+				gtk_action_group_add_action_with_accel (action_group, action, entries[ii].accelerator);
+				break;
+			}
+		}
+
+		g_object_unref (action);
+	}
+
+	g_list_free (actions);
+	g_object_unref (tmp_group);
+}
+
 /* Helper for e_categories_add_change_hook() */
 static void
 categories_changed_cb (GObject *useless_opaque_object,
diff --git a/e-util/e-util.h b/e-util/e-util.h
index c95ef0c..101706b 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -73,6 +73,12 @@ void		e_action_group_remove_all_actions
 						(GtkActionGroup *action_group);
 GtkRadioAction *e_radio_action_get_current_action
 						(GtkRadioAction *radio_action);
+void		e_action_group_add_actions_localized
+						(GtkActionGroup *action_group,
+						 const gchar *translation_domain,
+						 const GtkActionEntry *entries,
+						 guint n_entries,
+						 gpointer user_data);
 void		e_categories_add_change_hook	(GHookFunc func,
 						 gpointer object);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]