aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/reference/libeutil/libeutil-sections.txt1
-rw-r--r--e-util/e-misc-utils.c36
-rw-r--r--e-util/e-misc-utils.h2
3 files changed, 39 insertions, 0 deletions
diff --git a/doc/reference/libeutil/libeutil-sections.txt b/doc/reference/libeutil/libeutil-sections.txt
index 57ccb96ac7..6300e8c10a 100644
--- a/doc/reference/libeutil/libeutil-sections.txt
+++ b/doc/reference/libeutil/libeutil-sections.txt
@@ -2232,6 +2232,7 @@ e_radio_action_get_current_action
e_action_group_add_actions_localized
e_builder_get_widget
e_load_ui_builder_definition
+e_load_ui_manager_definition
e_categories_add_change_hook
e_str_without_underscores
e_str_compare
diff --git a/e-util/e-misc-utils.c b/e-util/e-misc-utils.c
index 776027da09..97e5c2d37e 100644
--- a/e-util/e-misc-utils.c
+++ b/e-util/e-misc-utils.c
@@ -708,6 +708,42 @@ e_load_ui_builder_definition (GtkBuilder *builder,
}
}
+/**
+ * e_load_ui_manager_definition:
+ * @ui_manager: a #GtkUIManager
+ * @basename: basename of the UI definition file
+ *
+ * Loads a UI definition into @ui_manager from Evolution's UI directory.
+ * Failure here is fatal, since the application can't function without
+ * its UI definitions.
+ *
+ * Returns: The merge ID for the merged UI. The merge ID can be used to
+ * unmerge the UI with gtk_ui_manager_remove_ui().
+ **/
+guint
+e_load_ui_manager_definition (GtkUIManager *ui_manager,
+ const gchar *basename)
+{
+ gchar *filename;
+ guint merge_id;
+ GError *error = NULL;
+
+ g_return_val_if_fail (GTK_IS_UI_MANAGER (ui_manager), 0);
+ g_return_val_if_fail (basename != NULL, 0);
+
+ filename = g_build_filename (EVOLUTION_UIDIR, basename, NULL);
+ merge_id = gtk_ui_manager_add_ui_from_file (
+ ui_manager, filename, &error);
+ g_free (filename);
+
+ if (error != NULL) {
+ g_error ("%s: %s", basename, error->message);
+ g_assert_not_reached ();
+ }
+
+ return merge_id;
+}
+
/* Helper for e_categories_add_change_hook() */
static void
categories_changed_cb (GObject *useless_opaque_object,
diff --git a/e-util/e-misc-utils.h b/e-util/e-misc-utils.h
index d45f8d34e8..d7dea7afc3 100644
--- a/e-util/e-misc-utils.h
+++ b/e-util/e-misc-utils.h
@@ -81,6 +81,8 @@ GtkWidget * e_builder_get_widget (GtkBuilder *builder,
const gchar *widget_name);
void e_load_ui_builder_definition (GtkBuilder *builder,
const gchar *basename);
+guint e_load_ui_manager_definition (GtkUIManager *ui_manager,
+ const gchar *basename);
void e_categories_add_change_hook (GHookFunc func,
gpointer object);