Allow panels to be offset (according to orientation) from screen corners. This adds an extra propery, corner-offset, to each panel. It represents the offset (in pixels) along the axis of orientation from the corner of the screen. It is only applied if the panel is positioned at a corner and is not full width. Signed-off-by: Darren Salt Index: panel/panel-properties.h =================================================================== --- panel/panel-properties.h (revision 22585) +++ panel/panel-properties.h (working copy) @@ -55,6 +55,11 @@ void panel_set_yoffset (Panel *panel, int yoffset); +int panel_get_corner_offset (Panel *panel); + +void panel_set_corner_offset (Panel *panel, int offset); + + /* initilization */ void panel_init_position (Panel *panel); Index: panel/panel.c =================================================================== --- panel/panel.c (revision 22585) +++ panel/panel.c (working copy) @@ -59,7 +59,8 @@ PROP_AUTOHIDE, PROP_FULL_WIDTH, PROP_TRANSPARENCY, - PROP_ACTIVE_TRANS + PROP_ACTIVE_TRANS, + PROP_CORNER_OFFSET, }; @@ -229,6 +230,14 @@ DEFAULT_ACTIVE_TRANS, G_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_ACTIVE_TRANS, pspec); + + pspec = g_param_spec_int ("corner-offset", + "panel_corneroffset", + "Offset from the screen corner (fixed position mode)", + 0, 128, + 0, G_PARAM_READWRITE); + + g_object_class_install_property (object_class, PROP_CORNER_OFFSET, pspec); } static void @@ -328,6 +337,9 @@ case PROP_ACTIVE_TRANS: g_value_set_boolean (value, priv->activetrans); break; + case PROP_CORNER_OFFSET: + g_value_set_int (value, priv->corner_offset); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -369,6 +381,9 @@ case PROP_ACTIVE_TRANS: panel_set_activetrans (panel, g_value_get_boolean (value)); break; + case PROP_CORNER_OFFSET: + panel_set_corner_offset (panel, g_value_get_int (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; Index: panel/panel-config.c =================================================================== --- panel/panel-config.c (revision 22585) +++ panel/panel-config.c (working copy) @@ -213,6 +213,7 @@ gboolean autohide; int transparency; gboolean activetrans; + int corner_offset; }; static void @@ -231,6 +232,7 @@ parser->autohide = DEFAULT_AUTOHIDE; parser->transparency = DEFAULT_TRANSPARENCY; parser->activetrans = DEFAULT_ACTIVE_TRANS; + parser->corner_offset = 0; } static void @@ -282,6 +284,10 @@ { parser->activetrans = ((int) strtol (value, NULL, 0) == 1); } + else if (strcmp (name, "corner-offset") == 0) + { + parser->corner_offset = (int) strtol (value, NULL, 0); + } } static void @@ -446,6 +452,7 @@ "autohide", parser->autohide, "transparency", parser->transparency, "activetrans", parser->activetrans, + "corner-offset", parser->corner_offset, NULL); } TIMER_ELAPSED(" ++ end properties"); @@ -643,7 +650,7 @@ { Panel *panel; int size, monitor, screen_position, xoffset, yoffset, handle_style, - transparency, fullwidth, j; + transparency, fullwidth, corner_offset, j; gboolean autohide, activetrans; XfcePanelItemConfig *configlist; @@ -666,6 +673,7 @@ "autohide", &autohide, "transparency", &transparency, "activetrans", &activetrans, + "corner-offset", &corner_offset, NULL); /* grouping */ @@ -702,7 +710,10 @@ fprintf (fp, "\t\t\t\n", activetrans); - + + fprintf (fp, "\t\t\t\n", + corner_offset); + /* grouping */ fprintf (fp, "\t\t\n" "\t\t\n"); Index: panel/panel-private.h =================================================================== --- panel/panel-private.h (revision 22585) +++ panel/panel-private.h (working copy) @@ -62,6 +62,7 @@ XfceScreenPosition screen_position; int xoffset; int yoffset; + int corner_offset; XfcePanelWidthType full_width; int transparency; Index: panel/panel-dialogs.c =================================================================== --- panel/panel-dialogs.c (revision 22585) +++ panel/panel-dialogs.c (working copy) @@ -94,6 +94,7 @@ GtkWidget *fullwidth; int n_width_items; GtkWidget *autohide; + GtkWidget *corner_offset; GtkWidget *floating_box; GtkWidget *orientation; @@ -656,6 +657,9 @@ gtk_combo_box_set_active (GTK_COMBO_BOX (pmd->fullwidth), priv->full_width); + + gtk_spin_button_set_value (GTK_SPIN_BUTTON (pmd->corner_offset), + priv->corner_offset); } else { @@ -884,6 +888,13 @@ } static void +corner_offset_changed (GtkSpinButton *btn, PanelManagerDialog *pmd) +{ + if (!pmd->updating) + panel_set_corner_offset (pmd->panel, gtk_spin_button_get_value (btn)); +} + +static void add_position_options (GtkBox *box, PanelManagerDialog *pmd) { GtkWidget *frame, *vbox, *vbox2, *hbox, *table, *align, *label, *sep; @@ -1032,7 +1043,22 @@ g_signal_connect (pmd->autohide, "toggled", G_CALLBACK (autohide_changed), pmd); - + + /* fixed:corner offset */ + label = gtk_label_new_with_mnemonic (_("_Offset from corner:")); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + gtk_widget_show (label); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + + pmd->corner_offset = gtk_spin_button_new_with_range (0, 128, 2); + g_object_set (G_OBJECT (pmd->corner_offset), "numeric", TRUE, NULL); + gtk_widget_show (pmd->corner_offset); + gtk_box_pack_start (GTK_BOX (vbox), pmd->corner_offset, FALSE, FALSE, 0); + + gtk_label_set_mnemonic_widget (GTK_LABEL (label), pmd->corner_offset); + g_signal_connect (pmd->corner_offset, "value-changed", + G_CALLBACK (corner_offset_changed), pmd); + /* floating */ pmd->floating_box = vbox = gtk_vbox_new (FALSE, BORDER); /* don't show by default */ Index: panel/panel-properties.c =================================================================== --- panel/panel-properties.c (revision 22585) +++ panel/panel-properties.c (working copy) @@ -67,10 +67,19 @@ /* moving and resizing */ +static int +_corner_offset (const PanelPrivate *priv) +{ + if (priv->full_width > XFCE_PANEL_NORMAL_WIDTH) + return 0; + return priv->corner_offset; +} + static void _calculate_coordinates (XfceScreenPosition position, /* screen position */ GdkRectangle *screen, /* monitor geometry */ int width, int height, /* panel size */ + int offset, /* panel corner offset */ int *x, int *y) /* output coordinates */ { switch (position) @@ -86,7 +95,7 @@ break; /* top */ case XFCE_SCREEN_POSITION_NW_H: - *x = screen->x; + *x = screen->x + offset; *y = screen->y; break; case XFCE_SCREEN_POSITION_N: @@ -94,13 +103,13 @@ *y = screen->y; break; case XFCE_SCREEN_POSITION_NE_H: - *x = MAX (screen->x, screen->x + screen->width - width); + *x = MAX (screen->x, screen->x + screen->width - width) - offset; *y = screen->y; break; /* left */ case XFCE_SCREEN_POSITION_NW_V: *x = screen->x; - *y = screen->y; + *y = screen->y + offset; break; case XFCE_SCREEN_POSITION_W: *x = screen->x; @@ -108,12 +117,12 @@ break; case XFCE_SCREEN_POSITION_SW_V: *x = screen->x; - *y = MAX (screen->y, screen->y + screen->height - height); + *y = MAX (screen->y, screen->y + screen->height - height) - offset; break; /* right */ case XFCE_SCREEN_POSITION_NE_V: *x = screen->x + screen->width - width; - *y = screen->y; + *y = screen->y + offset; break; case XFCE_SCREEN_POSITION_E: *x = screen->x + screen->width - width; @@ -121,11 +130,11 @@ break; case XFCE_SCREEN_POSITION_SE_V: *x = screen->x + screen->width - width; - *y = MAX (screen->y, screen->y + screen->height - height); + *y = MAX (screen->y, screen->y + screen->height - height) - offset; break; /* bottom */ case XFCE_SCREEN_POSITION_SW_H: - *x = screen->x; + *x = screen->x + offset; *y = screen->y + screen->height - height; break; case XFCE_SCREEN_POSITION_S: @@ -133,7 +142,7 @@ *y = screen->y + screen->height - height; break; case XFCE_SCREEN_POSITION_SE_H: - *x = MAX (screen->x, screen->x + screen->width - width); + *x = MAX (screen->x, screen->x + screen->width - width) - offset; *y = screen->y + screen->height - height; break; } @@ -366,7 +375,7 @@ _calculate_coordinates (priv->screen_position, &(xmon->geometry), GTK_WIDGET (window)->allocation.width, GTK_WIDGET (window)->allocation.height, - x, y); + _corner_offset (priv), x, y); } static void @@ -384,7 +393,7 @@ xmon = panel_app_get_monitor (priv->monitor); _calculate_coordinates (priv->screen_position, &(xmon->geometry), - new->width, new->height, x, y); + new->width, new->height, _corner_offset (priv), x, y); priv->xoffset = *x - xmon->geometry.x; priv->yoffset = *y - xmon->geometry.y; @@ -420,7 +429,7 @@ x = y = 0; _calculate_coordinates (position, &(xmon->geometry), - req.width, req.height, &x, &y); + req.width, req.height, _corner_offset (priv), &x, &y); if (G_UNLIKELY (xoffset < 0 || yoffset < 0)) { @@ -798,7 +807,8 @@ { gtk_widget_size_request (GTK_WIDGET (panel), &req); _calculate_coordinates (priv->screen_position, &(xmon->geometry), - req.width, req.height, &x, &y); + req.width, req.height, _corner_offset (priv), + &x, &y); } DBG (" + offsets: (%d, %d)\n", @@ -1261,3 +1271,26 @@ } } +int +panel_get_corner_offset (Panel *panel) +{ + PanelPrivate *priv; + + g_return_val_if_fail (PANEL_IS_PANEL (panel), DEFAULT_YOFFSET); + + priv = panel->priv; + + return priv->corner_offset; +} + +void +panel_set_corner_offset (Panel *panel, int offset) +{ + PanelPrivate *priv = panel->priv; + + if (offset != priv->corner_offset) + { + priv->corner_offset = offset; + panel_set_position (panel, priv->screen_position, 0, 0); + } +}