[gnome-builder/wip/chergert/perspective] egg: add egg_menu_manager_add_resource()



commit bc0aa30df5bec2a7bbf46ea314afc7247fcb965f
Author: Christian Hergert <chergert redhat com>
Date:   Thu Dec 3 15:00:48 2015 -0800

    egg: add egg_menu_manager_add_resource()
    
    Just like add_filename(), but for embedded resources.

 contrib/egg/egg-menu-manager.c |   26 ++++++++++++++++++++++++++
 contrib/egg/egg-menu-manager.h |    3 +++
 2 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/contrib/egg/egg-menu-manager.c b/contrib/egg/egg-menu-manager.c
index f2cd892..59e23b0 100644
--- a/contrib/egg/egg-menu-manager.c
+++ b/contrib/egg/egg-menu-manager.c
@@ -499,3 +499,29 @@ egg_menu_manager_get_menu_by_id (EggMenuManager *self,
 
   return menu;
 }
+
+guint
+egg_menu_manager_add_resource (EggMenuManager  *self,
+                               const gchar     *resource,
+                               GError         **error)
+{
+  GtkBuilder *builder;
+  guint merge_id;
+
+  g_return_val_if_fail (EGG_IS_MENU_MANAGER (self), 0);
+  g_return_val_if_fail (resource != NULL, 0);
+
+  builder = gtk_builder_new ();
+
+  if (!gtk_builder_add_from_resource (builder, resource, error))
+    {
+      g_object_unref (builder);
+      return 0;
+    }
+
+  merge_id = ++self->last_merge_id;
+  egg_menu_manager_merge (self, builder, merge_id);
+  g_object_unref (builder);
+
+  return merge_id;
+}
diff --git a/contrib/egg/egg-menu-manager.h b/contrib/egg/egg-menu-manager.h
index 3e8e6f4..225d878 100644
--- a/contrib/egg/egg-menu-manager.h
+++ b/contrib/egg/egg-menu-manager.h
@@ -31,6 +31,9 @@ EggMenuManager *egg_menu_manager_new            (void);
 guint           egg_menu_manager_add_filename   (EggMenuManager  *self,
                                                  const gchar     *filename,
                                                  GError         **error);
+guint           egg_menu_manager_add_resource   (EggMenuManager  *self,
+                                                 const gchar     *resource,
+                                                 GError         **error);
 void            egg_menu_manager_remove         (EggMenuManager  *self,
                                                  guint            merge_id);
 GMenu          *egg_menu_manager_get_menu_by_id (EggMenuManager  *self,


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