6 #include "render/render.h"
14 typedef struct _ObMenu ObMenu
;
15 typedef struct _ObMenuEntry ObMenuEntry
;
17 typedef void(*menu_controller_show
)(ObMenu
*self
, int x
, int y
,
19 typedef void(*menu_controller_update
)(ObMenu
*self
);
20 typedef void(*menu_controller_mouseover
)(ObMenuEntry
*self
, gboolean enter
);
21 typedef void(*menu_controller_selected
)(ObMenuEntry
*entry
,
23 unsigned int x
, unsigned int y
);
24 typedef void(*menu_controller_hide
)(ObMenu
*self
);
27 extern GHashTable
*menu_hash
;
28 extern GList
*menu_visible
;
34 /* The title displayed above the menu.
35 NULL for no titlebar */
39 Used in the action showmenu */
42 /* ObMenuEntry list */
45 /* If the menu is currently displayed */
48 /* If the rendering of the menu has changed and needs to be rerendered. */
51 /* Kind of lame.Each menu can only be a submenu, and each menu can only
52 have one submenu open */
57 /* behaviour callbacks
58 TODO: Document and split code that HAS to be in the overridden callback */
59 /* place a menu on screen */
60 menu_controller_show show
;
62 menu_controller_hide hide
;
64 menu_controller_update update
;
65 /* Event for a mouse enter/exit on an entry
66 TODO: May have to split from simple render updating?
68 menu_controller_mouseover mouseover
;
69 /* Entry is clicked/hit enter on */
70 menu_controller_selected selected
;
74 struct _ObClient
*client
;
77 RrAppearance
*a_title
;
78 gint title_min_w
, title_h
;
80 RrAppearance
*a_items
;
85 guint xin_area
; /* index of the xinerama head/area */
87 /* Name of plugin for menu */
95 OB_MENU_ENTRY_RENDER_TYPE_NONE
,
96 OB_MENU_ENTRY_RENDER_TYPE_SUBMENU
,
97 OB_MENU_ENTRY_RENDER_TYPE_BOOLEAN
,
98 OB_MENU_ENTRY_RENDER_TYPE_SEPARATOR
,
99 OB_MENU_ENTRY_RENDER_TYPE_OTHER
/* XXX what is this? */
100 } ObMenuEntryRenderType
;
109 ObMenuEntryRenderType render_type
;
112 gboolean boolean_value
;
120 RrAppearance
*a_item
;
121 RrAppearance
*a_disabled
;
122 RrAppearance
*a_hilite
;
123 RrAppearance
*a_submenu
;
128 typedef struct PluginMenuCreateData
{
129 struct _ObParseInst
*parse_inst
;
133 } PluginMenuCreateData
;
137 void menu_shutdown();
143 #define menu_new(l, n, p) \
144 menu_new_full(l, n, p, menu_show_full, menu_render, menu_entry_fire, \
145 menu_hide, menu_control_mouseover)
147 ObMenu
*menu_new_full(char *label
, char *name
, ObMenu
*parent
,
148 menu_controller_show show
, menu_controller_update update
,
149 menu_controller_selected selected
,
150 menu_controller_hide hide
,
151 menu_controller_mouseover mouseover
);
153 void menu_free(char *name
);
155 void menu_show(char *name
, int x
, int y
, struct _ObClient
*client
);
156 void menu_show_full(ObMenu
*menu
, int x
, int y
, struct _ObClient
*client
);
158 void menu_hide(ObMenu
*self
);
160 void menu_clear(ObMenu
*self
);
162 ObMenuEntry
*menu_entry_new_full(char *label
, ObAction
*action
,
163 ObMenuEntryRenderType render_type
,
166 #define menu_entry_new(label, action) \
167 menu_entry_new_full(label, action, OB_MENU_ENTRY_RENDER_TYPE_NONE, NULL)
169 #define menu_entry_new_separator(label) \
170 menu_entry_new_full(label, NULL, OB_MENU_ENTRY_RENDER_TYPE_SEPARATOR, NULL)
172 #define menu_entry_new_submenu(label, submenu) \
173 menu_entry_new_full(label, NULL, OB_MENU_ENTRY_RENDER_TYPE_SUBMENU, submenu)
175 #define menu_entry_new_boolean(label, action) \
176 menu_entry_new_full(label, action, OB_MENU_ENTRY_RENDER_TYPE_BOOLEAN, NULL)
178 void menu_entry_free(ObMenuEntry
*entry
);
180 void menu_entry_set_submenu(ObMenuEntry
*entry
, ObMenu
*submenu
);
182 void menu_add_entry(ObMenu
*menu
, ObMenuEntry
*entry
);
184 ObMenuEntry
*menu_find_entry(ObMenu
*menu
, Window win
);
185 ObMenuEntry
*menu_find_entry_by_submenu(ObMenu
*menu
, ObMenu
*submenu
);
186 ObMenuEntry
*menu_find_entry_by_pos(ObMenu
*menu
, int x
, int y
);
188 void menu_entry_render(ObMenuEntry
*self
);
190 void menu_entry_fire(ObMenuEntry
*entry
,
191 unsigned int button
, unsigned int x
, unsigned int y
);
193 void menu_render(ObMenu
*self
);
194 void menu_render_full(ObMenu
*self
);
196 /*so plugins can call it? */
197 void parse_menu_full(struct _ObParseInst
*i
, xmlDocPtr doc
, xmlNodePtr node
,
198 void *data
, gboolean
new);
199 void menu_control_mouseover(ObMenuEntry
*entry
, gboolean enter
);
200 void menu_control_keyboard_nav(unsigned int key
);