1 #include "openbox/action.h"
2 #include "openbox/action_list_run.h"
3 #include "openbox/action_value.h"
4 #include "openbox/screen.h"
12 static gpointer setup_func(GHashTable *config);
13 static gpointer setup_add_func(GHashTable *config);
14 static gpointer setup_remove_func(GHashTable *config);
15 static void free_func(gpointer o);
16 static gboolean run_func(const ObActionListRun *data, gpointer options);
18 void action_addremovedesktop_startup(void)
20 action_register("AddDesktop", OB_ACTION_DEFAULT_FILTER_EMPTY,
21 setup_add_func, free_func, run_func);
22 action_register("RemoveDesktop", OB_ACTION_DEFAULT_FILTER_EMPTY,
23 setup_remove_func, free_func, run_func);
26 static gpointer setup_func(GHashTable *config)
31 o = g_slice_new0(Options);
33 v = g_hash_table_lookup(config, "where");
34 if (v && action_value_is_string(v)) {
35 const gchar *s = action_value_string(v);
36 if (!g_ascii_strcasecmp(s, "last"))
38 else if (!g_ascii_strcasecmp(s, "current"))
45 static gpointer setup_add_func(GHashTable *config)
47 Options *o = setup_func(config);
52 static gpointer setup_remove_func(GHashTable *config)
54 Options *o = setup_func(config);
59 static void free_func(gpointer o)
61 g_slice_free(Options, o);
64 /* Always return FALSE because its not interactive */
65 static gboolean run_func(const ObActionListRun *data, gpointer options)
69 action_client_move(data, TRUE);
72 screen_add_desktop(o->current);
74 screen_remove_desktop(o->current);
76 action_client_move(data, FALSE);