summaryrefslogtreecommitdiff
path: root/gtk/gtkviewport.c
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.van.berkom@gmail.com>2010-04-12 22:21:46 -0400
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2010-04-12 22:21:46 -0400
commitd2c35ec62a595dc02542edae920b6a63dbb57446 (patch)
tree6eaa336a1b72f6bac9c0dcda1a0f27ed17e96bc4 /gtk/gtkviewport.c
parent1b2be80f10964e1ded1591294acc603f78980c93 (diff)
downloadgtk+-d2c35ec62a595dc02542edae920b6a63dbb57446.tar.gz
Mega commit to change ->get_desired_size() for ->get_desired_width/height().
This commit changes gtk_extended_layout_get_desired_size() for per dimension variants. Furthermore this commit reverts the actions done in size-groups for now as it needs a different approach. The natural width/height parameters added to aux_info have been changed for a per width cache for heights and a per height cache for widths. gtk-demo is still working, currently sizegroups are not taken into account as mentioned above - size groups need to be alerted both when the widths and heights are updated independantly and then that information needs to repropagate also to other extended layout implementors.
Diffstat (limited to 'gtk/gtkviewport.c')
-rw-r--r--gtk/gtkviewport.c68
1 files changed, 49 insertions, 19 deletions
diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c
index 404af32641..103a8572f6 100644
--- a/gtk/gtkviewport.c
+++ b/gtk/gtkviewport.c
@@ -69,6 +69,13 @@ static void gtk_viewport_style_set (GtkWidget *widget,
GtkStyle *previous_style);
static void gtk_viewport_extended_layout_init (GtkExtendedLayoutIface *iface);
+static void gtk_viewport_get_desired_width (GtkExtendedLayout *layout,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_viewport_get_desired_height (GtkExtendedLayout *layout,
+ gint *minimum_size,
+ gint *natural_size);
+
G_DEFINE_TYPE_WITH_CODE (GtkViewport, gtk_viewport, GTK_TYPE_BIN,
G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
@@ -829,44 +836,67 @@ gtk_viewport_style_set (GtkWidget *widget,
}
}
+
+static void
+gtk_viewport_extended_layout_init (GtkExtendedLayoutIface *iface)
+{
+ iface->get_desired_width = gtk_viewport_get_desired_width;
+ iface->get_desired_height = gtk_viewport_get_desired_height;
+}
+
static void
gtk_viewport_get_desired_size (GtkExtendedLayout *layout,
- GtkRequisition *minimum_size,
- GtkRequisition *natural_size)
+ GtkOrientation orientation,
+ gint *minimum_size,
+ gint *natural_size)
{
- GtkWidget *child;
- GtkRequisition child_min, child_nat;
+ GtkWidget *child;
+ gint child_min, child_nat;
+ gint minimum, natural;
child = gtk_bin_get_child (GTK_BIN (layout));
- minimum_size->width = GTK_CONTAINER (layout)->border_width;
- minimum_size->height = GTK_CONTAINER (layout)->border_width;
- natural_size->width = GTK_CONTAINER (layout)->border_width;
- natural_size->height = GTK_CONTAINER (layout)->border_width;
+ /* XXX This should probably be (border_width * 2); but GTK+ has
+ * been doing this with a single border for a while now...
+ */
+ minimum = GTK_CONTAINER (layout)->border_width;
if (GTK_VIEWPORT (layout)->shadow_type != GTK_SHADOW_NONE)
{
- minimum_size->width += 2 * GTK_WIDGET (layout)->style->xthickness;
- minimum_size->height += 2 * GTK_WIDGET (layout)->style->ythickness;
- natural_size->width += 2 * GTK_WIDGET (layout)->style->xthickness;
- natural_size->height += 2 * GTK_WIDGET (layout)->style->ythickness;
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ minimum += 2 * GTK_WIDGET (layout)->style->xthickness;
+ else
+ minimum += 2 * GTK_WIDGET (layout)->style->ythickness;
}
+ natural = minimum;
+
if (child && gtk_widget_get_visible (child))
{
- gtk_extended_layout_get_desired_size (GTK_EXTENDED_LAYOUT (child), &child_min, &child_nat);
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (child), &child_min, &child_nat);
+ else
+ gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (child), &child_min, &child_nat);
- minimum_size->width += child_min.width;
- minimum_size->height += child_min.height;
- natural_size->width += child_nat.width;
- natural_size->height += child_nat.height;
+ minimum += child_min;
+ natural += child_nat;
}
}
static void
-gtk_viewport_extended_layout_init (GtkExtendedLayoutIface *iface)
+gtk_viewport_get_desired_width (GtkExtendedLayout *layout,
+ gint *minimum_size,
+ gint *natural_size)
+{
+ gtk_viewport_get_desired_size (layout, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
+}
+
+static void
+gtk_viewport_get_desired_height (GtkExtendedLayout *layout,
+ gint *minimum_size,
+ gint *natural_size)
{
- iface->get_desired_size = gtk_viewport_get_desired_size;
+ gtk_viewport_get_desired_size (layout, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
}
#define __GTK_VIEWPORT_C__