Commit 22fa6181 authored by Alberts Muktupāvels's avatar Alberts Muktupāvels

menu: add gp_menu_set_append_func

parent 5fd21950
......@@ -19,9 +19,13 @@
#define GP_MENU_UTILS_H
#include <gio/gdesktopappinfo.h>
#include <gtk/gtk.h>
G_BEGIN_DECLS
typedef void (* GpAppendMenuItemsFunc) (GtkMenu *menu,
gpointer user_data);
void gp_menu_utils_app_info_launch (GDesktopAppInfo *app_info);
void gp_menu_utils_launch_uri (const gchar *uri);
......
......@@ -26,20 +26,23 @@
struct _GpMenu
{
GtkMenu parent;
GtkMenu parent;
gchar *name;
GpApplet *applet;
gboolean required;
gchar *name;
GpApplet *applet;
gboolean required;
GMenuTree *tree;
GMenuTree *tree;
gboolean empty;
gboolean empty;
guint reload_id;
GpAppendMenuItemsFunc append_func;
gpointer append_data;
gulong locked_down_id;
gulong menu_icon_size_id;
guint reload_id;
gulong locked_down_id;
gulong menu_icon_size_id;
};
enum
......@@ -304,6 +307,9 @@ menu_reload (GpMenu *menu)
directory = gmenu_tree_get_directory_from_path (menu->tree, "/");
directory_to_menu_items (directory, GTK_WIDGET (menu), menu);
gmenu_tree_item_unref (directory);
if (menu->append_func != NULL)
menu->append_func (GTK_MENU (menu), menu->append_data);
}
children = gtk_container_get_children (GTK_CONTAINER (menu));
......@@ -570,3 +576,14 @@ gp_menu_new (GpApplet *applet,
"required", required,
NULL);
}
void
gp_menu_set_append_func (GpMenu *menu,
GpAppendMenuItemsFunc append_func,
gpointer user_data)
{
menu->append_func = append_func;
menu->append_data = user_data;
queue_reload (menu);
}
......@@ -18,6 +18,7 @@
#ifndef GP_MENU_H
#define GP_MENU_H
#include "gp-menu-utils.h"
#include <libgnome-panel/gp-applet.h>
G_BEGIN_DECLS
......@@ -25,9 +26,13 @@ G_BEGIN_DECLS
#define GP_TYPE_MENU (gp_menu_get_type ())
G_DECLARE_FINAL_TYPE (GpMenu, gp_menu, GP, MENU, GtkMenu)
GtkWidget *gp_menu_new (GpApplet *applet,
const gchar *name,
gboolean required);
GtkWidget *gp_menu_new (GpApplet *applet,
const gchar *name,
gboolean required);
void gp_menu_set_append_func (GpMenu *menu,
GpAppendMenuItemsFunc append_func,
gpointer user_data);
G_END_DECLS
......
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