[gtk/wip/layout-manager: 130/135] Add GtkWidget:layout-manager



commit 9788f05a84231c7f2ce04c5dc7eec301a1a03adc
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 64ce2f7537..d36594c960 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
 };
 
@@ -1329,6 +1330,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_EXPLICIT_NOTIFY);
+
   g_object_class_install_properties (gobject_class, NUM_PROPERTIES, widget_props);
 
   /**
@@ -2323,6 +2337,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;
@@ -2463,6 +2480,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;
@@ -13627,6 +13647,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]