[gnome-panel] menu: add gp_menu_get_icon



commit e46cc732d2dd07ee73e3d87c46b3bc8336b2891c
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Wed Sep 12 02:09:25 2018 +0300

    menu: add gp_menu_get_icon

 modules/menu/gp-menu.c | 30 ++++++++++++++++++++++++++++++
 modules/menu/gp-menu.h |  2 ++
 2 files changed, 32 insertions(+)
---
diff --git a/modules/menu/gp-menu.c b/modules/menu/gp-menu.c
index 9d6f69d39..03b260a6f 100644
--- a/modules/menu/gp-menu.c
+++ b/modules/menu/gp-menu.c
@@ -625,6 +625,36 @@ gp_menu_set_path (GpMenu      *menu,
   queue_reload (menu);
 }
 
+GIcon *
+gp_menu_get_icon (GpMenu *menu)
+{
+  const gchar *path;
+  GMenuTreeDirectory *directory;
+  GIcon *icon;
+
+  if (!menu->loaded)
+    return NULL;
+
+  path = menu->path && *menu->path != '\0' ? menu->path : "/";
+  directory = gmenu_tree_get_directory_from_path (menu->tree, path);
+
+  if (directory == NULL)
+    return NULL;
+
+  icon = gmenu_tree_directory_get_icon (directory);
+
+  if (icon == NULL)
+    {
+      gmenu_tree_item_unref (directory);
+      return NULL;
+    }
+
+  g_object_ref (icon);
+  gmenu_tree_item_unref (directory);
+
+  return icon;
+}
+
 void
 gp_menu_set_append_func (GpMenu                *menu,
                          GpAppendMenuItemsFunc  append_func,
diff --git a/modules/menu/gp-menu.h b/modules/menu/gp-menu.h
index 0b8511bd4..5ceea69be 100644
--- a/modules/menu/gp-menu.h
+++ b/modules/menu/gp-menu.h
@@ -33,6 +33,8 @@ GtkWidget *gp_menu_new             (GpApplet              *applet,
 void       gp_menu_set_path        (GpMenu                *menu,
                                     const gchar           *path);
 
+GIcon     *gp_menu_get_icon        (GpMenu                *menu);
+
 void       gp_menu_set_append_func (GpMenu                *menu,
                                     GpAppendMenuItemsFunc  append_func,
                                     gpointer               user_data);


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