X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gtk%2Fgtkstylecascade.c;h=ea63fc86f6637c56c2a05f3e0cf29150ebfe0f38;hb=feb64f40b0f50735104da0a7fdafbe480763c180;hp=a05d36dd77619f2abf927ada295bca88a809572a;hpb=8dbe8c83491c5877c9b19928f257ec7a671cb45e;p=~andy%2Fgtk diff --git a/gtk/gtkstylecascade.c b/gtk/gtkstylecascade.c index a05d36dd7..ea63fc86f 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 * @@ -90,16 +91,6 @@ gtk_style_cascade_iter_init (GtkStyleCascade *cascade, return gtk_style_cascade_iter_next (cascade, iter); } -static GtkStyleProperties * -gtk_style_cascade_get_style (GtkStyleProvider *provider, - GtkWidgetPath *path) -{ - /* This function is not used anymore by GTK and nobody - * else is ever supposed to call it */ - g_warn_if_reached (); - return NULL; -} - static gboolean gtk_style_cascade_get_style_property (GtkStyleProvider *provider, GtkWidgetPath *path, @@ -126,30 +117,42 @@ gtk_style_cascade_get_style_property (GtkStyleProvider *provider, return FALSE; } -static GtkIconFactory * -gtk_style_cascade_get_icon_factory (GtkStyleProvider *provider, - GtkWidgetPath *path) -{ - /* If anyone ever implements get_icon_factory(), I'll - * look at this function. Until then I'll just: */ - return NULL; -} - static void gtk_style_cascade_provider_iface_init (GtkStyleProviderIface *iface) { - iface->get_style = gtk_style_cascade_get_style; iface->get_style_property = gtk_style_cascade_get_style_property; - iface->get_icon_factory = gtk_style_cascade_get_icon_factory; } -static GtkSymbolicColor * +static GtkSettings * +gtk_style_cascade_get_settings (GtkStyleProviderPrivate *provider) +{ + GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider); + GtkStyleCascadeIter iter; + GtkSettings *settings; + GtkStyleProvider *item; + + for (item = gtk_style_cascade_iter_init (cascade, &iter); + item; + item = gtk_style_cascade_iter_next (cascade, &iter)) + { + if (!GTK_IS_STYLE_PROVIDER_PRIVATE (item)) + continue; + + settings = _gtk_style_provider_private_get_settings (GTK_STYLE_PROVIDER_PRIVATE (item)); + if (settings) + return settings; + } + + return NULL; +} + +static GtkCssValue * gtk_style_cascade_get_color (GtkStyleProviderPrivate *provider, const char *name) { GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider); GtkStyleCascadeIter iter; - GtkSymbolicColor *symbolic; + GtkCssValue *color; GtkStyleProvider *item; for (item = gtk_style_cascade_iter_init (cascade, &iter); @@ -158,9 +161,9 @@ gtk_style_cascade_get_color (GtkStyleProviderPrivate *provider, { if (GTK_IS_STYLE_PROVIDER_PRIVATE (item)) { - symbolic = _gtk_style_provider_private_get_color (GTK_STYLE_PROVIDER_PRIVATE (item), name); - if (symbolic) - return symbolic; + color = _gtk_style_provider_private_get_color (GTK_STYLE_PROVIDER_PRIVATE (item), name); + if (color) + return color; } else { @@ -171,6 +174,30 @@ gtk_style_cascade_get_color (GtkStyleProviderPrivate *provider, return NULL; } +static GtkCssKeyframes * +gtk_style_cascade_get_keyframes (GtkStyleProviderPrivate *provider, + const char *name) +{ + GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider); + GtkStyleCascadeIter iter; + GtkCssKeyframes *keyframes; + GtkStyleProvider *item; + + for (item = gtk_style_cascade_iter_init (cascade, &iter); + item; + item = gtk_style_cascade_iter_next (cascade, &iter)) + { + if (!GTK_IS_STYLE_PROVIDER_PRIVATE (item)) + continue; + + keyframes = _gtk_style_provider_private_get_keyframes (GTK_STYLE_PROVIDER_PRIVATE (item), name); + if (keyframes) + return keyframes; + } + + return NULL; +} + static void gtk_style_cascade_lookup (GtkStyleProviderPrivate *provider, const GtkCssMatcher *matcher, @@ -229,6 +256,8 @@ static void gtk_style_cascade_provider_private_iface_init (GtkStyleProviderPrivateInterface *iface) { iface->get_color = gtk_style_cascade_get_color; + iface->get_settings = gtk_style_cascade_get_settings; + iface->get_keyframes = gtk_style_cascade_get_keyframes; iface->lookup = gtk_style_cascade_lookup; iface->get_change = gtk_style_cascade_get_change; } @@ -263,6 +292,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 +343,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 +376,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 +390,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 +410,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; } }