]> icculus.org git repositories - dana/openbox.git/blob - openbox/actions/restart.c
Pass a client set to all actions, and make focus cycling use a client set.
[dana/openbox.git] / openbox / actions / restart.c
1 #include "openbox/action.h"
2 #include "openbox/action_list_run.h"
3 #include "openbox/action_value.h"
4 #include "openbox/client_set.h"
5 #include "openbox/openbox.h"
6 #include "obt/paths.h"
7
8 typedef struct {
9     gchar   *cmd;
10 } Options;
11
12 static gpointer setup_func(GHashTable *config);
13 static void     free_func(gpointer options);
14 static gboolean run_func(const ObClientSet *set,
15                          const ObActionListRun *data, gpointer options);
16
17 void action_restart_startup(void)
18 {
19     action_register("Restart", OB_ACTION_DEFAULT_FILTER_EMPTY,
20                     setup_func, free_func, run_func);
21 }
22
23 static gpointer setup_func(GHashTable *config)
24 {
25     ObActionValue *v;
26     Options *o;
27
28     o = g_slice_new0(Options);
29
30     v = g_hash_table_lookup(config, "command");
31     if (v && action_value_is_string(v))
32         o->cmd = obt_paths_expand_tilde(action_value_string(v));
33     return o;
34 }
35
36 static void free_func(gpointer options)
37 {
38     Options *o = options;
39     g_free(o->cmd);
40     g_slice_free(Options, o);
41 }
42
43 /* Always return FALSE because its not interactive */
44 static gboolean run_func(const ObClientSet *set,
45                          const ObActionListRun *data, gpointer options)
46 {
47     Options *o = options;
48
49     ob_restart_other(o->cmd);
50
51     return FALSE;
52 }