diff options
author | Benjamin Otte <otte@redhat.com> | 2020-01-21 02:59:26 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2020-01-21 12:47:16 +0100 |
commit | 563ad2db1bba0ceffaaa49096939ec21e548a86c (patch) | |
tree | 2c5627703ea5b0419d0672cc46b061e0d0d94b1d | |
parent | c85d9a3259ad225ffe2ece1bb77987d86e9161a9 (diff) | |
download | gtk+-563ad2db1bba0ceffaaa49096939ec21e548a86c.tar.gz |
containter: Remove gtk_container_get_path_for_child()
-rw-r--r-- | docs/reference/gtk/gtk4-sections.txt | 1 | ||||
-rw-r--r-- | gtk/gtkbox.c | 103 | ||||
-rw-r--r-- | gtk/gtkcontainer.c | 48 | ||||
-rw-r--r-- | gtk/gtkcontainer.h | 8 | ||||
-rw-r--r-- | gtk/gtkwidget.c | 6 |
5 files changed, 2 insertions, 164 deletions
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index de0ec777dd..c36a4a2b54 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -775,7 +775,6 @@ gtk_container_add gtk_container_remove gtk_container_foreach gtk_container_get_children -gtk_container_get_path_for_child gtk_container_get_focus_vadjustment gtk_container_set_focus_vadjustment gtk_container_get_focus_hadjustment diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c index f6195dbfbb..800e31847f 100644 --- a/gtk/gtkbox.c +++ b/gtk/gtkbox.c @@ -109,9 +109,6 @@ static void gtk_box_forall (GtkContainer *container, GtkCallback callback, gpointer callback_data); static GType gtk_box_child_type (GtkContainer *container); -static GtkWidgetPath * gtk_box_get_path_for_child - (GtkContainer *container, - GtkWidget *child); G_DEFINE_TYPE_WITH_CODE (GtkBox, gtk_box, GTK_TYPE_CONTAINER, G_ADD_PRIVATE (GtkBox) @@ -131,7 +128,6 @@ gtk_box_class_init (GtkBoxClass *class) container_class->remove = gtk_box_remove; container_class->forall = gtk_box_forall; container_class->child_type = gtk_box_child_type; - container_class->get_path_for_child = gtk_box_get_path_for_child; g_object_class_override_property (object_class, PROP_ORIENTATION, @@ -242,105 +238,6 @@ gtk_box_child_type (GtkContainer *container) return GTK_TYPE_WIDGET; } -typedef struct _CountingData CountingData; -struct _CountingData { - GtkWidget *widget; - gboolean found; - guint before; - guint after; -}; - -static void -count_widget_position (GtkWidget *widget, - gpointer data) -{ - CountingData *count = data; - - if (!_gtk_widget_get_visible (widget)) - return; - - if (count->widget == widget) - count->found = TRUE; - else if (count->found) - count->after++; - else - count->before++; -} - -static gint -gtk_box_get_visible_position (GtkBox *box, - GtkWidget *child) -{ - CountingData count = { child, FALSE, 0, 0 }; - GtkBoxPrivate *priv = gtk_box_get_instance_private (box); - - /* foreach iterates in visible order */ - gtk_container_foreach (GTK_CONTAINER (box), - count_widget_position, - &count); - - /* the child wasn't found, it's likely an internal child of some - * subclass, return -1 to indicate that there is no sibling relation - * to the regular box children - */ - if (!count.found) - return -1; - - if (priv->orientation == GTK_ORIENTATION_HORIZONTAL && - gtk_widget_get_direction (GTK_WIDGET (box)) == GTK_TEXT_DIR_RTL) - return count.after; - else - return count.before; -} - -static GtkWidgetPath * -gtk_box_get_path_for_child (GtkContainer *container, - GtkWidget *child) -{ - GtkWidgetPath *path, *sibling_path; - GtkBox *box = GTK_BOX (container); - GtkBoxPrivate *priv = gtk_box_get_instance_private (box); - GList *list, *children; - - path = _gtk_widget_create_path (GTK_WIDGET (container)); - - if (_gtk_widget_get_visible (child)) - { - gint position; - - sibling_path = gtk_widget_path_new (); - - /* get_children works in visible order */ - children = gtk_container_get_children (container); - if (priv->orientation == GTK_ORIENTATION_HORIZONTAL && - _gtk_widget_get_direction (GTK_WIDGET (box)) == GTK_TEXT_DIR_RTL) - children = g_list_reverse (children); - - for (list = children; list; list = list->next) - { - if (!_gtk_widget_get_visible (list->data)) - continue; - - gtk_widget_path_append_for_widget (sibling_path, list->data); - } - - g_list_free (children); - - position = gtk_box_get_visible_position (box, child); - - if (position >= 0) - gtk_widget_path_append_with_siblings (path, sibling_path, position); - else - gtk_widget_path_append_for_widget (path, child); - - gtk_widget_path_unref (sibling_path); - } - else - gtk_widget_path_append_for_widget (path, child); - - return path; -} - static void gtk_box_init (GtkBox *box) { diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c index 71493d7ef3..3650f4ee97 100644 --- a/gtk/gtkcontainer.c +++ b/gtk/gtkcontainer.c @@ -115,9 +115,6 @@ static void gtk_container_children_callback (GtkWidget *widget, gpointer client_data); static GtkSizeRequestMode gtk_container_get_request_mode (GtkWidget *widget); -static GtkWidgetPath * gtk_container_real_get_path_for_child (GtkContainer *container, - GtkWidget *child); - /* GtkBuildable */ static void gtk_container_buildable_init (GtkBuildableIface *iface); static GtkBuildableIface *parent_buildable_iface; @@ -149,7 +146,6 @@ gtk_container_class_init (GtkContainerClass *class) class->forall = NULL; class->set_focus_child = gtk_container_real_set_focus_child; class->child_type = NULL; - class->get_path_for_child = gtk_container_real_get_path_for_child; container_signals[ADD] = g_signal_new (I_("add"), @@ -651,18 +647,6 @@ gtk_container_real_set_focus_child (GtkContainer *container, } } -static GtkWidgetPath * -gtk_container_real_get_path_for_child (GtkContainer *container, - GtkWidget *child) -{ - GtkWidgetPath *path; - - path = _gtk_widget_create_path (GTK_WIDGET (container)); - gtk_widget_path_append_for_widget (path, child); - - return path; -} - static void gtk_container_children_callback (GtkWidget *widget, gpointer client_data) @@ -783,35 +767,3 @@ gtk_container_get_focus_hadjustment (GtkContainer *container) return hadjustment; } -/** - * gtk_container_get_path_for_child: - * @container: a #GtkContainer - * @child: a child of @container - * - * Returns a newly created widget path representing all the widget hierarchy - * from the toplevel down to and including @child. - * - * Returns: A newly created #GtkWidgetPath - **/ -GtkWidgetPath * -gtk_container_get_path_for_child (GtkContainer *container, - GtkWidget *child) -{ - GtkWidgetPath *path; - - g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL); - g_return_val_if_fail (GTK_IS_WIDGET (child), NULL); - g_return_val_if_fail (container == (GtkContainer *) _gtk_widget_get_parent (child), NULL); - - path = GTK_CONTAINER_GET_CLASS (container)->get_path_for_child (container, child); - if (gtk_widget_path_get_object_type (path) != G_OBJECT_TYPE (child)) - { - g_critical ("%s %p returned a widget path for type %s, but child is %s", - G_OBJECT_TYPE_NAME (container), - container, - g_type_name (gtk_widget_path_get_object_type (path)), - G_OBJECT_TYPE_NAME (child)); - } - - return path; -} diff --git a/gtk/gtkcontainer.h b/gtk/gtkcontainer.h index e3dd79a0ac..332846df7f 100644 --- a/gtk/gtkcontainer.h +++ b/gtk/gtkcontainer.h @@ -62,8 +62,6 @@ struct _GtkContainer * @child_type: Returns the type of the children supported by the container. * @set_child_property: Set a property on a child of container. * @get_child_property: Get a property from a child of container. - * @get_path_for_child: Get path representing entire widget hierarchy - * from the toplevel down to and including @child. * * Base class for containers. */ @@ -83,8 +81,6 @@ struct _GtkContainerClass void (*set_focus_child) (GtkContainer *container, GtkWidget *child); GType (*child_type) (GtkContainer *container); - GtkWidgetPath * (*get_path_for_child) (GtkContainer *container, - GtkWidget *child); /*< private >*/ @@ -132,10 +128,6 @@ void gtk_container_forall (GtkContainer *container, GtkCallback callback, gpointer callback_data); -GDK_AVAILABLE_IN_ALL -GtkWidgetPath * gtk_container_get_path_for_child (GtkContainer *container, - GtkWidget *child); - G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkContainer, g_object_unref) G_END_DECLS diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index ccdf26d6d4..9f37c854f2 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -6320,7 +6320,7 @@ reset_style_recurse (GtkWidget *widget, gpointer user_data) * Updates the style context of @widget and all descendants * by updating its widget path. #GtkContainers may want * to use this on a child when reordering it in a way that a different - * style might apply to it. See also gtk_container_get_path_for_child(). + * style might apply to it. */ void gtk_widget_reset_style (GtkWidget *widget) @@ -11247,9 +11247,7 @@ _gtk_widget_create_path (GtkWidget *widget) { GtkWidget *parent = _gtk_widget_get_parent (widget); - if (parent && GTK_IS_CONTAINER (parent)) - return gtk_container_get_path_for_child (GTK_CONTAINER (parent), widget); - else if (parent) + if (parent) { GtkWidgetPath *path = _gtk_widget_create_path (parent); gtk_widget_path_append_for_widget (path, widget); |