add directionaldesktop action

This commit is contained in:
Dana Jansens 2007-06-22 19:10:00 +00:00
parent 16f2b255cb
commit 6973d5b8a5
8 changed files with 104 additions and 45 deletions

View 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 \

View file

@ -390,36 +390,6 @@ ActionString actionstrings[] =
action_send_to_desktop_dir,
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,
@ -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);

View file

@ -33,4 +33,5 @@ void action_all_startup()
action_resize_startup();
action_decorations_startup();
action_desktop_startup();
action_directionaldesktop_startup();
}

View 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

View 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,

View 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;

View file

@ -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;
}

View 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;