]> Dogcows Code - chaz/openbox/blob - openbox/actions/maximizehorizontal.c
abb8a8e1e665b2deee40f30f7bcbae1256dcefcc
[chaz/openbox] / openbox / actions / maximizehorizontal.c
1 #include "openbox/actions.h"
2 #include "openbox/client.h"
3
4 typedef struct {
5 gboolean toggle;
6 gboolean on;
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_maximizehorizontal_startup()
14 {
15 actions_register("MaximizeHorizontal",
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 o->toggle = TRUE;
29
30 if ((n = parse_find_node("state", node))) {
31 gchar *s = parse_string(doc, n);
32 if (g_ascii_strcasecmp(s, "toggle")) {
33 o->toggle = FALSE;
34 o->on = parse_bool(doc, n);
35 }
36 g_free(s);
37 }
38
39 return o;
40 }
41
42 static void free_func(gpointer options)
43 {
44 Options *o = options;
45
46 g_free(o);
47 }
48
49 /* Always return FALSE because its not interactive */
50 static gboolean run_func(ObActionsData *data, gpointer options)
51 {
52 Options *o = options;
53
54 if (data->client) {
55 actions_client_move(data, TRUE);
56
57 if (o->toggle)
58 client_maximize(data->client, !data->client->max_horz, 1);
59 else
60 client_maximize(data->client, o->on, 1);
61
62 actions_client_move(data, FALSE);
63 }
64
65 return FALSE;
66 }
This page took 0.034068 seconds and 3 git commands to generate.