[gtk/wip/layout-manager: 92/98] Add GtkWidget:layout-manager
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/layout-manager: 92/98] Add GtkWidget:layout-manager
- Date: Tue, 5 Feb 2019 13:17:27 +0000 (UTC)
commit 7677e6afd869ec0dfcb1a48260ce7814c1b7dffa
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 52b8b0f78a..10854fe214 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -540,6 +540,7 @@ enum {
PROP_EXPAND,
PROP_SCALE_FACTOR,
PROP_CSS_NAME,
+ PROP_LAYOUT_MANAGER,
NUM_PROPERTIES
};
@@ -1333,6 +1334,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);
/**
@@ -2327,6 +2341,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;
@@ -2467,6 +2484,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;
@@ -13634,6 +13654,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]