diff options
author | Matthias Clasen <mclasen@redhat.com> | 2014-07-10 08:57:27 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2014-07-11 23:22:15 -0400 |
commit | 3fd7e847d531fbbfc4ebba24864bdd0f8b81c750 (patch) | |
tree | da49e65b60e9876e8a23720bf3575c997ff768d1 /src/nautilus-application.c | |
parent | bec805a7596f6de500adfc0a751496b5661abf1f (diff) | |
download | nautilus-3fd7e847d531fbbfc4ebba24864bdd0f8b81c750.tar.gz |
Add application-specific theme extensions
This used to live in gnome-themes-standard, but with the move
of Adwaita to GTK+, it needs to find a new home.
https://bugzilla.gnome.org/show_bug.cgi?id=732995
Diffstat (limited to 'src/nautilus-application.c')
-rw-r--r-- | src/nautilus-application.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/nautilus-application.c b/src/nautilus-application.c index 7137d5ed9..88ed0f5dd 100644 --- a/src/nautilus-application.c +++ b/src/nautilus-application.c @@ -1154,6 +1154,56 @@ init_gtk_accels (void) } static void +theme_changed (GtkSettings *settings) +{ + static GtkCssProvider *provider = NULL; + gchar *theme; + GdkScreen *screen; + + g_object_get (settings, "gtk-theme-name", &theme, NULL); + screen = gdk_screen_get_default (); + + if (g_str_equal (theme, "Adwaita")) + { + if (provider == NULL) + { + GFile *file; + + provider = gtk_css_provider_new (); + file = g_file_new_for_uri ("resource:///org/gnome/nautilus/Adwaita.css"); + gtk_css_provider_load_from_file (provider, file, NULL); + g_object_unref (file); + } + + gtk_style_context_add_provider_for_screen (screen, + GTK_STYLE_PROVIDER (provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + } + else if (provider != NULL) + { + gtk_style_context_remove_provider_for_screen (screen, + GTK_STYLE_PROVIDER (provider)); + g_clear_object (&provider); + } + + g_free (theme); +} + +static void +setup_theme_extensions (void) +{ + GtkSettings *settings; + + /* Set up a handler to load our custom css for Adwaita. + * See https://bugzilla.gnome.org/show_bug.cgi?id=732959 + * for a more automatic solution that is still under discussion. + */ + settings = gtk_settings_get_default (); + g_signal_connect (settings, "notify::gtk-theme-name", G_CALLBACK (theme_changed), NULL); + theme_changed (settings); +} + +static void nautilus_application_startup (GApplication *app) { NautilusApplication *self = NAUTILUS_APPLICATION (app); @@ -1167,6 +1217,8 @@ nautilus_application_startup (GApplication *app) gtk_window_set_default_icon_name ("system-file-manager"); + setup_theme_extensions (); + /* create DBus manager */ self->priv->fdb_manager = nautilus_freedesktop_dbus_new (); |