]> icculus.org git repositories - dana/openbox.git/blob - openbox/menu.h
change the menu plugin interface, no need for the create/destroy functions any more.
[dana/openbox.git] / openbox / menu.h
1 #ifndef __menu_h
2 #define __menu_h
3
4 #include "action.h"
5 #include "window.h"
6 #include "render/render.h"
7 #include "geom.h"
8
9 #include <glib.h>
10
11 struct _ObClient;
12 struct _ObMenuFrame;
13
14 typedef struct _ObMenu ObMenu;
15 typedef struct _ObMenuEntry ObMenuEntry;
16 typedef struct _ObNormalMenuEntry ObNormalMenuEntry;
17 typedef struct _ObSubmenuMenuEntry ObSubmenuMenuEntry;
18 typedef struct _ObSeparatorMenuEntry ObSeparatorMenuEntry;
19
20 typedef void (*ObMenuUpdateFunc)(struct _ObMenuFrame *frame, gpointer data);
21
22 extern GList *menu_visible;
23
24 struct _ObMenu
25 {
26     /* Name of the menu. Used in the showmenu action. */
27     gchar *name;
28     /* Displayed title */
29     gchar *title;
30
31     /* ObMenuEntry list */
32     GList *entries;
33
34     /* plugin data */
35     gpointer data;
36
37     ObMenuUpdateFunc update_func;
38 };
39
40 typedef enum
41 {
42     OB_MENU_ENTRY_TYPE_NORMAL,
43     OB_MENU_ENTRY_TYPE_SUBMENU,
44     OB_MENU_ENTRY_TYPE_SEPARATOR
45 } ObMenuEntryType;
46
47 struct _ObNormalMenuEntry {
48     gchar *label;
49
50     /* List of ObActions */
51     GSList *actions;
52 };
53
54 struct _ObSubmenuMenuEntry {
55     ObMenu *submenu;
56 };
57
58 struct _ObSeparatorMenuEntry {
59     gchar foo; /* placeholder */
60 };
61
62 struct _ObMenuEntry
63 {
64     ObMenuEntryType type;
65     ObMenu *menu;
66
67     gint id;
68
69     /* state */
70     gboolean enabled;
71
72     union u {
73         ObNormalMenuEntry normal;
74         ObSubmenuMenuEntry submenu;
75         ObSeparatorMenuEntry separator;
76     } data;
77 };
78
79 void menu_startup();
80 void menu_shutdown();
81
82 void menu_parse();
83
84 gboolean menu_new(gchar *name, gchar *title, gpointer data);
85 void menu_free(gchar *name);
86
87 void menu_set_update_func(gchar *name, ObMenuUpdateFunc func);
88
89 void menu_show(gchar *name, gint x, gint y, struct _ObClient *client);
90
91 /* functions for building menus */
92 void menu_clear_entries(gchar *name);
93 void menu_add_normal(gchar *name, gint id, gchar *label, GSList *actions);
94 void menu_add_submenu(gchar *name, gint id, gchar *submenu);
95 void menu_add_separator(gchar *name, gint id);
96
97 ObMenuEntry* menu_find_entry_id(ObMenu *self, gint id);
98
99 #endif