From 600fbb680106b697c1801fcd67aa51477743a30d Mon Sep 17 00:00:00 2001 From: Mihai Moldovan Date: Tue, 6 Dec 2022 01:48:20 +0100 Subject: src/settings.vala: make SingleInstance class. This way, we will be able to use it everywhere, as long as we hold a reference in the main greeter object. We will extend this class with other properties later on. --- src/arctica-greeter.vala | 10 ++++++++++ src/settings.vala | 11 ++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/arctica-greeter.vala b/src/arctica-greeter.vala index 96a98ce..09c1feb 100644 --- a/src/arctica-greeter.vala +++ b/src/arctica-greeter.vala @@ -807,6 +807,16 @@ public class ArcticaGreeter if (value != "") settings.set ("gtk-xft-rgba", value, null); + /* + * Keep a reference to an AGSettings instance for the whole program + * run, so that the SingleInstance property is working the way we'd + * like it to work. + * + * We want to do this before creating the actual greeter, since the + * latter is using AGSettings quite extensively. + */ + var agsettings = new AGSettings (); + debug ("Creating Arctica Greeter"); var greeter = new ArcticaGreeter (do_test_mode); diff --git a/src/settings.vala b/src/settings.vala index 701d5a1..3c50bbc 100644 --- a/src/settings.vala +++ b/src/settings.vala @@ -2,6 +2,7 @@ * * Copyright (C) 2011,2012 Canonical Ltd * Copyright (C) 2015,2017 Mike Gabriel + * Copyright (C) 2022 Mihai Moldovan * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as @@ -20,7 +21,8 @@ * Mike Gabriel */ -public class AGSettings +[SingleInstance] +public class AGSettings : Object { public const string KEY_BACKGROUND = "background"; public const string KEY_BACKGROUND_COLOR = "background-color"; @@ -105,5 +107,12 @@ public class AGSettings return gsettings.set_strv (key, value); } + public AGSettings () + { + } + + construct { + } + private const string SCHEMA = "org.ArcticaProject.arctica-greeter"; } -- cgit v1.2.3