1 #include "openbox/action.h"
2 #include "openbox/action_list_run.h"
3 #include "openbox/config_value.h"
4 #include "openbox/client_set.h"
5 #include "openbox/screen.h"
13 static gpointer setup_func(GHashTable *config);
14 static gpointer setup_add_func(GHashTable *config);
15 static gpointer setup_remove_func(GHashTable *config);
16 static void free_func(gpointer o);
17 static gboolean run_func(const ObClientSet *set,
18 const ObActionListRun *data, gpointer options);
20 void action_addremovedesktop_startup(void)
22 action_register("AddDesktop", OB_ACTION_DEFAULT_FILTER_EMPTY,
23 setup_add_func, free_func, run_func);
24 action_register("RemoveDesktop", OB_ACTION_DEFAULT_FILTER_EMPTY,
25 setup_remove_func, free_func, run_func);
28 static gpointer setup_func(GHashTable *config)
33 o = g_slice_new0(Options);
35 v = g_hash_table_lookup(config, "where");
36 if (v && config_value_is_string(v)) {
37 const gchar *s = config_value_string(v);
38 if (!g_ascii_strcasecmp(s, "last"))
40 else if (!g_ascii_strcasecmp(s, "current"))
47 static gpointer setup_add_func(GHashTable *config)
49 Options *o = setup_func(config);
54 static gpointer setup_remove_func(GHashTable *config)
56 Options *o = setup_func(config);
61 static void free_func(gpointer o)
63 g_slice_free(Options, o);
66 /* Always return FALSE because its not interactive */
67 static gboolean run_func(const ObClientSet *set,
68 const ObActionListRun *data, gpointer options)
72 action_client_move(data, TRUE);
75 screen_add_desktop(o->current);
77 screen_remove_desktop(o->current);
79 action_client_move(data, FALSE);