summaryrefslogtreecommitdiff
path: root/src/authorize-dialog.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2024-07-21 19:58:31 +0200
committerJörg Frings-Fürst <debian@jff.email>2024-07-21 19:58:31 +0200
commit5a514d891db203b803a37c2110184f537fcd5608 (patch)
tree0c85f179d5cfeb471f3227bd4a94998e3aaf4ee1 /src/authorize-dialog.vala
parent408791709f23be34de957320384d02b228ea488f (diff)
parent35c7b263d4fc6910be51005193095cfbdeaa969a (diff)
Merge branch 'release/debian/46.0-1'HEADdebian/46.0-1master
Diffstat (limited to 'src/authorize-dialog.vala')
-rw-r--r--src/authorize-dialog.vala71
1 files changed, 65 insertions, 6 deletions
diff --git a/src/authorize-dialog.vala b/src/authorize-dialog.vala
index 7cb2a66..ab0237a 100644
--- a/src/authorize-dialog.vala
+++ b/src/authorize-dialog.vala
@@ -11,18 +11,21 @@
*/
[GtkTemplate (ui = "/org/gnome/SimpleScan/ui/authorize-dialog.ui")]
-private class AuthorizeDialog : Gtk.Dialog
+private class AuthorizeDialog : Gtk.Window
{
[GtkChild]
- private unowned Gtk.Label authorize_label;
+ private unowned Adw.PreferencesGroup preferences_group;
[GtkChild]
- private unowned Gtk.Entry username_entry;
+ private unowned Adw.EntryRow username_entry;
[GtkChild]
- private unowned Gtk.Entry password_entry;
+ private unowned Adw.PasswordEntryRow password_entry;
- public AuthorizeDialog (string title)
+ public signal void authorized (AuthorizeDialogResponse res);
+
+ public AuthorizeDialog (Gtk.Window parent, string title)
{
- authorize_label.set_text (title);
+ preferences_group.set_title (title);
+ set_transient_for (parent);
}
public string get_username ()
@@ -34,4 +37,60 @@ private class AuthorizeDialog : Gtk.Dialog
{
return password_entry.text;
}
+
+ [GtkCallback]
+ private void authorize_button_cb ()
+ {
+ authorized (AuthorizeDialogResponse.new_authorized (get_username (), get_password ()));
+ }
+
+ [GtkCallback]
+ private void cancel_button_cb ()
+ {
+ authorized (AuthorizeDialogResponse.new_canceled ());
+ }
+
+ public async AuthorizeDialogResponse open()
+ {
+ SourceFunc callback = open.callback;
+
+ AuthorizeDialogResponse response = {};
+
+ authorized.connect ((res) =>
+ {
+ response = res;
+ callback ();
+ });
+
+ present ();
+ yield;
+ close ();
+
+ return response;
+ }
+}
+
+public struct AuthorizeDialogResponse
+{
+ public string username;
+ public string password;
+ public bool success;
+
+ public static AuthorizeDialogResponse new_canceled ()
+ {
+ return AuthorizeDialogResponse ()
+ {
+ success = false,
+ };
+ }
+
+ public static AuthorizeDialogResponse new_authorized (string username, string password)
+ {
+ return AuthorizeDialogResponse ()
+ {
+ username = username,
+ password = password,
+ success = true,
+ };
+ }
}