6 #include "render/render.h"
13 typedef struct _ObMenu ObMenu
;
14 typedef struct _ObMenuEntry ObMenuEntry
;
16 typedef void(*menu_controller_show
)(ObMenu
*self
, int x
, int y
,
18 typedef void(*menu_controller_update
)(ObMenu
*self
);
19 typedef void(*menu_controller_mouseover
)(ObMenuEntry
*self
, gboolean enter
);
20 typedef void(*menu_controller_selected
)(ObMenuEntry
*entry
,
22 unsigned int x
, unsigned int y
);
23 typedef void(*menu_controller_hide
)(ObMenu
*self
);
26 extern GHashTable
*menu_hash
;
27 extern GList
*menu_visible
;
33 /* The title displayed above the menu.
34 NULL for no titlebar */
38 Used in the action showmenu */
41 /* ObMenuEntry list */
44 /* If the menu is currently displayed */
47 /* If the rendering of the menu has changed and needs to be rerendered. */
50 /* Kind of lame.Each menu can only be a submenu, and each menu can only
51 have one submenu open */
56 /* behaviour callbacks
57 TODO: Document and split code that HAS to be in the overridden callback */
58 /* place a menu on screen */
59 menu_controller_show show
;
61 menu_controller_hide hide
;
63 menu_controller_update update
;
64 /* Event for a mouse enter/exit on an entry
65 TODO: May have to split from simple render updating?
67 menu_controller_mouseover mouseover
;
68 /* Entry is clicked/hit enter on */
69 menu_controller_selected selected
;
73 struct _ObClient
*client
;
76 RrAppearance
*a_title
;
77 gint title_min_w
, title_h
;
79 RrAppearance
*a_items
;
84 guint xin_area
; /* index of the xinerama head/area */
86 /* Name of plugin for menu */
94 OB_MENU_ENTRY_RENDER_TYPE_NONE
,
95 OB_MENU_ENTRY_RENDER_TYPE_SUBMENU
,
96 OB_MENU_ENTRY_RENDER_TYPE_BOOLEAN
,
97 OB_MENU_ENTRY_RENDER_TYPE_SEPARATOR
,
98 OB_MENU_ENTRY_RENDER_TYPE_OTHER
/* XXX what is this? */
99 } ObMenuEntryRenderType
;
108 ObMenuEntryRenderType render_type
;
111 gboolean boolean_value
;
119 RrAppearance
*a_item
;
120 RrAppearance
*a_disabled
;
121 RrAppearance
*a_hilite
;
122 RrAppearance
*a_submenu
;
127 typedef struct PluginMenuCreateData
{
131 } PluginMenuCreateData
;
135 void menu_shutdown();
139 #define menu_new(l, n, p) \
140 menu_new_full(l, n, p, menu_show_full, menu_render, menu_entry_fire, \
141 menu_hide, menu_control_mouseover)
143 ObMenu
*menu_new_full(char *label
, char *name
, ObMenu
*parent
,
144 menu_controller_show show
, menu_controller_update update
,
145 menu_controller_selected selected
,
146 menu_controller_hide hide
,
147 menu_controller_mouseover mouseover
);
149 void menu_free(char *name
);
151 void menu_show(char *name
, int x
, int y
, struct _ObClient
*client
);
152 void menu_show_full(ObMenu
*menu
, int x
, int y
, struct _ObClient
*client
);
154 void menu_hide(ObMenu
*self
);
156 void menu_clear(ObMenu
*self
);
158 ObMenuEntry
*menu_entry_new_full(char *label
, ObAction
*action
,
159 ObMenuEntryRenderType render_type
,
162 #define menu_entry_new(label, action) \
163 menu_entry_new_full(label, action, OB_MENU_ENTRY_RENDER_TYPE_NONE, NULL)
165 #define menu_entry_new_separator(label) \
166 menu_entry_new_full(label, NULL, OB_MENU_ENTRY_RENDER_TYPE_SEPARATOR, NULL)
168 #define menu_entry_new_submenu(label, submenu) \
169 menu_entry_new_full(label, NULL, OB_MENU_ENTRY_RENDER_TYPE_SUBMENU, submenu)
171 #define menu_entry_new_boolean(label, action) \
172 menu_entry_new_full(label, action, OB_MENU_ENTRY_RENDER_TYPE_BOOLEAN, NULL)
174 void menu_entry_free(ObMenuEntry
*entry
);
176 void menu_entry_set_submenu(ObMenuEntry
*entry
, ObMenu
*submenu
);
178 void menu_add_entry(ObMenu
*menu
, ObMenuEntry
*entry
);
180 ObMenuEntry
*menu_find_entry(ObMenu
*menu
, Window win
);
181 ObMenuEntry
*menu_find_entry_by_submenu(ObMenu
*menu
, ObMenu
*submenu
);
182 ObMenuEntry
*menu_find_entry_by_pos(ObMenu
*menu
, int x
, int y
);
184 void menu_entry_render(ObMenuEntry
*self
);
186 void menu_entry_fire(ObMenuEntry
*entry
,
187 unsigned int button
, unsigned int x
, unsigned int y
);
189 void menu_render(ObMenu
*self
);
190 void menu_render_full(ObMenu
*self
);
192 /*so plugins can call it? */
193 void parse_menu_full(xmlDocPtr doc
, xmlNodePtr node
, void *data
, gboolean
new);
194 void menu_control_mouseover(ObMenuEntry
*entry
, gboolean enter
);
195 void menu_control_keyboard_nav(unsigned int key
);