[gtk/gtk-3-24: 1/2] Inspector: Find themes the same way GtkCSSProvider does



commit c33f9a27695c8c6d7f8f1e71ebf8154e4099b447
Author: Руслан Ижбулатов <lrn1986 gmail com>
Date:   Fri Mar 22 23:31:18 2019 +0000

    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 bc20d7bfa5..68e50d16c6 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);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]