]> Dogcows Code - chaz/openbox/blob - openbox/actions/showmenu.c
add the move action
[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(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
10 static void free_func(gpointer options);
11 static gboolean run_func(ObActionsData *data, gpointer options);
12
13 void action_showmenu_startup()
14 {
15 actions_register("ShowMenu",
16 setup_func,
17 free_func,
18 run_func,
19 NULL, NULL);
20 }
21
22 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
23 {
24 xmlNodePtr n;
25 Options *o;
26
27 o = g_new0(Options, 1);
28
29 if ((n = parse_find_node("menu", node)))
30 o->name = parse_string(doc, n);
31 return o;
32 }
33
34 static void free_func(gpointer options)
35 {
36 Options *o = options;
37
38 if (o) {
39 g_free(o->name);
40 g_free(o);
41 }
42 }
43
44 /* Always return FALSE because its not interactive */
45 static gboolean run_func(ObActionsData *data, gpointer options)
46 {
47 Options *o = options;
48
49 /* you cannot call ShowMenu from inside a menu */
50 if (data->uact == OB_USER_ACTION_MENU_SELECTION) return FALSE;
51
52 if (o->name) {
53 menu_show(o->name, data->x, data->y, data->button != 0, data->client);
54 }
55
56 return FALSE;
57 }
This page took 0.036173 seconds and 4 git commands to generate.