From 100428eaf9a38f3e02c4f6fb95bb83567346ad96 Mon Sep 17 00:00:00 2001 From: JosephMcc Date: Tue, 5 Dec 2017 00:10:49 -0800 Subject: [PATCH] css: Add support for Adwaita --- xed/resources/css/xed.adwaita.css | 17 +++++++++++ xed/resources/xed.gresource.xml | 1 + xed/xed-app.c | 50 +++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 xed/resources/css/xed.adwaita.css diff --git a/xed/resources/css/xed.adwaita.css b/xed/resources/css/xed.adwaita.css new file mode 100644 index 0000000..600a9d2 --- /dev/null +++ b/xed/resources/css/xed.adwaita.css @@ -0,0 +1,17 @@ +.xed-window .primary-toolbar { + border: 0px solid @borders; + border-bottom-width: 1px; +} + +.xed-statusbar { + border: 0px solid @borders; + border-top-width: 1px; +} + +.xed-searchbar { + box-shadow: inset 0 1px @borders; +} + +.xed-statusbar button { + padding: 0 4px; +} diff --git a/xed/resources/xed.gresource.xml b/xed/resources/xed.gresource.xml index 0a55cb5..29a9aed 100644 --- a/xed/resources/xed.gresource.xml +++ b/xed/resources/xed.gresource.xml @@ -9,5 +9,6 @@ ui/xed-shortcuts.ui ui/xed-view-frame.ui css/xed-style.css + css/xed.adwaita.css diff --git a/xed/xed-app.c b/xed/xed-app.c index 785e162..ef0f169 100644 --- a/xed/xed-app.c +++ b/xed/xed-app.c @@ -223,6 +223,54 @@ set_initial_theme_style (XedApp *app) } } +static void +theme_changed (GtkSettings *settings, + GParamSpec *pspec, + gpointer data) +{ + static GtkCssProvider *provider; + 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/x/editor/css/xed.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; + + settings = gtk_settings_get_default (); + g_signal_connect (settings, "notify::gtk-theme-name", + G_CALLBACK (theme_changed), NULL); + theme_changed (settings, NULL, NULL); +} + static void xed_app_startup (GApplication *application) { @@ -251,6 +299,8 @@ xed_app_startup (GApplication *application) gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), icon_dir); g_free (icon_dir); + setup_theme_extensions (); + #ifndef ENABLE_GVFS_METADATA /* Setup metadata-manager */ cache_dir = xed_dirs_get_user_cache_dir ();