]> Dogcows Code - chaz/openbox/blob - openbox/actions/showmenu.c
update openbox to use the current parser interface in libobt
[chaz/openbox] / openbox / actions / showmenu.c
1 #include "openbox/actions.h"
2 #include "openbox/menu.h"
3 #include <glib.h>
4
5 typedef struct {
6 gchar *name;
7 } Options;
8
9 static gpointer setup_func(xmlNodePtr node);
10 static void free_func(gpointer options);
11 static gboolean run_func(ObActionsData *data, gpointer options);
12
13 void action_showmenu_startup(void)
14 {
15 actions_register("ShowMenu", setup_func, free_func, run_func,
16 NULL, NULL);
17 }
18
19 static gpointer setup_func(xmlNodePtr node)
20 {
21 xmlNodePtr n;
22 Options *o;
23
24 o = g_new0(Options, 1);
25
26 if ((n = obt_parse_find_node(node, "menu")))
27 o->name = obt_parse_node_string(n);
28 return o;
29 }
30
31 static void free_func(gpointer options)
32 {
33 Options *o = options;
34 g_free(o->name);
35 g_free(o);
36 }
37
38 /* Always return FALSE because its not interactive */
39 static gboolean run_func(ObActionsData *data, gpointer options)
40 {
41 Options *o = options;
42
43 /* you cannot call ShowMenu from inside a menu */
44 if (data->uact != OB_USER_ACTION_MENU_SELECTION && o->name)
45 menu_show(o->name, data->x, data->y, data->button != 0, data->client);
46
47 return FALSE;
48 }
This page took 0.035634 seconds and 4 git commands to generate.