From c33f9a27695c8c6d7f8f1e71ebf8154e4099b447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Fri, 22 Mar 2019 23:31:18 +0000 Subject: [PATCH] Inspector: Find themes the same way GtkCSSProvider does Look for subdirectories named "gtk-3.x", where 'x' starts as current minor version and counts down to 14, then drops to 0. Only look for gtk.css in these directories though. If a theme only provides gtk-dark.css, it won't be found. --- gtk/inspector/visual.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/gtk/inspector/visual.c b/gtk/inspector/visual.c index bc20d7bfa5f..68e50d16c66 100644 --- a/gtk/inspector/visual.c +++ b/gtk/inspector/visual.c @@ -30,6 +30,7 @@ #include "gtkscale.h" #include "gtkwindow.h" #include "gtkcssproviderprivate.h" +#include "gtkversion.h" #include "fallback-c89.c" @@ -312,17 +313,42 @@ fill_gtk (const gchar *path, if (!dir) return; +#if (GTK_MINOR_VERSION % 2) +#define MINOR (GTK_MINOR_VERSION + 1) +#else +#define MINOR GTK_MINOR_VERSION +#endif + + /* Keep this in sync with _gtk_css_find_theme_dir() in gtkcssprovider.c */ while ((dir_entry = g_dir_read_name (dir))) { - gchar *filename = g_build_filename (path, dir_entry, "gtk-3.0", "gtk.css", NULL); + gint i; + gboolean found = FALSE; - if (g_file_test (filename, G_FILE_TEST_IS_REGULAR) && - !g_hash_table_contains (t, dir_entry)) - g_hash_table_add (t, g_strdup (dir_entry)); + for (i = MINOR; !found && i >= 0; i = i - 2) + { + gchar *filename, *subsubdir; - g_free (filename); + if (i < 14) + i = 0; + + subsubdir = g_strdup_printf ("gtk-3.%d", i); + filename = g_build_filename (path, dir_entry, subsubdir, "gtk.css", NULL); + g_free (subsubdir); + + if (g_file_test (filename, G_FILE_TEST_IS_REGULAR) && + !g_hash_table_contains (t, dir_entry)) + { + found = TRUE; + g_hash_table_add (t, g_strdup (dir_entry)); + } + + g_free (filename); + } } +#undef MINOR + g_dir_close (dir); } -- GitLab