[Xfce4-commits] [xfce/xfdesktop] 01/01: Use custom CSS for the iconview as a fallback (Bug #13609)
noreply at xfce.org
noreply at xfce.org
Mon Jun 26 15:47:48 CEST 2017
This is an automated email from the git hooks/post-receive script.
e r i c p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository xfce/xfdesktop.
commit 7fc30fa0a31e94c1e15133ca347f950593b822a1
Author: Eric Koegel <eric.koegel at gmail.com>
Date: Fri Jun 23 10:24:36 2017 +0300
Use custom CSS for the iconview as a fallback (Bug #13609)
This patch looks for the theme to provide custom CSS for the
XfdesktopIconView if that doesn't exist then we use ToZ's CSS
to theme it. It also watches for theme changes and updates
accordingly.
---
src/xfdesktop-application.c | 64 ++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 63 insertions(+), 1 deletion(-)
diff --git a/src/xfdesktop-application.c b/src/xfdesktop-application.c
index 3bbda43..45efca8 100644
--- a/src/xfdesktop-application.c
+++ b/src/xfdesktop-application.c
@@ -137,7 +137,24 @@ struct _XfdesktopApplicationClass
GApplicationClass parent;
};
-
+const gchar *ToZ_CSS =
+"XfdesktopIconView.view {"
+" background-color: rgba(0,0,0,0.0);"
+" color: white;"
+"}"
+"XfdesktopIconView.view:active {"
+" background-color: rgba(57,142,231,0.75);"
+" color: rgba(57,142,231,0.75);"
+" border-radius: 5px;"
+"}"
+"XfdesktopIconView.rubberband {"
+" background-color: rgba(0,0,0,0.25);"
+"}"
+"XfdesktopIconView.view.label,"
+"XfdesktopIconView.view.label:active {"
+" color: white;"
+" text-shadow: 1px 2px black;"
+"}";
G_DEFINE_TYPE(XfdesktopApplication, xfdesktop_application, G_TYPE_APPLICATION)
@@ -622,8 +639,49 @@ xfdesktop_application_startup(GApplication *g_application)
}
static void
+xfdesktop_application_theme_changed (GtkSettings *settings,
+ XfdesktopApplication *app)
+{
+ GtkCssProvider *provider = NULL;
+ static GtkCssProvider *custom_provider = NULL;
+ gchar *theme;
+ gchar *css;
+
+ g_object_get(settings, "gtk-theme-name", &theme, NULL);
+
+ provider = gtk_css_provider_get_named(theme, NULL);
+ css = gtk_css_provider_to_string (provider);
+
+ if (g_strrstr (css, "XfdesktopIconView") != NULL) {
+ DBG("XfdesktopIconView section found in theme %s", theme);
+ if (custom_provider != NULL) {
+ gtk_style_context_remove_provider_for_screen (gdk_screen_get_default (),
+ GTK_STYLE_PROVIDER(custom_provider));
+ g_clear_object (&custom_provider);
+ }
+ } else {
+ DBG("XfdesktopIconView section not found in theme %s, setting our fallback", theme);
+ if (custom_provider != NULL) {
+ gtk_style_context_remove_provider_for_screen (gdk_screen_get_default (),
+ GTK_STYLE_PROVIDER(custom_provider));
+ g_clear_object (&custom_provider);
+ }
+ custom_provider = gtk_css_provider_new();
+ gtk_css_provider_load_from_data(custom_provider,
+ ToZ_CSS,
+ -1,
+ NULL);
+ gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
+ GTK_STYLE_PROVIDER(custom_provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ }
+ g_free(css);
+}
+
+static void
xfdesktop_application_start(XfdesktopApplication *app)
{
+ GtkSettings *settings;
GdkDisplay *gdpy;
GError *error = NULL;
gchar buf[1024];
@@ -632,6 +690,10 @@ xfdesktop_application_start(XfdesktopApplication *app)
g_return_if_fail(app != NULL);
+ settings = gtk_settings_get_default();
+ g_signal_connect (settings, "notify::gtk-theme-name", G_CALLBACK (xfdesktop_application_theme_changed), NULL);
+ xfdesktop_application_theme_changed (settings, app);
+
/* stop autostart timeout */
if(app->wait_for_wm_timeout_id != 0)
g_source_remove(app->wait_for_wm_timeout_id);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list