[gtk/wip/layout-manager: 72/75] Add GtkWidget:layout-manager



commit 0b8bcaab892a6aea84a34e1b89dffcacd036a779
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Thu Dec 13 14:04:00 2018 +0000

    Add GtkWidget:layout-manager
    
    We can use a constructor property for existing container widgets with
    a layout policy, and move the layout policy implementation out of the
    widget itself and into a LayoutManager subclass.

 gtk/gtkwidget.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index c7b44362e7..fcbc967f18 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -536,6 +536,7 @@ enum {
   PROP_EXPAND,
   PROP_SCALE_FACTOR,
   PROP_CSS_NAME,
+  PROP_LAYOUT_MANAGER,
   NUM_PROPERTIES
 };
 
@@ -1332,6 +1333,19 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                            NULL,
                            GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
 
+  /**
+   * GtkWidget:layout-manager:
+   *
+   * The #GtkLayoutManager instance to use to compute the preferred size
+   * of the widget, and allocate its children.
+   */
+  widget_props[PROP_LAYOUT_MANAGER] =
+    g_param_spec_object ("layout-manager",
+                         P_("Layout Manager"),
+                         P_("The layout manager used to layout children of the widget"),
+                         GTK_TYPE_LAYOUT_MANAGER,
+                         GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT);
+
   g_object_class_install_properties (gobject_class, NUM_PROPERTIES, widget_props);
 
   /**
@@ -2326,6 +2340,9 @@ gtk_widget_set_property (GObject         *object,
       else
         gtk_css_node_set_name (priv->cssnode, GTK_WIDGET_GET_CLASS (widget)->priv->css_name);
       break;
+    case PROP_LAYOUT_MANAGER:
+      gtk_widget_set_layout_manager (widget, g_value_get_object (value));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -2466,6 +2483,9 @@ gtk_widget_get_property (GObject         *object,
     case PROP_CSS_NAME:
       g_value_set_string (value, gtk_css_node_get_name (priv->cssnode));
       break;
+    case PROP_LAYOUT_MANAGER:
+      g_value_set_object (value, gtk_widget_get_layout_manager (widget));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -13671,6 +13691,8 @@ gtk_widget_set_layout_manager (GtkWidget        *widget,
         gtk_layout_manager_set_widget (priv->layout_manager, widget);
 
       gtk_widget_queue_resize (widget);
+
+      g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_LAYOUT_MANAGER]);
     }
 }
 


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