From f1e23c401330615b16d9b3820c16e3792572b325 Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Thu, 21 Jun 2001 00:42:46 +0000 Subject: [PATCH] added gtk_container_child_set_property() and Thu Jun 21 02:13:40 2001 Tim Janik * gtk/gtkcontainer.[hc]: added gtk_container_child_set_property() and gtk_container_child_get_property(). --- ChangeLog | 5 +++ ChangeLog.pre-2-0 | 5 +++ ChangeLog.pre-2-10 | 5 +++ ChangeLog.pre-2-2 | 5 +++ ChangeLog.pre-2-4 | 5 +++ ChangeLog.pre-2-6 | 5 +++ ChangeLog.pre-2-8 | 5 +++ gtk/gtkcontainer.c | 107 +++++++++++++++++++++++++++++++++++++++++++++ gtk/gtkcontainer.h | 10 ++++- 9 files changed, 151 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 82c930c13..0c97a5280 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Jun 21 02:13:40 2001 Tim Janik + + * gtk/gtkcontainer.[hc]: added gtk_container_child_set_property() and + gtk_container_child_get_property(). + Wed Jun 20 19:19:15 2001 Jonathan Blandford * gtk/gtktreeview.c (gtk_tree_view_move_cursor_up_down): clean up diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 82c930c13..0c97a5280 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,8 @@ +Thu Jun 21 02:13:40 2001 Tim Janik + + * gtk/gtkcontainer.[hc]: added gtk_container_child_set_property() and + gtk_container_child_get_property(). + Wed Jun 20 19:19:15 2001 Jonathan Blandford * gtk/gtktreeview.c (gtk_tree_view_move_cursor_up_down): clean up diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 82c930c13..0c97a5280 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,8 @@ +Thu Jun 21 02:13:40 2001 Tim Janik + + * gtk/gtkcontainer.[hc]: added gtk_container_child_set_property() and + gtk_container_child_get_property(). + Wed Jun 20 19:19:15 2001 Jonathan Blandford * gtk/gtktreeview.c (gtk_tree_view_move_cursor_up_down): clean up diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 82c930c13..0c97a5280 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,8 @@ +Thu Jun 21 02:13:40 2001 Tim Janik + + * gtk/gtkcontainer.[hc]: added gtk_container_child_set_property() and + gtk_container_child_get_property(). + Wed Jun 20 19:19:15 2001 Jonathan Blandford * gtk/gtktreeview.c (gtk_tree_view_move_cursor_up_down): clean up diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 82c930c13..0c97a5280 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,8 @@ +Thu Jun 21 02:13:40 2001 Tim Janik + + * gtk/gtkcontainer.[hc]: added gtk_container_child_set_property() and + gtk_container_child_get_property(). + Wed Jun 20 19:19:15 2001 Jonathan Blandford * gtk/gtktreeview.c (gtk_tree_view_move_cursor_up_down): clean up diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 82c930c13..0c97a5280 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,8 @@ +Thu Jun 21 02:13:40 2001 Tim Janik + + * gtk/gtkcontainer.[hc]: added gtk_container_child_set_property() and + gtk_container_child_get_property(). + Wed Jun 20 19:19:15 2001 Jonathan Blandford * gtk/gtktreeview.c (gtk_tree_view_move_cursor_up_down): clean up diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 82c930c13..0c97a5280 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,8 @@ +Thu Jun 21 02:13:40 2001 Tim Janik + + * gtk/gtkcontainer.[hc]: added gtk_container_child_set_property() and + gtk_container_child_get_property(). + Wed Jun 20 19:19:15 2001 Jonathan Blandford * gtk/gtktreeview.c (gtk_tree_view_move_cursor_up_down): clean up diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c index ddd18f2fb..f0a587af3 100644 --- a/gtk/gtkcontainer.c +++ b/gtk/gtkcontainer.c @@ -379,6 +379,71 @@ gtk_container_child_get_valist (GtkContainer *container, g_object_unref (container); } +void +gtk_container_child_get_property (GtkContainer *container, + GtkWidget *child, + const gchar *property_name, + GValue *value) +{ + GParamSpec *pspec; + + g_return_if_fail (GTK_IS_CONTAINER (container)); + g_return_if_fail (GTK_IS_WIDGET (child)); + g_return_if_fail (child->parent == GTK_WIDGET (container)); + g_return_if_fail (property_name != NULL); + g_return_if_fail (G_IS_VALUE (value)); + + g_object_ref (container); + g_object_ref (child); + pspec = g_param_spec_pool_lookup (_gtk_widget_child_property_pool, property_name, + G_OBJECT_TYPE (container), TRUE); + if (!pspec) + g_warning ("%s: container class `%s' has no child property named `%s'", + G_STRLOC, + G_OBJECT_TYPE_NAME (container), + property_name); + else if (!(pspec->flags & G_PARAM_READABLE)) + g_warning ("%s: child property `%s' of container class `%s' is not readable", + G_STRLOC, + pspec->name, + G_OBJECT_TYPE_NAME (container)); + else + { + GValue *prop_value, tmp_value = { 0, }; + + /* auto-conversion of the callers value type + */ + if (G_VALUE_TYPE (value) == G_PARAM_SPEC_VALUE_TYPE (pspec)) + { + g_value_reset (value); + prop_value = value; + } + else if (!g_value_type_transformable (G_PARAM_SPEC_VALUE_TYPE (pspec), G_VALUE_TYPE (value))) + { + g_warning ("can't retrive child property `%s' of type `%s' as value of type `%s'", + pspec->name, + g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)), + G_VALUE_TYPE_NAME (value)); + g_object_unref (child); + g_object_unref (container); + return; + } + else + { + g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec)); + prop_value = &tmp_value; + } + container_get_child_property (container, child, pspec, prop_value); + if (prop_value != value) + { + g_value_transform (prop_value, value); + g_value_unset (&tmp_value); + } + } + g_object_unref (child); + g_object_unref (container); +} + void gtk_container_child_set_valist (GtkContainer *container, GtkWidget *child, @@ -445,6 +510,48 @@ gtk_container_child_set_valist (GtkContainer *container, g_object_unref (child); } +void +gtk_container_child_set_property (GtkContainer *container, + GtkWidget *child, + const gchar *property_name, + const GValue *value) +{ + GObject *object; + GObjectNotifyQueue *nqueue; + GParamSpec *pspec; + + g_return_if_fail (GTK_IS_CONTAINER (container)); + g_return_if_fail (GTK_IS_WIDGET (child)); + g_return_if_fail (child->parent == GTK_WIDGET (container)); + g_return_if_fail (property_name != NULL); + g_return_if_fail (G_IS_VALUE (value)); + + g_object_ref (container); + g_object_ref (child); + + object = G_OBJECT (container); + nqueue = g_object_notify_queue_freeze (G_OBJECT (child), _gtk_widget_child_property_notify_context); + pspec = g_param_spec_pool_lookup (_gtk_widget_child_property_pool, property_name, + G_OBJECT_TYPE (container), TRUE); + if (!pspec) + g_warning ("%s: container class `%s' has no child property named `%s'", + G_STRLOC, + G_OBJECT_TYPE_NAME (container), + property_name); + else if (!(pspec->flags & G_PARAM_WRITABLE)) + g_warning ("%s: child property `%s' of container class `%s' is not writable", + G_STRLOC, + pspec->name, + G_OBJECT_TYPE_NAME (container)); + else + { + container_set_child_property (container, child, pspec, value, nqueue); + } + g_object_notify_queue_thaw (G_OBJECT (child), nqueue); + g_object_unref (container); + g_object_unref (child); +} + void gtk_container_add_with_properties (GtkContainer *container, GtkWidget *widget, diff --git a/gtk/gtkcontainer.h b/gtk/gtkcontainer.h index 566b7d638..d8a9db2af 100644 --- a/gtk/gtkcontainer.h +++ b/gtk/gtkcontainer.h @@ -177,7 +177,15 @@ void gtk_container_child_get_valist (GtkContainer *container, GtkWidget *child, const gchar *first_property_name, va_list var_args); - +void gtk_container_child_set_property (GtkContainer *container, + GtkWidget *child, + const gchar *property_name, + const GValue *value); +void gtk_container_child_get_property (GtkContainer *container, + GtkWidget *child, + const gchar *property_name, + GValue *value); + #define GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID(object, property_id, pspec) \ G_OBJECT_WARN_INVALID_PSPEC ((object), "child property id", (property_id), (pspec))