[Xfce4-commits] <xfce4-weather-plugin:master> Fix scrollbox scroll direction in vertical mode.
Harald Judt
noreply at xfce.org
Tue Jul 3 00:06:02 CEST 2012
Updating branch refs/heads/master
to 5084944cbe03e7d8ef531b95d4e848759372b7d8 (commit)
from 09c4ffec8b218d6851772dfcbeedf9804631e179 (commit)
commit 5084944cbe03e7d8ef531b95d4e848759372b7d8
Author: Harald Judt <h.judt at gmx.at>
Date: Mon Jul 2 23:58:01 2012 +0200
Fix scrollbox scroll direction in vertical mode.
Even with the previous commit applied, the scroll direction in
vertical mode is still from bottom to top, respectively from
top to bottom when fading out. Change it so that the label
scrolls in from the left to the right and vice-versa.
panel-plugin/weather-scrollbox.c | 47 ++++++++++++++++++++++---------------
1 files changed, 28 insertions(+), 19 deletions(-)
diff --git a/panel-plugin/weather-scrollbox.c b/panel-plugin/weather-scrollbox.c
index a883e34..38ac0c3 100644
--- a/panel-plugin/weather-scrollbox.c
+++ b/panel-plugin/weather-scrollbox.c
@@ -141,24 +141,22 @@ gtk_scrollbox_expose_event (GtkWidget *widget,
pango_layout_get_extents (layout, NULL, &logical_rect);
if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
{
- width = PANGO_PIXELS (logical_rect.width);
- height = PANGO_PIXELS (logical_rect.height);
+ width = widget->allocation.x
+ + (widget->allocation.width - PANGO_PIXELS(logical_rect.width)) / 2;
+ height = widget->allocation.y
+ + (widget->allocation.height - PANGO_PIXELS(logical_rect.height)) / 2
+ + (self->animate ? self->offset : 0);
}
else
{
- height = PANGO_PIXELS (logical_rect.width);
- width = PANGO_PIXELS (logical_rect.height);
+ width = widget->allocation.x
+ + (widget->allocation.width - PANGO_PIXELS(logical_rect.height)) / 2
+ + (self->animate ? self->offset : 0);
+ height = widget->allocation.y
+ + (widget->allocation.height - PANGO_PIXELS(logical_rect.width)) / 2;
}
-
- gtk_paint_layout (widget->style,
- widget->window,
- GTK_WIDGET_STATE (widget),
- TRUE, &event->area,
- widget, "GtkScrollbox",
- widget->allocation.x + (widget->allocation.width - width) / 2,
- widget->allocation.y + (widget->allocation.height - height) / 2 + (self->animate ? self->offset : 0),
- layout);
-
+ gtk_paint_layout (widget->style, widget->window, GTK_WIDGET_STATE (widget), TRUE, &event->area,
+ widget, "GtkScrollbox", width, height, layout);
}
return result;
@@ -184,13 +182,16 @@ gtk_scrollbox_fade_in (gpointer user_data)
GtkScrollbox *self = GTK_SCROLLBOX (user_data);
/* decrease counter */
- self->offset--;
+ if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
+ self->offset--;
+ else
+ self->offset++;
gtk_widget_queue_draw (GTK_WIDGET (self));
- if (self->offset > 0)
+ if ((self->orientation == GTK_ORIENTATION_HORIZONTAL && self->offset > 0)
+ || (self->orientation == GTK_ORIENTATION_VERTICAL && self->offset < 0))
return TRUE;
-
self->timeout_id = g_timeout_add (LABEL_REFRESH, gtk_scrollbox_sleep, self);
return FALSE;
@@ -204,11 +205,15 @@ gtk_scrollbox_fade_out (gpointer user_data)
GtkScrollbox *self = GTK_SCROLLBOX (user_data);
/* increase counter */
- self->offset++;
+ if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
+ self->offset++;
+ else
+ self->offset--;
gtk_widget_queue_draw (GTK_WIDGET (self));
- if (self->offset < GTK_WIDGET (self)->allocation.height)
+ if ((self->orientation == GTK_ORIENTATION_HORIZONTAL && self->offset < GTK_WIDGET (self)->allocation.height)
+ || (self->orientation == GTK_ORIENTATION_VERTICAL && self->offset > 0 - GTK_WIDGET (self)->allocation.width))
return TRUE;
if (self->active != NULL)
@@ -240,7 +245,11 @@ gtk_scrollbox_start_fade (GtkScrollbox *self)
if (g_slist_length (self->labels) > 1)
{
+ if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
self->offset = GTK_WIDGET (self)->allocation.height;
+ else
+ self->offset = 0;
+
self->timeout_id = g_timeout_add (25, gtk_scrollbox_fade_in,
self);
}
More information about the Xfce4-commits
mailing list