diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-03-31 23:07:17 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-04-01 00:10:54 +0800 |
commit | 0125093ff7f0883fd8b97176a18cac5e798a37b9 (patch) | |
tree | 60305addf3034c827ee2ea02071df0a102bd97ad /e-util | |
parent | 440ea8e3a0b6689d49efae2e9be3471327cb782d (diff) | |
download | gsoc2013-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.
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/e-misc-utils.c | 36 | ||||
-rw-r--r-- | e-util/e-misc-utils.h | 2 |
2 files changed, 38 insertions, 0 deletions
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); |