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
;
117 RrAppearance
*a_item
;
118 RrAppearance
*a_disabled
;
119 RrAppearance
*a_hilite
;
124 typedef struct PluginMenuCreateData
{
128 } PluginMenuCreateData
;
132 void menu_shutdown();
136 #define menu_new(l, n, p) \
137 menu_new_full(l, n, p, menu_show_full, menu_render, menu_entry_fire, \
138 menu_hide, menu_control_mouseover)
140 ObMenu
*menu_new_full(char *label
, char *name
, ObMenu
*parent
,
141 menu_controller_show show
, menu_controller_update update
,
142 menu_controller_selected selected
,
143 menu_controller_hide hide
,
144 menu_controller_mouseover mouseover
);
146 void menu_free(char *name
);
148 void menu_show(char *name
, int x
, int y
, struct _ObClient
*client
);
149 void menu_show_full(ObMenu
*menu
, int x
, int y
, struct _ObClient
*client
);
151 void menu_hide(ObMenu
*self
);
153 void menu_clear(ObMenu
*self
);
155 ObMenuEntry
*menu_entry_new_full(char *label
, Action
*action
,
156 ObMenuEntryRenderType render_type
,
159 #define menu_entry_new(label, action) \
160 menu_entry_new_full(label, action, OB_MENU_ENTRY_RENDER_TYPE_NONE, NULL)
162 #define menu_entry_new_separator(label) \
163 menu_entry_new_full(label, NULL, OB_MENU_ENTRY_RENDER_TYPE_SEPARATOR, NULL)
165 #define menu_entry_new_submenu(label, submenu) \
166 menu_entry_new_full(label, NULL, OB_MENU_ENTRY_RENDER_TYPE_SUBMENU, submenu)
168 #define menu_entry_new_boolean(label, action) \
169 menu_entry_new_full(label, action, OB_MENU_ENTRY_RENDER_TYPE_BOOLEAN, NULL)
171 void menu_entry_free(ObMenuEntry
*entry
);
173 void menu_entry_set_submenu(ObMenuEntry
*entry
, ObMenu
*submenu
);
175 void menu_add_entry(ObMenu
*menu
, ObMenuEntry
*entry
);
177 ObMenuEntry
*menu_find_entry(ObMenu
*menu
, Window win
);
178 ObMenuEntry
*menu_find_entry_by_submenu(ObMenu
*menu
, ObMenu
*submenu
);
179 ObMenuEntry
*menu_find_entry_by_pos(ObMenu
*menu
, int x
, int y
);
181 void menu_entry_render(ObMenuEntry
*self
);
183 void menu_entry_fire(ObMenuEntry
*entry
,
184 unsigned int button
, unsigned int x
, unsigned int y
);
186 void menu_render(ObMenu
*self
);
187 void menu_render_full(ObMenu
*self
);
189 /*so plugins can call it? */
190 void parse_menu_full(xmlDocPtr doc
, xmlNodePtr node
, void *data
, gboolean
new);
191 void menu_control_mouseover(ObMenuEntry
*entry
, gboolean enter
);
192 void menu_control_keyboard_nav(unsigned int key
);