aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-03-31 23:07:17 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-04-01 00:10:54 +0800
commit0125093ff7f0883fd8b97176a18cac5e798a37b9 (patch)
tree60305addf3034c827ee2ea02071df0a102bd97ad
parent440ea8e3a0b6689d49efae2e9be3471327cb782d (diff)
downloadgsoc2013-evolution-0125093ff7f0883fd8b97176a18cac5e798a37b9.tar
gsoc2013-evolution-0125093ff7f0883fd8b97176a18cac5e798a37b9.tar.gz
gsoc2013-evolution-0125093ff7f0883fd8b97176a18cac5e798a37b9.tar.bz2
gsoc2013-evolution-0125093ff7f0883fd8b97176a18cac5e798a37b9.tar.lz
gsoc2013-evolution-0125093ff7f0883fd8b97176a18cac5e798a37b9.tar.xz
gsoc2013-evolution-0125093ff7f0883fd8b97176a18cac5e798a37b9.tar.zst
gsoc2013-evolution-0125093ff7f0883fd8b97176a18cac5e798a37b9.zip
Add e_load_ui_manager_definition().
Loads a UI definition into a GtkUIManager from Evolution's UI directory. We actually had this function for a brief period during the 2.29 series, before Express Mode was a thing. I'm reviving the function to take over for EUIManager.
-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);