aboutsummaryrefslogtreecommitdiff
path: root/src/arctica-greeter.vala
diff options
context:
space:
mode:
authorMihai Moldovan <ionic@ionic.de>2022-12-06 02:49:19 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2023-02-06 08:30:01 +0100
commit32d28d7bf2646fc7a0008937034246fcc96dbc8a (patch)
tree3cb1098e9925ee291b13d285c80f1233751ed1c2 /src/arctica-greeter.vala
parent600fbb680106b697c1801fcd67aa51477743a30d (diff)
downloadarctica-greeter-32d28d7bf2646fc7a0008937034246fcc96dbc8a.tar.gz
arctica-greeter-32d28d7bf2646fc7a0008937034246fcc96dbc8a.tar.bz2
arctica-greeter-32d28d7bf2646fc7a0008937034246fcc96dbc8a.zip
misc src/: make ArcticaGreeter a proper vala SingleInstance class.
This allows us to drop the rather awkward self-referencing static singleton member and use a standard vala/glib feature.
Diffstat (limited to 'src/arctica-greeter.vala')
-rw-r--r--src/arctica-greeter.vala30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/arctica-greeter.vala b/src/arctica-greeter.vala
index 09c1feb..013739c 100644
--- a/src/arctica-greeter.vala
+++ b/src/arctica-greeter.vala
@@ -21,16 +21,15 @@
public const int grid_size = 40;
-public class ArcticaGreeter
+[SingleInstance]
+public class ArcticaGreeter : Object
{
- public static ArcticaGreeter singleton;
-
public signal void show_message (string text, LightDM.MessageType type);
public signal void show_prompt (string text, LightDM.PromptType type);
public signal void authentication_complete ();
public signal void starting_session ();
- public bool test_mode = false;
+ public bool test_mode { get; construct; default = false; }
private string state_file;
private KeyFile state;
@@ -53,11 +52,8 @@ public class ArcticaGreeter
public signal void xsettings_ready ();
public signal void greeter_ready ();
- private ArcticaGreeter (bool test_mode_)
+ construct
{
- singleton = this;
- test_mode = test_mode_;
-
greeter = new LightDM.Greeter ();
greeter.show_message.connect ((text, type) => { show_message (text, type); });
greeter.show_prompt.connect ((text, type) => { show_prompt (text, type); });
@@ -140,6 +136,22 @@ public class ArcticaGreeter
xsettings_ready_cb ();
}
+ /*
+ * Note that we need a way to specify a parameter for the initial instance
+ * creation of the singleton, but also a constructor that takes no
+ * parameters for later usage.
+ *
+ * Making the parameter optional is a good compromise.
+ *
+ * This this parameter is construct-only, initializing it by passing it to
+ * the GObject constructor is both the correct way to do it, and it will
+ * additionally avoid changing it in later calls of our constructor.
+ */
+ public ArcticaGreeter (bool test_mode_ = false)
+ {
+ Object (test_mode: test_mode_);
+ }
+
public string? get_state (string key)
{
try
@@ -340,7 +352,7 @@ public class ArcticaGreeter
{
try
{
- ArcticaGreeter.singleton.greeter.authenticate_remote (session, userid);
+ greeter.authenticate_remote (session, userid);
}
catch (Error e)
{