From 9764d44bb1e6a34df8e9e2f4391688dea5a4b8c0 Mon Sep 17 00:00:00 2001 From: Michael Gratton Date: Fri, 30 Nov 2018 23:42:26 +1100 Subject: [PATCH] Add an activated signal to Validator component This will fire when the user has activated the entry and validation has completed, allowing use sites to hook up one place when waiting for asyc validation (e.g. host name validation) to occur. --- src/client/components/components-validator.vala | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/client/components/components-validator.vala b/src/client/components/components-validator.vala index ee500a59..9cc6d7a3 100644 --- a/src/client/components/components-validator.vala +++ b/src/client/components/components-validator.vala @@ -105,6 +105,9 @@ public class Components.Validator : GLib.Object { /** Fired when the validation state changes. */ public signal void state_changed(Trigger reason, Validity prev_state); + /** Fired when target entry is activated and validation completes. */ + public signal void activated(); + public Validator(Gtk.Entry target) { this.target = target; @@ -204,6 +207,10 @@ public class Components.Validator : GLib.Object { this.ui_update_timer.start(); } } + + if (reason == Trigger.ACTIVATED && new_state != Validity.IN_PROGRESS) { + activated(); + } } private void validate_entry(Trigger reason) { @@ -340,7 +347,7 @@ public class Components.NetworkAddressValidator : Validator { private GLib.Cancellable? cancellable = null; - public NetworkAddressValidator(Gtk.Entry target, uint16 default_port) { + public NetworkAddressValidator(Gtk.Entry target, uint16 default_port = 0) { base(target); this.default_port = default_port;