1 #include "openbox/actions.h"
2 #include "openbox/screen.h"
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 /* 3.4-compatibility */
15 static gpointer setup_addcurrent_func(xmlNodePtr node);
16 static gpointer setup_addlast_func(xmlNodePtr node);
17 static gpointer setup_removecurrent_func(xmlNodePtr node);
18 static gpointer setup_removelast_func(xmlNodePtr node);
20 void action_addremovedesktop_startup(void)
22 actions_register("AddDesktop", setup_add_func, g_free, run_func);
23 actions_register("RemoveDesktop", setup_remove_func, g_free, run_func);
25 /* 3.4-compatibility */
26 actions_register("AddDesktopLast", setup_addlast_func, g_free, run_func);
27 actions_register("RemoveDesktopLast", setup_removelast_func,
29 actions_register("AddDesktopCurrent", setup_addcurrent_func,
31 actions_register("RemoveDesktopCurrent", setup_removecurrent_func,
35 static gpointer setup_func(xmlNodePtr node)
40 o = g_new0(Options, 1);
42 if ((n = obt_xml_find_node(node, "where"))) {
43 gchar *s = obt_xml_node_string(n);
44 if (!g_ascii_strcasecmp(s, "last"))
46 else if (!g_ascii_strcasecmp(s, "current"))
54 static gpointer setup_add_func(xmlNodePtr node)
56 Options *o = setup_func(node);
61 static gpointer setup_remove_func(xmlNodePtr node)
63 Options *o = setup_func(node);
68 /* Always return FALSE because its not interactive */
69 static gboolean run_func(ObActionsData *data, gpointer options)
73 actions_client_move(data, TRUE);
76 screen_add_desktop(o->current);
78 screen_remove_desktop(o->current);
80 actions_client_move(data, FALSE);
85 /* 3.4-compatibility */
86 static gpointer setup_addcurrent_func(xmlNodePtr node)
88 Options *o = setup_add_func(node);
93 static gpointer setup_addlast_func(xmlNodePtr node)
95 Options *o = setup_add_func(node);
100 static gpointer setup_removecurrent_func(xmlNodePtr node)
102 Options *o = setup_remove_func(node);
107 static gpointer setup_removelast_func(xmlNodePtr node)
109 Options *o = setup_remove_func(node);