[gtk+] Fixed GtkViewport to set adjustments properly for width-for-height widgets
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Fixed GtkViewport to set adjustments properly for width-for-height widgets
- Date: Wed, 22 Sep 2010 03:48:12 +0000 (UTC)
commit 0e1bba6ef5817730dbe1cd53c9ba8a5ea6972053
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Wed Sep 22 12:48:37 2010 +0900
Fixed GtkViewport to set adjustments properly for width-for-height widgets
Make GtkViewport calculate widget-for-height as well as height-for-width
cases when setting the scroll adjustment values, also base the scrolling
on the minimum size instead of the natural size in the interest of showing
as much content as possible when the viewport is smaller than the natural
size.
gtk/gtkviewport.c | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c
index 81c40ec..644c9b0 100644
--- a/gtk/gtkviewport.c
+++ b/gtk/gtkviewport.c
@@ -49,6 +49,9 @@
* widget to a #GtkViewport, then add the viewport to the scrolled window.
* The convenience function gtk_scrolled_window_add_with_viewport() does
* exactly this, so you can ignore the presence of the viewport.
+ *
+ * The #GtkViewport will start scrolling content only if allocated less
+ * than the child widget's minimum size in a given orientation.
*/
struct _GtkViewportPrivate
@@ -442,11 +445,13 @@ viewport_set_hadjustment_values (GtkViewport *viewport,
child = gtk_bin_get_child (bin);
if (child && gtk_widget_get_visible (child))
{
- GtkRequisition child_requisition;
+ gint minimum_width;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
- &child_requisition, NULL);
- hadjustment->upper = MAX (child_requisition.width, view_allocation.width);
+ gtk_size_request_get_width_for_height (GTK_SIZE_REQUEST (child),
+ view_allocation.height,
+ &minimum_width,
+ NULL);
+ hadjustment->upper = MAX (minimum_width, view_allocation.width);
}
else
hadjustment->upper = view_allocation.width;
@@ -482,13 +487,14 @@ viewport_set_vadjustment_values (GtkViewport *viewport,
child = gtk_bin_get_child (bin);
if (child && gtk_widget_get_visible (child))
{
- gint natural_height;
+ gint minimum_height;
gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child),
view_allocation.width,
- NULL,
- &natural_height);
- vadjustment->upper = MAX (natural_height, view_allocation.height);
+ &minimum_height,
+ NULL);
+
+ vadjustment->upper = MAX (minimum_height, view_allocation.height);
}
else
vadjustment->upper = view_allocation.height;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]