diff --git a/src/common.h b/src/common.h index f5ad256..537c6d3 100644 --- a/src/common.h +++ b/src/common.h @@ -25,10 +25,16 @@ /* types */ typedef struct _Panel Panel; +typedef enum _PanelPosition +{ + PANEL_POSITION_TOP, PANEL_POSITION_BOTTOM +} PanelPosition; + typedef struct _PanelPrefs { GtkIconSize iconsize; int monitor; + PanelPosition position; } PanelPrefs; diff --git a/src/main.c b/src/main.c index d795fda..6a800dc 100644 --- a/src/main.c +++ b/src/main.c @@ -44,10 +44,12 @@ /* usage */ static int _usage(void) { - fputs(_("Usage: panel [-m monitor][-sSx]\n" + fputs(_("Usage: panel [-m monitor][-BsSTx]\n" +" -B Place the panel at the bottom of the screen (default)\n" " -m Monitor to use (default: 0)\n" " -s Use icons the size of a small toolbar\n" " -S Use icons the size of a large toolbar (default)\n" +" -T Place the panel at the top of the screen\n" " -x Use icons the size of menus\n"), stderr); return 1; } @@ -70,9 +72,13 @@ int main(int argc, char * argv[]) gtk_init(&argc, &argv); memset(&prefs, 0, sizeof(prefs)); prefs.iconsize = PANEL_ICON_SIZE_LARGE; - while((o = getopt(argc, argv, "m:sSx")) != -1) + prefs.position = PANEL_POSITION_BOTTOM; + while((o = getopt(argc, argv, "Bm:sSTx")) != -1) switch(o) { + case 'B': + prefs.position = PANEL_POSITION_BOTTOM; + break; case 'm': prefs.monitor = strtol(optarg, &p, 10); if(optarg[0] == '\0' || *p != '\0') @@ -84,6 +90,9 @@ int main(int argc, char * argv[]) case 'S': prefs.iconsize = PANEL_ICON_SIZE_LARGE; break; + case 'T': + prefs.position = PANEL_POSITION_TOP; + break; case 'x': prefs.iconsize = PANEL_ICON_SIZE_SMALLER; break; diff --git a/src/panel.c b/src/panel.c index 8515005..b39c344 100644 --- a/src/panel.c +++ b/src/panel.c @@ -36,6 +36,7 @@ struct _Panel { Config * config; + PanelPosition position; gint height; gint icon_width; @@ -99,6 +100,7 @@ Panel * panel_new(PanelPrefs * prefs) panel_delete(panel); return NULL; } + panel->position = prefs->position; panel->icon_width = 48; panel->icon_height = 48; if(prefs->iconsize != PANEL_ICON_SIZE_SMALL @@ -144,8 +146,11 @@ Panel * panel_new(PanelPrefs * prefs) panel->height); gtk_window_set_type_hint(GTK_WINDOW(panel->window), GDK_WINDOW_TYPE_HINT_DOCK); - gtk_window_move(GTK_WINDOW(panel->window), rect.x, - rect.y + panel->root_height - panel->height); + if(prefs->position == PANEL_POSITION_TOP) + gtk_window_move(GTK_WINDOW(panel->window), rect.x, 0); + else + gtk_window_move(GTK_WINDOW(panel->window), rect.x, + rect.y + panel->root_height - panel->height); gtk_window_stick(GTK_WINDOW(panel->window)); g_signal_connect(G_OBJECT(panel->window), "delete-event", G_CALLBACK( _on_closex), panel); @@ -388,7 +393,10 @@ static void _panel_helper_position_menu(GtkMenu * menu, gint * x, gint * y, if(req.height <= 0) return; *x = PANEL_BORDER_WIDTH; - *y = panel->root_height - panel->height - req.height; + if(panel->position == PANEL_POSITION_TOP) + *y = panel->height; + else + *y = panel->root_height - panel->height - req.height; *push_in = TRUE; }