[gtk/stackpage: 1/3] container: Add a function to get child metas
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/stackpage: 1/3] container: Add a function to get child metas
- Date: Wed, 6 Feb 2019 18:10:17 +0000 (UTC)
commit 2a1ce8c3299cf42862fa6ab4227c3fddf26f535d
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Feb 6 12:52:55 2019 -0500
container: Add a function to get child metas
Add gtk_container_get_child_meta and a corresponding vfunc.
This will be used to replace non-layout child properties.
gtk/gtkcontainer.c | 33 +++++++++++++++++++++++++++++++++
gtk/gtkcontainer.h | 6 +++++-
2 files changed, 38 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index 8dd90a51ec..e6dd40940f 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -413,6 +413,30 @@ gtk_container_buildable_set_child_property (GtkContainer *container,
GError *error = NULL;
GObjectNotifyQueue *nqueue;
+ if (GTK_CONTAINER_GET_CLASS (container)->get_child_meta != NULL)
+ {
+ GObject *child_meta = GTK_CONTAINER_GET_CLASS (container)->get_child_meta (container, child);
+ pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (child_meta), name);
+ if (pspec)
+ {
+ if (!gtk_builder_value_from_string (builder, pspec, value, &gvalue, &error))
+ {
+ g_warning ("Could not read property %s:%s with value %s of type %s: %s",
+ g_type_name (G_OBJECT_TYPE (container)),
+ name,
+ value,
+ g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
+ error->message);
+ g_error_free (error);
+ return;
+ }
+
+ g_object_set_property (child_meta, name, &gvalue);
+ g_value_unset (&gvalue);
+ return;
+ }
+ }
+
pspec = gtk_container_class_find_child_property (G_OBJECT_GET_CLASS (container), name);
if (!pspec)
{
@@ -1878,3 +1902,12 @@ gtk_container_get_path_for_child (GtkContainer *container,
return path;
}
+GObject *
+gtk_container_get_child_meta (GtkContainer *container,
+ GtkWidget *child)
+{
+ if (GTK_CONTAINER_GET_CLASS (container)->get_child_meta)
+ return GTK_CONTAINER_GET_CLASS (container)->get_child_meta (container, child);
+
+ return NULL;
+}
diff --git a/gtk/gtkcontainer.h b/gtk/gtkcontainer.h
index 8f07f97408..5d90fa17eb 100644
--- a/gtk/gtkcontainer.h
+++ b/gtk/gtkcontainer.h
@@ -98,6 +98,8 @@ struct _GtkContainerClass
GtkWidgetPath * (*get_path_for_child) (GtkContainer *container,
GtkWidget *child);
+ GObject * (*get_child_meta) (GtkContainer *container,
+ GtkWidget *child);
/*< private >*/
@@ -109,7 +111,6 @@ struct _GtkContainerClass
void (*_gtk_reserved5) (void);
void (*_gtk_reserved6) (void);
void (*_gtk_reserved7) (void);
- void (*_gtk_reserved8) (void);
};
@@ -233,6 +234,9 @@ void gtk_container_forall (GtkContainer *container,
GDK_AVAILABLE_IN_ALL
GtkWidgetPath * gtk_container_get_path_for_child (GtkContainer *container,
GtkWidget *child);
+GDK_AVAILABLE_IN_ALL
+GObject * gtk_container_get_child_meta (GtkContainer *container,
+ GtkWidget *child);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkContainer, g_object_unref)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]