From 195397e87ac7e03173dfe65d1cf52e2751c07706 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 14 Sep 2015 17:56:05 +0200 Subject: [PATCH] API: widget: Add gtk_widget_queue_allocate() This is so widgets can queue a rerun of their allocation logic, but without triggering resizes everywhere. For now, it just calls gtk_widget_queue_resize(). --- gtk/gtkwidget.c | 28 +++++++++++++++++++++++++--- gtk/gtkwidget.h | 2 ++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index cb2a178364..75fa7434f7 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -5576,6 +5576,28 @@ gtk_widget_queue_draw (GtkWidget *widget) 0, 0, rect.width, rect.height); } +/** + * gtk_widget_queue_allocate: + * @widget: a #GtkWidget + * + * This function is only for use in widget implementations. + * + * Flags the widget for a rerun of the GtkWidgetClass::size_allocate + * function. Use this function instead of gtk_widget_queue_resize() + * when the @widget's size request didn't change but it wants to + * reposition its contents. + * + * An example user of this function is gtk_widget_set_halign(). + */ +void +gtk_widget_queue_allocate (GtkWidget *widget) +{ + g_return_if_fail (GTK_IS_WIDGET (widget)); + + /* for now... */ + gtk_widget_queue_resize (widget); +} + /** * gtk_widget_queue_resize: * @widget: a #GtkWidget @@ -10979,7 +11001,7 @@ gtk_widget_error_bell (GtkWidget *widget) settings = gtk_widget_get_settings (widget); if (!settings) - return; + return; g_object_get (settings, "gtk-error-bell", &beep, @@ -14544,7 +14566,7 @@ gtk_widget_set_halign (GtkWidget *widget, return; widget->priv->halign = align; - gtk_widget_queue_resize (widget); + gtk_widget_queue_allocate (widget); g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_HALIGN]); } @@ -14610,7 +14632,7 @@ gtk_widget_set_valign (GtkWidget *widget, return; widget->priv->valign = align; - gtk_widget_queue_resize (widget); + gtk_widget_queue_allocate (widget); g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_VALIGN]); } diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index e98c537b34..61881c2ed6 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -663,6 +663,8 @@ GDK_AVAILABLE_IN_ALL void gtk_widget_queue_resize (GtkWidget *widget); GDK_AVAILABLE_IN_ALL void gtk_widget_queue_resize_no_redraw (GtkWidget *widget); +GDK_AVAILABLE_IN_3_20 +void gtk_widget_queue_allocate (GtkWidget *widget); GDK_AVAILABLE_IN_3_8 GdkFrameClock* gtk_widget_get_frame_clock (GtkWidget *widget);