glom r1558 - in trunk: . glom



Author: arminb
Date: Sun Apr 13 12:52:30 2008
New Revision: 1558
URL: http://svn.gnome.org/viewvc/glom?rev=1558&view=rev

Log:
2008-04-13  Armin Burgmeier  <armin openismus com>

	* glom/frame_glom.h:
	* glom/frame_glom.cc (create_database): Simplified the function,
	removed the request_password parameter. It was never set, and it
	seemed to be a relict from libgda-1.2.
	(connection_request_password_and_choose_new_database_name),
	(connection_request_password_and_attempt): Create the connection
	dialog when required, instead of loading it in the constructor, to
	improve startup time.

	* glom/dialog_existing_or_new.h: Added a comment about bug #527587.

	* glom/application.cc (recreate_database), (existing_or_new_new):
	Adapt to changed create_database() function in frame_glom.


Modified:
   trunk/ChangeLog
   trunk/glom/application.cc
   trunk/glom/dialog_existing_or_new.h
   trunk/glom/frame_glom.cc
   trunk/glom/frame_glom.h

Modified: trunk/glom/application.cc
==============================================================================
--- trunk/glom/application.cc	(original)
+++ trunk/glom/application.cc	Sun Apr 13 12:52:30 2008
@@ -1281,7 +1281,7 @@
     }
     else
     {
-      const bool db_created = m_pFrame->create_database(document->get_connection_database(), db_title, false /* do not request password */);
+      const bool db_created = m_pFrame->create_database(document->get_connection_database(), db_title);
       if(db_created)
       {
         const Glib::ustring database_name_used = document->get_connection_database();
@@ -1437,7 +1437,7 @@
 
   //Create the database: (This will show a connection dialog)
   connection_pool->set_database( Glib::ustring() );
-  const bool db_created = m_pFrame->create_database(db_name, pDocument->get_database_title(), false /* Don't ask for password etc again. */);
+  const bool db_created = m_pFrame->create_database(db_name, pDocument->get_database_title());
 
   if(!db_created)
   {

Modified: trunk/glom/dialog_existing_or_new.h
==============================================================================
--- trunk/glom/dialog_existing_or_new.h	(original)
+++ trunk/glom/dialog_existing_or_new.h	Sun Apr 13 12:52:30 2008
@@ -130,8 +130,9 @@
 
     // For recently used resources:
     // TODO: We can't use Glib::RefPtr<Gtk::RecentInfo> directly here, due to
-    // bug #. Therefore, the refptrs are dynamically allocated and explicitely
-    // freed in the destructor.
+    // bug #527587. Therefore, the refptrs are dynamically allocated and
+    // explicitely freed in the destructor. This has already been fixed in
+    // gtkmm trunk and is fixed for gtkmm 2.14.
     Gtk::TreeModelColumn<Glib::RefPtr<Gtk::RecentInfo>*> m_col_recent_info;
   };
   

Modified: trunk/glom/frame_glom.cc
==============================================================================
--- trunk/glom/frame_glom.cc	(original)
+++ trunk/glom/frame_glom.cc	Sun Apr 13 12:52:30 2008
@@ -129,9 +129,6 @@
 
   //m_pLabel_Mode->set_text(_("No database selected.\n Use the Navigation menu, or open a previous Glom document."));
 
-  //Load the Glade file and instantiate its widgets to get the dialog stuff:
-  Utils::get_glade_widget_derived_with_warning("dialog_connection", m_pDialogConnection);
-
   m_Mode = MODE_None;
   m_Mode_Previous = MODE_None;
 
@@ -145,7 +142,6 @@
 
   //Fill Composite View:
   //This means that set_document and load/save are delegated to these children:
-  add_view(m_pDialogConnection); //Also a composite view.
   add_view(&m_Notebook_Data); //Also a composite view.
   add_view(&m_Notebook_Find); //Also a composite view.
 
@@ -195,12 +191,6 @@
     m_pDialog_Relationships = 0;
   }
 
-  if(m_pDialog_Relationships)
-  {
-    delete m_pDialog_Relationships;
-    m_pDialog_Relationships = 0;
-  }
-
   if(m_pDialogLayoutReport)
   {
     remove_view(m_pDialogLayoutReport);
@@ -1505,6 +1495,12 @@
   }
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 
+  if(!m_pDialogConnection)
+  {
+    Utils::get_glade_widget_derived_with_warning("dialog_connection", m_pDialogConnection);
+    add_view(m_pDialogConnection); //Also a composite view.
+  }
+
   //Ask either for the existing username and password to use an existing database server,
   //or ask for a new username and password to specify when creating a new self-hosted database.
   int response = 0;
@@ -1574,12 +1570,12 @@
           return false;
 
         // Store in document, so these values are actually used when connecting
-	Document_Glom* document = get_document();
-	if(document)
-	{
-	  document->set_connection_port(connection_pool->get_port());
+        Document_Glom* document = get_document();
+        if(document)
+        {
+          document->set_connection_port(connection_pool->get_port());
           document->set_connection_try_other_ports(connection_pool->get_try_other_ports());
-	}
+        }
       }
       else
         return false;
@@ -1691,6 +1687,12 @@
 bool Frame_Glom::connection_request_password_and_attempt(const Glib::ustring known_username, const Glib::ustring& known_password, std::auto_ptr<ExceptionConnection>& error)
 #endif
 {
+  if(!m_pDialogConnection)
+  {
+    Utils::get_glade_widget_derived_with_warning("dialog_connection", m_pDialogConnection);
+    add_view(m_pDialogConnection); //Also a composite view.
+  }
+
   while(true) //Loop until a return
   {
     //Ask for connection details:
@@ -1765,104 +1767,49 @@
 }
 
 #ifndef GLOM_ENABLE_CLIENT_ONLY
-bool Frame_Glom::create_database(const Glib::ustring& database_name, const Glib::ustring& title, bool request_password)
+bool Frame_Glom::create_database(const Glib::ustring& database_name, const Glib::ustring& title)
 {
-  //Ask for connection details:
-  bool connection_possible = false;
-  try
-  {
-    if(request_password)
-      connection_possible = connection_request_password_and_attempt(); //If it succeeded and the user did not cancel.
-    else
-    {
-      m_pDialogConnection->set_database_name(Glib::ustring()); //Make sure that it always connects to the default database when creating a database.
-      connection_possible = true; //Assume that connection details are already correct.
-    }
-  }
-  catch(const ExceptionConnection& ex)
-  {
-     connection_possible = false;
-     std::cerr << "debug Frame_Glom::create_database() exception caught: connection failed: " << ex.what() << std::endl;
-  }
-
-  if(!connection_possible)
-  {
-    //g_warning("debug Frame_Glom::create_database(): connection was not possible.");
-    return false;
-  }
-  else
-  {
-    // TODO: I don't think this is required anymore since libgda-3.0 because
-    // we do not need a connection to create a database. armin.
-#if 0
-    //This must now succeed, because we've already tried it once:
-    sharedptr<SharedConnection> sharedconnection;
-    try
-    {
-      if(request_password)
-        sharedconnection = m_pDialogConnection->connect_to_server_with_connection_settings();
-      else
-      {
-        ConnectionPool* connection_pool = ConnectionPool::get_instance();
-        connection_pool->set_database(Glib::ustring()); //Make sure that it uses the default database for connections when creating databases.
-        sharedconnection = connection_pool->connect();
-      }
-    }
-    catch(const ExceptionConnection& ex)
-    {
-      //g_warning("debug Frame_Glom::create_database() Connection failed.");
-
-      return false;
-    }
-#endif
-
 #if 1
-    // This seems to increase the change that the database creation does not
-    // fail due to the "source database is still in use" error. armin.
-    //std::cout << "Going to sleep" << std::endl;
-    Glib::usleep(500 * 1000);
-    //std::cout << "Awake" << std::endl;
+  // This seems to increase the change that the database creation does not
+  // fail due to the "source database is still in use" error. armin.
+  //std::cout << "Going to sleep" << std::endl;
+  Glib::usleep(500 * 1000);
+  //std::cout << "Awake" << std::endl;
 #endif
 
-    Gtk::Window* pWindowApp = get_app_window();
-    g_assert(pWindowApp);
+  Gtk::Window* pWindowApp = get_app_window();
+  g_assert(pWindowApp);
 
-    Bakery::BusyCursor busycursor(*pWindowApp);
+  Bakery::BusyCursor busycursor(*pWindowApp);
 
+  try
+  {
+    ConnectionPool::get_instance()->create_database(database_name);
+  }
+  catch(const Glib::Exception& ex) // libgda does not set error domain
+  {
+    //I think a failure here might be caused by installing unstable libgda, which seems to affect stable libgda-1.2.
+    //Doing a "make install" in libgda-1.2 seems to fix this:
+    //TODO: Is this still relevant in libgda-3.0?
+    std::cerr << "Frame_Glom::create_database():  Gnome::Gda::Connection::create_database(" << database_name << ") failed: " << ex.what() << std::endl;
+
+    //Tell the user:
+    Gtk::Dialog* dialog = 0;
     try
     {
-      ConnectionPool::get_instance()->create_database(database_name);
+       // TODO: Tell the user what has gone wrong (ex.what())
+      Glib::RefPtr<Gnome::Glade::Xml> refXml = Gnome::Glade::Xml::create(Utils::get_glade_file_path("glom_developer.glade"), "dialog_error_create_database");
+      refXml->get_widget("dialog_error_create_database", dialog);
+      dialog->set_transient_for(*pWindowApp);
+      Glom::Utils::dialog_run_with_help(dialog, "dialog_error_create_database");
+      delete dialog;
     }
-    catch(const Glib::Exception& ex) // libgda does not set error domain
+    catch(const Gnome::Glade::XmlError& ex)
     {
-      //I think a failure here might be caused by installing unstable libgda, which seems to affect stable libgda-1.2.
-      //Doing a "make install" in libgda-1.2 seems to fix this:
-      //TODO: Is this still relevant in libgda-3.0?
-      std::cerr << "Frame_Glom::create_database():  Gnome::Gda::Connection::create_database(" << database_name << ") failed: " << ex.what() << std::endl;
-
-      //Tell the user:
-      Gtk::Dialog* dialog = 0;
-      try
-      {
-         // TODO: Tell the user what has gone wrong (ex.what())
-        Glib::RefPtr<Gnome::Glade::Xml> refXml = Gnome::Glade::Xml::create(Utils::get_glade_file_path("glom_developer.glade"), "dialog_error_create_database");
-        refXml->get_widget("dialog_error_create_database", dialog);
-        dialog->set_transient_for(*pWindowApp);
-        Glom::Utils::dialog_run_with_help(dialog, "dialog_error_create_database");
-        delete dialog;
-      }
-      catch(const Gnome::Glade::XmlError& ex)
-      {
-        std::cerr << ex.what() << std::endl;
-      }
-
-       return false;
+      std::cerr << ex.what() << std::endl;
     }
 
-    //if(result)
-    //{
-    //  std::cout << "Frame_Glom::create_database(): Creation succeeded: database_name=" << database_name << std::endl;
-    //}
+     return false;
   }
 
   //Connect to the actual database:

Modified: trunk/glom/frame_glom.h
==============================================================================
--- trunk/glom/frame_glom.h	(original)
+++ trunk/glom/frame_glom.h	Sun Apr 13 12:52:30 2008
@@ -152,7 +152,7 @@
 
 #ifndef GLOM_ENABLE_CLIENT_ONLY
   ///Create the database for new documents, showing the Connection dialog
-  bool create_database(const Glib::ustring& database_name, const Glib::ustring& title, bool request_password = true);
+  bool create_database(const Glib::ustring& database_name, const Glib::ustring& title);
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 
   void export_data_to_string(Glib::ustring& the_string, const FoundSet& found_set, const Document_Glom::type_list_layout_groups& sequence);



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