add directionaldesktop action
[dana/openbox-history.git] / openbox / actions / desktop.c
1 #include "openbox/actions.h"
2 #include "openbox/screen.h"
3 #include <glib.h>
4
5 typedef struct {
6     guint desktop;
7 } Options;
8
9 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
10 static void     free_func(gpointer options);
11 static gboolean run_func(ObActionsData *data, gpointer options);
12
13 void action_desktop_startup()
14 {
15     actions_register("Desktop",
16                      setup_func,
17                      free_func,
18                      run_func,
19                      NULL, NULL);
20 }
21
22 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
23 {
24     xmlNodePtr n;
25     Options *o;
26
27     o = g_new0(Options, 1);
28
29     if ((n = parse_find_node("desktop", node)))
30         o->desktop = parse_int(doc, n) - 1;
31     return o;
32 }
33
34 static void free_func(gpointer options)
35 {
36     Options *o = options;
37
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     if (o->desktop < screen_num_desktops)
47         screen_set_desktop(o->desktop, TRUE);
48
49     return FALSE;
50 }