add directionaldesktop action
authorDana Jansens <danakj@orodu.net>
Fri, 22 Jun 2007 19:10:00 +0000 (19:10 +0000)
committerDana Jansens <danakj@orodu.net>
Fri, 22 Jun 2007 19:10:00 +0000 (19:10 +0000)
Makefile.am
openbox/action.c
openbox/actions/all.c
openbox/actions/all.h
openbox/actions/desktop.c
openbox/actions/directionalcyclewindows.c
openbox/actions/directionaldesktop.c [new file with mode: 0644]
openbox/actions/directionaltargetwindow.c

index 5134c9c..63c3f84 100644 (file)
@@ -163,6 +163,7 @@ openbox_openbox_SOURCES = \
        openbox/actions/decorations.c \
        openbox/actions/desktop.c \
        openbox/actions/directionalcyclewindows.c \
+       openbox/actions/directionaldesktop.c \
        openbox/actions/directionaltargetwindow.c \
        openbox/actions/execute.c \
        openbox/actions/exit.c \
index 58a0e61..be54a00 100644 (file)
@@ -391,36 +391,6 @@ ActionString actionstrings[] =
         setup_action_send_to_desktop_down
     },
     {
-        "desktopnext",
-        action_desktop_dir,
-        setup_action_desktop_next
-    },
-    {
-        "desktopprevious",
-        action_desktop_dir,
-        setup_action_desktop_prev
-    },
-    {
-        "desktopright",
-        action_desktop_dir,
-        setup_action_desktop_right
-    },
-    {
-        "desktopleft",
-        action_desktop_dir,
-        setup_action_desktop_left
-    },
-    {
-        "desktopup",
-        action_desktop_dir,
-        setup_action_desktop_up
-    },
-    {
-        "desktopdown",
-        action_desktop_dir,
-        setup_action_desktop_down
-    },
-    {
         "toggledockautohide",
         action_toggle_dockautohide,
         NULL
@@ -607,12 +577,6 @@ ObAction *action_parse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
                 if (act->data.sendto.desk > 0) act->data.sendto.desk--;
                 if ((n = parse_find_node("follow", node->xmlChildrenNode)))
                     act->data.sendto.follow = parse_bool(doc, n);
-            } else if (act->func == action_desktop_dir) {
-                if ((n = parse_find_node("wrap", node->xmlChildrenNode)))
-                    act->data.desktopdir.wrap = parse_bool(doc, n); 
-                if ((n = parse_find_node("dialog", node->xmlChildrenNode)))
-                    act->data.desktopdir.inter.any.interactive =
-                        parse_bool(doc, n);
             } else if (act->func == action_send_to_desktop_dir) {
                 if ((n = parse_find_node("wrap", node->xmlChildrenNode)))
                     act->data.sendtodir.wrap = parse_bool(doc, n);
index 3fb4f81..cb3f987 100644 (file)
@@ -33,4 +33,5 @@ void action_all_startup()
     action_resize_startup();
     action_decorations_startup();
     action_desktop_startup();
+    action_directionaldesktop_startup();
 }
index 290c8f1..ea0a3d2 100644 (file)
@@ -34,5 +34,6 @@ void action_directionaltargetwindow_startup();
 void action_resize_startup();
 void action_decorations_startup();
 void action_desktop_startup();
+void action_directionaldesktop_startup();
 
 #endif
index 7461d84..2d2014e 100644 (file)
@@ -12,7 +12,7 @@ static gboolean run_func(ObActionsData *data, gpointer options);
 
 void action_desktop_startup()
 {
-    actions_register("desktop",
+    actions_register("Desktop",
                      setup_func,
                      free_func,
                      run_func,
index 6554eef..65cc05b 100644 (file)
@@ -50,17 +50,21 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
         o->desktop_windows = parse_bool(doc, n);
     if ((n = parse_find_node("direction", node))) {
         gchar *s = parse_string(doc, n);
-        if (!g_ascii_strcasecmp(s, "north"))
+        if (!g_ascii_strcasecmp(s, "north") ||
+            !g_ascii_strcasecmp(s, "up"))
             o->direction = OB_DIRECTION_NORTH;
         else if (!g_ascii_strcasecmp(s, "northwest"))
             o->direction = OB_DIRECTION_NORTHWEST;
         else if (!g_ascii_strcasecmp(s, "northeast"))
             o->direction = OB_DIRECTION_NORTHEAST;
-        else if (!g_ascii_strcasecmp(s, "west"))
+        else if (!g_ascii_strcasecmp(s, "west") ||
+                 !g_ascii_strcasecmp(s, "left"))
             o->direction = OB_DIRECTION_WEST;
-        else if (!g_ascii_strcasecmp(s, "east"))
+        else if (!g_ascii_strcasecmp(s, "east") ||
+                 !g_ascii_strcasecmp(s, "right"))
             o->direction = OB_DIRECTION_EAST;
-        else if (!g_ascii_strcasecmp(s, "south"))
+        else if (!g_ascii_strcasecmp(s, "south") ||
+                 !g_ascii_strcasecmp(s, "down"))
             o->direction = OB_DIRECTION_NORTH;
         else if (!g_ascii_strcasecmp(s, "southwest"))
             o->direction = OB_DIRECTION_NORTHWEST;
diff --git a/openbox/actions/directionaldesktop.c b/openbox/actions/directionaldesktop.c
new file mode 100644 (file)
index 0000000..c052e6e
--- /dev/null
@@ -0,0 +1,84 @@
+#include "openbox/actions.h"
+#include "openbox/screen.h"
+#include <glib.h>
+
+typedef struct {
+    gboolean linear;
+    gboolean wrap;
+    ObDirection dir;
+} Options;
+
+static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
+static void     free_func(gpointer options);
+static gboolean run_func(ObActionsData *data, gpointer options);
+
+void action_directionaldesktop_startup()
+{
+    actions_register("DirectionalDesktop",
+                     setup_func,
+                     free_func,
+                     run_func,
+                     NULL, NULL);
+}
+
+static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+{
+    xmlNodePtr n;
+    Options *o;
+
+    o = g_new0(Options, 1);
+    o->wrap = TRUE;
+    o->dir = OB_DIRECTION_EAST;
+
+    if ((n = parse_find_node("wrap", node)))
+        o->wrap = parse_bool(doc, n);
+    if ((n = parse_find_node("direction", node))) {
+        gchar *s = parse_string(doc, n);
+        if (!g_ascii_strcasecmp(s, "next")) {
+            o->linear = TRUE;
+            o->dir = OB_DIRECTION_EAST;
+        }
+        else if (!g_ascii_strcasecmp(s, "previous")) {
+            o->linear = TRUE;
+            o->dir = OB_DIRECTION_WEST;
+        }
+        else if (!g_ascii_strcasecmp(s, "north") ||
+                 !g_ascii_strcasecmp(s, "up"))
+            o->dir = OB_DIRECTION_NORTH;
+        else if (!g_ascii_strcasecmp(s, "south") ||
+                 !g_ascii_strcasecmp(s, "down"))
+            o->dir = OB_DIRECTION_SOUTH;
+        else if (!g_ascii_strcasecmp(s, "west") ||
+                 !g_ascii_strcasecmp(s, "left"))
+            o->dir = OB_DIRECTION_WEST;
+        else if (!g_ascii_strcasecmp(s, "east") ||
+                 !g_ascii_strcasecmp(s, "right"))
+            o->dir = OB_DIRECTION_EAST;
+        g_free(s);
+    }
+
+    return o;
+}
+
+static void free_func(gpointer options)
+{
+    Options *o = options;
+
+    g_free(o);
+}
+
+/* Always return FALSE because its not interactive */
+static gboolean run_func(ObActionsData *data, gpointer options)
+{
+    Options *o = options;
+    guint d;
+
+    d = screen_cycle_desktop(o->dir,
+                             o->wrap,
+                             o->linear,
+                             FALSE, TRUE, FALSE);
+    if (d != screen_desktop)
+        screen_set_desktop(d, TRUE);
+
+    return FALSE;
+}
index 93d33fb..ac6d8b7 100644 (file)
@@ -42,17 +42,21 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
         o->desktop_windows = parse_bool(doc, n);
     if ((n = parse_find_node("direction", node))) {
         gchar *s = parse_string(doc, n);
-        if (!g_ascii_strcasecmp(s, "north"))
+        if (!g_ascii_strcasecmp(s, "north") ||
+            !g_ascii_strcasecmp(s, "up"))
             o->direction = OB_DIRECTION_NORTH;
         else if (!g_ascii_strcasecmp(s, "northwest"))
             o->direction = OB_DIRECTION_NORTHWEST;
         else if (!g_ascii_strcasecmp(s, "northeast"))
             o->direction = OB_DIRECTION_NORTHEAST;
-        else if (!g_ascii_strcasecmp(s, "west"))
+        else if (!g_ascii_strcasecmp(s, "west") ||
+                 !g_ascii_strcasecmp(s, "left"))
             o->direction = OB_DIRECTION_WEST;
-        else if (!g_ascii_strcasecmp(s, "east"))
+        else if (!g_ascii_strcasecmp(s, "east") ||
+                 !g_ascii_strcasecmp(s, "right"))
             o->direction = OB_DIRECTION_EAST;
-        else if (!g_ascii_strcasecmp(s, "south"))
+        else if (!g_ascii_strcasecmp(s, "south") ||
+                 !g_ascii_strcasecmp(s, "down"))
             o->direction = OB_DIRECTION_NORTH;
         else if (!g_ascii_strcasecmp(s, "southwest"))
             o->direction = OB_DIRECTION_NORTHWEST;