From f0ac99072eb67fd2221a00e9fd1378ff6326c62d Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Wed, 10 Oct 2012 20:35:52 +0200 Subject: Win32 bugfixes. * Force redraw on LdCategorySymbolView size allocation. * Fix an infinite loop sometimes caused by update_adjustments(). --- liblogdiag/ld-category-symbol-view.c | 3 +++ liblogdiag/ld-diagram-view.c | 33 ++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 15 deletions(-) (limited to 'liblogdiag') diff --git a/liblogdiag/ld-category-symbol-view.c b/liblogdiag/ld-category-symbol-view.c index a2ae4cc..19df4b8 100644 --- a/liblogdiag/ld-category-symbol-view.c +++ b/liblogdiag/ld-category-symbol-view.c @@ -298,7 +298,10 @@ on_size_allocate (GtkWidget *widget, GdkRectangle *allocation, self = LD_CATEGORY_SYMBOL_VIEW (widget); if (self->priv->height_negotiation) + { + gtk_widget_queue_draw (widget); self->priv->height_negotiation = FALSE; + } else { self->priv->height_negotiation = TRUE; diff --git a/liblogdiag/ld-diagram-view.c b/liblogdiag/ld-diagram-view.c index 14186ef..e40b55f 100644 --- a/liblogdiag/ld-diagram-view.c +++ b/liblogdiag/ld-diagram-view.c @@ -729,31 +729,34 @@ on_size_allocate (GtkWidget *widget, GtkAllocation *allocation, update_adjustments (self); } +static void +update_adjustment_value (LdDiagramView *self, GtkAdjustment *adjustment, + gdouble value, gdouble page_size) +{ + gtk_adjustment_set_page_size (adjustment, page_size); + g_signal_handlers_block_by_func (adjustment, + on_adjustment_value_changed, self); + gtk_adjustment_set_value (adjustment, value - page_size / 2); + g_signal_handlers_unblock_by_func (adjustment, + on_adjustment_value_changed, self); + gtk_adjustment_changed (adjustment); +} + static void update_adjustments (LdDiagramView *self) { GtkAllocation allocation; - gdouble scale, page_size; + gdouble scale; gtk_widget_get_allocation (GTK_WIDGET (self), &allocation); scale = ld_diagram_view_get_scale_in_px (self); if (self->priv->adjustment_h) - { - page_size = allocation.width / scale; - gtk_adjustment_set_page_size (self->priv->adjustment_h, page_size); - gtk_adjustment_set_value (self->priv->adjustment_h, - self->priv->x - page_size / 2); - gtk_adjustment_changed (self->priv->adjustment_h); - } + update_adjustment_value (self, self->priv->adjustment_h, + self->priv->x, allocation.width / scale); if (self->priv->adjustment_v) - { - page_size = allocation.height / scale; - gtk_adjustment_set_page_size (self->priv->adjustment_v, page_size); - gtk_adjustment_set_value (self->priv->adjustment_v, - self->priv->y - page_size / 2); - gtk_adjustment_changed (self->priv->adjustment_v); - } + update_adjustment_value (self, self->priv->adjustment_v, + self->priv->y, allocation.height / scale); } static void -- cgit v1.2.3-70-g09d2