From b3570de983215cfe1ae7fddf97ca1a511bc3badc Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 17 Mar 2005 18:37:35 +0000 Subject: [PATCH] Clamp adjustment values on resize. (#170567, Tomislav Jonjic) 2005-03-17 Matthias Clasen * gtk/gtkiconview.c (gtk_icon_view_size_allocate): Clamp adjustment values on resize. (#170567, Tomislav Jonjic) --- ChangeLog | 3 +++ ChangeLog.pre-2-10 | 3 +++ ChangeLog.pre-2-8 | 3 +++ gtk/gtkiconview.c | 36 ++++++++++++++++++++++++------------ 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 99c2c972f1..807ba5c250 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2005-03-17 Matthias Clasen + * gtk/gtkiconview.c (gtk_icon_view_size_allocate): Clamp + adjustment values on resize. (#170567, Tomislav Jonjic) + * gtk/gtkicontheme.c (theme_lookup_icon): Don't crash if there is no cache. (#170652, Diego Gonzalez) diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 99c2c972f1..807ba5c250 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,5 +1,8 @@ 2005-03-17 Matthias Clasen + * gtk/gtkiconview.c (gtk_icon_view_size_allocate): Clamp + adjustment values on resize. (#170567, Tomislav Jonjic) + * gtk/gtkicontheme.c (theme_lookup_icon): Don't crash if there is no cache. (#170652, Diego Gonzalez) diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 99c2c972f1..807ba5c250 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,5 +1,8 @@ 2005-03-17 Matthias Clasen + * gtk/gtkiconview.c (gtk_icon_view_size_allocate): Clamp + adjustment values on resize. (#170567, Tomislav Jonjic) + * gtk/gtkicontheme.c (theme_lookup_icon): Don't crash if there is no cache. (#170652, Diego Gonzalez) diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c index 205e0d2e82..518bd00d32 100644 --- a/gtk/gtkiconview.c +++ b/gtk/gtkiconview.c @@ -953,6 +953,7 @@ gtk_icon_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkIconView *icon_view; + GtkAdjustment *hadjustment, *vadjustment; widget->allocation = *allocation; @@ -968,19 +969,30 @@ gtk_icon_view_size_allocate (GtkWidget *widget, MAX (icon_view->priv->height, allocation->height)); } - icon_view->priv->hadjustment->page_size = allocation->width; - icon_view->priv->hadjustment->page_increment = allocation->width * 0.9; - icon_view->priv->hadjustment->step_increment = allocation->width * 0.1; - icon_view->priv->hadjustment->lower = 0; - icon_view->priv->hadjustment->upper = MAX (allocation->width, icon_view->priv->width); - gtk_adjustment_changed (icon_view->priv->hadjustment); + hadjustment = icon_view->priv->hadjustment; + vadjustment = icon_view->priv->vadjustment; - icon_view->priv->vadjustment->page_size = allocation->height; - icon_view->priv->vadjustment->page_increment = allocation->height * 0.9; - icon_view->priv->vadjustment->step_increment = allocation->width * 0.1; - icon_view->priv->vadjustment->lower = 0; - icon_view->priv->vadjustment->upper = MAX (allocation->height, icon_view->priv->height); - gtk_adjustment_changed (icon_view->priv->vadjustment); + hadjustment->page_size = allocation->width; + hadjustment->page_increment = allocation->width * 0.9; + hadjustment->step_increment = allocation->width * 0.1; + hadjustment->lower = 0; + hadjustment->upper = MAX (allocation->width, icon_view->priv->width); + + if (hadjustment->value > hadjustment->upper - hadjustment->page_size) + gtk_adjustment_set_value (hadjustment, MAX (0, hadjustment->upper - hadjustment->page_size)); + + gtk_adjustment_changed (hadjustment); + + vadjustment->page_size = allocation->height; + vadjustment->page_increment = allocation->height * 0.9; + vadjustment->step_increment = allocation->height * 0.1; + vadjustment->lower = 0; + vadjustment->upper = MAX (allocation->height, icon_view->priv->height); + + if (vadjustment->value > vadjustment->upper - vadjustment->page_size) + gtk_adjustment_set_value (vadjustment, MAX (0, vadjustment->upper - vadjustment->page_size)); + + gtk_adjustment_changed (vadjustment); gtk_icon_view_layout (icon_view); }