6 #include "render/render.h"
14 typedef struct _ObMenu ObMenu;
15 typedef struct _ObMenuEntry ObMenuEntry;
17 typedef void(*menu_controller_destroy)(ObMenu *self);
18 typedef void(*menu_controller_show)(ObMenu *self, int x, int y,
20 typedef void(*menu_controller_update)(ObMenu *self);
21 typedef void(*menu_controller_mouseover)(ObMenuEntry *self, gboolean enter);
22 typedef void(*menu_controller_selected)(ObMenuEntry *entry,
24 unsigned int x, unsigned int y);
25 typedef void(*menu_controller_hide)(ObMenu *self);
28 extern GHashTable *menu_hash;
29 extern GList *menu_visible;
35 /* The title displayed above the menu.
36 NULL for no titlebar */
40 Used in the action showmenu */
43 /* ObMenuEntry list */
46 /* If the menu is currently displayed */
49 /* If the rendering of the menu has changed and needs to be rerendered. */
52 /* Kind of lame.Each menu can only be a submenu, and each menu can only
53 have one submenu open */
59 menu_controller_destroy destroy;
61 /* behaviour callbacks
62 TODO: Document and split code that HAS to be in the overridden callback */
63 /* place a menu on screen */
64 menu_controller_show show;
66 menu_controller_hide hide;
68 menu_controller_update update;
69 /* Event for a mouse enter/exit on an entry
70 TODO: May have to split from simple render updating?
72 menu_controller_mouseover mouseover;
73 /* Entry is clicked/hit enter on */
74 menu_controller_selected selected;
78 struct _ObClient *client;
81 RrAppearance *a_title;
82 gint title_min_w, title_h;
84 RrAppearance *a_items;
89 guint xin_area; /* index of the xinerama head/area */
91 /* Name of plugin for menu */
99 OB_MENU_ENTRY_RENDER_TYPE_NONE,
100 OB_MENU_ENTRY_RENDER_TYPE_SUBMENU,
101 OB_MENU_ENTRY_RENDER_TYPE_BOOLEAN,
102 OB_MENU_ENTRY_RENDER_TYPE_SEPARATOR,
103 OB_MENU_ENTRY_RENDER_TYPE_OTHER /* XXX what is this? */
104 } ObMenuEntryRenderType;
113 ObMenuEntryRenderType render_type;
116 gboolean boolean_value;
124 RrAppearance *a_item;
125 RrAppearance *a_disabled;
126 RrAppearance *a_hilite;
127 RrAppearance *a_submenu;
132 typedef struct PluginMenuCreateData{
133 struct _ObParseInst *parse_inst;
137 } PluginMenuCreateData;
141 void menu_shutdown();
147 #define menu_new(l, n, p) \
148 menu_new_full(l, n, p, menu_show_full, menu_render, menu_entry_fire, \
149 menu_hide, menu_control_mouseover, NULL)
151 ObMenu *menu_new_full(char *label, char *name, ObMenu *parent,
152 menu_controller_show show,
153 menu_controller_update update,
154 menu_controller_selected selected,
155 menu_controller_hide hide,
156 menu_controller_mouseover mouseover,
157 menu_controller_destroy destroy);
159 void menu_free(char *name);
161 void menu_show(char *name, int x, int y, struct _ObClient *client);
162 void menu_show_full(ObMenu *menu, int x, int y, struct _ObClient *client);
164 void menu_hide(ObMenu *self);
166 void menu_clear(ObMenu *self);
168 ObMenuEntry *menu_entry_new_full(char *label, ObAction *action,
169 ObMenuEntryRenderType render_type,
172 #define menu_entry_new(label, action) \
173 menu_entry_new_full(label, action, OB_MENU_ENTRY_RENDER_TYPE_NONE, NULL)
175 #define menu_entry_new_separator(label) \
176 menu_entry_new_full(label, NULL, OB_MENU_ENTRY_RENDER_TYPE_SEPARATOR, NULL)
178 #define menu_entry_new_submenu(label, submenu) \
179 menu_entry_new_full(label, NULL, OB_MENU_ENTRY_RENDER_TYPE_SUBMENU, submenu)
181 #define menu_entry_new_boolean(label, action) \
182 menu_entry_new_full(label, action, OB_MENU_ENTRY_RENDER_TYPE_BOOLEAN, NULL)
184 void menu_entry_free(ObMenuEntry *entry);
186 void menu_entry_set_submenu(ObMenuEntry *entry, ObMenu *submenu);
188 void menu_add_entry(ObMenu *menu, ObMenuEntry *entry);
190 ObMenuEntry *menu_find_entry(ObMenu *menu, Window win);
191 ObMenuEntry *menu_find_entry_by_submenu(ObMenu *menu, ObMenu *submenu);
192 ObMenuEntry *menu_find_entry_by_pos(ObMenu *menu, int x, int y);
194 void menu_entry_render(ObMenuEntry *self);
196 void menu_entry_fire(ObMenuEntry *entry,
197 unsigned int button, unsigned int x, unsigned int y);
199 void menu_render(ObMenu *self);
200 void menu_render_full(ObMenu *self);
202 /*so plugins can call it? */
203 void parse_menu_full(struct _ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
204 void *data, gboolean new);
205 void menu_control_mouseover(ObMenuEntry *entry, gboolean enter);
206 void menu_control_keyboard_nav(unsigned int key);