[dconf-editor] Test use fo SettingsBackend.



commit ef79c635bb24cbe4e2a2383740fa56be77dd7f6f
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Wed Nov 22 05:16:25 2017 +0100

    Test use fo SettingsBackend.

 editor/dconf-editor.vala |   18 ++++++++++++++++++
 editor/meson.build       |    1 +
 2 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/editor/dconf-editor.vala b/editor/dconf-editor.vala
index 6e045aa..8982e2c 100644
--- a/editor/dconf-editor.vala
+++ b/editor/dconf-editor.vala
@@ -80,6 +80,24 @@ class ConfigurationEditor : Gtk.Application
         Gdk.Screen? screen = Gdk.Screen.get_default ();
         return_if_fail (screen != null);
         Gtk.StyleContext.add_provider_for_screen ((!) screen, css_provider, 
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
+
+        test_backend ();
+    }
+
+    private static void test_backend ()
+    {
+        SettingsBackend? backend1 = SettingsBackend.get_default ();
+        if (backend1 == null)
+            return; // TODO something, probably
+        string backend_name = ((!) backend1).get_type ().name ();
+        if (backend_name == "GMemorySettingsBackend")       // called with GSETTINGS_BACKEND=memory
+            warning (_("The Memory settings backend is used, no change will be saved on quit."));
+        else if (backend_name == "GNullSettingsBackend")    // called with GSETTINGS_BACKEND=null
+            warning (_("The Null settings backend is used, changes will not be saved."));
+        else if (backend_name != "DConfSettingsBackend")
+            warning (_("The backend used is unknown, bad thing might happen."));
+        else                                                // called by default or with 
GSETTINGS_BACKEND=dconf
+            info (_("Looks like the DConf settings backend is used, all looks good."));
     }
 
     /*\
diff --git a/editor/meson.build b/editor/meson.build
index 99c3a4c..86c2fa7 100644
--- a/editor/meson.build
+++ b/editor/meson.build
@@ -102,6 +102,7 @@ cflags = [
   '-DVERSION="@0@"'.format(dconf_editor_version),
   '-DLOCALEDIR="@0@"'.format(dconf_editor_localedir),
   '-DGETTEXT_PACKAGE="@0@"'.format(dconf_editor_gettext),
+  '-DG_SETTINGS_ENABLE_BACKEND=1',
   '-w'
 ]
 


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