From f5adc2a1c3bfd317f2288ba39925e7f7d6b50e38 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 23 Apr 2010 02:36:47 +0200 Subject: [PATCH] Add region details in gtk_widget_get_path(). --- gtk/gtkwidget.c | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index e4e3e32b86..8fcff94b67 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -13182,17 +13182,53 @@ _gtk_widget_set_height_request_needed (GtkWidget *widget, GtkWidgetPath * gtk_widget_get_path (GtkWidget *widget) { + GtkStyleContext *context; GtkWidgetPath *path; + GtkWidget *parent; + GList *regions, *reg; g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); g_return_val_if_fail (GTK_WIDGET_REALIZED (widget), NULL); - path = gtk_widget_path_new (); + parent = widget->priv->parent; - while (widget) + path = gtk_widget_path_new (); + gtk_widget_path_prepend_type (path, G_OBJECT_TYPE (widget)); + regions = reg = NULL; + + if (widget->priv->name) + gtk_widget_path_iter_set_name (path, 0, widget->priv->name); + + context = g_object_get_qdata (G_OBJECT (widget), + quark_style_context); + + if (context) + regions = reg = gtk_style_context_list_child_classes (context); + + while (reg) { - gtk_widget_path_prepend_type (path, G_OBJECT_TYPE (widget)); - widget = widget->parent; + GtkChildClassFlags flags; + const gchar *region_name; + + region_name = reg->data; + reg = reg->next; + + gtk_style_context_has_child_class (context, region_name, &flags); + gtk_widget_path_iter_add_region (path, 0, region_name, flags); + } + + g_list_free (regions); + + while (parent) + { + guint position; + + position = gtk_widget_path_prepend_type (path, G_OBJECT_TYPE (parent)); + + if (parent->priv->name) + gtk_widget_path_iter_set_name (path, position, parent->priv->name); + + parent = parent->priv->parent; } return path;