]> Dogcows Code - chaz/openbox/blob - openbox/actions/addremovedesktop.c
update openbox to use the current parser interface in libobt
[chaz/openbox] / openbox / actions / addremovedesktop.c
1 #include "openbox/actions.h"
2 #include "openbox/screen.h"
3 #include <glib.h>
4
5 typedef struct {
6 gboolean current;
7 gboolean add;
8 } Options;
9
10 static gpointer setup_func(xmlNodePtr node);
11 static gpointer setup_add_func(xmlNodePtr node);
12 static gpointer setup_remove_func(xmlNodePtr node);
13 static gboolean run_func(ObActionsData *data, gpointer options);
14
15 void action_addremovedesktop_startup(void)
16 {
17 actions_register("AddDesktop", setup_add_func, g_free, run_func,
18 NULL, NULL);
19 actions_register("RemoveDesktop", setup_remove_func, g_free, run_func,
20 NULL, NULL);
21 }
22
23 static gpointer setup_func(xmlNodePtr node)
24 {
25 xmlNodePtr n;
26 Options *o;
27
28 o = g_new0(Options, 1);
29
30 if ((n = obt_parse_find_node(node, "where"))) {
31 gchar *s = obt_parse_node_string(n);
32 if (!g_ascii_strcasecmp(s, "last"))
33 o->current = FALSE;
34 else if (!g_ascii_strcasecmp(s, "current"))
35 o->current = TRUE;
36 g_free(s);
37 }
38
39 return o;
40 }
41
42 static gpointer setup_add_func(xmlNodePtr node)
43 {
44 Options *o = setup_func(node);
45 o->add = TRUE;
46 return o;
47 }
48
49 static gpointer setup_remove_func(xmlNodePtr node)
50 {
51 Options *o = setup_func(node);
52 o->add = FALSE;
53 return o;
54 }
55
56 /* Always return FALSE because its not interactive */
57 static gboolean run_func(ObActionsData *data, gpointer options)
58 {
59 Options *o = options;
60
61 actions_client_move(data, TRUE);
62
63 if (o->add)
64 screen_add_desktop(o->current);
65 else
66 screen_remove_desktop(o->current);
67
68 actions_client_move(data, FALSE);
69
70 return FALSE;
71 }
This page took 0.038781 seconds and 4 git commands to generate.