use the ObOrientation enum instead of a horz bool for configuring the dock's orientation

This commit is contained in:
Dana Jansens 2003-07-10 16:38:45 +00:00
parent d206303a9f
commit 5c2e4cced4
3 changed files with 87 additions and 41 deletions

View file

@ -20,7 +20,7 @@ gboolean config_dock_floating;
ObDirection config_dock_pos;
int config_dock_x;
int config_dock_y;
gboolean config_dock_horz;
ObOrientation config_dock_orient;
gboolean config_dock_hide;
guint config_dock_hide_timeout;
@ -132,9 +132,9 @@ static void parse_dock(xmlDocPtr doc, xmlNodePtr node, void *d)
}
if ((n = parse_find_node("direction", node))) {
if (parse_contains("horizontal", doc, n))
config_dock_horz = TRUE;
config_dock_orient = OB_ORIENTATION_HORZ;
else if (parse_contains("vertical", doc, n))
config_dock_horz = FALSE;
config_dock_orient = OB_ORIENTATION_VERT;
}
if ((n = parse_find_node("autoHide", node)))
config_dock_hide = parse_bool(doc, n);
@ -171,7 +171,7 @@ void config_startup()
config_dock_floating = FALSE;
config_dock_x = 0;
config_dock_y = 0;
config_dock_horz = FALSE;
config_dock_orient = OB_ORIENTATION_VERT;
config_dock_hide = FALSE;
config_dock_hide_timeout = 3000;

View file

@ -39,7 +39,7 @@ extern int config_dock_x;
position */
extern int config_dock_y;
/*! Whether the dock places the dockapps in it horizontally or vertically */
extern gboolean config_dock_horz;
extern ObOrientation config_dock_orient;
/*! Whether to auto-hide the dock when the pointer is not over it */
extern gboolean config_dock_hide;
/*! The number of milliseconds to wait before hiding the dock */

View file

@ -161,28 +161,34 @@ void dock_configure()
/* get the size */
for (it = dock->dock_apps; it; it = it->next) {
ObDockApp *app = it->data;
if (config_dock_horz) {
switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
dock->w += app->w;
dock->h = MAX(dock->h, app->h);
} else {
break;
case OB_ORIENTATION_VERT:
dock->w = MAX(dock->w, app->w);
dock->h += app->h;
break;
}
}
spot = (config_dock_horz ? minw : minh) / 2;
spot = (config_dock_orient == OB_ORIENTATION_HORZ ? minw : minh) / 2;
/* position the apps */
for (it = dock->dock_apps; it; it = it->next) {
ObDockApp *app = it->data;
if (config_dock_horz) {
switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
app->x = spot;
app->y = (dock->h - app->h) / 2;
spot += app->w;
} else {
break;
case OB_ORIENTATION_VERT:
app->x = (dock->w - app->w) / 2;
app->y = spot;
spot += app->h;
break;
}
XMoveWindow(ob_display, app->icon_win, app->x, app->y);
@ -273,20 +279,28 @@ void dock_configure()
if (!config_dock_floating) {
switch (config_dock_pos) {
case OB_DIRECTION_NORTHWEST:
if (config_dock_horz)
switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
dock->y -= dock->h - ob_rr_theme->bwidth;
else
break;
case OB_ORIENTATION_VERT:
dock->x -= dock->w - ob_rr_theme->bwidth;
break;
}
break;
case OB_DIRECTION_NORTH:
dock->y -= dock->h - ob_rr_theme->bwidth;
break;
case OB_DIRECTION_NORTHEAST:
if (config_dock_horz)
switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
dock->y -= dock->h - ob_rr_theme->bwidth;
else
break;
case OB_ORIENTATION_VERT:
dock->x += dock->w - ob_rr_theme->bwidth;
break;
}
break;
case OB_DIRECTION_WEST:
dock->x -= dock->w - ob_rr_theme->bwidth;
break;
@ -294,21 +308,28 @@ void dock_configure()
dock->x += dock->w - ob_rr_theme->bwidth;
break;
case OB_DIRECTION_SOUTHWEST:
if (config_dock_horz)
switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
dock->y += dock->h - ob_rr_theme->bwidth;
else
break;
case OB_ORIENTATION_VERT:
dock->x -= dock->w - ob_rr_theme->bwidth;
break;
} break;
case OB_DIRECTION_SOUTH:
dock->y += dock->h - ob_rr_theme->bwidth;
break;
case OB_DIRECTION_SOUTHEAST:
if (config_dock_horz)
switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
dock->y += dock->h - ob_rr_theme->bwidth;
else
break;
case OB_ORIENTATION_VERT:
dock->x += dock->w - ob_rr_theme->bwidth;
break;
}
break;
}
}
}
@ -325,20 +346,28 @@ void dock_configure()
} else {
switch (config_dock_pos) {
case OB_DIRECTION_NORTHWEST:
if (config_dock_horz)
switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
STRUT_SET(dock_strut, 0, strh, 0, 0);
else
break;
case OB_ORIENTATION_VERT:
STRUT_SET(dock_strut, strw, 0, 0, 0);
break;
}
break;
case OB_DIRECTION_NORTH:
STRUT_SET(dock_strut, 0, strh, 0, 0);
break;
case OB_DIRECTION_NORTHEAST:
if (config_dock_horz)
switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
STRUT_SET(dock_strut, 0, strh, 0, 0);
else
break;
case OB_ORIENTATION_VERT:
STRUT_SET(dock_strut, 0, 0, strw, 0);
break;
}
break;
case OB_DIRECTION_WEST:
STRUT_SET(dock_strut, strw, 0, 0, 0);
break;
@ -346,21 +375,29 @@ void dock_configure()
STRUT_SET(dock_strut, 0, 0, strw, 0);
break;
case OB_DIRECTION_SOUTHWEST:
if (config_dock_horz)
switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
STRUT_SET(dock_strut, 0, 0, 0, strh);
else
break;
case OB_ORIENTATION_VERT:
STRUT_SET(dock_strut, strw, 0, 0, 0);
break;
}
break;
case OB_DIRECTION_SOUTH:
STRUT_SET(dock_strut, 0, 0, 0, strh);
break;
case OB_DIRECTION_SOUTHEAST:
if (config_dock_horz)
switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
STRUT_SET(dock_strut, 0, 0, 0, strh);
else
break;
case OB_ORIENTATION_VERT:
STRUT_SET(dock_strut, 0, 0, strw, 0);
break;
}
break;
}
}
dock->w += minw;
@ -399,6 +436,7 @@ void dock_app_drag(ObDockApp *app, XMotionEvent *e)
GList *it;
gint x, y;
gboolean after;
gboolean stop;
x = e->x_root;
y = e->y_root;
@ -414,13 +452,17 @@ void dock_app_drag(ObDockApp *app, XMotionEvent *e)
y -= dock->y;
/* which dock app are we on top of? */
for (it = dock->dock_apps; it; it = it->next) {
stop = FALSE;
for (it = dock->dock_apps; it && !stop; it = it->next) {
over = it->data;
if (config_dock_horz) {
switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
if (x >= over->x && x < over->x + over->w)
stop = TRUE;
break;
} else {
case OB_ORIENTATION_VERT:
if (y >= over->y && y < over->y + over->h)
stop = TRUE;
break;
}
}
@ -429,10 +471,14 @@ void dock_app_drag(ObDockApp *app, XMotionEvent *e)
x -= over->x;
y -= over->y;
if (config_dock_horz)
switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
after = (x > over->w / 2);
else
break;
case OB_ORIENTATION_VERT:
after = (y > over->h / 2);
break;
}
/* remove before doing the it->next! */
dock->dock_apps = g_list_remove(dock->dock_apps, app);