[gimp] app: allow a dark variant of a same theme, instead of having 2 themes.



commit c3dca26d1a5801f21a078f8d35c49540ff532575
Author: Jehan <jehan girinstud io>
Date:   Sat Aug 20 16:02:55 2022 +0200

    app: allow a dark variant of a same theme, instead of having 2 themes.
    
    This way, what will happen is that:
    
    - We can have a single "Default" theme which will have both the light
      and dark versions.
    - With our Default theme, when "Use dark theme variant if available" is
      unchecked, we just follow the system-wide dark settings. (though I'm
      unsure we actually do with current code; we do load our theme over the
      system theme, which may be dark, but I don't think we'd load a dark
      theme variant then)
    - If the option is checked, we will load the specific dark variant,
      bypassing system settings specifically for GIMP.
    
    Technically for theme designers, all it takes to have a dark variant is
    to add a gimp-dark.css next to gimp.css. `gimp-dark.css` is loaded
    instead of `gimp.css` when the settings is checked.
    
    Note: there is apparently a new freedesktop portal for setting the
    prefered variant (and now it's apparently either light, dark or
    default), which is now implemented by GNOME, KDE and Elementary at
    least. It would be nice if we could grab this settings and use it if
    available. The below link has code sample showing how to do it with
    DBus:
    https://gitlab.gnome.org/GNOME/Initiatives/-/wikis/Dark-Style-Preference

 app/gui/themes.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/app/gui/themes.c b/app/gui/themes.c
index 885be271bc..f0fa4688b0 100644
--- a/app/gui/themes.c
+++ b/app/gui/themes.c
@@ -248,8 +248,11 @@ themes_apply_theme (Gimp          *gimp,
 
       if (theme_dir)
         {
-          css_files = g_slist_prepend (
-            css_files, g_file_get_child (theme_dir, "gimp.css"));
+          css_files = g_slist_prepend (css_files, g_file_get_child (theme_dir,
+                                                                    "gimp.css"));
+          if (config->prefer_dark_theme)
+            css_files = g_slist_prepend (css_files, g_file_get_child (theme_dir,
+                                                                      "gimp-dark.css"));
         }
       else
         {


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