Set classes info in GtkWidgetPath.

This commit is contained in:
Carlos Garnacho 2010-08-06 12:06:29 +02:00
parent 2dabf20cfd
commit 27c91622f6
2 changed files with 61 additions and 16 deletions

View File

@ -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

View File

@ -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;