[gnome-text-editor] preferences: extract dark variant information from scheme



commit c4881e48dcf2d81f648808324b3956278560ad83
Author: Christian Hergert <chergert redhat com>
Date:   Wed Dec 1 14:06:34 2021 -0800

    preferences: extract dark variant information from scheme
    
    Now that we have this information in GtkSourceView, lets use it.
    
    Fixes #183

 src/editor-preferences-dialog.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/src/editor-preferences-dialog.c b/src/editor-preferences-dialog.c
index 67462f8..bf16b9f 100644
--- a/src/editor-preferences-dialog.c
+++ b/src/editor-preferences-dialog.c
@@ -175,9 +175,18 @@ update_style_scheme_selection (EditorPreferencesDialog *self)
 }
 
 static gboolean
-scheme_is_dark (const char *id)
+scheme_is_dark (GtkSourceStyleScheme *scheme)
 {
-  return strstr (id, "-dark") != NULL;
+  const char *id = gtk_source_style_scheme_get_id (scheme);
+  const char *variant = gtk_source_style_scheme_get_metadata (scheme, "variant");
+
+  if (strstr (id, "-dark") != NULL)
+    return TRUE;
+
+  if (g_strcmp0 (variant, "dark") == 0)
+    return TRUE;
+
+  return FALSE;
 }
 
 static void
@@ -202,10 +211,11 @@ update_style_schemes (EditorPreferencesDialog *self)
           GtkSourceStyleScheme *scheme;
           GtkWidget *preview;
 
-          if (is_dark != scheme_is_dark (scheme_ids[i]))
+          scheme = gtk_source_style_scheme_manager_get_scheme (sm, scheme_ids[i]);
+
+          if (is_dark != scheme_is_dark (scheme))
             continue;
 
-          scheme = gtk_source_style_scheme_manager_get_scheme (sm, scheme_ids[i]);
           preview = gtk_source_style_scheme_preview_new (scheme);
           gtk_actionable_set_action_name (GTK_ACTIONABLE (preview), "app.style-scheme");
           gtk_actionable_set_action_target (GTK_ACTIONABLE (preview), "s", scheme_ids[i]);


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