[glom] Replace progress dialog with infobar, bug 661051



commit fe8aa967b730cbe4789e4be582c1ccfe76379044
Author: David King <davidk openismus com>
Date:   Thu Oct 6 15:45:06 2011 +0200

    Replace progress dialog with infobar, bug 661051

 ChangeLog                                          |    6 +
 Makefile.am                                        |    3 +-
 Makefile_glom.am                                   |    4 +-
 glom/application.cc                                |  134 ++++++++------------
 glom/application.h                                 |   39 +++++-
 glom/dialog_progress_creating.cc                   |  101 ---------------
 glom/frame_glom.cc                                 |   65 +++-------
 glom/frame_glom.h                                  |    6 -
 glom/glade_utils.cc                                |   23 ----
 glom/glade_utils.h                                 |    4 +-
 glom/infobar_progress_creating.cc                  |   53 ++++++++
 ...ress_creating.h => infobar_progress_creating.h} |   29 ++---
 tests/test_glade_derived_instantiation.cc          |    2 -
 ui/operator/window_main.glade                      |   48 +++++++-
 ui/operator/window_progress.glade                  |   44 -------
 15 files changed, 226 insertions(+), 335 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a491d1f..8d77f79 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-10-24  David King  <davidk openismus com>
+
+  Replace progress dialog with infobar.
+
+  Bug #661051
+
 2011-10-21  Murray Cumming  <murrayc murrayc com>
 
 	Avoid calling g_thread_init() if possible.
diff --git a/Makefile.am b/Makefile.am
index f8a05fe..9a145d0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -93,8 +93,7 @@ dist_glade_operator_DATA = \
 	ui/operator/dialog_image_save_progress.glade \
 	ui/operator/dialog_import_csv.glade \
 	ui/operator/dialog_import_csv_progress.glade \
-	ui/operator/window_main.glade \
-	ui/operator/window_progress.glade
+	ui/operator/window_main.glade
 		
 glade_developerdir = $(pkgdatadir)/glade/developer
 dist_glade_developer_DATA = ui/developer/dialog_add_related_table.glade \
diff --git a/Makefile_glom.am b/Makefile_glom.am
index ec0ff6e..2b32b67 100644
--- a/Makefile_glom.am
+++ b/Makefile_glom.am
@@ -89,14 +89,14 @@ glom_source_files = \
 	glom/dialog_existing_or_new.h					\
 	glom/dialog_invalid_data.cc					\
 	glom/dialog_invalid_data.h					\
-	glom/dialog_progress_creating.cc				\
-	glom/dialog_progress_creating.h					\
 	glom/filechooser_export.cc					\
 	glom/filechooser_export.h					\
 	glom/frame_glom.cc						\
 	glom/frame_glom.h						\
 	glom/glade_utils.cc						\
 	glom/glade_utils.h						\
+	glom/infobar_progress_creating.cc				\
+	glom/infobar_progress_creating.h				\
 	glom/notebook_glom.cc						\
 	glom/notebook_glom.h						\
 	glom/signal_reemitter.h						\
diff --git a/glom/application.cc b/glom/application.cc
index 5868fd2..464238f 100644
--- a/glom/application.cc
+++ b/glom/application.cc
@@ -23,8 +23,6 @@
 #include <glom/application.h>
 #include <glom/dialog_existing_or_new.h>
 
-#include <glom/dialog_progress_creating.h>
-
 #ifndef GLOM_ENABLE_CLIENT_ONLY
 #include <glom/mode_design/translation/dialog_change_language.h>
 #include <glom/mode_design/translation/window_translations.h>
@@ -85,9 +83,6 @@ Application::Application(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builde
   m_ui_save_extra_showextras(false),
   m_ui_save_extra_newdb_hosting_mode(Document::HOSTING_MODE_DEFAULT),
   m_avahi_progress_dialog(0),
-  m_dialog_progress_creating(0),
-  m_dialog_progess_save_backup(0),
-  m_dialog_progess_convert_backup(0),
 #endif // !GLOM_ENABLE_CLIENT_ONLY
   m_show_sql_debug(false)
 {
@@ -96,6 +91,7 @@ Application::Application(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builde
   //Load widgets from glade file:
   builder->get_widget("bakery_vbox", m_pBoxTop);
   builder->get_widget_derived("vbox_frame", m_pFrame); //This one is derived. There's a lot happening here.
+  builder->get_widget_derived("infobar_progress", m_infobar_progress);
 
   add_mime_type("application/x-glom"); //TODO: make this actually work - we need to register it properly.
 
@@ -126,13 +122,6 @@ Application::~Application()
   delete m_avahi_progress_dialog;
   m_avahi_progress_dialog = 0;
 
-  delete m_dialog_progress_creating;
-  m_dialog_progress_creating = 0;
-
-  delete m_dialog_progess_save_backup;
-
-  delete m_dialog_progess_convert_backup;
-  m_dialog_progess_convert_backup = 0;
   #endif // !GLOM_ENABLE_CLIENT_ONLY
   
   delete m_pAbout;
@@ -1275,18 +1264,12 @@ void Application::on_connection_close_progress()
 
 void Application::on_connection_save_backup_progress()
 {
-  if(!m_dialog_progess_save_backup)
-    m_dialog_progess_save_backup = Utils::get_and_show_pulse_dialog(_("Exporting Backup"), this);
-
-  m_dialog_progess_save_backup->pulse();
+  pulse_progress_message();
 }
 
 void Application::on_connection_convert_backup_progress()
 {
-  if(!m_dialog_progess_convert_backup)
-    m_dialog_progess_convert_backup = Utils::get_and_show_pulse_dialog(_("Restoring Backup"), this);
-
-  m_dialog_progess_convert_backup->pulse();
+  pulse_progress_message();
 }
 
 void Application::on_document_close()
@@ -1607,27 +1590,17 @@ void Application::on_menu_help_contents()
 void Application::on_recreate_database_progress()
 {
   //Show the user that something is happening, because the INSERTS might take time.
-  //TOOD: This doesn't actually show up until near the end, even with Gtk::Main::instance()->iteration().
-  if(!m_dialog_progress_creating)
-  {
-    Utils::get_glade_widget_derived_with_warning(m_dialog_progress_creating);
-
-    m_dialog_progress_creating->set_message(_("Creating Glom Database"), _("Creating Glom database from example file."));
-
-    m_dialog_progress_creating->set_transient_for(*this);
-    m_dialog_progress_creating->show();
+  pulse_progress_message();
 
-  }
-
-  //Ensure that the dialog is shown, instead of waiting for the application to be idle:
+  //Ensure that the infobar is shown, instead of waiting for the application to be idle.
   while(Gtk::Main::instance()->events_pending())
     Gtk::Main::instance()->iteration();
-
-  m_dialog_progress_creating->pulse();
 }
 
 bool Application::recreate_database_from_example(bool& user_cancelled)
 {
+  ShowProgressMessage progress_message(_("Creating Glom database from example file."));
+
   //Create a database, based on the information in the current document:
   Document* pDocument = static_cast<Document*>(get_document());
   if(!pDocument)
@@ -1689,21 +1662,12 @@ bool Application::recreate_database_from_example(bool& user_cancelled)
   }
 
   //Show the user that something is happening, because the INSERTS might take time.
-  //TOOD: This doesn't actually show up until near the end, even with Gtk::Main::instance()->iteration().
-  Dialog_ProgressCreating* dialog_progress_temp = 0;
-  Utils::get_glade_widget_derived_with_warning(dialog_progress_temp);
-  dialog_progress_temp->set_message(_("Creating Glom Database"), _("Creating Glom database from example file."));
-  std::auto_ptr<Dialog_ProgressCreating> dialog_progress(dialog_progress_temp); //Put the dialog in an auto_ptr so that it will be deleted (and hidden) when the current function returns.
+  pulse_progress_message();
 
-  dialog_progress->set_transient_for(*this);
-  dialog_progress->show();
-
-  //Ensure that the dialog is shown, instead of waiting for the application to be idle:
+  //Ensure that the infobar is shown, instead of waiting for the application to be idle.
   while(Gtk::Main::instance()->events_pending())
     Gtk::Main::instance()->iteration();
 
-  dialog_progress->pulse();
-
   //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());
@@ -1715,7 +1679,7 @@ bool Application::recreate_database_from_example(bool& user_cancelled)
   else
     connection_pool->set_database(db_name); //Specify the new database when connecting from now on.
 
-  dialog_progress->pulse();
+  pulse_progress_message();
   BusyCursor busy_cursor(this);
 
   sharedptr<SharedConnection> sharedconnection;
@@ -1743,16 +1707,14 @@ bool Application::recreate_database_from_example(bool& user_cancelled)
     return false;
   }
 
-  dialog_progress->pulse();
-
   //Create the developer group, and make this user a member of it:
-  dialog_progress->pulse();
+  pulse_progress_message();
   bool test = DbUtils::add_standard_groups(pDocument);
   if(!test)
     return false;
 
   //Add any extra groups from the example file:
-  dialog_progress->pulse();
+  pulse_progress_message();
   test = DbUtils::add_groups_from_document(pDocument);
   if(!test)
     return false;
@@ -1767,9 +1729,9 @@ bool Application::recreate_database_from_example(bool& user_cancelled)
     Glib::ustring sql_fields;
     Document::type_vec_fields fields = pDocument->get_table_fields(table_info->get_name());
 
-    dialog_progress->pulse();
+    pulse_progress_message();
     const bool table_creation_succeeded = DbUtils::create_table(table_info, fields);
-    dialog_progress->pulse();
+    pulse_progress_message();
     if(!table_creation_succeeded)
     {
       g_warning("Application::recreate_database_from_example(): CREATE TABLE failed with the newly-created database.");
@@ -1777,11 +1739,11 @@ bool Application::recreate_database_from_example(bool& user_cancelled)
     }
   }
 
-  dialog_progress->pulse();
+  pulse_progress_message();
   DbUtils::add_standard_tables(pDocument); //Add internal, hidden, tables.
 
   //Set table priviliges, using the groups we just added:
-  dialog_progress->pulse();
+  pulse_progress_message();
   test = DbUtils::set_table_privileges_groups_from_document(pDocument);
   if(!test)
     return false;
@@ -1791,7 +1753,7 @@ bool Application::recreate_database_from_example(bool& user_cancelled)
     sharedptr<const TableInfo> table_info = *iter;
 
     //Add any example data to the table:
-    dialog_progress->pulse();
+    pulse_progress_message();
 
     //try
     //{
@@ -1816,6 +1778,8 @@ bool Application::recreate_database_from_example(bool& user_cancelled)
 
 bool Application::recreate_database_from_backup(const Glib::ustring& backup_uri, bool& user_cancelled)
 {
+  ShowProgressMessage progress_message(_("Creating Glom database from backup file."));
+
   //Create a database, based on the information in the current document:
   Document* pDocument = static_cast<Document*>(get_document());
   if(!pDocument)
@@ -1877,20 +1841,13 @@ bool Application::recreate_database_from_backup(const Glib::ustring& backup_uri,
   }
 
   //Show the user that something is happening, because the INSERTS might take time.
-  //TOOD: This doesn't actually show up until near the end, even with Gtk::Main::instance()->iteration().
-  Dialog_ProgressCreating* dialog_progress_temp = 0;
-  Utils::get_glade_widget_derived_with_warning(dialog_progress_temp);
-  dialog_progress_temp->set_message(_("Creating Glom Database"), _("Creating Glom database from backup file."));
-  std::auto_ptr<Dialog_ProgressCreating> dialog_progress(dialog_progress_temp); //Put the dialog in an auto_ptr so that it will be deleted (and hidden) when the current function returns.
+  pulse_progress_message();
 
-  dialog_progress->set_transient_for(*this);
-  dialog_progress->show();
-
-  //Ensure that the dialog is shown, instead of waiting for the application to be idle:
+  //Ensure that the infobar is shown, instead of waiting for the application to be idle.
   while(Gtk::Main::instance()->events_pending())
     Gtk::Main::instance()->iteration();
 
-  dialog_progress->pulse();
+  pulse_progress_message();
 
   //Create the database: (This will show a connection dialog)
   connection_pool->set_database( Glib::ustring() );
@@ -1915,18 +1872,17 @@ bool Application::recreate_database_from_backup(const Glib::ustring& backup_uri,
   connection_pool->set_database(db_name); //Specify the new database when connecting from now on.
 
   //Create the developer group, and make this user a member of it:
-  dialog_progress->pulse();
+  pulse_progress_message();
   bool test = DbUtils::add_standard_groups(pDocument);
   if(!test)
     return false;
 
   //Add any extra groups from the example file:
-  dialog_progress->pulse();
+  pulse_progress_message();
   test = DbUtils::add_groups_from_document(pDocument);
   if(!test)
     return false;
 
-  //dialog_progress->pulse();
   //m_pFrame->add_standard_tables(); //Add internal, hidden, tables.
 
   //Restore the backup into the database:
@@ -1960,9 +1916,6 @@ bool Application::recreate_database_from_backup(const Glib::ustring& backup_uri,
   const bool restored = connection_pool->convert_backup(
     sigc::mem_fun(*this, &Application::on_connection_convert_backup_progress), original_dir_path);
 
-  delete m_dialog_progess_convert_backup;
-  m_dialog_progess_convert_backup = 0;
-
   if(!restored)
   {
     std::cerr << G_STRFUNC << ": Restore failed." << std::endl;
@@ -2660,10 +2613,8 @@ void Application::on_menu_developer_export_backup()
   if(saved)
   {
     ConnectionPool* connection_pool = ConnectionPool::get_instance();
+    ShowProgressMessage progress_message(_("Exporting backup"));
     saved = connection_pool->save_backup(sigc::mem_fun(*this, &Application::on_connection_save_backup_progress), path_dir);
-
-    delete m_dialog_progess_save_backup;
-    m_dialog_progess_save_backup = 0;
   }
 
   //Compress the backup in a .tar.gz, so it is slightly more safe from changes:
@@ -2698,6 +2649,7 @@ void Application::on_menu_developer_export_backup()
 
       //std::cout << "DEBUG: command_tar=" << command_tar << std::endl;
 
+      ShowProgressMessage progress_message(_("Exporting backup"));
       saved = Glom::Spawn::execute_command_line_and_wait(command_tar,
         sigc::mem_fun(*this, &Application::on_connection_save_backup_progress));
 
@@ -2705,9 +2657,6 @@ void Application::on_menu_developer_export_backup()
       {
         std::cerr << G_STRFUNC << "tar failed with command:" << command_tar << std::endl;
       }
-
-      delete m_dialog_progess_save_backup;
-      m_dialog_progess_save_backup = 0;
     }
   }
 
@@ -2793,6 +2742,7 @@ bool Application::do_restore_backup(const Glib::ustring& backup_uri)
 
   //std::cout << "DEBUG: command_tar=" << command_tar << std::endl;
 
+  ShowProgressMessage progress_message(_("Restoring backup"));
   const bool untarred = Glom::Spawn::execute_command_line_and_wait(command_tar,
     sigc::mem_fun(*this, &Application::on_connection_convert_backup_progress));
   if(!untarred)
@@ -2800,8 +2750,7 @@ bool Application::do_restore_backup(const Glib::ustring& backup_uri)
     std::cerr << G_STRFUNC << ": tar failed with command:" << command_tar << std::endl;
   }
 
-  delete m_dialog_progess_convert_backup;
-  m_dialog_progess_convert_backup = 0;
+  clear_progress_message();
 
   if(!untarred)
     ui_warning(_("Restore Backup failed."), _("There was an error while restoring the backup. The tar utility failed to extract the archive."));
@@ -2958,8 +2907,35 @@ void Application::print_layout()
 void Application::start_new_record()
 {
   m_pFrame->on_menu_add_record();
+}
+
+void Application::set_progress_message(const Glib::ustring& message)
+{
+  const Glib::ustring title = _("Processing");
+  const std::string collate_key = (title + message).collate_key();
 
+  if(collate_key != m_progress_collate_key)
+  {
+    // New progress message.
+    m_progress_collate_key = collate_key;
+    m_infobar_progress->set_message(title, message);
+    m_infobar_progress->show();
+  }
+
+  // Pulse the progress bar regardless of whether the message is new or not.
+  m_infobar_progress->pulse();
+  // TODO: Block interaction with the rest of the UI.
 }
 
+void Application::pulse_progress_message()
+{
+  m_infobar_progress->pulse();
+}
+
+void Application::clear_progress_message()
+{
+  m_progress_collate_key.clear();
+  m_infobar_progress->hide();
+}
 
 } //namespace Glom
diff --git a/glom/application.h b/glom/application.h
index 8770a7c..12bc72c 100644
--- a/glom/application.h
+++ b/glom/application.h
@@ -26,7 +26,7 @@
 #include <glom/bakery/app_withdoc_gtk.h>
 
 #include <glom/frame_glom.h>
-
+#include "infobar_progress_creating.h"
 
 
 //Avoid including the header here:
@@ -41,7 +41,7 @@ namespace Glom
 {
 
 class Window_Translations;
-class Dialog_ProgressCreating; //TODO: Rename this because it's not just about creating databases.
+class ShowProgressMessage;
 
 class Application : public GlomBakery::App_WithDoc_Gtk
 {
@@ -124,6 +124,10 @@ public:
    */
   void start_new_record();
 
+  void set_progress_message(const Glib::ustring& message);
+  void pulse_progress_message();
+  void clear_progress_message();
+
   static Application* get_application();
 
 protected:
@@ -230,6 +234,9 @@ private:
   bool m_bAboutShown;
   Gtk::AboutDialog* m_pAbout; //About box.
 
+  Infobar_ProgressCreating* m_infobar_progress;
+  std::string m_progress_collate_key;
+
 #ifndef GLOM_ENABLE_CLIENT_ONLY
   Window_Translations* m_window_translations;
 
@@ -252,9 +259,6 @@ private:
 
   Gtk::MessageDialog* m_avahi_progress_dialog;
 
-  Dialog_ProgressCreating* m_dialog_progress_creating;
-  Dialog_ProgressCreating* m_dialog_progess_save_backup;
-  Dialog_ProgressCreating* m_dialog_progess_convert_backup;
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 
   // This is set to the URI of an example file that is loaded to be able to
@@ -270,6 +274,31 @@ private:
   bool m_show_sql_debug;
 };
 
+/* Use this class to ensure that the progress message is cleared upon exiting a
+ * method with multiple return points. */
+class ShowProgressMessage
+{
+public:
+  ShowProgressMessage(const Glib::ustring &message)
+  : app(dynamic_cast<Application*>(Application::get_application())),
+    message(message)
+  {
+    g_return_if_fail(app);
+    app->set_progress_message(message);
+  };
+
+  ~ShowProgressMessage()
+  {
+    app->clear_progress_message();
+  };
+
+  void pulse() { app->set_progress_message(message); };
+
+private:
+  Application * const app;
+  const Glib::ustring &message;
+};
+
 } //namespace Glom
 
 #endif // GLOM_APPLICATION_H
diff --git a/glom/frame_glom.cc b/glom/frame_glom.cc
index 9951da7..4a59370 100644
--- a/glom/frame_glom.cc
+++ b/glom/frame_glom.cc
@@ -94,10 +94,7 @@ Frame_Glom::Frame_Glom(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>
   m_pDialog_Relationships(0),
   m_dialog_addrelatedtable(0),
   m_dialog_relationships_overview(0),
-  m_dialog_progess_connection_initialize(0),
 #endif // !GLOM_ENABLE_CLIENT_ONLY
-  m_dialog_progess_connection_startup(0),
-  m_dialog_progess_connection_cleanup(0),
   m_pDialogConnection(0)
 {
   m_pLabel_Table_DataMode = Gtk::manage(new Gtk::Label(_("No Table Selected")));
@@ -185,17 +182,7 @@ Frame_Glom::~Frame_Glom()
     m_pDialogConnection = 0;
   }
 
-
-  delete m_dialog_progess_connection_startup;
-  m_dialog_progess_connection_startup = 0;
-
-  delete m_dialog_progess_connection_cleanup;
-  m_dialog_progess_connection_cleanup = 0;
-
 #ifndef GLOM_ENABLE_CLIENT_ONLY
-  delete m_dialog_progess_connection_initialize;
-  m_dialog_progess_connection_initialize = 0;
-
   if(m_pBox_Reports)
     remove_view(m_pBox_Reports);
 
@@ -984,11 +971,10 @@ void Frame_Glom::on_menu_file_toggle_share(const Glib::RefPtr<Gtk::ToggleAction>
       sharedconnection.clear();
     }
 
-    connectionpool->cleanup( sigc::mem_fun(*this, &Frame_Glom::on_connection_cleanup_progress) );
-
-    delete m_dialog_progess_connection_cleanup;
-    m_dialog_progess_connection_cleanup = 0;
+    ShowProgressMessage cleanup_message(_("Stopping Database Server"));
+    connectionpool->cleanup (sigc::mem_fun(*this, &Frame_Glom::on_connection_cleanup_progress) );
 
+    ShowProgressMessage startup_message(_("Starting Database Server"));
     connectionpool->set_network_shared(sigc::mem_fun(*this, &Frame_Glom::on_connection_startup_progress), shared);
     ConnectionPool::StartupErrors started = connectionpool->startup( sigc::mem_fun(*this, &Frame_Glom::on_connection_startup_progress) );
     if(started != ConnectionPool::Backend::STARTUPERROR_NONE)
@@ -998,9 +984,6 @@ void Frame_Glom::on_menu_file_toggle_share(const Glib::RefPtr<Gtk::ToggleAction>
     }
 
     connectionpool->set_ready_to_connect();
-
-    delete m_dialog_progess_connection_startup;
-    m_dialog_progess_connection_startup = 0;
   }
 
   //Update the UI:
@@ -1777,27 +1760,24 @@ void Frame_Glom::on_developer_dialog_hide()
 #ifndef GLOM_ENABLE_CLIENT_ONLY
 void Frame_Glom::on_connection_initialize_progress()
 {
-  if(!m_dialog_progess_connection_initialize)
-    m_dialog_progess_connection_initialize = Utils::get_and_show_pulse_dialog(_("Initializing Database Data"), get_app_window());
-
-  m_dialog_progess_connection_initialize->pulse();
+  Application *app = dynamic_cast<Application*>(Application::get_application());
+  if(app)
+    app->pulse_progress_message();
 }
 #endif //GLOM_ENABLE_CLIENT_ONLY
 
 void Frame_Glom::on_connection_startup_progress()
 {
-  if(!m_dialog_progess_connection_startup)
-    m_dialog_progess_connection_startup = Utils::get_and_show_pulse_dialog(_("Starting Database Server"), get_app_window());
-
-  m_dialog_progess_connection_startup->pulse();
+  Application *app = dynamic_cast<Application*>(Application::get_application());
+  if(app)
+    app->pulse_progress_message();
 }
 
 void Frame_Glom::on_connection_cleanup_progress()
 {
-  if(!m_dialog_progess_connection_cleanup)
-    m_dialog_progess_connection_cleanup = Utils::get_and_show_pulse_dialog(_("Stopping Database Server"), get_app_window());
-
-  m_dialog_progess_connection_cleanup->pulse();
+  Application *app = dynamic_cast<Application*>(Application::get_application());
+  if(app)
+    app->pulse_progress_message();
 }
 
 bool Frame_Glom::handle_connection_initialize_errors(ConnectionPool::InitErrors error)
@@ -1812,7 +1792,7 @@ bool Frame_Glom::handle_connection_initialize_errors(ConnectionPool::InitErrors
     title = _("Directory Already Exists");
     message = _("There is an existing directory with the same name as the directory that should be created for the new database files. You should specify a different filename to use a new directory instead.");
   }
-  else if (error == ConnectionPool::Backend::INITERROR_COULD_NOT_CREATE_DIRECTORY)
+  else if(error == ConnectionPool::Backend::INITERROR_COULD_NOT_CREATE_DIRECTORY)
   {
     title = _("Could Not Create Directory");
     message = _("There was an error when attempting to create the directory for the new database files.");
@@ -1925,11 +1905,9 @@ bool Frame_Glom::connection_request_password_and_choose_new_database_name()
       connection_pool->set_user(user);
       connection_pool->set_password(password);
 
+      ShowProgressMessage progress_message(_("Initializing Database Data"));
       const bool initialized = handle_connection_initialize_errors( connection_pool->initialize(
-        sigc::mem_fun(*this, &Frame_Glom::on_connection_initialize_progress) ) );
-
-      delete m_dialog_progess_connection_initialize;
-      m_dialog_progess_connection_initialize = 0;
+         sigc::mem_fun(*this, &Frame_Glom::on_connection_initialize_progress) ) );
 
       if(!initialized)
         return false;
@@ -1996,6 +1974,7 @@ bool Frame_Glom::connection_request_password_and_choose_new_database_name()
   }
 
   // Do startup, such as starting the self-hosting database server
+  ShowProgressMessage progress_message(_("Starting Database Server"));
   const ConnectionPool::StartupErrors started =
     connection_pool->startup( sigc::mem_fun(*this, &Frame_Glom::on_connection_startup_progress) );
   if(started != ConnectionPool::Backend::STARTUPERROR_NONE)
@@ -2004,9 +1983,6 @@ bool Frame_Glom::connection_request_password_and_choose_new_database_name()
     return false;
   }
 
-  delete m_dialog_progess_connection_startup;
-  m_dialog_progess_connection_startup = 0;
-
   const Glib::ustring database_name = document->get_connection_database();
 
   //std::cout << "debug: database_name to create=" << database_name << std::endl;
@@ -2110,10 +2086,8 @@ bool Frame_Glom::connection_request_password_and_choose_new_database_name()
 void Frame_Glom::cleanup_connection()
 {
   ConnectionPool* connection_pool = ConnectionPool::get_instance();
+  ShowProgressMessage progress_message(_("Stopping Database Server"));
   connection_pool->cleanup( sigc::mem_fun(*this, &Frame_Glom::on_connection_cleanup_progress) );
-
-  delete m_dialog_progess_connection_cleanup;
-  m_dialog_progess_connection_cleanup = 0;
 }
 
 bool Frame_Glom::handle_request_password_connection_error(bool asked_for_password, const ExceptionConnection& ex, bool& database_not_found)
@@ -2158,6 +2132,7 @@ bool Frame_Glom::connection_request_password_and_attempt(bool& database_not_foun
 
   //Start a self-hosted server if necessary:
   ConnectionPool* connection_pool = ConnectionPool::get_instance();
+  ShowProgressMessage progress_message(_("Starting Database Server"));
   connection_pool->setup_from_document(document);
   const ConnectionPool::StartupErrors started =
     connection_pool->startup( sigc::mem_fun(*this, &Frame_Glom::on_connection_startup_progress) );
@@ -2167,8 +2142,8 @@ bool Frame_Glom::connection_request_password_and_attempt(bool& database_not_foun
     return false;
   }
 
-  delete m_dialog_progess_connection_startup;
-  m_dialog_progess_connection_startup = 0;
+  Application* app = dynamic_cast<Application*>(get_app_window());
+  app->clear_progress_message();
 
   //Only ask for the password if we are shared on the network, or we are using a centrally hosted server.
   //Otherwise, no password question is necessary, due to how our self-hosted database server is configured.
diff --git a/glom/frame_glom.h b/glom/frame_glom.h
index f8bb8eb..29efa56 100644
--- a/glom/frame_glom.h
+++ b/glom/frame_glom.h
@@ -57,8 +57,6 @@ class Dialog_AddRelatedTable;
 class Dialog_RelationshipsOverview;
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 
-class Dialog_ProgressCreating; //TODO: Rename this because it's not just about creating databases.
-
 class Frame_Glom :
   public PlaceHolder,
   //public GlomBakery::View_Composite<Document>,
@@ -285,12 +283,8 @@ private:
   Dialog_AddRelatedTable* m_dialog_addrelatedtable;
   Dialog_RelationshipsOverview* m_dialog_relationships_overview;
 
-  Dialog_ProgressCreating* m_dialog_progess_connection_initialize;
 #endif //GLOM_ENABLE_CLIENT_ONLY
 
-  Dialog_ProgressCreating* m_dialog_progess_connection_startup;
-  Dialog_ProgressCreating* m_dialog_progess_connection_cleanup;
-
   Dialog_Connection* m_pDialogConnection;
 };
 
diff --git a/glom/glade_utils.cc b/glom/glade_utils.cc
index 0626e34..fdc01f9 100644
--- a/glom/glade_utils.cc
+++ b/glom/glade_utils.cc
@@ -27,28 +27,5 @@ namespace Glom
 namespace Utils
 {
 
-
-Dialog_ProgressCreating* get_and_show_pulse_dialog(const Glib::ustring& message, Gtk::Window* parent_window)
-{
-  if(!parent_window)
-    std::cerr << G_STRFUNC << ": parent_window is NULL" << std::endl;
-
-  Dialog_ProgressCreating* dialog_progress = 0;
-  Utils::get_glade_widget_derived_with_warning(dialog_progress);
-  if(!dialog_progress) //Unlikely and it already warns on stderr.
-    return 0;
-    
-  dialog_progress->set_message(_("Processing"), message);
-  dialog_progress->set_modal();
-
-  if(parent_window)
-    dialog_progress->set_transient_for(*parent_window);
-
-  dialog_progress->show();
-
-  return dialog_progress;
-}
-
 } //namespace Utils
 } //namespace Glom
-
diff --git a/glom/glade_utils.h b/glom/glade_utils.h
index 24ef83e..c55af7c 100644
--- a/glom/glade_utils.h
+++ b/glom/glade_utils.h
@@ -23,7 +23,7 @@
 
 #include <iostream> // For std::cerr
 #include <gtkmm/builder.h>
-#include <glom/dialog_progress_creating.h>
+#include <gtkmm/window.h>
 #include <giomm/file.h>
 
 namespace Glom
@@ -167,8 +167,6 @@ void get_glade_widget_with_warning(const std::string& filename, const Glib::ustr
     window->set_icon_name("glom");
 }
 
-Dialog_ProgressCreating* get_and_show_pulse_dialog(const Glib::ustring& message, Gtk::Window* parent_window);
-
 } //namespace Utils
 
 } //namespace Glom
diff --git a/glom/infobar_progress_creating.cc b/glom/infobar_progress_creating.cc
new file mode 100644
index 0000000..c165d35
--- /dev/null
+++ b/glom/infobar_progress_creating.cc
@@ -0,0 +1,53 @@
+/* Glom
+ *
+ * Copyright (C) 2001-2004 Murray Cumming
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <gtkmm/dialog.h>
+#include <glom/application.h>
+#include <glom/infobar_progress_creating.h>
+#include <gtkmm/main.h>
+#include <glibmm/i18n.h>
+
+namespace Glom
+{
+
+Infobar_ProgressCreating::Infobar_ProgressCreating(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& builder)
+: Gtk::InfoBar(cobject),
+  m_progress(0),
+  m_label_message(0)
+{
+  builder->get_widget("progressbar", m_progress);
+  builder->get_widget("label_message", m_label_message);
+}
+
+Infobar_ProgressCreating::~Infobar_ProgressCreating()
+{
+}
+
+void Infobar_ProgressCreating::pulse()
+{
+  m_progress->pulse();
+}
+
+void Infobar_ProgressCreating::set_message(const Glib::ustring& title, const Glib::ustring& secondary_text)
+{
+  m_label_message->set_markup("<b>" + title + "</b>\n\n" + secondary_text);
+}
+
+} //namespace Glom
diff --git a/glom/dialog_progress_creating.h b/glom/infobar_progress_creating.h
similarity index 66%
rename from glom/dialog_progress_creating.h
rename to glom/infobar_progress_creating.h
index a977f4e..73a9768 100644
--- a/glom/dialog_progress_creating.h
+++ b/glom/infobar_progress_creating.h
@@ -18,11 +18,11 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#ifndef GLOM_DIALOG_PROGRESS_CREATING_H
-#define GLOM_DIALOG_PROGRESS_CREATING_H
+#ifndef GLOM_INFOBAR_PROGRESS_CREATING_H
+#define GLOM_INFOBAR_PROGRESS_CREATING_H
 
 #include <gtkmm/builder.h>
-#include <gtkmm/window.h>
+#include <gtkmm/infobar.h>
 #include <gtkmm/label.h>
 #include <gtkmm/progressbar.h>
 
@@ -32,35 +32,22 @@ namespace Glom
 /** Use this to show the user that something is happening.
  * Call pulse() repeatedly to show that we are still working. 
  */
-class Dialog_ProgressCreating
-  : public Gtk::Window
+class Infobar_ProgressCreating
+  : public Gtk::InfoBar
 {
 public:
-  static const char* glade_id;
-  static const bool glade_developer;
-
-  Dialog_ProgressCreating(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& builder);
-  virtual ~Dialog_ProgressCreating();
+  Infobar_ProgressCreating(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& builder);
+  virtual ~Infobar_ProgressCreating();
 
   void set_message(const Glib::ustring& title, const Glib::ustring& secondary_text);
 
   void pulse();
 
-  // TODO: This should probably derive from Gtk::Dialog... armin.
-  void response(int response_id);
-  int run();
-
-  virtual bool on_delete_event(GdkEventAny* event);
-
 private:
   Gtk::ProgressBar* m_progress;
   Gtk::Label* m_label_message;
-
-  int m_response_id;
-  bool m_running;
 };
 
 } //namespace Glom
 
-#endif //GLOM_DIALOG_PROGRESS_CREATING_H
-
+#endif //GLOM_INFOBAR_PROGRESS_CREATING_H
diff --git a/tests/test_glade_derived_instantiation.cc b/tests/test_glade_derived_instantiation.cc
index 928217c..fed2f0d 100644
--- a/tests/test_glade_derived_instantiation.cc
+++ b/tests/test_glade_derived_instantiation.cc
@@ -52,7 +52,6 @@
 #include <glom/mode_design/users/dialog_choose_user.h>
 #include <glom/mode_design/users/dialog_user.h>
 #include <glom/mode_design/print_layouts/dialog_text_formatting.h>
-#include <glom/dialog_progress_creating.h>
 #include <glom/dialog_invalid_data.h>
 
 const int GLOM_MAX_WINDOW_WIDTH = 800;
@@ -110,7 +109,6 @@ int main(int argc, char *argv[])
   instantiate_widget<Dialog_InvalidData>();
   instantiate_widget<DialogImageLoadProgress>();
   instantiate_widget<DialogImageSaveProgress>();
-  instantiate_widget<Dialog_ProgressCreating>();
 
   //Developer mode UI:
   instantiate_widget<Box_Print_Layouts>();
diff --git a/ui/operator/window_main.glade b/ui/operator/window_main.glade
index 381f3f7..be57f36 100644
--- a/ui/operator/window_main.glade
+++ b/ui/operator/window_main.glade
@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <requires lib="gtk+" version="2.16"/>
-  <!-- interface-naming-policy toplevel-contextual -->
+  <!-- interface-requires gtk+ 3.0 -->
   <object class="GtkWindow" id="window_main">
     <property name="can_focus">False</property>
     <property name="title" translatable="yes">Glom</property>
@@ -18,6 +17,51 @@
             <property name="border_width">12</property>
             <property name="spacing">6</property>
             <child>
+              <object class="GtkInfoBar" id="infobar_progress">
+                <property name="can_focus">False</property>
+                <child internal-child="content_area">
+                  <object class="GtkBox" id="infobar-content_area1">
+                    <property name="can_focus">False</property>
+                    <property name="border_width">6</property>
+                    <property name="orientation">vertical</property>
+                    <property name="spacing">6</property>
+                    <child>
+                      <object class="GtkLabel" id="label_message">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                        <property name="yalign">0</property>
+                        <property name="label" translatable="yes">Processing</property>
+                        <property name="use_markup">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkProgressBar" id="progressbar">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="pulse_step">0.10000000149</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
               <object class="GtkVBox" id="vbox_quickfind">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>



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