diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index fd93df5a50..473a96fb2a 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -753,7 +753,6 @@ GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID gtk_container_add gtk_container_remove gtk_container_add_with_properties -gtk_container_check_resize gtk_container_foreach gtk_container_get_children gtk_container_get_path_for_child diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c index 58085d3135..f1ef23e8e4 100644 --- a/gtk/gtkcontainer.c +++ b/gtk/gtkcontainer.c @@ -34,12 +34,11 @@ #include "gtkpopovermenu.h" #include "gtkprivate.h" #include "gtkmarshalers.h" -#include "gtkshortcutssection.h" -#include "gtkshortcutswindow.h" #include "gtksizerequest.h" #include "gtkstylecontextprivate.h" #include "gtktypebuiltins.h" #include "gtkwidgetprivate.h" +#include "gtkwindowprivate.h" #include "a11y/gtkcontaineraccessibleprivate.h" @@ -129,7 +128,6 @@ struct _GtkContainerPrivate enum { ADD, REMOVE, - CHECK_RESIZE, SET_FOCUS_CHILD, LAST_SIGNAL }; @@ -148,7 +146,6 @@ static void gtk_container_add_unimplemented (GtkContainer *container GtkWidget *widget); static void gtk_container_remove_unimplemented (GtkContainer *container, GtkWidget *widget); -static void gtk_container_real_check_resize (GtkContainer *container); static void gtk_container_compute_expand (GtkWidget *widget, gboolean *hexpand_p, gboolean *vexpand_p); @@ -284,7 +281,6 @@ gtk_container_class_init (GtkContainerClass *class) class->add = gtk_container_add_unimplemented; class->remove = gtk_container_remove_unimplemented; - class->check_resize = gtk_container_real_check_resize; class->forall = NULL; class->set_focus_child = gtk_container_real_set_focus_child; class->child_type = NULL; @@ -308,14 +304,6 @@ gtk_container_class_init (GtkContainerClass *class) NULL, G_TYPE_NONE, 1, GTK_TYPE_WIDGET); - container_signals[CHECK_RESIZE] = - g_signal_new (I_("check-resize"), - G_OBJECT_CLASS_TYPE (gobject_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GtkContainerClass, check_resize), - NULL, NULL, - NULL, - G_TYPE_NONE, 0); container_signals[SET_FOCUS_CHILD] = g_signal_new (I_("set-focus-child"), G_OBJECT_CLASS_TYPE (gobject_class), @@ -1397,7 +1385,10 @@ gtk_container_idle_sizer (GdkFrameClock *clock, */ if (gtk_widget_needs_allocate (GTK_WIDGET (container))) { - gtk_container_check_resize (container); + if (GTK_IS_WINDOW (container)) + gtk_window_check_resize (GTK_WINDOW (container)); + else + g_warning ("gtk_container_idle_sizer() called on a non-window"); } if (!gtk_container_needs_idle_sizer (container)) @@ -1460,44 +1451,6 @@ _gtk_container_queue_restyle (GtkContainer *container) gtk_container_start_idle_sizer (container); } -void -gtk_container_check_resize (GtkContainer *container) -{ - g_return_if_fail (GTK_IS_CONTAINER (container)); - - g_signal_emit (container, container_signals[CHECK_RESIZE], 0); -} - -static void -gtk_container_real_check_resize (GtkContainer *container) -{ - GtkWidget *widget = GTK_WIDGET (container); - GtkAllocation allocation; - GtkRequisition requisition; - int baseline; - - if (_gtk_widget_get_alloc_needed (widget)) - { - if (!_gtk_widget_is_toplevel (widget)) - { - gtk_widget_get_preferred_size (widget, &requisition, NULL); - gtk_widget_get_allocated_size (widget, &allocation, &baseline); - - if (allocation.width < requisition.width) - allocation.width = requisition.width; - if (allocation.height < requisition.height) - allocation.height = requisition.height; - gtk_widget_size_allocate (widget, &allocation, baseline); - } - else - gtk_widget_queue_resize (widget); - } - else - { - gtk_widget_ensure_allocate (widget); - } -} - static GtkSizeRequestMode gtk_container_get_request_mode (GtkWidget *widget) { diff --git a/gtk/gtkcontainer.h b/gtk/gtkcontainer.h index 8f07f97408..4e2aa50aec 100644 --- a/gtk/gtkcontainer.h +++ b/gtk/gtkcontainer.h @@ -56,7 +56,6 @@ struct _GtkContainer * @parent_class: The parent class. * @add: Signal emitted when a widget is added to container. * @remove: Signal emitted when a widget is removed from container. - * @check_resize: Signal emitted when a size recalculation is needed. * @forall: Invokes callback on each child of container. The callback handler * may remove the child. * @set_focus_child: Sets the focused child of container. @@ -78,7 +77,6 @@ struct _GtkContainerClass GtkWidget *widget); void (*remove) (GtkContainer *container, GtkWidget *widget); - void (*check_resize) (GtkContainer *container); void (*forall) (GtkContainer *container, GtkCallback callback, gpointer callback_data); @@ -125,9 +123,6 @@ GDK_AVAILABLE_IN_ALL void gtk_container_remove (GtkContainer *container, GtkWidget *widget); -GDK_AVAILABLE_IN_ALL -void gtk_container_check_resize (GtkContainer *container); - GDK_AVAILABLE_IN_ALL void gtk_container_foreach (GtkContainer *container, GtkCallback callback, diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index b101fc7376..03b8c500e9 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -432,7 +432,6 @@ static void gtk_window_focus_out (GtkWidget *widget); static void surface_state_changed (GtkWidget *widget); static void gtk_window_remove (GtkContainer *container, GtkWidget *widget); -static void gtk_window_check_resize (GtkContainer *container); static void gtk_window_forall (GtkContainer *container, GtkCallback callback, gpointer callback_data); @@ -809,7 +808,6 @@ gtk_window_class_init (GtkWindowClass *klass) container_class->add = gtk_window_add; container_class->remove = gtk_window_remove; - container_class->check_resize = gtk_window_check_resize; container_class->forall = gtk_window_forall; klass->set_focus = gtk_window_real_set_focus; @@ -5704,7 +5702,6 @@ gtk_window_show (GtkWidget *widget) { GtkWindow *window = GTK_WINDOW (widget); GtkWindowPrivate *priv = gtk_window_get_instance_private (window); - GtkContainer *container = GTK_CONTAINER (window); if (!_gtk_widget_is_toplevel (GTK_WIDGET (widget))) { @@ -5718,7 +5715,7 @@ gtk_window_show (GtkWidget *widget) gtk_widget_realize (widget); - gtk_container_check_resize (container); + gtk_window_check_resize (window); gtk_widget_map (widget); @@ -7157,13 +7154,15 @@ gtk_window_remove (GtkContainer *container, GTK_CONTAINER_CLASS (gtk_window_parent_class)->remove (container, widget); } -static void -gtk_window_check_resize (GtkContainer *container) +void +gtk_window_check_resize (GtkWindow *self) { - if (!_gtk_widget_get_alloc_needed (GTK_WIDGET (container))) - GTK_CONTAINER_CLASS (gtk_window_parent_class)->check_resize (container); - else if (gtk_widget_get_visible (GTK_WIDGET (container))) - gtk_window_move_resize (GTK_WINDOW (container)); + GtkWidget *widget = GTK_WIDGET (self); + + if (!_gtk_widget_get_alloc_needed (widget)) + gtk_widget_ensure_allocate (widget); + else if (gtk_widget_get_visible (widget)) + gtk_window_move_resize (self); } static void diff --git a/gtk/gtkwindowprivate.h b/gtk/gtkwindowprivate.h index 1de4e0bedb..f57a1b377b 100644 --- a/gtk/gtkwindowprivate.h +++ b/gtk/gtkwindowprivate.h @@ -54,6 +54,7 @@ void _gtk_window_set_allocation (GtkWindow *window, int width, int height, GtkAllocation *allocation_out); +void gtk_window_check_resize (GtkWindow *self); typedef void (*GtkWindowKeysForeachFunc) (GtkWindow *window, guint keyval,