diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index 287de5409e..52bb2d9a6b 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -974,9 +974,6 @@ GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID gtk_container_add gtk_container_remove gtk_container_add_with_properties -GtkResizeMode -gtk_container_get_resize_mode -gtk_container_set_resize_mode gtk_container_check_resize gtk_container_foreach gtk_container_get_children diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c index fcd086d765..f5396bddb4 100644 --- a/gtk/gtkcontainer.c +++ b/gtk/gtkcontainer.c @@ -283,8 +283,6 @@ struct _GtkContainerPrivate guint has_focus_chain : 1; guint reallocate_redraws : 1; guint restyle_pending : 1; - guint resize_mode : 2; - guint resize_mode_set : 1; guint request_mode : 2; }; @@ -298,7 +296,6 @@ enum { enum { PROP_0, - PROP_RESIZE_MODE, PROP_CHILD, LAST_PROP }; @@ -502,14 +499,6 @@ gtk_container_class_init (GtkContainerClass *class) class->composite_name = gtk_container_child_default_composite_name; class->get_path_for_child = gtk_container_real_get_path_for_child; - container_props[PROP_RESIZE_MODE] = - g_param_spec_enum ("resize-mode", - P_("Resize mode"), - P_("Specify how resize events are handled"), - GTK_TYPE_RESIZE_MODE, - GTK_RESIZE_PARENT, - GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY|G_PARAM_DEPRECATED); - container_props[PROP_CHILD] = g_param_spec_object ("child", P_("Child"), @@ -1642,7 +1631,6 @@ gtk_container_init (GtkContainer *container) priv = container->priv; priv->focus_child = NULL; - priv->resize_mode = GTK_RESIZE_PARENT; priv->reallocate_redraws = FALSE; } @@ -1678,11 +1666,6 @@ gtk_container_set_property (GObject *object, switch (prop_id) { - case PROP_RESIZE_MODE: - G_GNUC_BEGIN_IGNORE_DEPRECATIONS; - gtk_container_set_resize_mode (container, g_value_get_enum (value)); - G_GNUC_END_IGNORE_DEPRECATIONS; - break; case PROP_CHILD: gtk_container_add (container, GTK_WIDGET (g_value_get_object (value))); break; @@ -1698,14 +1681,11 @@ gtk_container_get_property (GObject *object, GValue *value, GParamSpec *pspec) { - GtkContainer *container = GTK_CONTAINER (object); - GtkContainerPrivate *priv = container->priv; + //GtkContainer *container = GTK_CONTAINER (object); + //GtkContainerPrivate *priv = container->priv; switch (prop_id) { - case PROP_RESIZE_MODE: - g_value_set_enum (value, priv->resize_mode); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1790,91 +1770,6 @@ gtk_container_remove (GtkContainer *container, g_object_unref (container); } -static void -gtk_container_real_set_resize_mode (GtkContainer *container, - GtkResizeMode resize_mode) -{ - GtkWidget *widget = GTK_WIDGET (container); - GtkContainerPrivate *priv = container->priv; - - if (_gtk_widget_is_toplevel (widget) && - resize_mode == GTK_RESIZE_PARENT) - { - resize_mode = GTK_RESIZE_QUEUE; - } - - if (priv->resize_mode != resize_mode) - { - priv->resize_mode = resize_mode; - - gtk_widget_queue_resize (widget); - g_object_notify_by_pspec (G_OBJECT (container), container_props[PROP_RESIZE_MODE]); - } -} - -/** - * gtk_container_set_resize_mode: - * @container: a #GtkContainer - * @resize_mode: the new resize mode - * - * Sets the resize mode for the container. - * - * The resize mode of a container determines whether a resize request - * will be passed to the container’s parent, queued for later execution - * or executed immediately. - * - * Deprecated: 3.12: Resize modes are deprecated. They aren’t necessary - * anymore since frame clocks and might introduce obscure bugs if - * used. - **/ -void -gtk_container_set_resize_mode (GtkContainer *container, - GtkResizeMode resize_mode) -{ - GtkContainerPrivate *priv; - - g_return_if_fail (GTK_IS_CONTAINER (container)); - g_return_if_fail (resize_mode <= GTK_RESIZE_IMMEDIATE); - - priv = container->priv; - priv->resize_mode_set = TRUE; - - gtk_container_real_set_resize_mode (container, resize_mode); -} - -void -gtk_container_set_default_resize_mode (GtkContainer *container, - GtkResizeMode resize_mode) -{ - GtkContainerPrivate *priv = container->priv; - - if (priv->resize_mode_set) - return; - - gtk_container_real_set_resize_mode (container, resize_mode); -} - -/** - * gtk_container_get_resize_mode: - * @container: a #GtkContainer - * - * Returns the resize mode for the container. See - * gtk_container_set_resize_mode (). - * - * Returns: the current resize mode - * - * Deprecated: 3.12: Resize modes are deprecated. They aren’t necessary - * anymore since frame clocks and might introduce obscure bugs if - * used. - **/ -GtkResizeMode -gtk_container_get_resize_mode (GtkContainer *container) -{ - g_return_val_if_fail (GTK_IS_CONTAINER (container), GTK_RESIZE_PARENT); - - return container->priv->resize_mode; -} - /** * gtk_container_set_reallocate_redraws: * @container: a #GtkContainer @@ -1901,15 +1796,9 @@ gtk_container_needs_idle_sizer (GtkContainer *container) { GtkContainerPrivate *priv = container->priv; - if (priv->resize_mode == GTK_RESIZE_PARENT) - return FALSE; - - if (container->priv->restyle_pending) + if (priv->restyle_pending) return TRUE; - if (priv->resize_mode == GTK_RESIZE_IMMEDIATE) - return FALSE; - return gtk_widget_needs_allocate (GTK_WIDGET (container)); } @@ -1991,32 +1880,13 @@ gtk_container_queue_resize_handler (GtkContainer *container) { GtkWidget *widget; - G_GNUC_BEGIN_IGNORE_DEPRECATIONS; - g_return_if_fail (GTK_IS_RESIZE_CONTAINER (container)); - G_GNUC_END_IGNORE_DEPRECATIONS; - widget = GTK_WIDGET (container); if (_gtk_widget_get_visible (widget) && - (_gtk_widget_is_toplevel (widget) || - _gtk_widget_get_realized (widget))) + gtk_widget_needs_allocate (widget) && + _gtk_widget_is_toplevel (widget)) { - switch (container->priv->resize_mode) - { - case GTK_RESIZE_QUEUE: - if (gtk_widget_needs_allocate (widget)) - gtk_container_start_idle_sizer (container); - break; - - case GTK_RESIZE_IMMEDIATE: - gtk_container_check_resize (container); - break; - - case GTK_RESIZE_PARENT: - default: - g_assert_not_reached (); - break; - } + gtk_container_start_idle_sizer (container); } } @@ -2061,25 +1931,19 @@ gtk_container_real_check_resize (GtkContainer *container) if (_gtk_widget_get_alloc_needed (widget)) { - gtk_widget_get_preferred_size (widget, &requisition, NULL); - gtk_widget_get_allocated_size (widget, &allocation, &baseline); + if (_gtk_widget_is_toplevel (widget)) + { + gtk_widget_get_preferred_size (widget, &requisition, NULL); + gtk_widget_get_allocated_size (widget, &allocation, &baseline); - if (requisition.width > allocation.width || - requisition.height > allocation.height) - { - G_GNUC_BEGIN_IGNORE_DEPRECATIONS; - if (GTK_IS_RESIZE_CONTAINER (container)) - { - gtk_widget_size_allocate (widget, &allocation); - } - else - gtk_widget_queue_resize (widget); - G_GNUC_END_IGNORE_DEPRECATIONS; - } - else - { + if (allocation.width < requisition.width) + allocation.width = requisition.width; + if (allocation.height < requisition.height) + allocation.height = requisition.height; gtk_widget_size_allocate_with_baseline (widget, &allocation, baseline); } + else + gtk_widget_queue_resize (widget); } else { @@ -2087,39 +1951,6 @@ gtk_container_real_check_resize (GtkContainer *container) } } -/* The container hasn't changed size but one of its children - * queued a resize request. Which means that the allocation - * is not sufficient for the requisition of some child. - * We’ve already performed a size request at this point, - * so we simply need to reallocate and let the allocation - * trickle down via GTK_WIDGET_ALLOC_NEEDED flags. - */ -/** - * gtk_container_resize_children: - * @container: a #GtkContainer - * - * Deprecated: 3.10 - **/ -void -gtk_container_resize_children (GtkContainer *container) -{ - GtkAllocation allocation; - GtkWidget *widget; - gint baseline; - - /* resizing invariants: - * toplevels have *always* resize_mode != GTK_RESIZE_PARENT set. - * containers that have an idle sizer pending must be flagged with - * RESIZE_PENDING. - */ - g_return_if_fail (GTK_IS_CONTAINER (container)); - - widget = GTK_WIDGET (container); - gtk_widget_get_allocated_size (widget, &allocation, &baseline); - - gtk_widget_size_allocate_with_baseline (widget, &allocation, baseline); -} - typedef struct { gint hfw; gint wfh; diff --git a/gtk/gtkcontainer.h b/gtk/gtkcontainer.h index 63420cd5bb..aa59f4f273 100644 --- a/gtk/gtkcontainer.h +++ b/gtk/gtkcontainer.h @@ -119,20 +119,6 @@ struct _GtkContainerClass }; -/** - * GtkResizeMode: - * @GTK_RESIZE_PARENT: Pass resize request to the parent - * @GTK_RESIZE_QUEUE: Queue resizes on this widget - * @GTK_RESIZE_IMMEDIATE: Resize immediately. Deprecated. - */ -typedef enum -{ - GTK_RESIZE_PARENT, - GTK_RESIZE_QUEUE, - GTK_RESIZE_IMMEDIATE -} GtkResizeMode; - - /* Application-level methods */ GDK_AVAILABLE_IN_ALL @@ -145,12 +131,6 @@ GDK_AVAILABLE_IN_ALL void gtk_container_remove (GtkContainer *container, GtkWidget *widget); -GDK_DEPRECATED_IN_3_12 -void gtk_container_set_resize_mode (GtkContainer *container, - GtkResizeMode resize_mode); -GDK_DEPRECATED_IN_3_12 -GtkResizeMode gtk_container_get_resize_mode (GtkContainer *container); - GDK_AVAILABLE_IN_ALL void gtk_container_check_resize (GtkContainer *container); @@ -175,9 +155,6 @@ gboolean gtk_container_get_focus_chain (GtkContainer *container, GDK_AVAILABLE_IN_ALL void gtk_container_unset_focus_chain (GtkContainer *container); -#define GTK_IS_RESIZE_CONTAINER(widget) (GTK_IS_CONTAINER (widget) && \ - (gtk_container_get_resize_mode (GTK_CONTAINER (widget)) != GTK_RESIZE_PARENT)) - /* Widget-level methods */ GDK_DEPRECATED_IN_3_14 @@ -200,9 +177,6 @@ void gtk_container_set_focus_hadjustment (GtkContainer *container, GDK_AVAILABLE_IN_ALL GtkAdjustment *gtk_container_get_focus_hadjustment (GtkContainer *container); -GDK_DEPRECATED_IN_3_10 -void gtk_container_resize_children (GtkContainer *container); - GDK_AVAILABLE_IN_ALL GType gtk_container_child_type (GtkContainer *container); diff --git a/gtk/gtkcontainerprivate.h b/gtk/gtkcontainerprivate.h index 0681909d51..e581df958b 100644 --- a/gtk/gtkcontainerprivate.h +++ b/gtk/gtkcontainerprivate.h @@ -41,8 +41,6 @@ void _gtk_container_stop_idle_sizer (GtkContainer *container); void _gtk_container_maybe_start_idle_sizer (GtkContainer *container); void gtk_container_get_children_clip (GtkContainer *container, GtkAllocation *out_clip); -void gtk_container_set_default_resize_mode (GtkContainer *container, - GtkResizeMode resize_mode); G_END_DECLS diff --git a/gtk/gtkcsswidgetnode.c b/gtk/gtkcsswidgetnode.c index 3cce56dc87..e2db2eface 100644 --- a/gtk/gtkcsswidgetnode.c +++ b/gtk/gtkcsswidgetnode.c @@ -94,13 +94,11 @@ gtk_css_widget_node_queue_validate (GtkCssNode *node) { GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node); - G_GNUC_BEGIN_IGNORE_DEPRECATIONS - if (GTK_IS_RESIZE_CONTAINER (widget_node->widget)) + if (widget_node->widget && _gtk_widget_is_toplevel (widget_node->widget)) widget_node->validate_cb_id = gtk_widget_add_tick_callback (widget_node->widget, gtk_css_widget_node_queue_callback, node, NULL); - G_GNUC_END_IGNORE_DEPRECATIONS } static void @@ -108,11 +106,9 @@ gtk_css_widget_node_dequeue_validate (GtkCssNode *node) { GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node); - G_GNUC_BEGIN_IGNORE_DEPRECATIONS - if (GTK_IS_RESIZE_CONTAINER (widget_node->widget)) + if (widget_node->widget && _gtk_widget_is_toplevel (widget_node->widget)) gtk_widget_remove_tick_callback (widget_node->widget, widget_node->validate_cb_id); - G_GNUC_END_IGNORE_DEPRECATIONS } static void diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index c35fefd5dd..32985f4253 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -5272,11 +5272,9 @@ G_GNUC_END_IGNORE_DEPRECATIONS } } -G_GNUC_BEGIN_IGNORE_DEPRECATIONS; - if (GTK_IS_RESIZE_CONTAINER (widget)) + if (_gtk_widget_is_toplevel (widget)) { gtk_container_queue_resize_handler (GTK_CONTAINER (widget)); -G_GNUC_END_IGNORE_DEPRECATIONS; } else if (_gtk_widget_get_visible (widget)) { @@ -14948,13 +14946,11 @@ gtk_widget_set_alloc_needed (GtkWidget *widget) if (!priv->visible) break; -G_GNUC_BEGIN_IGNORE_DEPRECATIONS; - if (GTK_IS_RESIZE_CONTAINER (widget)) + if (_gtk_widget_is_toplevel (widget)) { gtk_container_queue_resize_handler (GTK_CONTAINER (widget)); break; } -G_GNUC_END_IGNORE_DEPRECATIONS; widget = priv->parent; if (widget == NULL) diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 93ad17120d..2f9356186c 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -1603,8 +1603,6 @@ gtk_window_init (GtkWindow *window) _gtk_widget_set_is_toplevel (widget, TRUE); _gtk_widget_set_anchored (widget, TRUE); - gtk_container_set_default_resize_mode (GTK_CONTAINER (window), GTK_RESIZE_QUEUE); - priv->title = NULL; priv->wm_role = NULL; priv->geometry_info = NULL; @@ -6893,8 +6891,6 @@ gtk_window_realize (GtkWidget *widget) if (gtk_widget_get_parent_window (widget)) { - gtk_container_set_default_resize_mode (GTK_CONTAINER (widget), GTK_RESIZE_PARENT); - attributes.x = allocation.x; attributes.y = allocation.y; attributes.width = allocation.width; @@ -6925,8 +6921,6 @@ gtk_window_realize (GtkWidget *widget) return; } - gtk_container_set_default_resize_mode (GTK_CONTAINER (window), GTK_RESIZE_QUEUE); - /* ensure widget tree is properly size allocated */ if (allocation.x == -1 && allocation.y == -1 && @@ -9080,7 +9074,6 @@ gtk_window_move_resize (GtkWindow *window) */ GtkWindowPrivate *priv = window->priv; GtkWidget *widget; - GtkContainer *container; GtkWindowGeometryInfo *info; GdkGeometry new_geometry; GdkWindow *gdk_window; @@ -9095,7 +9088,6 @@ gtk_window_move_resize (GtkWindow *window) widget = GTK_WIDGET (window); gdk_window = _gtk_widget_get_window (widget); - container = GTK_CONTAINER (widget); info = gtk_window_get_geometry_info (window, TRUE); configure_request_size_changed = FALSE; @@ -9378,11 +9370,6 @@ gtk_window_move_resize (GtkWindow *window) allocation.height = new_request.height; gtk_widget_size_allocate (widget, &allocation); - - G_GNUC_BEGIN_IGNORE_DEPRECATIONS; - if (gtk_container_get_resize_mode (container) == GTK_RESIZE_QUEUE) - gtk_widget_queue_draw (widget); - G_GNUC_END_IGNORE_DEPRECATIONS; } else {