[evolution] Add e_load_ui_manager_definition().



commit 0125093ff7f0883fd8b97176a18cac5e798a37b9
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sun Mar 31 11:07:17 2013 -0400

    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.

 doc/reference/libeutil/libeutil-sections.txt |    1 +
 e-util/e-misc-utils.c                        |   36 ++++++++++++++++++++++++++
 e-util/e-misc-utils.h                        |    2 +
 3 files changed, 39 insertions(+), 0 deletions(-)
---
diff --git a/doc/reference/libeutil/libeutil-sections.txt b/doc/reference/libeutil/libeutil-sections.txt
index 57ccb96..6300e8c 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 776027d..97e5c2d 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 d45f8d3..d7dea7a 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);
 


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