[geary/geary-0.8] Password dialog always has transient parent: Bug #720769



commit 2de628ab360725ffb3cd879cf41d7600da4e4f7c
Author: Jim Nelson <jim yorba org>
Date:   Tue Oct 28 16:31:31 2014 -0700

    Password dialog always has transient parent: Bug #720769
    
    Not only a transient parent, but the main window is shown and
    presented if hidden to ensure everything is displayed.  This ensures
    the password prompt is associated with Geary, answering some of the
    concerns in bug #739195.

 src/client/application/secret-mediator.vala        |    9 ++++++++-
 src/client/dialogs/password-dialog.vala            |    3 ++-
 .../imap-engine/imap-engine-generic-account.vala   |   12 ++++++------
 3 files changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/src/client/application/secret-mediator.vala b/src/client/application/secret-mediator.vala
index e1ed1ae..ea53c2b 100644
--- a/src/client/application/secret-mediator.vala
+++ b/src/client/application/secret-mediator.vala
@@ -112,7 +112,14 @@ public class SecretMediator : Geary.CredentialsMediator, Object {
         // API would indicate it does.  We need to revamp the API.
         assert(!services.has_imap() || !services.has_smtp());
         
-        PasswordDialog password_dialog = new PasswordDialog(services.has_smtp(),
+        // If the main window is hidden, make it visible now and present to user as transient parent
+        Gtk.Window? main_window = GearyApplication.instance.controller.main_window;
+        if (main_window != null && !main_window.visible) {
+            main_window.show_all();
+            main_window.present_with_time(Gdk.CURRENT_TIME);
+        }
+        
+        PasswordDialog password_dialog = new PasswordDialog(main_window, services.has_smtp(),
             account_information, services);
         
         if (!password_dialog.run()) {
diff --git a/src/client/dialogs/password-dialog.vala b/src/client/dialogs/password-dialog.vala
index 8ca620d..2c95c10 100644
--- a/src/client/dialogs/password-dialog.vala
+++ b/src/client/dialogs/password-dialog.vala
@@ -23,11 +23,12 @@ public class PasswordDialog {
     public string password { get; private set; default = ""; }
     public bool remember_password { get; private set; }
     
-    public PasswordDialog(bool smtp, Geary.AccountInformation account_information,
+    public PasswordDialog(Gtk.Window? parent, bool smtp, Geary.AccountInformation account_information,
         Geary.ServiceFlag password_flags) {
         Gtk.Builder builder = GearyApplication.instance.create_builder("password-dialog.glade");
         
         dialog = (Gtk.Dialog) builder.get_object("PasswordDialog");
+        dialog.transient_for = parent;
         dialog.set_type_hint(Gdk.WindowTypeHint.DIALOG);
         dialog.set_default_response(Gtk.ResponseType.OK);
         
diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala 
b/src/engine/imap-engine/imap-engine-generic-account.vala
index 92fef95..ef84ee6 100644
--- a/src/engine/imap-engine/imap-engine-generic-account.vala
+++ b/src/engine/imap-engine/imap-engine-generic-account.vala
@@ -118,12 +118,6 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.AbstractAccount {
     }
     
     private async void internal_open_async(Cancellable? cancellable) throws Error {
-        // To prevent spurious connection failures, we make sure we have the
-        // IMAP password before attempting a connection.  This might have to be
-        // reworked when we allow passwordless logins.
-        if (!information.imap_credentials.is_complete())
-            yield information.fetch_passwords_async(ServiceFlag.IMAP);
-        
         try {
             yield local.open_async(information.settings_dir, Engine.instance.resource_dir.get_child("sql"),
                 cancellable);
@@ -146,6 +140,12 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.AbstractAccount {
         // Search folder.
         local_only.set(search_path, local.search_folder);
         
+        // To prevent spurious connection failures, we make sure we have the
+        // IMAP password before attempting a connection.  This might have to be
+        // reworked when we allow passwordless logins.
+        if (!information.imap_credentials.is_complete())
+            yield information.fetch_passwords_async(ServiceFlag.IMAP);
+        
         // need to back out local.open_async() if remote fails
         try {
             yield remote.open_async(cancellable);


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