[gtk/child-properties-be-gone: 10/12] Drop child property related apis
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/child-properties-be-gone: 10/12] Drop child property related apis
- Date: Fri, 5 Apr 2019 12:04:27 +0000 (UTC)
commit 70bf6d4b971b4cf03e4f156fd1b8b0bd5b998ac2
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Apr 5 04:02:53 2019 +0000
Drop child property related apis
We no longer have any child properties in
our containers, so drop the infrastructure for it.
docs/reference/gtk/gtk4-sections.txt | 17 -
gtk/gtkcontainer.c | 916 +----------------------------------
gtk/gtkcontainer.h | 85 ----
gtk/gtkwidget.c | 130 -----
gtk/gtkwidget.h | 16 -
5 files changed, 1 insertion(+), 1163 deletions(-)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index 6083aaee1b..a7e624f154 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -744,10 +744,8 @@ gtk_combo_box_text_get_type
<TITLE>GtkContainer</TITLE>
GtkContainer
GtkContainerClass
-GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID
gtk_container_add
gtk_container_remove
-gtk_container_add_with_properties
gtk_container_foreach
gtk_container_get_children
gtk_container_get_path_for_child
@@ -756,19 +754,7 @@ gtk_container_set_focus_vadjustment
gtk_container_get_focus_hadjustment
gtk_container_set_focus_hadjustment
gtk_container_child_type
-gtk_container_child_get
-gtk_container_child_set
-gtk_container_child_get_property
-gtk_container_child_set_property
-gtk_container_child_get_valist
-gtk_container_child_set_valist
-gtk_container_child_notify
-gtk_container_child_notify_by_pspec
gtk_container_forall
-gtk_container_class_find_child_property
-gtk_container_class_install_child_property
-gtk_container_class_install_child_properties
-gtk_container_class_list_child_properties
<SUBSECTION Standard>
GTK_CONTAINER
@@ -4485,8 +4471,6 @@ gtk_widget_class_set_accessible_type
gtk_widget_class_set_accessible_role
gtk_widget_get_accessible
gtk_widget_child_focus
-gtk_widget_child_notify
-gtk_widget_freeze_child_notify
gtk_widget_get_child_visible
gtk_widget_get_parent
gtk_widget_get_settings
@@ -4496,7 +4480,6 @@ gtk_widget_get_display
gtk_widget_get_size_request
gtk_widget_set_child_visible
gtk_widget_set_size_request
-gtk_widget_thaw_child_notify
gtk_widget_list_mnemonic_labels
gtk_widget_add_mnemonic_label
gtk_widget_remove_mnemonic_label
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index 9fb6d81d9e..47c375c6ef 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -27,18 +27,16 @@
#include "gtkcontainerprivate.h"
#include "gtkadjustment.h"
-#include "gtkassistant.h"
#include "gtkbuildable.h"
#include "gtkbuilderprivate.h"
#include "gtkintl.h"
-#include "gtkpopovermenu.h"
#include "gtkprivate.h"
#include "gtkmarshalers.h"
#include "gtksizerequest.h"
#include "gtkstylecontextprivate.h"
#include "gtktypebuiltins.h"
#include "gtkwidgetprivate.h"
-#include "gtkwindowprivate.h"
+//#include "gtkwindowprivate.h"
#include "a11y/gtkcontaineraccessibleprivate.h"
@@ -84,37 +82,6 @@
* with gtk_widget_set_parent() on init() and removed with gtk_widget_unparent()
* in the #GtkWidgetClass.destroy() implementation.
* See more about implementing custom widgets at https://wiki.gnome.org/HowDoI/CustomWidgets
- *
- * # Child properties
- *
- * GtkContainer introduces child properties.
- * These are object properties that are not specific
- * to either the container or the contained widget, but rather to their relation.
- * Typical examples of child properties are the position or pack-type of a widget
- * which is contained in a #GtkBox.
- *
- * Use gtk_container_class_install_child_property() to install child properties
- * for a container class and gtk_container_class_find_child_property() or
- * gtk_container_class_list_child_properties() to get information about existing
- * child properties.
- *
- * To set the value of a child property, use gtk_container_child_set_property(),
- * gtk_container_child_set() or gtk_container_child_set_valist().
- * To obtain the value of a child property, use
- * gtk_container_child_get_property(), gtk_container_child_get() or
- * gtk_container_child_get_valist(). To emit notification about child property
- * changes, use gtk_widget_child_notify().
- *
- * # GtkContainer as GtkBuildable
- *
- * The GtkContainer implementation of the GtkBuildable interface supports
- * a <packing> element for children, which can contain multiple <property>
- * elements that specify child properties for the child.
- *
- * Child properties can also be marked as translatable using
- * the same “translatable”, “comments” and “context” attributes that are used
- * for regular properties.
- *
*/
@@ -164,17 +131,6 @@ static void gtk_container_buildable_add_child (GtkBuildable *buildable,
GtkBuilder *builder,
GObject *child,
const gchar *type);
-static gboolean gtk_container_buildable_custom_tag_start (GtkBuildable *buildable,
- GtkBuilder *builder,
- GObject *child,
- const gchar *tagname,
- GMarkupParser *parser,
- gpointer *data);
-static void gtk_container_buildable_custom_tag_end (GtkBuildable *buildable,
- GtkBuilder *builder,
- GObject *child,
- const gchar *tagname,
- gpointer data);
/* --- variables --- */
static GQuark vadjustment_key_id;
@@ -182,8 +138,6 @@ static GQuark hadjustment_key_id;
static guint container_signals[LAST_SIGNAL] = { 0 };
static gint GtkContainer_private_offset;
static GtkWidgetClass *gtk_container_parent_class = NULL;
-extern GParamSpecPool *_gtk_widget_child_property_pool;
-extern GObjectNotifyContext *_gtk_widget_child_property_notify_context;
static GtkBuildableIface *parent_buildable_iface;
@@ -241,26 +195,11 @@ gtk_container_get_type (void)
static void
gtk_container_base_class_init (GtkContainerClass *class)
{
- /* reset instance specifc class fields that don't get inherited */
- class->set_child_property = NULL;
- class->get_child_property = NULL;
}
static void
gtk_container_base_class_finalize (GtkContainerClass *class)
{
- GList *list, *node;
-
- list = g_param_spec_pool_list_owned (_gtk_widget_child_property_pool, G_OBJECT_CLASS_TYPE (class));
- for (node = list; node; node = node->next)
- {
- GParamSpec *pspec = node->data;
-
- g_param_spec_pool_remove (_gtk_widget_child_property_pool, pspec);
- PARAM_SPEC_SET_PARAM_ID (pspec, 0);
- g_param_spec_unref (pspec);
- }
- g_list_free (list);
}
static void
@@ -315,8 +254,6 @@ gtk_container_buildable_init (GtkBuildableIface *iface)
{
parent_buildable_iface = g_type_interface_peek_parent (iface);
iface->add_child = gtk_container_buildable_add_child;
- iface->custom_tag_start = gtk_container_buildable_custom_tag_start;
- iface->custom_tag_end = gtk_container_buildable_custom_tag_end;
}
static void
@@ -343,261 +280,6 @@ gtk_container_buildable_add_child (GtkBuildable *buildable,
}
}
-static inline void
-container_set_child_property (GtkContainer *container,
- GtkWidget *child,
- GParamSpec *pspec,
- const GValue *value,
- GObjectNotifyQueue *nqueue)
-{
- GValue tmp_value = G_VALUE_INIT;
- GtkContainerClass *class = g_type_class_peek (pspec->owner_type);
-
- /* provide a copy to work from, convert (if necessary) and validate */
- g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
- if (!g_value_transform (value, &tmp_value))
- g_warning ("unable to set child property '%s' of type '%s' from value of type '%s'",
- pspec->name,
- g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
- G_VALUE_TYPE_NAME (value));
- else if (g_param_value_validate (pspec, &tmp_value) && !(pspec->flags & G_PARAM_LAX_VALIDATION))
- {
- gchar *contents = g_strdup_value_contents (value);
-
- g_warning ("value \"%s\" of type '%s' is invalid for property '%s' of type '%s'",
- contents,
- G_VALUE_TYPE_NAME (value),
- pspec->name,
- g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
- g_free (contents);
- }
- else
- {
- class->set_child_property (container, child, PARAM_SPEC_PARAM_ID (pspec), &tmp_value, pspec);
- g_object_notify_queue_add (G_OBJECT (child), nqueue, pspec);
- }
- g_value_unset (&tmp_value);
-}
-
-static void
-gtk_container_buildable_set_child_property (GtkContainer *container,
- GtkBuilder *builder,
- GtkWidget *child,
- gchar *name,
- const gchar *value)
-{
- GParamSpec *pspec;
- GValue gvalue = G_VALUE_INIT;
- GError *error = NULL;
- GObjectNotifyQueue *nqueue;
-
- pspec = gtk_container_class_find_child_property (G_OBJECT_GET_CLASS (container), name);
- if (!pspec)
- {
- g_warning ("%s does not have a child property called %s",
- G_OBJECT_TYPE_NAME (container), name);
- return;
- }
- else if (!(pspec->flags & G_PARAM_WRITABLE))
- {
- g_warning ("Child property '%s' of container class '%s' is not writable",
- name, G_OBJECT_TYPE_NAME (container));
- return;
- }
-
- 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_ref (container);
- g_object_ref (child);
- nqueue = g_object_notify_queue_freeze (G_OBJECT (child), _gtk_widget_child_property_notify_context);
- container_set_child_property (container, child, pspec, &gvalue, nqueue);
- g_object_notify_queue_thaw (G_OBJECT (child), nqueue);
- g_object_unref (container);
- g_object_unref (child);
- g_value_unset (&gvalue);
-}
-
-typedef struct {
- GtkBuilder *builder;
- GtkContainer *container;
- GtkWidget *child;
- GString *string;
- gchar *child_prop_name;
- gchar *context;
- gboolean translatable;
-} PackingData;
-
-static void
-packing_start_element (GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **names,
- const gchar **values,
- gpointer user_data,
- GError **error)
-{
- PackingData *data = (PackingData*)user_data;
-
- if (strcmp (element_name, "property") == 0)
- {
- const gchar *name;
- gboolean translatable = FALSE;
- const gchar *ctx = NULL;
-
- if (!_gtk_builder_check_parent (data->builder, context, "packing", error))
- return;
-
- if (!g_markup_collect_attributes (element_name, names, values, error,
- G_MARKUP_COLLECT_STRING, "name", &name,
- G_MARKUP_COLLECT_BOOLEAN|G_MARKUP_COLLECT_OPTIONAL, "translatable",
&translatable,
- G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "comments", NULL,
- G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "context", &ctx,
- G_MARKUP_COLLECT_INVALID))
- {
- _gtk_builder_prefix_error (data->builder, context, error);
- return;
- }
-
- data->child_prop_name = g_strdup (name);
- data->translatable = translatable;
- data->context = g_strdup (ctx);
- }
- else if (strcmp (element_name, "packing") == 0)
- {
- if (!_gtk_builder_check_parent (data->builder, context, "child", error))
- return;
-
- if (!g_markup_collect_attributes (element_name, names, values, error,
- G_MARKUP_COLLECT_INVALID, NULL, NULL,
- G_MARKUP_COLLECT_INVALID))
- _gtk_builder_prefix_error (data->builder, context, error);
- }
- else
- {
- _gtk_builder_error_unhandled_tag (data->builder, context,
- "GtkContainer", element_name,
- error);
- }
-}
-
-static void
-packing_text_element (GMarkupParseContext *context,
- const gchar *text,
- gsize text_len,
- gpointer user_data,
- GError **error)
-{
- PackingData *data = (PackingData*)user_data;
-
- if (data->child_prop_name)
- g_string_append_len (data->string, text, text_len);
-}
-
-static void
-packing_end_element (GMarkupParseContext *context,
- const gchar *element_name,
- gpointer user_data,
- GError **error)
-{
- PackingData *data = (PackingData*)user_data;
-
- /* translate the string */
- if (data->string->len && data->translatable)
- {
- const gchar *translated;
- const gchar *domain;
-
- domain = gtk_builder_get_translation_domain (data->builder);
-
- translated = _gtk_builder_parser_translate (domain,
- data->context,
- data->string->str);
- g_string_assign (data->string, translated);
- }
-
- if (data->child_prop_name)
- gtk_container_buildable_set_child_property (data->container,
- data->builder,
- data->child,
- data->child_prop_name,
- data->string->str);
-
- g_string_set_size (data->string, 0);
- g_clear_pointer (&data->child_prop_name, g_free);
- g_clear_pointer (&data->context, g_free);
- data->translatable = FALSE;
-}
-
-static const GMarkupParser packing_parser =
- {
- packing_start_element,
- packing_end_element,
- packing_text_element,
- };
-
-static gboolean
-gtk_container_buildable_custom_tag_start (GtkBuildable *buildable,
- GtkBuilder *builder,
- GObject *child,
- const gchar *tagname,
- GMarkupParser *parser,
- gpointer *parser_data)
-{
- if (parent_buildable_iface->custom_tag_start (buildable, builder, child,
- tagname, parser, parser_data))
- return TRUE;
-
- if (child && strcmp (tagname, "packing") == 0)
- {
- PackingData *data;
-
- data = g_slice_new0 (PackingData);
- data->string = g_string_new ("");
- data->builder = builder;
- data->container = GTK_CONTAINER (buildable);
- data->child = GTK_WIDGET (child);
- data->child_prop_name = NULL;
-
- *parser = packing_parser;
- *parser_data = data;
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-gtk_container_buildable_custom_tag_end (GtkBuildable *buildable,
- GtkBuilder *builder,
- GObject *child,
- const gchar *tagname,
- gpointer parser_data)
-{
- if (strcmp (tagname, "packing") == 0)
- {
- PackingData *data = (PackingData*)parser_data;
-
- g_string_free (data->string, TRUE);
- g_slice_free (PackingData, data);
-
- return;
- }
-
- if (parent_buildable_iface->custom_tag_end)
- parent_buildable_iface->custom_tag_end (buildable, builder,
- child, tagname, parser_data);
-}
-
/**
* gtk_container_child_type:
* @container: a #GtkContainer
@@ -627,602 +309,6 @@ gtk_container_child_type (GtkContainer *container)
return slot;
}
-/* --- GtkContainer child property mechanism --- */
-
-/**
- * gtk_container_child_notify:
- * @container: the #GtkContainer
- * @child: the child widget
- * @child_property: the name of a child property installed on
- * the class of @container
- *
- * Emits a #GtkWidget::child-notify signal for the
- * [child property][child-properties]
- * @child_property on the child.
- *
- * This is an analogue of g_object_notify() for child properties.
- *
- * Also see gtk_widget_child_notify().
- */
-void
-gtk_container_child_notify (GtkContainer *container,
- GtkWidget *child,
- const gchar *child_property)
-{
- GObject *obj;
- GParamSpec *pspec;
-
- g_return_if_fail (GTK_IS_CONTAINER (container));
- g_return_if_fail (GTK_IS_WIDGET (child));
- g_return_if_fail (child_property != NULL);
-
- obj = G_OBJECT (child);
-
- if (obj->ref_count == 0)
- return;
-
- g_object_ref (obj);
-
- pspec = g_param_spec_pool_lookup (_gtk_widget_child_property_pool,
- child_property,
- G_OBJECT_TYPE (container),
- TRUE);
-
- if (pspec == NULL)
- {
- g_warning ("%s: container class '%s' has no child property named '%s'",
- G_STRLOC,
- G_OBJECT_TYPE_NAME (container),
- child_property);
- }
- else
- {
- GObjectNotifyQueue *nqueue;
-
- nqueue = g_object_notify_queue_freeze (obj, _gtk_widget_child_property_notify_context);
-
- g_object_notify_queue_add (obj, nqueue, pspec);
- g_object_notify_queue_thaw (obj, nqueue);
- }
-
- g_object_unref (obj);
-}
-
-/**
- * gtk_container_child_notify_by_pspec:
- * @container: the #GtkContainer
- * @child: the child widget
- * @pspec: the #GParamSpec of a child property instealled on
- * the class of @container
- *
- * Emits a #GtkWidget::child-notify signal for the
- * [child property][child-properties] specified by
- * @pspec on the child.
- *
- * This is an analogue of g_object_notify_by_pspec() for child properties.
- */
-void
-gtk_container_child_notify_by_pspec (GtkContainer *container,
- GtkWidget *child,
- GParamSpec *pspec)
-{
- GObject *obj = G_OBJECT (child);
- GObjectNotifyQueue *nqueue;
-
- g_return_if_fail (GTK_IS_CONTAINER (container));
- g_return_if_fail (GTK_IS_WIDGET (child));
- g_return_if_fail (G_IS_PARAM_SPEC (pspec));
-
- if (obj->ref_count == 0)
- return;
-
- g_object_ref (obj);
-
- nqueue = g_object_notify_queue_freeze (obj, _gtk_widget_child_property_notify_context);
-
- g_object_notify_queue_add (obj, nqueue, pspec);
- g_object_notify_queue_thaw (obj, nqueue);
-
- g_object_unref (obj);
-}
-
-static inline void
-container_get_child_property (GtkContainer *container,
- GtkWidget *child,
- GParamSpec *pspec,
- GValue *value)
-{
- GtkContainerClass *class = g_type_class_peek (pspec->owner_type);
-
- class->get_child_property (container, child, PARAM_SPEC_PARAM_ID (pspec), value, pspec);
-}
-
-/**
- * gtk_container_child_get_valist:
- * @container: a #GtkContainer
- * @child: a widget which is a child of @container
- * @first_property_name: the name of the first property to get
- * @var_args: return location for the first property, followed
- * optionally by more name/return location pairs, followed by %NULL
- *
- * Gets the values of one or more child properties for @child and @container.
- **/
-void
-gtk_container_child_get_valist (GtkContainer *container,
- GtkWidget *child,
- const gchar *first_property_name,
- va_list var_args)
-{
- const gchar *name;
-
- g_return_if_fail (GTK_IS_CONTAINER (container));
- g_return_if_fail (GTK_IS_WIDGET (child));
-
- g_object_ref (container);
- g_object_ref (child);
-
- name = first_property_name;
- while (name)
- {
- GValue value = G_VALUE_INIT;
- GParamSpec *pspec;
- gchar *error;
-
- pspec = g_param_spec_pool_lookup (_gtk_widget_child_property_pool,
- 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),
- name);
- break;
- }
- 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));
- break;
- }
- g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
- container_get_child_property (container, child, pspec, &value);
- G_VALUE_LCOPY (&value, var_args, 0, &error);
- if (error)
- {
- g_warning ("%s: %s", G_STRLOC, error);
- g_free (error);
- g_value_unset (&value);
- break;
- }
- g_value_unset (&value);
- name = va_arg (var_args, gchar*);
- }
-
- g_object_unref (child);
- g_object_unref (container);
-}
-
-/**
- * gtk_container_child_get_property:
- * @container: a #GtkContainer
- * @child: a widget which is a child of @container
- * @property_name: the name of the property to get
- * @value: a location to return the value
- *
- * Gets the value of a child property for @child and @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 (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 = G_VALUE_INIT;
-
- /* 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 retrieve 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);
-}
-
-/**
- * gtk_container_child_set_valist:
- * @container: a #GtkContainer
- * @child: a widget which is a child of @container
- * @first_property_name: the name of the first property to set
- * @var_args: a %NULL-terminated list of property names and values, starting
- * with @first_prop_name
- *
- * Sets one or more child properties for @child and @container.
- **/
-void
-gtk_container_child_set_valist (GtkContainer *container,
- GtkWidget *child,
- const gchar *first_property_name,
- va_list var_args)
-{
- GObjectNotifyQueue *nqueue;
- const gchar *name;
-
- g_return_if_fail (GTK_IS_CONTAINER (container));
- g_return_if_fail (GTK_IS_WIDGET (child));
-
- g_object_ref (container);
- g_object_ref (child);
-
- nqueue = g_object_notify_queue_freeze (G_OBJECT (child), _gtk_widget_child_property_notify_context);
- name = first_property_name;
- while (name)
- {
- GValue value = G_VALUE_INIT;
- gchar *error = NULL;
- GParamSpec *pspec = g_param_spec_pool_lookup (_gtk_widget_child_property_pool,
- 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),
- name);
- break;
- }
- 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));
- break;
- }
-
- G_VALUE_COLLECT_INIT (&value, G_PARAM_SPEC_VALUE_TYPE (pspec),
- var_args, 0, &error);
- if (error)
- {
- g_warning ("%s: %s", G_STRLOC, error);
- g_free (error);
-
- /* we purposely leak the value here, it might not be
- * in a sane state if an error condition occoured
- */
- break;
- }
- container_set_child_property (container, child, pspec, &value, nqueue);
- g_value_unset (&value);
- name = va_arg (var_args, gchar*);
- }
- g_object_notify_queue_thaw (G_OBJECT (child), nqueue);
-
- g_object_unref (container);
- g_object_unref (child);
-}
-
-/**
- * gtk_container_child_set_property:
- * @container: a #GtkContainer
- * @child: a widget which is a child of @container
- * @property_name: the name of the property to set
- * @value: the value to set the property to
- *
- * Sets a child property for @child and @container.
- **/
-void
-gtk_container_child_set_property (GtkContainer *container,
- GtkWidget *child,
- const gchar *property_name,
- const GValue *value)
-{
- GObjectNotifyQueue *nqueue;
- GParamSpec *pspec;
-
- g_return_if_fail (GTK_IS_CONTAINER (container));
- g_return_if_fail (GTK_IS_WIDGET (child));
- g_return_if_fail (property_name != NULL);
- g_return_if_fail (G_IS_VALUE (value));
-
- g_object_ref (container);
- g_object_ref (child);
-
- 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);
-}
-
-/**
- * gtk_container_add_with_properties:
- * @container: a #GtkContainer
- * @widget: a widget to be placed inside @container
- * @first_prop_name: the name of the first child property to set
- * @...: a %NULL-terminated list of property names and values, starting
- * with @first_prop_name
- *
- * Adds @widget to @container, setting child properties at the same time.
- * See gtk_container_add() and gtk_container_child_set() for more details.
- */
-void
-gtk_container_add_with_properties (GtkContainer *container,
- GtkWidget *widget,
- const gchar *first_prop_name,
- ...)
-{
- g_return_if_fail (GTK_IS_CONTAINER (container));
- g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (_gtk_widget_get_parent (widget) == NULL);
-
- g_object_ref (container);
- g_object_ref (widget);
- gtk_widget_freeze_child_notify (widget);
-
- g_signal_emit (container, container_signals[ADD], 0, widget);
- if (_gtk_widget_get_parent (widget))
- {
- va_list var_args;
-
- va_start (var_args, first_prop_name);
- gtk_container_child_set_valist (container, widget, first_prop_name, var_args);
- va_end (var_args);
- }
-
- gtk_widget_thaw_child_notify (widget);
- g_object_unref (widget);
- g_object_unref (container);
-}
-
-/**
- * gtk_container_child_set:
- * @container: a #GtkContainer
- * @child: a widget which is a child of @container
- * @first_prop_name: the name of the first property to set
- * @...: a %NULL-terminated list of property names and values, starting
- * with @first_prop_name
- *
- * Sets one or more child properties for @child and @container.
- */
-void
-gtk_container_child_set (GtkContainer *container,
- GtkWidget *child,
- const gchar *first_prop_name,
- ...)
-{
- va_list var_args;
-
- va_start (var_args, first_prop_name);
- gtk_container_child_set_valist (container, child, first_prop_name, var_args);
- va_end (var_args);
-}
-
-/**
- * gtk_container_child_get:
- * @container: a #GtkContainer
- * @child: a widget which is a child of @container
- * @first_prop_name: the name of the first property to get
- * @...: return location for the first property, followed
- * optionally by more name/return location pairs, followed by %NULL
- *
- * Gets the values of one or more child properties for @child and @container.
- */
-void
-gtk_container_child_get (GtkContainer *container,
- GtkWidget *child,
- const gchar *first_prop_name,
- ...)
-{
- va_list var_args;
-
- va_start (var_args, first_prop_name);
- gtk_container_child_get_valist (container, child, first_prop_name, var_args);
- va_end (var_args);
-}
-
-static inline void
-install_child_property_internal (GType g_type,
- guint property_id,
- GParamSpec *pspec)
-{
- if (g_param_spec_pool_lookup (_gtk_widget_child_property_pool, pspec->name, g_type, FALSE))
- {
- g_warning ("Class '%s' already contains a child property named '%s'",
- g_type_name (g_type),
- pspec->name);
- return;
- }
- g_param_spec_ref (pspec);
- g_param_spec_sink (pspec);
- PARAM_SPEC_SET_PARAM_ID (pspec, property_id);
- g_param_spec_pool_insert (_gtk_widget_child_property_pool, pspec, g_type);
-}
-
-/**
- * gtk_container_class_install_child_property:
- * @cclass: a #GtkContainerClass
- * @property_id: the id for the property
- * @pspec: the #GParamSpec for the property
- *
- * Installs a child property on a container class.
- **/
-void
-gtk_container_class_install_child_property (GtkContainerClass *cclass,
- guint property_id,
- GParamSpec *pspec)
-{
- g_return_if_fail (GTK_IS_CONTAINER_CLASS (cclass));
- g_return_if_fail (G_IS_PARAM_SPEC (pspec));
- if (pspec->flags & G_PARAM_WRITABLE)
- g_return_if_fail (cclass->set_child_property != NULL);
- if (pspec->flags & G_PARAM_READABLE)
- g_return_if_fail (cclass->get_child_property != NULL);
- g_return_if_fail (property_id > 0);
- g_return_if_fail (PARAM_SPEC_PARAM_ID (pspec) == 0); /* paranoid */
- if (pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY))
- g_return_if_fail ((pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY)) == 0);
-
- install_child_property_internal (G_OBJECT_CLASS_TYPE (cclass), property_id, pspec);
-}
-
-/**
- * gtk_container_class_install_child_properties:
- * @cclass: a #GtkContainerClass
- * @n_pspecs: the length of the #GParamSpec array
- * @pspecs: (array length=n_pspecs): the #GParamSpec array defining the new
- * child properties
- *
- * Installs child properties on a container class.
- */
-void
-gtk_container_class_install_child_properties (GtkContainerClass *cclass,
- guint n_pspecs,
- GParamSpec **pspecs)
-{
- gint i;
-
- g_return_if_fail (GTK_IS_CONTAINER_CLASS (cclass));
- g_return_if_fail (n_pspecs > 1);
- g_return_if_fail (pspecs[0] == NULL);
-
- /* we skip the first element of the array as it would have a 0 prop_id */
- for (i = 1; i < n_pspecs; i++)
- {
- GParamSpec *pspec = pspecs[i];
-
- g_return_if_fail (G_IS_PARAM_SPEC (pspec));
- if (pspec->flags & G_PARAM_WRITABLE)
- g_return_if_fail (cclass->set_child_property != NULL);
- if (pspec->flags & G_PARAM_READABLE)
- g_return_if_fail (cclass->get_child_property != NULL);
- g_return_if_fail (PARAM_SPEC_PARAM_ID (pspec) == 0); /* paranoid */
- if (pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY))
- g_return_if_fail ((pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY)) == 0);
-
- install_child_property_internal (G_OBJECT_CLASS_TYPE (cclass), i, pspec);
- }
-}
-
-/**
- * gtk_container_class_find_child_property:
- * @cclass: (type GtkContainerClass): a #GtkContainerClass
- * @property_name: the name of the child property to find
- *
- * Finds a child property of a container class by name.
- *
- * Returns: (nullable) (transfer none): the #GParamSpec of the child
- * property or %NULL if @class has no child property with that
- * name.
- */
-GParamSpec*
-gtk_container_class_find_child_property (GObjectClass *cclass,
- const gchar *property_name)
-{
- g_return_val_if_fail (GTK_IS_CONTAINER_CLASS (cclass), NULL);
- g_return_val_if_fail (property_name != NULL, NULL);
-
- return g_param_spec_pool_lookup (_gtk_widget_child_property_pool,
- property_name,
- G_OBJECT_CLASS_TYPE (cclass),
- TRUE);
-}
-
-/**
- * gtk_container_class_list_child_properties:
- * @cclass: (type GtkContainerClass): a #GtkContainerClass
- * @n_properties: location to return the number of child properties found
- *
- * Returns all child properties of a container class.
- *
- * Returns: (array length=n_properties) (transfer container):
- * a newly allocated %NULL-terminated array of #GParamSpec*.
- * The array must be freed with g_free().
- */
-GParamSpec**
-gtk_container_class_list_child_properties (GObjectClass *cclass,
- guint *n_properties)
-{
- GParamSpec **pspecs;
- guint n;
-
- g_return_val_if_fail (GTK_IS_CONTAINER_CLASS (cclass), NULL);
-
- pspecs = g_param_spec_pool_list (_gtk_widget_child_property_pool,
- G_OBJECT_CLASS_TYPE (cclass),
- &n);
- if (n_properties)
- *n_properties = n;
-
- return pspecs;
-}
-
static void
gtk_container_add_unimplemented (GtkContainer *container,
GtkWidget *widget)
diff --git a/gtk/gtkcontainer.h b/gtk/gtkcontainer.h
index 4e2aa50aec..f092e40c86 100644
--- a/gtk/gtkcontainer.h
+++ b/gtk/gtkcontainer.h
@@ -83,16 +83,6 @@ struct _GtkContainerClass
void (*set_focus_child) (GtkContainer *container,
GtkWidget *child);
GType (*child_type) (GtkContainer *container);
- void (*set_child_property) (GtkContainer *container,
- GtkWidget *child,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
- void (*get_child_property) (GtkContainer *container,
- GtkWidget *child,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
GtkWidgetPath * (*get_path_for_child) (GtkContainer *container,
GtkWidget *child);
@@ -145,81 +135,6 @@ GtkAdjustment *gtk_container_get_focus_hadjustment (GtkContainer *container);
GDK_AVAILABLE_IN_ALL
GType gtk_container_child_type (GtkContainer *container);
-
-GDK_AVAILABLE_IN_ALL
-void gtk_container_class_install_child_property (GtkContainerClass *cclass,
- guint property_id,
- GParamSpec *pspec);
-GDK_AVAILABLE_IN_ALL
-void gtk_container_class_install_child_properties (GtkContainerClass *cclass,
- guint n_pspecs,
- GParamSpec **pspecs);
-GDK_AVAILABLE_IN_ALL
-GParamSpec* gtk_container_class_find_child_property (GObjectClass *cclass,
- const gchar *property_name);
-GDK_AVAILABLE_IN_ALL
-GParamSpec** gtk_container_class_list_child_properties (GObjectClass *cclass,
- guint *n_properties);
-GDK_AVAILABLE_IN_ALL
-void gtk_container_add_with_properties (GtkContainer *container,
- GtkWidget *widget,
- const gchar *first_prop_name,
- ...) G_GNUC_NULL_TERMINATED;
-GDK_AVAILABLE_IN_ALL
-void gtk_container_child_set (GtkContainer *container,
- GtkWidget *child,
- const gchar *first_prop_name,
- ...) G_GNUC_NULL_TERMINATED;
-GDK_AVAILABLE_IN_ALL
-void gtk_container_child_get (GtkContainer *container,
- GtkWidget *child,
- const gchar *first_prop_name,
- ...) G_GNUC_NULL_TERMINATED;
-GDK_AVAILABLE_IN_ALL
-void gtk_container_child_set_valist (GtkContainer *container,
- GtkWidget *child,
- const gchar *first_property_name,
- va_list var_args);
-GDK_AVAILABLE_IN_ALL
-void gtk_container_child_get_valist (GtkContainer *container,
- GtkWidget *child,
- const gchar *first_property_name,
- va_list var_args);
-GDK_AVAILABLE_IN_ALL
-void gtk_container_child_set_property (GtkContainer *container,
- GtkWidget *child,
- const gchar *property_name,
- const GValue *value);
-GDK_AVAILABLE_IN_ALL
-void gtk_container_child_get_property (GtkContainer *container,
- GtkWidget *child,
- const gchar *property_name,
- GValue *value);
-
-GDK_AVAILABLE_IN_ALL
-void gtk_container_child_notify (GtkContainer *container,
- GtkWidget *child,
- const gchar *child_property);
-
-GDK_AVAILABLE_IN_ALL
-void gtk_container_child_notify_by_pspec (GtkContainer *container,
- GtkWidget *child,
- GParamSpec *pspec);
-
-/**
- * GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID:
- * @object: the #GObject on which set_child_property() or get_child_property()
- * was called
- * @property_id: the numeric id of the property
- * @pspec: the #GParamSpec of the property
- *
- * This macro should be used to emit a standard warning about unexpected
- * properties in set_child_property() and get_child_property() implementations.
- */
-#define GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID(object, property_id, pspec) \
- G_OBJECT_WARN_INVALID_PSPEC ((object), "child property", (property_id), (pspec))
-
-
GDK_AVAILABLE_IN_ALL
void gtk_container_forall (GtkContainer *container,
GtkCallback callback,
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index be0a2e8126..c7011be782 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -627,9 +627,6 @@ static gboolean gtk_widget_real_query_tooltip (GtkWidget *widget,
GtkTooltip *tooltip);
static void gtk_widget_real_style_updated (GtkWidget *widget);
-static void gtk_widget_dispatch_child_properties_changed (GtkWidget *object,
- guint n_pspecs,
- GParamSpec **pspecs);
static gboolean gtk_widget_real_focus (GtkWidget *widget,
GtkDirectionType direction);
static void gtk_widget_real_move_focus (GtkWidget *widget,
@@ -804,14 +801,6 @@ gtk_widget_base_class_init (gpointer g_class)
klass->priv->template = NULL;
}
-static void
-child_property_notify_dispatcher (GObject *object,
- guint n_pspecs,
- GParamSpec **pspecs)
-{
- GTK_WIDGET_GET_CLASS (object)->dispatch_child_properties_changed (GTK_WIDGET (object), n_pspecs, pspecs);
-}
-
static void
gtk_widget_real_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
@@ -924,7 +913,6 @@ gtk_widget_real_unroot (GtkWidget *widget)
static void
gtk_widget_class_init (GtkWidgetClass *klass)
{
- static GObjectNotifyContext cpn_context = { 0, NULL, NULL };
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkBindingSet *binding_set;
@@ -946,11 +934,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
quark_font_options = g_quark_from_static_string ("gtk-widget-font-options");
quark_font_map = g_quark_from_static_string ("gtk-widget-font-map");
- _gtk_widget_child_property_pool = g_param_spec_pool_new (TRUE);
- cpn_context.quark_notify_queue = g_quark_from_static_string ("GtkWidget-child-property-notify-queue");
- cpn_context.dispatcher = child_property_notify_dispatcher;
- _gtk_widget_child_property_notify_context = &cpn_context;
-
gobject_class->constructed = gtk_widget_constructed;
gobject_class->dispose = gtk_widget_dispose;
gobject_class->finalize = gtk_widget_finalize;
@@ -960,7 +943,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
klass->destroy = gtk_widget_real_destroy;
klass->activate_signal = 0;
- klass->dispatch_child_properties_changed = gtk_widget_dispatch_child_properties_changed;
klass->show = gtk_widget_real_show;
klass->hide = gtk_widget_real_hide;
klass->map = gtk_widget_real_map;
@@ -975,7 +957,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
klass->state_flags_changed = gtk_widget_real_state_flags_changed;
klass->direction_changed = gtk_widget_real_direction_changed;
klass->grab_notify = gtk_widget_real_grab_notify;
- klass->child_notify = NULL;
klass->snapshot = gtk_widget_real_snapshot;
klass->mnemonic_activate = gtk_widget_real_mnemonic_activate;
klass->grab_focus = gtk_widget_real_grab_focus;
@@ -1673,25 +1654,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
G_TYPE_NONE, 1,
G_TYPE_BOOLEAN);
- /**
- * GtkWidget::child-notify:
- * @widget: the object which received the signal
- * @child_property: the #GParamSpec of the changed child property
- *
- * The ::child-notify signal is emitted for each
- * [child property][child-properties] that has
- * changed on an object. The signal's detail holds the property name.
- */
- widget_signals[CHILD_NOTIFY] =
- g_signal_new (I_("child-notify"),
- G_TYPE_FROM_CLASS (gobject_class),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED | G_SIGNAL_NO_HOOKS,
- G_STRUCT_OFFSET (GtkWidgetClass, child_notify),
- NULL, NULL,
- g_cclosure_marshal_VOID__PARAM,
- G_TYPE_NONE, 1,
- G_TYPE_PARAM);
-
/**
* GtkWidget::mnemonic-activate:
* @widget: the object which received the signal.
@@ -2940,98 +2902,6 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class)
priv->root = (GtkRoot *) widget;
}
-
-static void
-gtk_widget_dispatch_child_properties_changed (GtkWidget *widget,
- guint n_pspecs,
- GParamSpec **pspecs)
-{
- GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
- GtkWidget *container = priv->parent;
- guint i;
-
- for (i = 0; widget->priv->parent == container && i < n_pspecs; i++)
- g_signal_emit (widget, widget_signals[CHILD_NOTIFY], g_param_spec_get_name_quark (pspecs[i]), pspecs[i]);
-}
-
-/**
- * gtk_widget_freeze_child_notify:
- * @widget: a #GtkWidget
- *
- * Stops emission of #GtkWidget::child-notify signals on @widget. The
- * signals are queued until gtk_widget_thaw_child_notify() is called
- * on @widget.
- *
- * This is the analogue of g_object_freeze_notify() for child properties.
- **/
-void
-gtk_widget_freeze_child_notify (GtkWidget *widget)
-{
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- if (!G_OBJECT (widget)->ref_count)
- return;
-
- g_object_ref (widget);
- g_object_notify_queue_freeze (G_OBJECT (widget), _gtk_widget_child_property_notify_context);
- g_object_unref (widget);
-}
-
-/**
- * gtk_widget_child_notify:
- * @widget: a #GtkWidget
- * @child_property: the name of a child property installed on the
- * class of @widget’s parent
- *
- * Emits a #GtkWidget::child-notify signal for the
- * [child property][child-properties] @child_property
- * on @widget.
- *
- * This is the analogue of g_object_notify() for child properties.
- *
- * Also see gtk_container_child_notify().
- */
-void
-gtk_widget_child_notify (GtkWidget *widget,
- const gchar *child_property)
-{
- GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
-
- if (priv->parent == NULL)
- return;
-
- gtk_container_child_notify (GTK_CONTAINER (priv->parent), widget, child_property);
-}
-
-/**
- * gtk_widget_thaw_child_notify:
- * @widget: a #GtkWidget
- *
- * Reverts the effect of a previous call to gtk_widget_freeze_child_notify().
- * This causes all queued #GtkWidget::child-notify signals on @widget to be
- * emitted.
- */
-void
-gtk_widget_thaw_child_notify (GtkWidget *widget)
-{
- GObjectNotifyQueue *nqueue;
-
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- if (!G_OBJECT (widget)->ref_count)
- return;
-
- g_object_ref (widget);
- nqueue = g_object_notify_queue_from_object (G_OBJECT (widget), _gtk_widget_child_property_notify_context);
- if (!nqueue || !nqueue->freeze_count)
- g_warning (G_STRLOC ": child-property-changed notification for %s(%p) is not frozen",
- G_OBJECT_TYPE_NAME (widget), widget);
- else
- g_object_notify_queue_thaw (G_OBJECT (widget), nqueue);
- g_object_unref (widget);
-}
-
-
/**
* gtk_widget_new:
* @type: type ID of the widget to create
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index 24edcc230e..8ff503a400 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -133,7 +133,6 @@ struct _GtkWidget
* @activate_signal: The signal to emit when a widget of this class is
* activated, gtk_widget_activate() handles the emission.
* Implementation of this signal is optional.
- * @dispatch_child_properties_changed: Seldomly overidden.
* @destroy: Signals that all holders of a reference to the widget
* should release the reference that they hold.
* @show: Signal emitted when widget is shown
@@ -234,11 +233,6 @@ struct _GtkWidgetClass
guint activate_signal;
- /* seldomly overidden */
- void (*dispatch_child_properties_changed) (GtkWidget *widget,
- guint n_pspecs,
- GParamSpec **pspecs);
-
/* basics */
void (* destroy) (GtkWidget *widget);
void (* show) (GtkWidget *widget);
@@ -259,8 +253,6 @@ struct _GtkWidgetClass
GtkTextDirection previous_direction);
void (* grab_notify) (GtkWidget *widget,
gboolean was_grabbed);
- void (* child_notify) (GtkWidget *widget,
- GParamSpec *child_property);
/* size requests */
GtkSizeRequestMode (* get_request_mode) (GtkWidget *widget);
@@ -461,14 +453,6 @@ gboolean gtk_widget_event (GtkWidget *widget,
GDK_AVAILABLE_IN_ALL
gboolean gtk_widget_activate (GtkWidget *widget);
-GDK_AVAILABLE_IN_ALL
-void gtk_widget_freeze_child_notify (GtkWidget *widget);
-GDK_AVAILABLE_IN_ALL
-void gtk_widget_child_notify (GtkWidget *widget,
- const gchar *child_property);
-GDK_AVAILABLE_IN_ALL
-void gtk_widget_thaw_child_notify (GtkWidget *widget);
-
GDK_AVAILABLE_IN_ALL
void gtk_widget_set_can_focus (GtkWidget *widget,
gboolean can_focus);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]