diff options
-rw-r--r-- | docs/reference/gtk/gtk3-sections.txt | 14 | ||||
-rw-r--r-- | gtk/gtk.symbols | 14 | ||||
-rw-r--r-- | gtk/gtkenums.h | 15 | ||||
-rw-r--r-- | gtk/gtkiconview.c | 24 | ||||
-rw-r--r-- | gtk/gtklayout.c | 32 | ||||
-rw-r--r-- | gtk/gtkscrollable.c | 122 | ||||
-rw-r--r-- | gtk/gtkscrollable.h | 6 | ||||
-rw-r--r-- | gtk/gtkscrolledwindow.c | 216 | ||||
-rw-r--r-- | gtk/gtkscrolledwindow.h | 13 | ||||
-rw-r--r-- | gtk/gtktextview.c | 27 | ||||
-rw-r--r-- | gtk/gtktoolpalette.c | 26 | ||||
-rw-r--r-- | gtk/gtktreeview.c | 21 | ||||
-rw-r--r-- | gtk/gtkviewport.c | 125 | ||||
-rw-r--r-- | gtk/tests/treeview-scrolling.c | 4 |
14 files changed, 304 insertions, 355 deletions
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt index 2ebc6b1101..9c7f70a5bf 100644 --- a/docs/reference/gtk/gtk3-sections.txt +++ b/docs/reference/gtk/gtk3-sections.txt @@ -2751,10 +2751,6 @@ gtk_scrollable_get_hadjustment gtk_scrollable_set_hadjustment gtk_scrollable_get_vadjustment gtk_scrollable_set_vadjustment -gtk_scrollable_get_min_display_width -gtk_scrollable_set_min_display_width -gtk_scrollable_get_min_display_height -gtk_scrollable_set_min_display_height <SUBSECTION Standard> GtkScrollableIface @@ -2804,6 +2800,16 @@ gtk_scrolled_window_set_vadjustment gtk_scrolled_window_get_placement gtk_scrolled_window_get_policy gtk_scrolled_window_get_shadow_type +gtk_scrolled_window_get_min_content_width +gtk_scrolled_window_set_min_content_width +gtk_scrolled_window_get_min_content_height +gtk_scrolled_window_set_min_content_height +GtkScrollablePolicy +gtk_scrolled_window_get_hscroll_policy +gtk_scrolled_window_set_hscroll_policy +gtk_scrolled_window_get_vscroll_policy +gtk_scrolled_window_set_vscroll_policy + <SUBSECTION Standard> GTK_SCROLLED_WINDOW GTK_IS_SCROLLED_WINDOW diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index 795cd3cc1b..c61b4659f2 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -2893,15 +2893,11 @@ gtk_scale_button_get_popup #if IN_HEADER(__GTK_SCROLLABLE_H__) #if IN_FILE(__GTK_SCROLLABLE_C__) -gtk_scrollable_get_hadjustment gtk_scrollable_get_type G_GNUC_CONST +gtk_scrollable_get_hadjustment gtk_scrollable_get_vadjustment gtk_scrollable_set_hadjustment gtk_scrollable_set_vadjustment -gtk_scrollable_get_min_display_width -gtk_scrollable_set_min_display_width -gtk_scrollable_get_min_display_height -gtk_scrollable_set_min_display_height #endif #endif @@ -2930,6 +2926,14 @@ gtk_scrolled_window_set_policy gtk_scrolled_window_set_shadow_type gtk_scrolled_window_set_vadjustment gtk_scrolled_window_unset_placement +gtk_scrolled_window_get_min_content_width +gtk_scrolled_window_set_min_content_width +gtk_scrolled_window_get_min_content_height +gtk_scrolled_window_set_min_content_height +gtk_scrolled_window_get_hscroll_policy +gtk_scrolled_window_set_hscroll_policy +gtk_scrolled_window_get_vscroll_policy +gtk_scrolled_window_set_vscroll_policy #endif #endif diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h index 515881e9e4..60ffbc7c10 100644 --- a/gtk/gtkenums.h +++ b/gtk/gtkenums.h @@ -543,4 +543,19 @@ typedef enum G_END_DECLS +/** + * GtkScrollablePolicy: + * @GTK_SCROLL_MINIMUM: Scrollable adjustments are based on the minimum size + * @GTK_SCROLL_NATURAL: Scrollable adjustments are based on the natural size + * + * Defines the policy to be used in a scrollable widget when updating + * the scrolled window adjustments in a given orientation. + */ +typedef enum +{ + GTK_SCROLL_MINIMUM = 0, + GTK_SCROLL_NATURAL +} GtkScrollablePolicy; + + #endif /* __GTK_ENUMS_H__ */ diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c index 7651763655..d844de8683 100644 --- a/gtk/gtkiconview.c +++ b/gtk/gtkiconview.c @@ -135,8 +135,6 @@ struct _GtkIconViewPrivate GtkAdjustment *hadjustment; GtkAdjustment *vadjustment; - gint min_display_width; - gint min_display_height; guint layout_idle_id; @@ -245,9 +243,7 @@ enum /* For scrollable interface */ PROP_HADJUSTMENT, - PROP_VADJUSTMENT, - PROP_MIN_DISPLAY_WIDTH, - PROP_MIN_DISPLAY_HEIGHT + PROP_VADJUSTMENT }; /* GObject vfuncs */ @@ -800,9 +796,6 @@ gtk_icon_view_class_init (GtkIconViewClass *klass) /* Scrollable interface properties */ 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"); - /* Style properties */ gtk_widget_class_install_style_property (widget_class, @@ -1133,9 +1126,6 @@ gtk_icon_view_init (GtkIconView *icon_view) icon_view->priv->margin = 6; icon_view->priv->item_padding = 6; - icon_view->priv->min_display_width = -1; - icon_view->priv->min_display_height = -1; - icon_view->priv->draw_focus = TRUE; } @@ -1215,12 +1205,6 @@ gtk_icon_view_set_property (GObject *object, case PROP_VADJUSTMENT: gtk_icon_view_set_vadjustment (icon_view, g_value_get_object (value)); break; - case PROP_MIN_DISPLAY_WIDTH: - icon_view->priv->min_display_width = g_value_get_int (value); - break; - case PROP_MIN_DISPLAY_HEIGHT: - icon_view->priv->min_display_height = g_value_get_int (value); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -1293,12 +1277,6 @@ gtk_icon_view_get_property (GObject *object, case PROP_VADJUSTMENT: g_value_set_object (value, icon_view->priv->vadjustment); break; - case PROP_MIN_DISPLAY_WIDTH: - g_value_set_int (value, icon_view->priv->min_display_width); - break; - case PROP_MIN_DISPLAY_HEIGHT: - g_value_set_int (value, icon_view->priv->min_display_height); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); diff --git a/gtk/gtklayout.c b/gtk/gtklayout.c index 1a4a536d55..ec06056eb9 100644 --- a/gtk/gtklayout.c +++ b/gtk/gtklayout.c @@ -52,8 +52,6 @@ struct _GtkLayoutPrivate GtkAdjustment *hadjustment; GtkAdjustment *vadjustment; - gint min_display_width; - gint min_display_height; /* Properties */ @@ -78,8 +76,6 @@ enum { PROP_0, PROP_HADJUSTMENT, PROP_VADJUSTMENT, - PROP_MIN_DISPLAY_WIDTH, - PROP_MIN_DISPLAY_HEIGHT, PROP_WIDTH, PROP_HEIGHT }; @@ -622,18 +618,8 @@ gtk_layout_class_init (GtkLayoutClass *class) GTK_PARAM_READWRITE)); /* Scrollable interface */ - 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_WIDTH, @@ -685,12 +671,6 @@ gtk_layout_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_WIDTH: g_value_set_uint (value, priv->width); break; @@ -722,12 +702,6 @@ gtk_layout_set_property (GObject *object, gtk_layout_set_vadjustment (layout, (GtkAdjustment*) g_value_get_object (value)); break; - case PROP_MIN_DISPLAY_WIDTH: - priv->min_display_width = g_value_get_int (value); - break; - case PROP_MIN_DISPLAY_HEIGHT: - priv->min_display_height = g_value_get_int (value); - break; case PROP_WIDTH: gtk_layout_set_size (layout, g_value_get_uint (value), priv->height); @@ -811,8 +785,6 @@ gtk_layout_init (GtkLayout *layout) priv->hadjustment = NULL; priv->vadjustment = NULL; - priv->min_display_width = -1; - priv->min_display_height = -1; priv->bin_window = NULL; diff --git a/gtk/gtkscrollable.c b/gtk/gtkscrollable.c index 12e7379e3f..3e19c79ca6 100644 --- a/gtk/gtkscrollable.c +++ b/gtk/gtkscrollable.c @@ -106,41 +106,6 @@ gtk_scrollable_default_init (GtkScrollableInterface *iface) GTK_TYPE_ADJUSTMENT, GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT); g_object_interface_install_property (iface, pspec); - - - /** - * GtkScrollable:min-display-width: - * - * Minimum width to display in the parent scrolled window, this - * can be greater or less than the scrollable widget's real minimum - * width. - * - * Since: 3.0 - */ - pspec = g_param_spec_int ("min-display-width", - P_("Minimum Display Width"), - P_("Minimum width to display in the parent scrolled window"), - -1, G_MAXINT, -1, - GTK_PARAM_READWRITE); - g_object_interface_install_property (iface, pspec); - - - /** - * GtkScrollable:min-display-height: - * - * Minimum height to display in the parent scrolled window, this - * can be greater or less than the scrollable widget's real minimum - * height. - * - * Since: 3.0 - */ - pspec = g_param_spec_int ("min-display-height", - P_("Minimum Display Height"), - P_("Minimum height to display in the parent scrolled window"), - -1, G_MAXINT, -1, - GTK_PARAM_READWRITE); - g_object_interface_install_property (iface, pspec); - } /** @@ -238,90 +203,3 @@ gtk_scrollable_set_vadjustment (GtkScrollable *scrollable, g_object_set (scrollable, "vadjustment", vadjustment, NULL); } - - -/** - * gtk_scrollable_get_min_display_width: - * @scrollable: a #GtkScrollable - * - * Retrieves the minimum width of content to display in the - * parent scrolled window. - * - * Return value: The minimum display width. - * - * Since: 3.0 - **/ -gint -gtk_scrollable_get_min_display_width (GtkScrollable *scrollable) -{ - gint width; - - g_return_val_if_fail (GTK_IS_SCROLLABLE (scrollable), 0); - - g_object_get (scrollable, "min-display-width", &width, NULL); - - return width; -} - -/** - * gtk_scrollable_set_min_display_width: - * @scrollable: a #GtkScrollable - * @width: the minimum width of scrollable content to display - * - * Sets the minimum width of content to display in the parent scrolled window, - * this can be greater or less than the scrollable widget's real minimum - * width. - * - * Since: 3.0 - **/ -void -gtk_scrollable_set_min_display_width (GtkScrollable *scrollable, - gint width) -{ - g_return_if_fail (GTK_IS_SCROLLABLE (scrollable)); - - g_object_set (scrollable, "min-display-width", width, NULL); -} - -/** - * gtk_scrollable_get_min_display_height: - * @scrollable: a #GtkScrollable - * - * Retrieves the minimum height of content to display in the - * parent scrolled window. - * - * Return value: The minimum display height. - * - * Since: 3.0 - **/ -gint -gtk_scrollable_get_min_display_height (GtkScrollable *scrollable) -{ - gint height; - - g_return_val_if_fail (GTK_IS_SCROLLABLE (scrollable), 0); - - g_object_get (scrollable, "min-display-height", &height, NULL); - - return height; -} - -/** - * gtk_scrollable_set_min_display_height: - * @scrollable: a #GtkScrollable - * @height: the minimum height of scrollable content to display - * - * Sets the minimum height of content to display in the parent scrolled window, - * this can be greater or less than the scrollable widget's real minimum - * height. - * - * Since: 3.0 - **/ -void -gtk_scrollable_set_min_display_height (GtkScrollable *scrollable, - gint height) -{ - g_return_if_fail (GTK_IS_SCROLLABLE (scrollable)); - - g_object_set (scrollable, "min-display-height", height, NULL); -} diff --git a/gtk/gtkscrollable.h b/gtk/gtkscrollable.h index ce881a009e..fdb1c11273 100644 --- a/gtk/gtkscrollable.h +++ b/gtk/gtkscrollable.h @@ -49,12 +49,6 @@ void gtk_scrollable_set_hadjustment (GtkScrollable *scrollable, GtkAdjustment *gtk_scrollable_get_vadjustment (GtkScrollable *scrollable); void gtk_scrollable_set_vadjustment (GtkScrollable *scrollable, GtkAdjustment *vadjustment); -gint gtk_scrollable_get_min_display_width (GtkScrollable *scrollable); -void gtk_scrollable_set_min_display_width (GtkScrollable *scrollable, - gint width); -gint gtk_scrollable_get_min_display_height (GtkScrollable *scrollable); -void gtk_scrollable_set_min_display_height (GtkScrollable *scrollable, - gint height); G_END_DECLS diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c index 483a348757..ea7136bcb4 100644 --- a/gtk/gtkscrolledwindow.c +++ b/gtk/gtkscrolledwindow.c @@ -134,6 +134,11 @@ struct _GtkScrolledWindowPrivate guint vscrollbar_visible : 1; guint window_placement : 2; guint focus_out : 1; /* Flag used by ::move-focus-out implementation */ + guint hscroll_policy : 1; + guint vscroll_policy : 1; + + gint min_content_width; + gint min_content_height; }; @@ -143,9 +148,13 @@ enum { PROP_VADJUSTMENT, PROP_HSCROLLBAR_POLICY, PROP_VSCROLLBAR_POLICY, + PROP_HSCROLL_POLICY, + PROP_VSCROLL_POLICY, PROP_WINDOW_PLACEMENT, PROP_WINDOW_PLACEMENT_SET, - PROP_SHADOW_TYPE + PROP_SHADOW_TYPE, + PROP_MIN_CONTENT_WIDTH, + PROP_MIN_CONTENT_HEIGHT }; /* Signals */ @@ -372,6 +381,37 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class) DEFAULT_SCROLLBAR_SPACING, GTK_PARAM_READABLE)); + g_object_class_install_property (gobject_class, + PROP_HSCROLL_POLICY, + g_param_spec_enum ("hscroll-policy", + P_("Horizontal Scrollable Policy"), + P_("How the size of the content should be determined"), + GTK_TYPE_SCROLLABLE_POLICY, +GTK_SCROLL_NATURAL, + GTK_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROP_VSCROLL_POLICY, + g_param_spec_enum ("vscroll-policy", + P_("Vertical Scrollable Policy"), + P_("How the size of the content should be determined"), + GTK_TYPE_SCROLLABLE_POLICY, +GTK_SCROLL_NATURAL, + GTK_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, + PROP_MIN_CONTENT_WIDTH, + g_param_spec_int ("min-content-width", + P_("Minimum Content Width"), + P_("The minimum width that the scrolled window will allocate to its content"), + -1, G_MAXINT, -1, + GTK_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROP_MIN_CONTENT_HEIGHT, + g_param_spec_int ("min-content-height", + P_("Minimum Content Height"), + P_("The minimum height that the scrolled window will allocate to its content"), + -1, G_MAXINT, -1, + GTK_PARAM_READWRITE)); /** * GtkScrolledWindow::scroll-child: * @scrolled_window: a #GtkScrolledWindow @@ -467,6 +507,10 @@ gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window) priv->focus_out = FALSE; priv->window_placement = GTK_CORNER_TOP_LEFT; gtk_scrolled_window_update_real_placement (scrolled_window); + priv->hscroll_policy = GTK_SCROLL_NATURAL; + priv->vscroll_policy = GTK_SCROLL_NATURAL; + priv->min_content_width = -1; + priv->min_content_height = -1; } /** @@ -1037,6 +1081,22 @@ gtk_scrolled_window_set_property (GObject *object, gtk_scrolled_window_set_shadow_type (scrolled_window, g_value_get_enum (value)); break; + case PROP_HSCROLL_POLICY: + gtk_scrolled_window_set_hscroll_policy (scrolled_window, + g_value_get_enum (value)); + break; + case PROP_VSCROLL_POLICY: + gtk_scrolled_window_set_vscroll_policy (scrolled_window, + g_value_get_enum (value)); + break; + case PROP_MIN_CONTENT_WIDTH: + gtk_scrolled_window_set_min_content_width (scrolled_window, + g_value_get_int (value)); + break; + case PROP_MIN_CONTENT_HEIGHT: + gtk_scrolled_window_set_min_content_height (scrolled_window, + g_value_get_int (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1062,12 +1122,6 @@ gtk_scrolled_window_get_property (GObject *object, g_value_set_object (value, G_OBJECT (gtk_scrolled_window_get_vadjustment (scrolled_window))); break; - case PROP_HSCROLLBAR_POLICY: - g_value_set_enum (value, priv->hscrollbar_policy); - break; - case PROP_VSCROLLBAR_POLICY: - g_value_set_enum (value, priv->vscrollbar_policy); - break; case PROP_WINDOW_PLACEMENT: g_value_set_enum (value, priv->window_placement); break; @@ -1077,6 +1131,24 @@ gtk_scrolled_window_get_property (GObject *object, case PROP_SHADOW_TYPE: g_value_set_enum (value, priv->shadow_type); break; + case PROP_HSCROLLBAR_POLICY: + g_value_set_enum (value, priv->hscrollbar_policy); + break; + case PROP_VSCROLLBAR_POLICY: + g_value_set_enum (value, priv->vscrollbar_policy); + break; + case PROP_HSCROLL_POLICY: + g_value_set_enum (value, priv->hscroll_policy); + break; + case PROP_VSCROLL_POLICY: + g_value_set_enum (value, priv->vscroll_policy); + break; + case PROP_MIN_CONTENT_WIDTH: + g_value_set_int (value, priv->min_content_width); + break; + case PROP_MIN_CONTENT_HEIGHT: + g_value_set_int (value, priv->min_content_height); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -2015,13 +2087,12 @@ gtk_scrolled_window_get_preferred_size (GtkWidget *widget, } else { - gint min_display_width = - gtk_scrollable_get_min_display_width (GTK_SCROLLABLE (child)); + gint min_content_width = priv->min_content_width; - if (min_display_width > 0) + if (min_content_width >= 0) { - minimum_req.width += min_display_width; - natural_req.width += min_display_width; + minimum_req.width = MAX (minimum_req.width, min_content_width); + natural_req.width = MAX (natural_req.width, min_content_width); extra_width = -1; } else @@ -2044,13 +2115,12 @@ gtk_scrolled_window_get_preferred_size (GtkWidget *widget, } else { - gint min_display_height = - gtk_scrollable_get_min_display_height (GTK_SCROLLABLE (child)); + gint min_content_height = priv->min_content_height; - if (min_display_height > 0) + if (min_content_height >= 0) { - minimum_req.height += min_display_height; - natural_req.height += min_display_height; + minimum_req.height = MAX (minimum_req.height, min_content_height); + natural_req.height = MAX (natural_req.height, min_content_height); extra_height = -1; } else @@ -2147,3 +2217,115 @@ gtk_scrolled_window_get_preferred_width_for_height (GtkWidget *widget, GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, minimum_width, natural_width); } + +gint +gtk_scrolled_window_get_min_content_width (GtkScrolledWindow *scrolled_window) +{ + g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window), 0); + + return scrolled_window->priv->min_content_width; +} + +void +gtk_scrolled_window_set_min_content_width (GtkScrolledWindow *scrolled_window, + gint min_content_width) +{ + GtkScrolledWindowPrivate *priv; + + g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window)); + + priv = scrolled_window->priv; + + if (priv->min_content_width != min_content_width) + { + priv->min_content_width = min_content_width; + + gtk_widget_queue_resize (GTK_WIDGET (scrolled_window)); + + g_object_notify (G_OBJECT (scrolled_window), "min-content-width"); + } +} + +gint +gtk_scrolled_window_get_min_content_height (GtkScrolledWindow *scrolled_window) +{ + g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window), 0); + + return scrolled_window->priv->min_content_height; +} + +void +gtk_scrolled_window_set_min_content_height (GtkScrolledWindow *scrolled_window, + gint min_content_height) +{ + GtkScrolledWindowPrivate *priv; + + g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window)); + + priv = scrolled_window->priv; + + if (priv->min_content_height != min_content_height) + { + priv->min_content_height = min_content_height; + + gtk_widget_queue_resize (GTK_WIDGET (scrolled_window)); + + g_object_notify (G_OBJECT (scrolled_window), "min-content-height"); + } +} + +GtkScrollablePolicy +gtk_scrolled_window_get_hscroll_policy (GtkScrolledWindow *scrolled_window) +{ + g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window), 0); + + return scrolled_window->priv->hscroll_policy; +} + +void +gtk_scrolled_window_set_hscroll_policy (GtkScrolledWindow *scrolled_window, + GtkScrollablePolicy policy) +{ + GtkScrolledWindowPrivate *priv; + + g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window)); + + priv = scrolled_window->priv; + + if (priv->hscroll_policy != policy) + { + priv->hscroll_policy = policy; + + gtk_widget_queue_resize (GTK_WIDGET (scrolled_window)); + + g_object_notify (G_OBJECT (scrolled_window), "hscroll-policy"); + } +} + +GtkScrollablePolicy +gtk_scrolled_window_get_vscroll_policy (GtkScrolledWindow *scrolled_window) +{ + g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window), 0); + + return scrolled_window->priv->vscroll_policy; +} + +void +gtk_scrolled_window_set_vscroll_policy (GtkScrolledWindow *scrolled_window, + GtkScrollablePolicy policy) +{ + GtkScrolledWindowPrivate *priv; + + g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window)); + + priv = scrolled_window->priv; + + if (priv->vscroll_policy != policy) + { + priv->vscroll_policy = policy; + + gtk_widget_queue_resize (GTK_WIDGET (scrolled_window)); + + g_object_notify (G_OBJECT (scrolled_window), "vscroll-policy"); + } +} diff --git a/gtk/gtkscrolledwindow.h b/gtk/gtkscrolledwindow.h index 682ea02a38..44f4818608 100644 --- a/gtk/gtkscrolledwindow.h +++ b/gtk/gtkscrolledwindow.h @@ -115,6 +115,19 @@ GtkShadowType gtk_scrolled_window_get_shadow_type (GtkScrolledWindow *scrolle void gtk_scrolled_window_add_with_viewport (GtkScrolledWindow *scrolled_window, GtkWidget *child); +gint gtk_scrolled_window_get_min_content_width (GtkScrolledWindow *scrolled_window); +void gtk_scrolled_window_set_min_content_width (GtkScrolledWindow *scrolled_window, + gint width); +gint gtk_scrolled_window_get_min_content_height (GtkScrolledWindow *scrolled_window); +void gtk_scrolled_window_set_min_content_height (GtkScrolledWindow *scrolled_window, + gint height); +GtkScrollablePolicy gtk_scrolled_window_get_hscroll_policy (GtkScrolledWindow *scrolled_window); +void gtk_scrolled_window_set_hscroll_policy (GtkScrolledWindow *scrolled_window, + GtkScrollablePolicy policy); +GtkScrollablePolicy gtk_scrolled_window_get_vscroll_policy (GtkScrolledWindow *scrolled_window); +void gtk_scrolled_window_set_vscroll_policy (GtkScrolledWindow *scrolled_window, + GtkScrollablePolicy policy); + gint _gtk_scrolled_window_get_scrollbar_spacing (GtkScrolledWindow *scrolled_window); diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 4b254a0958..f0eca6575f 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -129,8 +129,6 @@ struct _GtkTextViewPrivate GtkAdjustment *hadjustment; GtkAdjustment *vadjustment; - gint min_display_width; - gint min_display_height; gint xoffset; /* Offsets between widget coordinates and buffer coordinates */ gint yoffset; @@ -262,9 +260,7 @@ enum PROP_ACCEPTS_TAB, PROP_IM_MODULE, PROP_HADJUSTMENT, - PROP_VADJUSTMENT, - PROP_MIN_DISPLAY_WIDTH, - PROP_MIN_DISPLAY_HEIGHT + PROP_VADJUSTMENT }; static void gtk_text_view_finalize (GObject *object); @@ -777,8 +773,6 @@ gtk_text_view_class_init (GtkTextViewClass *klass) /* GtkScrollable interface */ 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"); /* * Style properties @@ -1394,9 +1388,6 @@ gtk_text_view_init (GtkTextView *text_view) priv->pending_place_cursor_button = 0; - priv->min_display_width = -1; - priv->min_display_height = -1; - /* We handle all our own redrawing */ gtk_widget_set_redraw_on_allocate (widget, FALSE); } @@ -3101,14 +3092,6 @@ gtk_text_view_set_property (GObject *object, gtk_text_view_set_vadjustment (text_view, g_value_get_object (value)); break; - case PROP_MIN_DISPLAY_WIDTH: - priv->min_display_width = g_value_get_int (value); - break; - - case PROP_MIN_DISPLAY_HEIGHT: - priv->min_display_height = g_value_get_int (value); - break; - default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -3197,14 +3180,6 @@ gtk_text_view_get_property (GObject *object, 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; - default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; diff --git a/gtk/gtktoolpalette.c b/gtk/gtktoolpalette.c index a324cedd2f..6d9c5c13f6 100644 --- a/gtk/gtktoolpalette.c +++ b/gtk/gtktoolpalette.c @@ -122,9 +122,7 @@ enum PROP_ORIENTATION, PROP_TOOLBAR_STYLE, PROP_HADJUSTMENT, - PROP_VADJUSTMENT, - PROP_MIN_DISPLAY_WIDTH, - PROP_MIN_DISPLAY_HEIGHT + PROP_VADJUSTMENT }; enum @@ -150,8 +148,6 @@ struct _GtkToolPalettePrivate GtkAdjustment *hadjustment; GtkAdjustment *vadjustment; - gint min_display_width; - gint min_display_height; GtkIconSize icon_size; gboolean icon_size_set; @@ -211,8 +207,6 @@ gtk_tool_palette_init (GtkToolPalette *palette) palette->priv->orientation = DEFAULT_ORIENTATION; palette->priv->style = DEFAULT_TOOLBAR_STYLE; palette->priv->style_set = FALSE; - palette->priv->min_display_width = -1; - palette->priv->min_display_height = -1; palette->priv->text_size_group = gtk_size_group_new (GTK_SIZE_GROUP_BOTH); } @@ -282,14 +276,6 @@ gtk_tool_palette_set_property (GObject *object, gtk_tool_palette_set_vadjustment (palette, g_value_get_object (value)); break; - case PROP_MIN_DISPLAY_WIDTH: - palette->priv->min_display_width = g_value_get_int (value); - break; - - case PROP_MIN_DISPLAY_HEIGHT: - palette->priv->min_display_height = g_value_get_int (value); - break; - default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -330,14 +316,6 @@ gtk_tool_palette_get_property (GObject *object, g_value_set_object (value, palette->priv->vadjustment); break; - case PROP_MIN_DISPLAY_WIDTH: - g_value_set_int (value, palette->priv->min_display_width); - break; - - case PROP_MIN_DISPLAY_HEIGHT: - g_value_set_int (value, palette->priv->min_display_height); - break; - default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -978,8 +956,6 @@ gtk_tool_palette_class_init (GtkToolPaletteClass *cls) g_object_class_override_property (oclass, PROP_HADJUSTMENT, "hadjustment"); g_object_class_override_property (oclass, PROP_VADJUSTMENT, "vadjustment"); - g_object_class_override_property (oclass, PROP_MIN_DISPLAY_WIDTH, "min-display-width"); - g_object_class_override_property (oclass, PROP_MIN_DISPLAY_HEIGHT, "min-display-height"); /** * GtkToolPalette:icon-size: diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index df809d7bf6..412f8f3d94 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -146,9 +146,7 @@ enum { PROP_RUBBER_BANDING, PROP_ENABLE_GRID_LINES, PROP_ENABLE_TREE_LINES, - PROP_TOOLTIP_COLUMN, - PROP_MIN_DISPLAY_WIDTH, - PROP_MIN_DISPLAY_HEIGHT + PROP_TOOLTIP_COLUMN }; /* object signals */ @@ -572,8 +570,6 @@ gtk_tree_view_class_init (GtkTreeViewClass *class) g_object_class_override_property (o_class, PROP_HADJUSTMENT, "hadjustment"); g_object_class_override_property (o_class, PROP_VADJUSTMENT, "vadjustment"); - g_object_class_override_property (o_class, PROP_MIN_DISPLAY_WIDTH, "min-display-width"); - g_object_class_override_property (o_class, PROP_MIN_DISPLAY_HEIGHT, "min-display-height"); g_object_class_install_property (o_class, PROP_HEADERS_VISIBLE, @@ -1339,9 +1335,6 @@ gtk_tree_view_init (GtkTreeView *tree_view) tree_view->priv->event_last_x = -10000; tree_view->priv->event_last_y = -10000; - - tree_view->priv->min_display_width = -1; - tree_view->priv->min_display_height = -1; } @@ -1418,12 +1411,6 @@ gtk_tree_view_set_property (GObject *object, case PROP_TOOLTIP_COLUMN: gtk_tree_view_set_tooltip_column (tree_view, g_value_get_int (value)); break; - case PROP_MIN_DISPLAY_WIDTH: - tree_view->priv->min_display_width = g_value_get_int (value); - break; - case PROP_MIN_DISPLAY_HEIGHT: - tree_view->priv->min_display_height = g_value_get_int (value); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1499,12 +1486,6 @@ gtk_tree_view_get_property (GObject *object, case PROP_TOOLTIP_COLUMN: g_value_set_int (value, tree_view->priv->tooltip_column); break; - case PROP_MIN_DISPLAY_WIDTH: - g_value_set_int (value, tree_view->priv->min_display_width); - break; - case PROP_MIN_DISPLAY_HEIGHT: - g_value_set_int (value, tree_view->priv->min_display_height); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; 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) { diff --git a/gtk/tests/treeview-scrolling.c b/gtk/tests/treeview-scrolling.c index 8faf5656b2..40d5b81c75 100644 --- a/gtk/tests/treeview-scrolling.c +++ b/gtk/tests/treeview-scrolling.c @@ -125,8 +125,8 @@ scroll_fixture_setup (ScrollFixture *fixture, fixture->tree_view = gtk_tree_view_new_with_model (model); g_object_unref (model); - gtk_scrollable_set_min_display_width (GTK_SCROLLABLE (fixture->tree_view), VIEW_WIDTH); - gtk_scrollable_set_min_display_height (GTK_SCROLLABLE (fixture->tree_view), VIEW_HEIGHT); + gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW (sw), VIEW_WIDTH); + gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (sw), VIEW_HEIGHT); gtk_widget_set_size_request (fixture->tree_view, VIEW_WIDTH, VIEW_HEIGHT); renderer = gtk_cell_renderer_text_new (); |