Merge branch 'backport' into work
[dana/openbox.git] / openbox / actions / restart.c
1 #include "openbox/actions.h"
2 #include "openbox/openbox.h"
3 #include "obt/paths.h"
4
5 typedef struct {
6     gchar   *cmd;
7 } Options;
8
9 static gpointer setup_func(xmlNodePtr node);
10 static void     free_func(gpointer options);
11 static gboolean run_func(ObActionsData *data, gpointer options);
12
13 void action_restart_startup(void)
14 {
15     actions_register("Restart", setup_func, free_func, run_func, NULL, NULL);
16 }
17
18 static gpointer setup_func(xmlNodePtr node)
19 {
20     xmlNodePtr n;
21     Options *o;
22
23     o = g_new0(Options, 1);
24
25     if ((n = obt_parse_find_node(node, "command")) ||
26         (n = obt_parse_find_node(node, "execute")))
27     {
28         gchar *s = obt_parse_node_string(n);
29         o->cmd = obt_paths_expand_tilde(s);
30         g_free(s);
31     }
32     return o;
33 }
34
35 static void free_func(gpointer options)
36 {
37     Options *o = options;
38     g_free(o->cmd);
39     g_free(o);
40 }
41
42 /* Always return FALSE because its not interactive */
43 static gboolean run_func(ObActionsData *data, gpointer options)
44 {
45     Options *o = options;
46
47     ob_restart_other(o->cmd);
48
49     return FALSE;
50 }