1 #include "openbox/actions.h"
2 #include "openbox/misc.h"
3 #include "openbox/client.h"
4 #include "openbox/frame.h"
5 #include "openbox/screen.h"
23 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
24 static void free_func(gpointer options);
25 static gboolean run_func(ObActionsData *data, gpointer options);
27 void action_if_startup()
29 actions_register("If",
36 static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
41 o = g_new0(Options, 1);
43 if ((n = parse_find_node("shaded", node))) {
44 if (parse_bool(doc, n))
49 if ((n = parse_find_node("maximized", node))) {
50 if (parse_bool(doc, n))
53 o->maxfull_off = TRUE;
55 if ((n = parse_find_node("maximizedhorizontal", node))) {
56 if (parse_bool(doc, n))
59 o->maxhorz_off = TRUE;
61 if ((n = parse_find_node("maximizedvertical", node))) {
62 if (parse_bool(doc, n))
65 o->maxvert_off = TRUE;
67 if ((n = parse_find_node("iconified", node))) {
68 if (parse_bool(doc, n))
74 if ((n = parse_find_node("then", node))) {
77 m = parse_find_node("action", n->xmlChildrenNode);
79 ObActionsAct *action = actions_parse(i, doc, m);
80 if (action) o->thenacts = g_slist_prepend(o->thenacts, action);
81 m = parse_find_node("action", m->next);
84 if ((n = parse_find_node("else", node))) {
87 m = parse_find_node("action", n->xmlChildrenNode);
89 ObActionsAct *action = actions_parse(i, doc, m);
90 if (action) o->elseacts = g_slist_prepend(o->elseacts, action);
91 m = parse_find_node("action", m->next);
98 static void free_func(gpointer options)
100 Options *o = options;
105 /* Always return FALSE because its not interactive */
106 static gboolean run_func(ObActionsData *data, gpointer options)
108 Options *o = options;
110 ObClient *c = data->client;
112 if ((!o->shaded_on || (c && c->shaded)) &&
113 (!o->shaded_off || (c && !c->shaded)) &&
114 (!o->iconic_on || (c && c->iconic)) &&
115 (!o->iconic_off || (c && !c->iconic)) &&
116 (!o->maxhorz_on || (c && c->max_horz)) &&
117 (!o->maxhorz_off || (c && !c->max_horz)) &&
118 (!o->maxvert_on || (c && c->max_vert)) &&
119 (!o->maxvert_off || (c && !c->max_vert)) &&
120 (!o->maxfull_on || (c && c->max_vert && c->max_horz)) &&
121 (!o->maxfull_off || (c && !(c->max_vert && c->max_horz))))
128 actions_run_acts(acts, data->uact, data->state,
129 data->x, data->y, data->button,
130 data->context, data->client);