]> icculus.org git repositories - dana/openbox.git/blob - openbox/menu.h
half way through the changes to new menu code/design. hot shit. static menus work...
[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 extern GList *menu_visible;
21
22
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
38 typedef enum
39 {
40     OB_MENU_ENTRY_TYPE_NORMAL,
41     OB_MENU_ENTRY_TYPE_SUBMENU,
42     OB_MENU_ENTRY_TYPE_SEPARATOR
43 } ObMenuEntryType;
44
45 struct _ObNormalMenuEntry {
46     gchar *label;
47
48     /* List of ObActions */
49     GSList *actions;
50 };
51
52 struct _ObSubmenuMenuEntry {
53     ObMenu *submenu;
54 };
55
56 struct _ObSeparatorMenuEntry {
57     gchar foo; /* placeholder */
58 };
59
60 struct _ObMenuEntry
61 {
62     ObMenuEntryType type;
63     ObMenu *menu;
64
65     /* state */
66     gboolean enabled;
67
68     union u {
69         ObNormalMenuEntry normal;
70         ObSubmenuMenuEntry submenu;
71         ObSeparatorMenuEntry separator;
72     } data;
73 };
74
75 void menu_startup();
76 void menu_shutdown();
77
78 void menu_parse();
79
80 gboolean menu_new(gchar *name, gchar *title, gpointer data);
81
82 void menu_show(gchar *name, gint x, gint y, struct _ObClient *client);
83
84 /* functions for building menus */
85 void menu_clear_entries(gchar *name);
86 void menu_add_normal(gchar *name, gchar *label, GSList *actions);
87 void menu_add_submenu(gchar *name, gchar *submenu);
88 void menu_add_separator(gchar *name);
89
90 #endif