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