[gtk/theme-redux: 54/58] cssprovider: Stop supporting theme variants



commit cdec48799865d7d82fa655b5dc848ac3b01db36f
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Apr 11 16:12:33 2020 -0400

    cssprovider: Stop supporting theme variants
    
    We are no longer using variants, so drop the variant
    argument from gtk_css_provider_load_named().

 gtk/gtkcssprovider.c | 50 +++++++++++++++-----------------------------------
 gtk/gtkcssprovider.h |  3 +--
 gtk/gtksettings.c    |  2 +-
 3 files changed, 17 insertions(+), 38 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 829e2ec42c..5ade761eaf 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -1221,17 +1221,16 @@ _gtk_css_provider_get_theme_dir (GtkCssProvider *provider)
 
 /*
  * Look for
- * $dir/$subdir/gtk-4.16/gtk-$variant.css
- * $dir/$subdir/gtk-4.14/gtk-$variant.css
+ * $dir/$subdir/gtk-4.16/gtk.css
+ * $dir/$subdir/gtk-4.14/gtk.css
  *  ...
- * $dir/$subdir/gtk-4.0/gtk-$variant.css
+ * $dir/$subdir/gtk-4.0/gtk.css
  * and return the first found file.
  */
 static gchar *
 _gtk_css_find_theme_dir (const gchar *dir,
                          const gchar *subdir,
-                         const gchar *name,
-                         const gchar *variant)
+                         const gchar *name)
 {
   gchar *file;
   gchar *base;
@@ -1239,10 +1238,7 @@ _gtk_css_find_theme_dir (const gchar *dir,
   gint i;
   gchar *path;
 
-  if (variant)
-    file = g_strconcat ("gtk-", variant, ".css", NULL);
-  else
-    file = g_strdup ("gtk.css");
+  file = g_strdup ("gtk.css");
 
   if (subdir)
     base = g_build_filename (dir, subdir, name, NULL);
@@ -1271,8 +1267,7 @@ _gtk_css_find_theme_dir (const gchar *dir,
 #undef MINOR
 
 static gchar *
-_gtk_css_find_theme (const gchar *name,
-                     const gchar *variant)
+_gtk_css_find_theme (const gchar *name)
 {
   gchar *path;
   const char *const *dirs;
@@ -1280,12 +1275,12 @@ _gtk_css_find_theme (const gchar *name,
   char *dir;
 
   /* First look in the user's data directory */
-  path = _gtk_css_find_theme_dir (g_get_user_data_dir (), "themes", name, variant);
+  path = _gtk_css_find_theme_dir (g_get_user_data_dir (), "themes", name);
   if (path)
     return path;
 
   /* Next look in the user's home directory */
-  path = _gtk_css_find_theme_dir (g_get_home_dir (), ".themes", name, variant);
+  path = _gtk_css_find_theme_dir (g_get_home_dir (), ".themes", name);
   if (path)
     return path;
 
@@ -1293,14 +1288,14 @@ _gtk_css_find_theme (const gchar *name,
   dirs = g_get_system_data_dirs ();
   for (i = 0; dirs[i]; i++)
     {
-      path = _gtk_css_find_theme_dir (dirs[i], "themes", name, variant);
+      path = _gtk_css_find_theme_dir (dirs[i], "themes", name);
       if (path)
         return path;
     }
 
   /* Finally, try in the default theme directory */
   dir = _gtk_get_theme_dir ();
-  path = _gtk_css_find_theme_dir (dir, NULL, name, variant);
+  path = _gtk_css_find_theme_dir (dir, NULL, name);
   g_free (dir);
 
   return path;
@@ -1310,8 +1305,6 @@ _gtk_css_find_theme (const gchar *name,
  * gtk_css_provider_load_named:
  * @provider: a #GtkCssProvider
  * @name: A theme name
- * @variant: (allow-none): variant to load, for example, "dark", or
- *     %NULL for the default
  *
  * Loads a theme from the usual theme paths. The actual process of
  * finding the theme might change between releases, but it is
@@ -1320,8 +1313,7 @@ _gtk_css_find_theme (const gchar *name,
  **/
 void
 gtk_css_provider_load_named (GtkCssProvider *provider,
-                             const gchar    *name,
-                             const gchar    *variant)
+                             const gchar    *name)
 {
   gchar *path;
   gchar *resource_path;
@@ -1334,10 +1326,7 @@ gtk_css_provider_load_named (GtkCssProvider *provider,
   /* try loading the resource for the theme. This is mostly meant for built-in
    * themes.
    */
-  if (variant)
-    resource_path = g_strdup_printf ("/org/gtk/libgtk/theme/%s/gtk-%s.css", name, variant);
-  else
-    resource_path = g_strdup_printf ("/org/gtk/libgtk/theme/%s/gtk.css", name);
+  resource_path = g_strdup_printf ("/org/gtk/libgtk/theme/%s/gtk.css", name);
 
   if (g_resources_get_info (resource_path, 0, NULL, NULL, NULL))
     {
@@ -1348,7 +1337,7 @@ gtk_css_provider_load_named (GtkCssProvider *provider,
   g_free (resource_path);
 
   /* Next try looking for files in the various theme directories. */
-  path = _gtk_css_find_theme (name, variant);
+  path = _gtk_css_find_theme (name);
   if (path)
     {
       GtkCssProviderPrivate *priv = gtk_css_provider_get_instance_private (provider);
@@ -1375,17 +1364,8 @@ gtk_css_provider_load_named (GtkCssProvider *provider,
     {
       /* Things failed! Fall back! Fall back! */
 
-      if (variant)
-        {
-          /* If there was a variant, try without */
-          gtk_css_provider_load_named (provider, name, NULL);
-        }
-      else
-        {
-          /* Worst case, fall back to the default */
-          g_return_if_fail (!g_str_equal (name, DEFAULT_THEME_NAME)); /* infloop protection */
-          gtk_css_provider_load_named (provider, DEFAULT_THEME_NAME, NULL);
-        }
+      g_return_if_fail (!g_str_equal (name, DEFAULT_THEME_NAME)); /* infloop protection */
+      gtk_css_provider_load_named (provider, DEFAULT_THEME_NAME);
     }
 }
 
diff --git a/gtk/gtkcssprovider.h b/gtk/gtkcssprovider.h
index 01d26bf326..58dab6dff1 100644
--- a/gtk/gtkcssprovider.h
+++ b/gtk/gtkcssprovider.h
@@ -63,8 +63,7 @@ void             gtk_css_provider_load_from_resource (GtkCssProvider *css_provid
 
 GDK_AVAILABLE_IN_ALL
 void             gtk_css_provider_load_named     (GtkCssProvider  *provider,
-                                                  const char      *name,
-                                                  const char      *variant);
+                                                  const char      *name);
 
 G_END_DECLS
 
diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c
index 802ca328b9..fc3be49302 100644
--- a/gtk/gtksettings.c
+++ b/gtk/gtksettings.c
@@ -1643,7 +1643,7 @@ settings_update_theme (GtkSettings *settings)
 
   theme_name = get_theme_name (settings);
 
-  gtk_css_provider_load_named (settings->theme_provider, theme_name, NULL);
+  gtk_css_provider_load_named (settings->theme_provider, theme_name);
 
   /* reload per-theme settings */
   theme_dir = _gtk_css_provider_get_theme_dir (settings->theme_provider);


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