Commit 143b2a49 authored by Alberts Muktupāvels's avatar Alberts Muktupāvels

menu: add gp_menu_set_path

parent f19f1294
......@@ -43,6 +43,8 @@ struct _GpMenu
gulong locked_down_id;
gulong menu_icon_size_id;
gchar *path;
};
enum
......@@ -309,9 +311,18 @@ menu_reload (GpMenu *menu)
if (loaded)
{
const gchar *path;
GMenuTreeDirectory *directory;
directory = gmenu_tree_get_directory_from_path (menu->tree, "/");
path = menu->path && *menu->path != '\0' ? menu->path : "/";
directory = gmenu_tree_get_directory_from_path (menu->tree, path);
if (directory == NULL)
{
g_warning ("Menu path '%s' does not exist!", path);
directory = gmenu_tree_get_directory_from_path (menu->tree, "/");
}
directory_to_menu_items (directory, GTK_WIDGET (menu), menu);
gmenu_tree_item_unref (directory);
......@@ -584,6 +595,16 @@ gp_menu_new (GpApplet *applet,
NULL);
}
void
gp_menu_set_path (GpMenu *menu,
const gchar *path)
{
g_free (menu->path);
menu->path = g_strdup (path);
queue_reload (menu);
}
void
gp_menu_set_append_func (GpMenu *menu,
GpAppendMenuItemsFunc append_func,
......
......@@ -30,6 +30,9 @@ GtkWidget *gp_menu_new (GpApplet *applet,
const gchar *name,
gboolean required);
void gp_menu_set_path (GpMenu *menu,
const gchar *path);
void gp_menu_set_append_func (GpMenu *menu,
GpAppendMenuItemsFunc append_func,
gpointer user_data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment