summaryrefslogtreecommitdiff
path: root/gtk/gtkviewport.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2010-10-22 18:46:33 +0200
committerMatthias Clasen <mclasen@redhat.com>2010-10-22 19:21:17 +0200
commit0d9ebb501df60cf1803858efcd1c79542588abd8 (patch)
treee2347bda6bad31a926399b9342a1680045ec8546 /gtk/gtkviewport.c
parentce5a29bc384542839a5f12061499c8ec706b1c34 (diff)
downloadgtk+-0d9ebb501df60cf1803858efcd1c79542588abd8.tar.gz
Move min-display-width/height to GtkScrolledWindow
It is just too annoying to have to implement these properties in every scrollable. Instead, we now have ::min-content-height/width in GtkScrolledWindow. We also add GtkScrollablePolicy to determine how to size the scrollable content.
Diffstat (limited to 'gtk/gtkviewport.c')
-rw-r--r--gtk/gtkviewport.c125
1 files changed, 50 insertions, 75 deletions
diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c
index f91f2efd8d..4389646325 100644
--- a/gtk/gtkviewport.c
+++ b/gtk/gtkviewport.c
@@ -25,13 +25,14 @@
*/
#include "config.h"
+
+#undef GTK_DISABLE_DEPRECATED
+#include "gtkviewport.h"
+#define GTK_DISABLE_DEPRECATED
#include "gtkintl.h"
#include "gtkmarshalers.h"
#include "gtktypeutils.h"
#include "gtkscrollable.h"
-#undef GTK_DISABLE_DEPRECATED
-#include "gtkviewport.h"
-#define GTK_DISABLE_DEPRECATED
#include "gtkprivate.h"
@@ -61,8 +62,6 @@ struct _GtkViewportPrivate
{
GtkAdjustment *hadjustment;
GtkAdjustment *vadjustment;
- gint min_display_width;
- gint min_display_height;
GtkShadowType shadow_type;
GdkWindow *bin_window;
@@ -140,18 +139,8 @@ gtk_viewport_class_init (GtkViewportClass *class)
container_class->add = gtk_viewport_add;
/* GtkScrollable implementation */
- g_object_class_override_property (gobject_class,
- PROP_HADJUSTMENT,
- "hadjustment");
- g_object_class_override_property (gobject_class,
- PROP_VADJUSTMENT,
- "vadjustment");
- g_object_class_override_property (gobject_class,
- PROP_MIN_DISPLAY_WIDTH,
- "min-display-width");
- g_object_class_override_property (gobject_class,
- PROP_MIN_DISPLAY_HEIGHT,
- "min-display-height");
+ g_object_class_override_property (gobject_class, PROP_HADJUSTMENT, "hadjustment");
+ g_object_class_override_property (gobject_class, PROP_VADJUSTMENT, "vadjustment");
g_object_class_install_property (gobject_class,
PROP_SHADOW_TYPE,
@@ -183,12 +172,6 @@ gtk_viewport_set_property (GObject *object,
case PROP_VADJUSTMENT:
gtk_viewport_set_vadjustment (viewport, g_value_get_object (value));
break;
- case PROP_MIN_DISPLAY_WIDTH:
- viewport->priv->min_display_width = g_value_get_int (value);
- break;
- case PROP_MIN_DISPLAY_HEIGHT:
- viewport->priv->min_display_height = g_value_get_int (value);
- break;
case PROP_SHADOW_TYPE:
gtk_viewport_set_shadow_type (viewport, g_value_get_enum (value));
break;
@@ -215,12 +198,6 @@ gtk_viewport_get_property (GObject *object,
case PROP_VADJUSTMENT:
g_value_set_object (value, priv->vadjustment);
break;
- case PROP_MIN_DISPLAY_WIDTH:
- g_value_set_int (value, priv->min_display_width);
- break;
- case PROP_MIN_DISPLAY_HEIGHT:
- g_value_set_int (value, priv->min_display_height);
- break;
case PROP_SHADOW_TYPE:
g_value_set_enum (value, priv->shadow_type);
break;
@@ -250,8 +227,6 @@ gtk_viewport_init (GtkViewport *viewport)
priv->bin_window = NULL;
priv->hadjustment = NULL;
priv->vadjustment = NULL;
- priv->min_display_width = -1;
- priv->min_display_height = -1;
}
/**
@@ -319,6 +294,50 @@ gtk_viewport_destroy (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_viewport_parent_class)->destroy (widget);
}
+static void
+viewport_get_view_allocation (GtkViewport *viewport,
+ GtkAllocation *view_allocation)
+{
+ GtkViewportPrivate *priv = viewport->priv;
+ GtkStyle *style;
+ GtkWidget *widget = GTK_WIDGET (viewport);
+ GtkAllocation allocation;
+ guint border_width;
+
+ gtk_widget_get_allocation (widget, &allocation);
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (viewport));
+
+ view_allocation->x = 0;
+ view_allocation->y = 0;
+
+ if (priv->shadow_type != GTK_SHADOW_NONE)
+ {
+ style = gtk_widget_get_style (widget);
+ view_allocation->x = style->xthickness;
+ view_allocation->y = style->ythickness;
+ }
+
+ view_allocation->width = MAX (1, allocation.width - view_allocation->x * 2 - border_width * 2);
+ view_allocation->height = MAX (1, allocation.height - view_allocation->y * 2 - border_width * 2);
+}
+
+static void
+viewport_reclamp_adjustment (GtkAdjustment *adjustment,
+ gboolean *value_changed)
+{
+ gdouble value = adjustment->value;
+
+ value = CLAMP (value, 0, adjustment->upper - adjustment->page_size);
+ if (value != adjustment->value)
+ {
+ adjustment->value = value;
+ if (value_changed)
+ *value_changed = TRUE;
+ }
+ else if (value_changed)
+ *value_changed = FALSE;
+}
+
/**
* gtk_viewport_get_hadjustment:
* @viewport: a #GtkViewport.
@@ -370,50 +389,6 @@ gtk_viewport_get_vadjustment (GtkViewport *viewport)
}
static void
-viewport_get_view_allocation (GtkViewport *viewport,
- GtkAllocation *view_allocation)
-{
- GtkViewportPrivate *priv = viewport->priv;
- GtkStyle *style;
- GtkWidget *widget = GTK_WIDGET (viewport);
- GtkAllocation allocation;
- guint border_width;
-
- gtk_widget_get_allocation (widget, &allocation);
- border_width = gtk_container_get_border_width (GTK_CONTAINER (viewport));
-
- view_allocation->x = 0;
- view_allocation->y = 0;
-
- if (priv->shadow_type != GTK_SHADOW_NONE)
- {
- style = gtk_widget_get_style (widget);
- view_allocation->x = style->xthickness;
- view_allocation->y = style->ythickness;
- }
-
- view_allocation->width = MAX (1, allocation.width - view_allocation->x * 2 - border_width * 2);
- view_allocation->height = MAX (1, allocation.height - view_allocation->y * 2 - border_width * 2);
-}
-
-static void
-viewport_reclamp_adjustment (GtkAdjustment *adjustment,
- gboolean *value_changed)
-{
- gdouble value = adjustment->value;
-
- value = CLAMP (value, 0, adjustment->upper - adjustment->page_size);
- if (value != adjustment->value)
- {
- adjustment->value = value;
- if (value_changed)
- *value_changed = TRUE;
- }
- else if (value_changed)
- *value_changed = FALSE;
-}
-
-static void
viewport_set_hadjustment_values (GtkViewport *viewport,
gboolean *value_changed)
{