glom r2047 - in trunk: . glom



Author: murrayc
Date: Fri Apr  3 09:30:41 2009
New Revision: 2047
URL: http://svn.gnome.org/viewvc/glom?rev=2047&view=rev

Log:
2009-04-03  Murray Cumming  <murrayc murrayc com>

* glom/frame_glom.cc: connection_request_password_and_attempt():
When the password fails, just loop around the while again to ask again, 
instead of showing a one-off extra dialog. That fixes the problem of being 
asked twice when the first try failed.
Load the document outside of the while() instead of each time we ask for the 
password.

Modified:
   trunk/ChangeLog
   trunk/glom/frame_glom.cc

Modified: trunk/glom/frame_glom.cc
==============================================================================
--- trunk/glom/frame_glom.cc	(original)
+++ trunk/glom/frame_glom.cc	Fri Apr  3 09:30:41 2009
@@ -1881,6 +1881,7 @@
       //Ask for connection details:
       m_pDialogConnection->load_from_document(); //Get good defaults.
       m_pDialogConnection->set_transient_for(*get_app_window());
+ 
       const int response = Glom::Utils::dialog_run_with_help(m_pDialogConnection, "dialog_connection");
       m_pDialogConnection->hide();
 
@@ -2053,7 +2054,18 @@
     Utils::get_glade_widget_derived_with_warning("dialog_connection", m_pDialogConnection);
     add_view(m_pDialogConnection); //Also a composite view.
   }
+  
+  m_pDialogConnection->load_from_document(); //Get good defaults.
+  m_pDialogConnection->set_transient_for(*get_app_window());
+
+  if(!known_username.empty())
+    m_pDialogConnection->set_username(known_username);
+
+  if(!known_password.empty())
+    m_pDialogConnection->set_password(known_password);
+
 
+  //Start a self-hosted server if necessary:
   ConnectionPool* connection_pool = ConnectionPool::get_instance();
   setup_connection_pool_from_document(document);
   if(!connection_pool->startup( sigc::mem_fun(*this, &Frame_Glom::on_connection_startup_progress) ))
@@ -2065,18 +2077,10 @@
     m_dialog_progess_connection_startup = 0;
   }
 
+
+  //Ask for connection details: 
   while(true) //Loop until a return
   {
-    //Ask for connection details:
-    m_pDialogConnection->load_from_document(); //Get good defaults.
-    m_pDialogConnection->set_transient_for(*get_app_window());
-
-    if(!known_username.empty())
-      m_pDialogConnection->set_username(known_username);
-
-    if(!known_password.empty())
-      m_pDialogConnection->set_password(known_password);
-
     //Only show the dialog if we don't know the correct username/password yet:
     int response = Gtk::RESPONSE_OK;
 
@@ -2095,6 +2099,7 @@
       }
     }
 
+    //Try to use the entered username/password:
     if(response == Gtk::RESPONSE_OK)
     {
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
@@ -2122,13 +2127,7 @@
           //Warn the user, and let him try again:
           Utils::show_ok_dialog(_("Connection Failed"), _("Glom could not connect to the database server. Maybe you entered an incorrect user name or password, or maybe the postgres database server is not running."), *(get_app_window()), Gtk::MESSAGE_ERROR); //TODO: Add help button.
 
-          response = Glom::Utils::dialog_run_with_help(m_pDialogConnection, "dialog_connection");
-          m_pDialogConnection->hide();
-          if(response != Gtk::RESPONSE_OK)
-          {
-            cleanup_connection();
-            return false; //The user cancelled.
-          }
+          //The while() loop will run again, showing the username/password dialog again.
         }
         else
         {



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