[xdg-desktop-portal-gnome/wip/exalm/dark] settings: Provide org.freedesktop.appearance.color-scheme key




commit 7a6684614054af640cc10354595d8fef9d9347de
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Wed Aug 25 01:24:17 2021 +0500

    settings: Provide org.freedesktop.appearance.color-scheme key

 src/settings.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
---
diff --git a/src/settings.c b/src/settings.c
index 8e1bb28..3caef2b 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -136,6 +136,18 @@ settings_handle_read_all (XdpImplSettings       *object,
       g_variant_builder_add (builder, "{s@a{sv}}", "org.gnome.fontconfig", g_variant_dict_end (&dict));
     }
 
+  if (namespace_matches ("org.freedesktop.appearance", arg_namespaces))
+    {
+      SettingsBundle *bundle = g_hash_table_lookup (settings, "org.gnome.desktop.interface");
+      GVariant *color_scheme_value = g_settings_get_value (bundle->settings, "color-scheme");
+      GVariantDict dict;
+
+      g_variant_dict_init (&dict, NULL);
+      g_variant_dict_insert_value (&dict, "color-scheme", color_scheme_value);
+
+      g_variant_builder_add (builder, "{s@a{sv}}", "org.freedesktop.appearance", g_variant_dict_end (&dict));
+    }
+
   g_variant_builder_close (builder);
 
   g_dbus_method_invocation_return_value (invocation, g_variant_builder_end (builder));
@@ -161,6 +173,16 @@ settings_handle_read (XdpImplSettings       *object,
           return TRUE;
         }
     }
+  else if (strcmp (arg_namespace, "org.freedesktop.appearance") == 0 &&
+           strcmp (arg_key, "color-scheme") == 0)
+    {
+      SettingsBundle *bundle = g_hash_table_lookup (settings, "org.gnome.desktop.interface");
+      GVariant *color_scheme_value = g_settings_get_value (bundle->settings, "color-scheme");
+
+      g_dbus_method_invocation_return_value (invocation,
+                                             g_variant_new ("(v)", color_scheme_value));
+      return TRUE;
+    }
   else if (strcmp (arg_namespace, "org.gnome.desktop.interface") == 0 &&
            strcmp (arg_key, "enable-animations") == 0)
     {
@@ -225,6 +247,12 @@ on_settings_changed (GSettings             *settings,
     xdp_impl_settings_emit_setting_changed (user_data->self,
                                             user_data->namespace, key,
                                             g_variant_new ("v", new_value));
+
+  if (strcmp (user_data->namespace, "org.gnome.desktop.interface") == 0 &&
+      strcmp (key, "color-scheme") == 0)
+    xdp_impl_settings_emit_setting_changed (user_data->self,
+                                            "org.freedesktop.appearance", key,
+                                            g_variant_new ("v", new_value));
 }
 
 static void


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