Allowed the panel to be placed on top of the screen instead
This commit is contained in:
parent
c994cc43f9
commit
1385570d77
|
@ -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;
|
||||
|
||||
|
||||
|
|
13
src/main.c
13
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;
|
||||
|
|
|
@ -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,6 +146,9 @@ Panel * panel_new(PanelPrefs * prefs)
|
|||
panel->height);
|
||||
gtk_window_set_type_hint(GTK_WINDOW(panel->window),
|
||||
GDK_WINDOW_TYPE_HINT_DOCK);
|
||||
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));
|
||||
|
@ -388,6 +393,9 @@ static void _panel_helper_position_menu(GtkMenu * menu, gint * x, gint * y,
|
|||
if(req.height <= 0)
|
||||
return;
|
||||
*x = PANEL_BORDER_WIDTH;
|
||||
if(panel->position == PANEL_POSITION_TOP)
|
||||
*y = panel->height;
|
||||
else
|
||||
*y = panel->root_height - panel->height - req.height;
|
||||
*push_in = TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user