]> Dogcows Code - chaz/openbox/blob - openbox/actions/showmenu.c
more using g_slice_new() instead of g_new()
[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 }
17
18 static gpointer setup_func(xmlNodePtr node)
19 {
20 xmlNodePtr n;
21 Options *o;
22
23 o = g_slice_new0(Options);
24
25 if ((n = obt_xml_find_node(node, "menu")))
26 o->name = obt_xml_node_string(n);
27 return o;
28 }
29
30 static void free_func(gpointer options)
31 {
32 Options *o = options;
33 g_free(o->name);
34 g_slice_free(Options, o);
35 }
36
37 /* Always return FALSE because its not interactive */
38 static gboolean run_func(ObActionsData *data, gpointer options)
39 {
40 Options *o = options;
41
42 /* you cannot call ShowMenu from inside a menu */
43 if (data->uact != OB_USER_ACTION_MENU_SELECTION && o->name)
44 menu_show(o->name, data->x, data->y, data->button != 0, data->client);
45
46 return FALSE;
47 }
This page took 0.035054 seconds and 4 git commands to generate.