Revision: 7246
          http://svn.sourceforge.net/mahogany/?rev=7246&view=rev
Author:   vadz
Date:     2007-04-26 09:30:37 -0700 (Thu, 26 Apr 2007)

Log Message:
-----------
don't create wxDialUpManager unless really necessary, this removes a very long 
delay when opening the preferences dialog under Windows

Modified Paths:
--------------
    trunk/M/include/gui/wxOptionsPage.h
    trunk/M/src/gui/wxOptionsDlg.cpp

Modified: trunk/M/include/gui/wxOptionsPage.h
===================================================================
--- trunk/M/include/gui/wxOptionsPage.h 2007-04-26 16:06:11 UTC (rev 7245)
+++ trunk/M/include/gui/wxOptionsPage.h 2007-04-26 16:30:37 UTC (rev 7246)
@@ -554,7 +554,16 @@
    {
    }
 
+#if defined(OS_WIN) && defined(USE_DIALUP)
+   // fill the choice control with the names of available dialup connections:
+   // this can take a relatively long time as it requires wxDialUpManager
+   // initialization, so we only do it when absolutely necessary
+   void FillDialupConnections();
 
+   // event handler to detect when the use of dialup manager is enabled
+   void OnDialUp(wxCommandEvent& event);
+#endif // USE_DIALUP
+
 #ifdef USE_OWN_CCLIENT
    wxString m_oldAuthsDisabled;
 #endif // USE_OWN_CCLIENT

Modified: trunk/M/src/gui/wxOptionsDlg.cpp
===================================================================
--- trunk/M/src/gui/wxOptionsDlg.cpp    2007-04-26 16:06:11 UTC (rev 7245)
+++ trunk/M/src/gui/wxOptionsDlg.cpp    2007-04-26 16:30:37 UTC (rev 7246)
@@ -3732,7 +3732,48 @@
 {
 }
 
-// dynamicially fill the RAS connections combo box under Windows
+#if defined(OS_WIN) && defined(USE_DIALUP)
+
+void wxOptionsPageNetwork::FillDialupConnections()
+{
+   wxControl *control = GetControl(ConfigField_NetConnection);
+   wxChoice *choice = control ? wxStaticCast(control, wxChoice) : NULL;
+
+   // may be NULL if we don't use dial up manager at all
+   if ( !choice )
+      return;
+
+   // we may have already filled it
+   if ( !choice->IsEmpty() )
+      return;
+
+   // this could take a long time
+   wxBusyCursor bc;
+
+   wxDialUpManager *dial = wxDialUpManager::Create();
+
+   if ( !dial )
+      return;
+
+   wxArrayString aConnections;
+   dial->GetISPNames(aConnections);
+
+   choice->Append(aConnections);
+
+   delete dial;
+}
+
+void wxOptionsPageNetwork::OnDialUp(wxCommandEvent& event)
+{
+   if ( event.IsChecked() )
+      FillDialupConnections();
+
+   event.Skip();
+}
+
+#endif // USE_DIALUP
+
+// dynamically fill the RAS connections combo box under Windows
 bool wxOptionsPageNetwork::TransferDataToWindow()
 {
 #ifdef USE_OWN_CCLIENT
@@ -3756,32 +3797,19 @@
 #if defined(OS_WIN) && defined(USE_DIALUP)
    if ( bRc )
    {
-      wxControl *control = GetControl(ConfigField_NetConnection);
-      wxChoice *choice = control ? wxStaticCast(control, wxChoice) : NULL;
-
-      if ( choice )
+      wxCheckBox *chkDialUp =
+         wxStaticCast(GetControl(ConfigField_DialUpSupport), wxCheckBox);
+      if ( chkDialUp )
       {
-         // may be NULL if we don't use dial up manager at all
-         wxDialUpManager *dial = wxDialUpManager::Create();
+         if ( chkDialUp->GetValue() )
+            FillDialupConnections();
 
-         if ( dial )
-         {
-            // wxDialUpManager can fail to enumerate the connections but we
-            // don't want to present the user with an error each time he opens
-            // the preferences dialog just because of this
-            wxLogNull noLog;
-
-            wxArrayString aConnections;
-            dial->GetISPNames(aConnections);
-
-            size_t count = aConnections.GetCount();
-            for ( size_t n = 0; n < count; n++ )
-            {
-               choice->Append(aConnections[n]);
-            }
-
-            delete dial;
-         }
+         Connect
+         (
+            chkDialUp->GetId(),
+            wxEVT_COMMAND_CHECKBOX_CLICKED,
+            wxCommandEventHandler(wxOptionsPageNetwork::OnDialUp)
+         );
       }
    }
 #endif // USE_DIALUP


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to