[gtk+] Fix initial size allocation with child widgets



commit 630b2c58b4e7f5ba245ab57794c31a6b2e6090d4
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Oct 29 21:13:55 2010 -0400

    Fix initial size allocation with child widgets
    
    On some cases, it would take a resize of the window for children
    to 'jump into place'.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=633500

 gtk/gtkstatusbar.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkstatusbar.c b/gtk/gtkstatusbar.c
index 704b3b6..cee0143 100644
--- a/gtk/gtkstatusbar.c
+++ b/gtk/gtkstatusbar.c
@@ -106,6 +106,7 @@ static GObject *gtk_statusbar_buildable_get_internal_child (GtkBuildable *builda
 static void     gtk_statusbar_update            (GtkStatusbar      *statusbar,
 						 guint              context_id,
 						 const gchar       *text);
+static void     gtk_statusbar_realize           (GtkWidget         *widget);
 static void     gtk_statusbar_destroy           (GtkWidget         *widget);
 static void     gtk_statusbar_size_allocate     (GtkWidget         *widget,
                                                  GtkAllocation     *allocation);
@@ -128,6 +129,7 @@ gtk_statusbar_class_init (GtkStatusbarClass *class)
   gobject_class = (GObjectClass *) class;
   widget_class = (GtkWidgetClass *) class;
 
+  widget_class->realize = gtk_statusbar_realize;
   widget_class->destroy = gtk_statusbar_destroy;
   widget_class->size_allocate = gtk_statusbar_size_allocate;
   widget_class->hierarchy_changed = gtk_statusbar_hierarchy_changed;
@@ -646,11 +648,11 @@ gtk_statusbar_size_allocate (GtkWidget     *widget,
   GdkRectangle translated_rect;
 
   window = gtk_widget_get_toplevel (widget);
+
   if (GTK_IS_WINDOW (window) &&
       gtk_window_resize_grip_is_visible (GTK_WINDOW (window)))
     {
       gtk_window_get_resize_grip_area (GTK_WINDOW (window), &rect);
-
       if (gtk_widget_translate_coordinates (gtk_widget_get_parent (widget),
                                             window,
                                             allocation->x,
@@ -733,9 +735,9 @@ resize_grip_visible_changed (GObject    *object,
   GtkStatusbar *statusbar = GTK_STATUSBAR (user_data);
   GtkStatusbarPrivate *priv = statusbar->priv;
 
-  gtk_widget_queue_resize (GTK_WIDGET (statusbar));
   gtk_widget_queue_resize (priv->label);
   gtk_widget_queue_resize (priv->frame);
+  gtk_widget_queue_resize (GTK_WIDGET (statusbar));
 }
 
 static void
@@ -752,4 +754,14 @@ gtk_statusbar_hierarchy_changed (GtkWidget *widget,
   if (GTK_IS_WINDOW (window))
     g_signal_connect (window, "notify::resize-grip-visible",
                       G_CALLBACK (resize_grip_visible_changed), widget);
+
+  resize_grip_visible_changed (NULL, NULL, widget);
+}
+
+static void
+gtk_statusbar_realize (GtkWidget *widget)
+{
+  GTK_WIDGET_CLASS (gtk_statusbar_parent_class)->realize (widget);
+
+  resize_grip_visible_changed (NULL, NULL, widget);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]