[gnome-initial-setup/wip/bin-fanciness] gis-page: implement size request/allocation methods



commit b1f9b3ffaa22d39cb398d2979e986607c5f4f899
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Thu Nov 8 18:11:18 2012 -0500

    gis-page: implement size request/allocation methods
    
    Since GtkBin is an abstract class, it expects clients to implement the
    size request and allocation methods.
    Do that, or the pages will always be 0x0.

 gnome-initial-setup/gis-page.c |   51 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 51 insertions(+), 0 deletions(-)
---
diff --git a/gnome-initial-setup/gis-page.c b/gnome-initial-setup/gis-page.c
index d01135f..68924fc 100644
--- a/gnome-initial-setup/gis-page.c
+++ b/gnome-initial-setup/gis-page.c
@@ -171,9 +171,56 @@ gis_page_constructed (GObject *object)
 }
 
 static void
+gis_page_get_preferred_width (GtkWidget           *widget,
+                              gint                *minimum_width,
+                              gint                *natural_width)
+{
+  GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
+
+  if (child && gtk_widget_get_visible (child))
+    {
+      gint child_min, child_nat;
+      gtk_widget_get_preferred_width (child, &child_min, &child_nat);
+
+      *minimum_width = child_min;
+      *natural_width = child_nat;
+    }
+}
+
+static void
+gis_page_get_preferred_height (GtkWidget           *widget,
+                               gint                *minimum_height,
+                               gint                *natural_height)
+{
+  GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
+
+  if (child && gtk_widget_get_visible (child))
+    {
+      gint child_min, child_nat;
+      gtk_widget_get_preferred_height (child, &child_min, &child_nat);
+
+      *minimum_height = child_min;
+      *natural_height = child_nat;
+    }
+}
+
+static void
+gis_page_size_allocate (GtkWidget *widget,
+                        GtkAllocation *allocation)
+{
+  GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
+
+  gtk_widget_set_allocation (widget, allocation);
+
+  if (child && gtk_widget_get_visible (child))
+    gtk_widget_size_allocate (child, allocation);
+}
+
+static void
 gis_page_class_init (GisPageClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GtkWidgetClass *wclass = GTK_WIDGET_CLASS (klass);
 
   object_class->constructed = gis_page_constructed;
   object_class->dispose = gis_page_dispose;
@@ -183,6 +230,10 @@ gis_page_class_init (GisPageClass *klass)
 
   klass->get_builder = gis_page_real_get_builder;
 
+  wclass->get_preferred_width = gis_page_get_preferred_width;
+  wclass->get_preferred_height = gis_page_get_preferred_height;
+  wclass->size_allocate = gis_page_size_allocate;
+
   obj_props[PROP_DRIVER] =
     g_param_spec_object ("driver", "", "", GIS_TYPE_DRIVER,
                          G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);



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