]> Dogcows Code - chaz/openbox/blob - openbox/menu.h
add a func to find a menu entry from a submenu.
[chaz/openbox] / 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
13 typedef struct _ObMenu ObMenu;
14 typedef struct _ObMenuEntry ObMenuEntry;
15
16 typedef void(*menu_controller_show)(ObMenu *self, int x, int y,
17 struct _ObClient *);
18 typedef void(*menu_controller_update)(ObMenu *self);
19 typedef void(*menu_controller_mouseover)(ObMenuEntry *self, gboolean enter);
20
21 extern GHashTable *menu_hash;
22 extern GList *menu_visible;
23
24 struct _ObMenu
25 {
26 ObWindow obwin;
27
28 gchar *label;
29 gchar *name;
30
31 GList *entries;
32
33 gboolean shown;
34 gboolean invalid;
35
36 ObMenu *parent;
37
38 ObMenu *open_submenu;
39
40 /* place a menu on screen */
41 menu_controller_show show;
42 void (*hide)( /* some bummu */);
43
44 /* render a menu */
45 menu_controller_update update;
46 menu_controller_mouseover mouseover;
47 void (*selected)( /* some bummu */);
48
49
50 /* render stuff */
51 struct _ObClient *client;
52 Window frame;
53 Window title;
54 RrAppearance *a_title;
55 gint title_min_w, title_h;
56 Window items;
57 RrAppearance *a_items;
58 gint bullet_w;
59 gint item_h;
60 Point location;
61 Size size;
62 guint xin_area; /* index of the xinerama head/area */
63
64 /* plugin stuff */
65 char *plugin;
66 void *plugin_data;
67 };
68
69 typedef enum
70 {
71 OB_MENU_ENTRY_RENDER_TYPE_NONE,
72 OB_MENU_ENTRY_RENDER_TYPE_SUBMENU,
73 OB_MENU_ENTRY_RENDER_TYPE_BOOLEAN,
74 OB_MENU_ENTRY_RENDER_TYPE_SEPARATOR,
75 OB_MENU_ENTRY_RENDER_TYPE_OTHER /* XXX what is this? */
76 } ObMenuEntryRenderType;
77
78 struct _ObMenuEntry
79 {
80 char *label;
81 ObMenu *parent;
82
83 Action *action;
84
85 ObMenuEntryRenderType render_type;
86 gboolean hilite;
87 gboolean enabled;
88 gboolean boolean_value;
89
90 ObMenu *submenu;
91
92 /* render stuff */
93 Window item;
94 RrAppearance *a_item;
95 RrAppearance *a_disabled;
96 RrAppearance *a_hilite;
97 gint y;
98 gint min_w;
99 } MenuEntry;
100
101 typedef struct PluginMenuCreateData{
102 xmlDocPtr doc;
103 xmlNodePtr node;
104 ObMenu *parent;
105 } PluginMenuCreateData;
106
107
108 void menu_startup();
109 void menu_shutdown();
110
111 #define menu_new(l, n, p) \
112 menu_new_full(l, n, p, NULL, NULL)
113
114 ObMenu *menu_new_full(char *label, char *name, ObMenu *parent,
115 menu_controller_show show, menu_controller_update update);
116 void menu_free(char *name);
117
118 void menu_show(char *name, int x, int y, struct _ObClient *client);
119 void menu_show_full(ObMenu *menu, int x, int y, struct _ObClient *client);
120
121 void menu_hide(ObMenu *self);
122
123 void menu_clear(ObMenu *self);
124
125 ObMenuEntry *menu_entry_new_full(char *label, Action *action,
126 ObMenuEntryRenderType render_type,
127 gpointer submenu);
128
129 #define menu_entry_new(label, action) \
130 menu_entry_new_full(label, action, OB_MENU_ENTRY_RENDER_TYPE_NONE, NULL)
131
132 #define menu_entry_new_separator(label) \
133 menu_entry_new_full(label, NULL, OB_MENU_ENTRY_RENDER_TYPE_SEPARATOR, NULL)
134
135 #define menu_entry_new_submenu(label, submenu) \
136 menu_entry_new_full(label, NULL, OB_MENU_ENTRY_RENDER_TYPE_SUBMENU, submenu)
137
138 #define menu_entry_new_boolean(label, action) \
139 menu_entry_new_full(label, action, OB_MENU_ENTRY_RENDER_TYPE_BOOLEAN, NULL)
140
141 void menu_entry_free(ObMenuEntry *entry);
142
143 void menu_entry_set_submenu(ObMenuEntry *entry, ObMenu *submenu);
144
145 void menu_add_entry(ObMenu *menu, ObMenuEntry *entry);
146
147 ObMenuEntry *menu_find_entry(ObMenu *menu, Window win);
148 ObMenuEntry *menu_find_entry_by_submenu(ObMenu *menu, ObMenu *submenu);
149 ObMenuEntry *menu_find_entry_by_pos(ObMenu *menu, int x, int y);
150
151 void menu_entry_render(ObMenuEntry *self);
152
153 void menu_entry_fire(ObMenuEntry *self);
154
155 void menu_render(ObMenu *self);
156 void menu_render_full(ObMenu *self);
157
158 /*so plugins can call it? */
159 void parse_menu_full(xmlDocPtr doc, xmlNodePtr node, void *data, gboolean new);
160 void menu_control_mouseover(ObMenuEntry *entry, gboolean enter);
161 ObMenuEntry *menu_control_keyboard_nav(ObMenuEntry *over, ObKey key);
162 #endif
This page took 0.045394 seconds and 4 git commands to generate.