From 27c91622f63b31928066ed269a2df12b0c4975fb Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 6 Aug 2010 12:06:29 +0200 Subject: [PATCH] Set classes info in GtkWidgetPath. --- gtk/gtkstylecontext.c | 35 ++++++++++++++++++++++++++++++++--- gtk/gtkwidget.c | 42 +++++++++++++++++++++++++++++------------- 2 files changed, 61 insertions(+), 16 deletions(-) diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 647d09078f..f944014ab2 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -669,9 +669,10 @@ gtk_style_context_restore (GtkStyleContext *context) { guint i; + info = priv->info_stack->data; + /* Update widget path regions */ gtk_widget_path_iter_clear_regions (priv->widget_path, 0); - info = priv->info_stack->data; for (i = 0; i < info->regions->len; i++) { @@ -682,6 +683,18 @@ gtk_style_context_restore (GtkStyleContext *context) g_quark_to_string (region->class_quark), region->flags); } + + /* Update widget path classes */ + gtk_widget_path_iter_clear_classes (priv->widget_path, 0); + + for (i = 0; i < info->style_classes->len; i++) + { + GQuark quark; + + quark = g_array_index (info->style_classes, GQuark, i); + gtk_widget_path_iter_add_class (priv->widget_path, 0, + g_quark_to_string (quark)); + } } } @@ -788,7 +801,15 @@ gtk_style_context_set_class (GtkStyleContext *context, info = priv->info_stack->data; if (!style_class_find (info->style_classes, class_quark, &position)) - g_array_insert_val (info->style_classes, position, class_quark); + { + g_array_insert_val (info->style_classes, position, class_quark); + + if (priv->widget_path) + { + gtk_widget_path_iter_add_class (priv->widget_path, 0, class_name); + rebuild_properties (context); + } + } } void @@ -814,7 +835,15 @@ gtk_style_context_unset_class (GtkStyleContext *context, info = priv->info_stack->data; if (style_class_find (info->style_classes, class_quark, &position)) - g_array_remove_index (info->style_classes, position); + { + g_array_remove_index (info->style_classes, position); + + if (priv->widget_path) + { + gtk_widget_path_iter_remove_class (priv->widget_path, 0, class_name); + rebuild_properties (context); + } + } } gboolean diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index e9c4937517..6321348ea2 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -13216,7 +13216,6 @@ 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); @@ -13224,7 +13223,6 @@ gtk_widget_get_path (GtkWidget *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); @@ -13233,22 +13231,40 @@ gtk_widget_get_path (GtkWidget *widget) quark_style_context); if (context) - regions = reg = gtk_style_context_list_regions (context); - - while (reg) { - GtkRegionFlags flags; - const gchar *region_name; + GList *list, *l; - region_name = reg->data; - reg = reg->next; + list = l = gtk_style_context_list_regions (context); - gtk_style_context_has_region (context, region_name, &flags); - gtk_widget_path_iter_add_region (path, 0, region_name, flags); + while (l) + { + GtkRegionFlags flags; + const gchar *region_name; + + region_name = l->data; + l = l->next; + + gtk_style_context_has_region (context, region_name, &flags); + gtk_widget_path_iter_add_region (path, 0, region_name, flags); + } + + g_list_free (list); + + list = l = gtk_style_context_list_classes (context); + + while (l) + { + const gchar *class_name; + + class_name = l->data; + l = l->next; + + gtk_widget_path_iter_add_class (path, 0, class_name); + } + + g_list_free (list); } - g_list_free (regions); - while (parent) { guint position;