Change "plain" to "exact" for If's <title>
[openbox.git] / openbox / actions / addremovedesktop.c
blobff6767e29423a14eab5ec46ea102f8e6ee422cd0
1 #include "openbox/actions.h"
2 #include "openbox/screen.h"
3 #include <glib.h>
5 typedef struct {
6 gboolean current;
7 gboolean add;
8 } Options;
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 void free_func(gpointer o);
14 static gboolean run_func(ObActionsData *data, gpointer options);
15 /* 3.4-compatibility */
16 static gpointer setup_addcurrent_func(xmlNodePtr node);
17 static gpointer setup_addlast_func(xmlNodePtr node);
18 static gpointer setup_removecurrent_func(xmlNodePtr node);
19 static gpointer setup_removelast_func(xmlNodePtr node);
21 void action_addremovedesktop_startup(void)
23 actions_register("AddDesktop", setup_add_func, free_func, run_func);
24 actions_register("RemoveDesktop", setup_remove_func, free_func, run_func);
26 /* 3.4-compatibility */
27 actions_register("AddDesktopLast", setup_addlast_func,
28 free_func, run_func);
29 actions_register("RemoveDesktopLast", setup_removelast_func,
30 free_func, run_func);
31 actions_register("AddDesktopCurrent", setup_addcurrent_func,
32 free_func, run_func);
33 actions_register("RemoveDesktopCurrent", setup_removecurrent_func,
34 free_func, run_func);
37 static gpointer setup_func(xmlNodePtr node)
39 xmlNodePtr n;
40 Options *o;
42 o = g_slice_new0(Options);
44 if ((n = obt_xml_find_node(node, "where"))) {
45 gchar *s = obt_xml_node_string(n);
46 if (!g_ascii_strcasecmp(s, "last"))
47 o->current = FALSE;
48 else if (!g_ascii_strcasecmp(s, "current"))
49 o->current = TRUE;
50 g_free(s);
53 return o;
56 static gpointer setup_add_func(xmlNodePtr node)
58 Options *o = setup_func(node);
59 o->add = TRUE;
60 return o;
63 static gpointer setup_remove_func(xmlNodePtr node)
65 Options *o = setup_func(node);
66 o->add = FALSE;
67 return o;
70 static void free_func(gpointer o)
72 g_slice_free(Options, o);
75 /* Always return FALSE because its not interactive */
76 static gboolean run_func(ObActionsData *data, gpointer options)
78 Options *o = options;
80 actions_client_move(data, TRUE);
82 if (o->add)
83 screen_add_desktop(o->current);
84 else
85 screen_remove_desktop(o->current);
87 actions_client_move(data, FALSE);
89 return FALSE;
92 /* 3.4-compatibility */
93 static gpointer setup_addcurrent_func(xmlNodePtr node)
95 Options *o = setup_add_func(node);
96 o->current = TRUE;
97 return o;
100 static gpointer setup_addlast_func(xmlNodePtr node)
102 Options *o = setup_add_func(node);
103 o->current = FALSE;
104 return o;
107 static gpointer setup_removecurrent_func(xmlNodePtr node)
109 Options *o = setup_remove_func(node);
110 o->current = TRUE;
111 return o;
114 static gpointer setup_removelast_func(xmlNodePtr node)
116 Options *o = setup_remove_func(node);
117 o->current = FALSE;
118 return o;