Add an action AllClients that runs actions on all windows.
authorMikael Magnusson <mikachu@comhem.se>
Sat, 1 Mar 2008 17:23:52 +0000 (18:23 +0100)
committerMikael Magnusson <mikachu@comhem.se>
Sat, 8 Mar 2008 16:24:09 +0000 (17:24 +0100)
Add <action> tags as children to it, obviously intended for use with
the If action.

Makefile.am
openbox/actions/all.c
openbox/actions/all.h
openbox/actions/allclients.c [new file with mode: 0644]

index e14fd8f..b5e132d 100644 (file)
@@ -171,6 +171,7 @@ openbox_openbox_SOURCES = \
        gettext.h \
        openbox/actions/all.c \
        openbox/actions/all.h \
+       openbox/actions/allclients.c \
        openbox/actions/addremovedesktop.c \
        openbox/actions/breakchroot.c \
        openbox/actions/close.c \
index 9b4284e..5bb7163 100644 (file)
@@ -41,4 +41,5 @@ void action_all_startup(void)
     action_focustobottom_startup();
     action_sendkeyevent_startup();
     action_lock_startup();
+    action_zenbu_startup();
 }
index f444aae..9890ea5 100644 (file)
@@ -42,5 +42,6 @@ void action_if_startup(void);
 void action_focustobottom_startup(void);
 void action_sendkeyevent_startup(void);
 void action_lock_startup(void);
+void action_zenbu_startup(void);
 
 #endif
diff --git a/openbox/actions/allclients.c b/openbox/actions/allclients.c
new file mode 100644 (file)
index 0000000..d7af806
--- /dev/null
@@ -0,0 +1,54 @@
+#include "openbox/actions.h"
+#include "openbox/event.h"
+#include "openbox/client.h"
+
+static gpointer setup_func(xmlNodePtr node);
+static void     free_func(gpointer acts);
+static gboolean run_func(ObActionsData *data, gpointer options);
+
+void action_allclients_startup(void)
+{
+    actions_register("AllClients", setup_func, free_func, run_func, NULL, NULL);
+}
+
+static gpointer setup_func(xmlNodePtr node)
+{
+    xmlNodePtr n;
+    GSList *acts = NULL;
+
+    n = obt_parse_find_node(node, "action");
+    while (n) {
+        ObActionsAct *action = actions_parse(n);
+        if (action) acts = g_slist_prepend(acts, action);
+        n = obt_parse_find_node(n->next, "action");
+    }
+
+    return acts;
+}
+
+static void free_func(gpointer acts)
+{
+    GSList *a = acts;
+
+    while (a) {
+        actions_act_unref(a->data);
+        a = g_slist_delete_link(a, a);
+    }
+}
+
+/* Always return FALSE because its not interactive */
+static gboolean run_func(ObActionsData *data, gpointer acts)
+{
+    GList *it;
+    GSList *a = acts;
+
+    if (a)
+        for (it = client_list; it; it = g_list_next(it)) {
+            ObClient *c = it->data;
+            actions_run_acts(a, data->uact, data->state,
+                             data->x, data->y, data->button,
+                             data->context, c);
+        }
+
+    return FALSE;
+}