[gtk+/gtk-style-context: 181/347] Set classes info in GtkWidgetPath.
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-style-context: 181/347] Set classes info in GtkWidgetPath.
- Date: Thu, 11 Nov 2010 01:19:44 +0000 (UTC)
commit dcac664dea85001cb9ecef1c8fe7d7dbe542a428
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Aug 6 12:06:29 2010 +0200
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 647d090..f944014 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 a7f6de1..4761e16 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -13324,7 +13324,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);
@@ -13332,7 +13331,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);
@@ -13341,21 +13339,39 @@ 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);
- g_list_free (regions);
+ 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);
+ }
while (parent)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]