[gtk+/wip/cssvalue: 143/164] styleprovider: Make all implementors emit the new signal
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cssvalue: 143/164] styleprovider: Make all implementors emit the new signal
- Date: Wed, 11 Apr 2012 14:51:55 +0000 (UTC)
commit 03e9833026ceddf2ea6f94cb79dd404668ab33c2
Author: Benjamin Otte <otte redhat com>
Date: Sun Apr 8 17:35:24 2012 +0200
styleprovider: Make all implementors emit the new signal
... and listen to it in the cases where they use other style providers.
gtk/gtkcssprovider.c | 10 +++++++++-
gtk/gtkmodifierstyle.c | 4 ++++
gtk/gtksettings.c | 2 ++
gtk/gtkstylecascade.c | 25 +++++++++++++++++++++++--
gtk/gtkstyleproperties.c | 10 ++++++++++
5 files changed, 48 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index d7445b8..a2df0f0 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -2537,6 +2537,8 @@ gtk_css_provider_load_from_data (GtkCssProvider *css_provider,
g_free (free_data);
+ _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (css_provider));
+
return ret;
}
@@ -2556,12 +2558,18 @@ gtk_css_provider_load_from_file (GtkCssProvider *css_provider,
GFile *file,
GError **error)
{
+ gboolean success;
+
g_return_val_if_fail (GTK_IS_CSS_PROVIDER (css_provider), FALSE);
g_return_val_if_fail (G_IS_FILE (file), FALSE);
gtk_css_provider_reset (css_provider);
- return gtk_css_provider_load_internal (css_provider, NULL, file, NULL, error);
+ success = gtk_css_provider_load_internal (css_provider, NULL, file, NULL, error);
+
+ _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (css_provider));
+
+ return success;
}
/**
diff --git a/gtk/gtkmodifierstyle.c b/gtk/gtkmodifierstyle.c
index 2700250..9837a0d 100644
--- a/gtk/gtkmodifierstyle.c
+++ b/gtk/gtkmodifierstyle.c
@@ -210,6 +210,7 @@ modifier_style_set_color (GtkModifierStyle *style,
gtk_style_properties_unset_property (priv->style, prop, state);
g_signal_emit (style, signals[CHANGED], 0);
+ _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (style));
}
void
@@ -250,6 +251,7 @@ _gtk_modifier_style_set_font (GtkModifierStyle *style,
gtk_style_properties_unset_property (priv->style, "font", 0);
g_signal_emit (style, signals[CHANGED], 0);
+ _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (style));
}
void
@@ -272,6 +274,7 @@ _gtk_modifier_style_map_color (GtkModifierStyle *style,
name, symbolic_color);
g_signal_emit (style, signals[CHANGED], 0);
+ _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (style));
}
void
@@ -312,4 +315,5 @@ _gtk_modifier_style_set_color_property (GtkModifierStyle *style,
}
g_signal_emit (style, signals[CHANGED], 0);
+ _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (style));
}
diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c
index f1b03ee..3cd8b0c 100644
--- a/gtk/gtksettings.c
+++ b/gtk/gtksettings.c
@@ -1738,6 +1738,8 @@ settings_invalidate_style (GtkSettings *settings)
g_object_unref (priv->style);
priv->style = NULL;
}
+
+ _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (settings));
}
static void
diff --git a/gtk/gtkstylecascade.c b/gtk/gtkstylecascade.c
index 05b0db8..565ac61 100644
--- a/gtk/gtkstylecascade.c
+++ b/gtk/gtkstylecascade.c
@@ -34,6 +34,7 @@ struct _GtkStyleProviderData
{
GtkStyleProvider *provider;
guint priority;
+ guint changed_signal_id;
};
static GtkStyleProvider *
@@ -263,6 +264,7 @@ style_provider_data_clear (gpointer data_)
{
GtkStyleProviderData *data = data_;
+ g_signal_handler_disconnect (data->provider, data->changed_signal_id);
g_object_unref (data->provider);
}
@@ -313,10 +315,21 @@ _gtk_style_cascade_set_parent (GtkStyleCascade *cascade,
return;
if (parent)
- g_object_ref (parent);
+ {
+ g_object_ref (parent);
+ g_signal_connect_swapped (parent,
+ "-gtk-private-changed",
+ G_CALLBACK (_gtk_style_provider_private_changed),
+ cascade);
+ }
if (cascade->parent)
- g_object_unref (cascade->parent);
+ {
+ g_signal_handlers_disconnect_by_func (cascade->parent,
+ _gtk_style_provider_private_changed,
+ cascade);
+ g_object_unref (cascade->parent);
+ }
cascade->parent = parent;
}
@@ -335,6 +348,10 @@ _gtk_style_cascade_add_provider (GtkStyleCascade *cascade,
data.provider = g_object_ref (provider);
data.priority = priority;
+ data.changed_signal_id = g_signal_connect_swapped (provider,
+ "-gtk-private-changed",
+ G_CALLBACK (_gtk_style_provider_private_changed),
+ cascade);
/* ensure it gets removed first */
_gtk_style_cascade_remove_provider (cascade, provider);
@@ -345,6 +362,8 @@ _gtk_style_cascade_add_provider (GtkStyleCascade *cascade,
break;
}
g_array_insert_val (cascade->providers, i, data);
+
+ _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (cascade));
}
void
@@ -363,6 +382,8 @@ _gtk_style_cascade_remove_provider (GtkStyleCascade *cascade,
if (data->provider == provider)
{
g_array_remove_index (cascade->providers, i);
+
+ _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (cascade));
break;
}
}
diff --git a/gtk/gtkstyleproperties.c b/gtk/gtkstyleproperties.c
index ebb8d7c..fe91feb 100644
--- a/gtk/gtkstyleproperties.c
+++ b/gtk/gtkstyleproperties.c
@@ -399,6 +399,8 @@ gtk_style_properties_map_color (GtkStyleProperties *props,
g_hash_table_replace (priv->color_map,
g_strdup (name),
gtk_symbolic_color_ref (color));
+
+ _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (props));
}
/**
@@ -453,6 +455,8 @@ _gtk_style_properties_set_property_by_property (GtkStyleProperties *props,
_gtk_css_value_unref (val->value);
val->value = _gtk_css_value_ref (value);
+
+ _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (props));
}
/**
@@ -797,6 +801,8 @@ gtk_style_properties_unset_property (GtkStyleProperties *props,
data->value = NULL;
g_array_remove_index (prop->values, pos);
+
+ _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (props));
}
}
@@ -815,6 +821,8 @@ gtk_style_properties_clear (GtkStyleProperties *props)
priv = props->priv;
g_hash_table_remove_all (priv->properties);
+
+ _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (props));
}
/**
@@ -935,4 +943,6 @@ gtk_style_properties_merge (GtkStyleProperties *props,
}
}
}
+
+ _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (props));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]