]> icculus.org git repositories - dana/openbox.git/blob - openbox/actions/debug.c
Add action_list_run.c/h with action_list_run() and struct ObActionListRun.
[dana/openbox.git] / openbox / actions / debug.c
1 #include "openbox/action.h"
2 #include "openbox/action_list_run.h"
3 #include "openbox/action_value.h"
4 #include <glib.h>
5
6 typedef struct {
7     gchar   *str;
8 } Options;
9
10 static gpointer setup_func(GHashTable *config);
11 static void     free_func(gpointer options);
12 static gboolean run_func(const ObActionListRun *data, gpointer options);
13
14 void action_debug_startup(void)
15 {
16     action_register("Debug", OB_ACTION_DEFAULT_FILTER_EMPTY,
17                     setup_func, free_func, run_func);
18 }
19
20 static gpointer setup_func(GHashTable *config)
21 {
22     ObActionValue *v;
23     Options *o;
24
25     o = g_slice_new0(Options);
26
27     v = g_hash_table_lookup(config, "string");
28     if (v && action_value_is_string(v))
29         o->str = g_strdup(action_value_string(v));
30     return o;
31 }
32
33 static void free_func(gpointer options)
34 {
35     Options *o = options;
36     g_free(o->str);
37     g_slice_free(Options, o);
38 }
39
40 /* Always return FALSE because its not interactive */
41 static gboolean run_func(const ObActionListRun *data, gpointer options)
42 {
43     Options *o = options;
44
45     if (o->str) g_print("%s\n", o->str);
46
47     return FALSE;
48 }