]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
GTK3 port: replace size_request in the Columns layout class.
authorSimon Tatham <anakin@pobox.com>
Sun, 16 Aug 2015 13:16:08 +0000 (14:16 +0100)
committerSimon Tatham <anakin@pobox.com>
Sun, 16 Aug 2015 13:50:48 +0000 (14:50 +0100)
It's been replaced by a new pair of methods get_preferred_width and
get_preferred_height. For the moment, I've followed the porting
guide's suggestion of keeping the old size_request function as an
underlying implementation and having each of those methods just return
one of its outputs. The results are ugly, but it'll compile and run,
which is a start.

unix/gtkcols.c

index 3f5873200678cdf464c6da2bfe749ed22a284eb4..4ecddb435513999356dc31587f8104d2fe63a6f8 100644 (file)
@@ -22,6 +22,12 @@ static void columns_forall(GtkContainer *container, gboolean include_internals,
 static gint columns_focus(GtkContainer *container, GtkDirectionType dir);
 #endif
 static GType columns_child_type(GtkContainer *container);
+#if GTK_CHECK_VERSION(3,0,0)
+static void columns_get_preferred_width(GtkWidget *widget,
+                                        gint *min, gint *nat);
+static void columns_get_preferred_height(GtkWidget *widget,
+                                         gint *min, gint *nat);
+#endif
 static void columns_size_request(GtkWidget *widget, GtkRequisition *req);
 static void columns_size_allocate(GtkWidget *widget, GtkAllocation *alloc);
 
@@ -104,7 +110,12 @@ static void columns_class_init(ColumnsClass *klass)
     widget_class->draw = columns_draw;
     widget_class->expose_event = columns_expose;
 #endif
+#if GTK_CHECK_VERSION(3,0,0)
+    widget_class->get_preferred_width = columns_get_preferred_width;
+    widget_class->get_preferred_height = columns_get_preferred_height;
+#else
     widget_class->size_request = columns_size_request;
+#endif
     widget_class->size_allocate = columns_size_allocate;
 
     container_class->add = columns_base_add;
@@ -642,6 +653,24 @@ static void columns_size_request(GtkWidget *widget, GtkRequisition *req)
     g_free(colypos);
 }
 
+#if GTK_CHECK_VERSION(3,0,0)
+static void columns_get_preferred_width(GtkWidget *widget,
+                                        gint *min, gint *nat)
+{
+    GtkRequisition req;
+    columns_size_request(widget, &req);
+    *min = *nat = req.width;
+}
+
+static void columns_get_preferred_height(GtkWidget *widget,
+                                        gint *min, gint *nat)
+{
+    GtkRequisition req;
+    columns_size_request(widget, &req);
+    *min = *nat = req.height;
+}
+#endif
+
 static void columns_size_allocate(GtkWidget *widget, GtkAllocation *alloc)
 {
     Columns *cols;