glom r2034 - in trunk: . glom glom/layout_item_dialogs glom/libglom glom/libglom/connectionpool_backends glom/libglom/data_structure glom/libglom/data_structure/layout glom/libglom/document glom/libglom/python_embed glom/mode_data glom/mode_design glom/mode_design/fields glom/mode_design/print_layouts glom/mode_design/script_library glom/mode_design/users glom/mode_find glom/navigation glom/python_embed glom/translation glom/utility_widgets glom/utility_widgets/adddel glom/utility_widgets/adddel/eggcolumnchooser glom/utility_widgets/db_adddel



Author: murrayc
Date: Mon Mar 30 12:01:39 2009
New Revision: 2034
URL: http://svn.gnome.org/viewvc/glom?rev=2034&view=rev

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

* glom/glade_utils.cc: Added missing file to fix the build.

* glom/Makefile.am:
* glom/libglom/Makefile.am:
* glom/libglom/utils.cc:
* glom/libglom/utils.h: Moved some of these functions to new 
glom/utils_ui.[h|cc] files to avoid having the UI stuff in libglom.
*.cc: Adapted.
glom/libglom/connectionpool.[h|cc]:
* glom/libglom/connectionpool_backends/backend.[h|cc]:
* glom/libglom/connectionpool_backends/postgres.[h|cc]:
* glom/libglom/connectionpool_backends/postgres_self.[h|cc]: 
initialize(): Return an enum instead of a bool, to report errors, instead of 
showing a UI warning here.
Added set_avahi_publish_callbacks() to avoid showing that UI here.
* glom/frame_glom.[h|cc]: Adapt to the new API, showing UI here instead of 
in libglom.

* glom/libglom/spawn_with_feedback.cc: Disconnect the progress timeout 
dlers.

* glom/libglom/data_structure/layout/layoutitem_image.[h|cc]: Removed 
get_image_as_pixbuf() to avoid a gtkmm dependency in libglom. Made m_image 
public instead, to avoid performance problems with copying lots of binary 
data via a get*() method.
* glom/libglom/document/document_glom.cc: Adapted.

* glom/libglom/data_structure/print_layout.[h|cc]: Use a string instead of a 
Gtk::PrintLayout, using the Glib::KeyFile format, to avoid depending on gtkmm 
in libglom.
* glom/mode_design/print_layouts/canvas_layout_item.cc:
* glom/mode_design/print_layouts/canvas_print_layout.cc: Adapted.

Added:
   trunk/glom/glade_utils.cc
   trunk/glom/utils_ui.cc
   trunk/glom/utils_ui.h
Modified:
   trunk/ChangeLog
   trunk/glom/Makefile.am
   trunk/glom/application.cc
   trunk/glom/application.h
   trunk/glom/base_db.cc
   trunk/glom/base_db_table_data.cc
   trunk/glom/box_withbuttons.cc
   trunk/glom/dialog_glom.cc
   trunk/glom/dialog_invalid_data.cc
   trunk/glom/dialog_new_self_hosted_connection.cc
   trunk/glom/dialog_new_self_hosted_connection.h
   trunk/glom/filechooser_export.cc
   trunk/glom/frame_glom.cc
   trunk/glom/frame_glom.h
   trunk/glom/layout_item_dialogs/dialog_group_by.cc
   trunk/glom/libglom/connectionpool.cc
   trunk/glom/libglom/connectionpool.h
   trunk/glom/libglom/connectionpool_backends/backend.cc
   trunk/glom/libglom/connectionpool_backends/backend.h
   trunk/glom/libglom/connectionpool_backends/postgres.cc
   trunk/glom/libglom/connectionpool_backends/postgres.h
   trunk/glom/libglom/connectionpool_backends/postgres_self.cc
   trunk/glom/libglom/connectionpool_backends/postgres_self.h
   trunk/glom/libglom/data_structure/layout/layoutitem_image.cc
   trunk/glom/libglom/data_structure/layout/layoutitem_image.h
   trunk/glom/libglom/data_structure/print_layout.cc
   trunk/glom/libglom/data_structure/print_layout.h
   trunk/glom/libglom/document/document_glom.cc
   trunk/glom/libglom/python_embed/py_glom_relatedrecord.cc
   trunk/glom/libglom/spawn_with_feedback.cc
   trunk/glom/libglom/utils.cc
   trunk/glom/libglom/utils.h
   trunk/glom/main.cc
   trunk/glom/mode_data/box_data.cc
   trunk/glom/mode_data/box_data_calendar_related.cc
   trunk/glom/mode_data/box_data_details.cc
   trunk/glom/mode_data/box_data_list_related.cc
   trunk/glom/mode_data/box_data_portal.cc
   trunk/glom/mode_data/dialog_layout_details.cc
   trunk/glom/mode_data/flowtablewithfields.cc
   trunk/glom/mode_design/dialog_fields.cc
   trunk/glom/mode_design/dialog_relationships.cc
   trunk/glom/mode_design/fields/box_db_table_definition.cc
   trunk/glom/mode_design/fields/dialog_fielddefinition.cc
   trunk/glom/mode_design/print_layouts/canvas_layout_item.cc
   trunk/glom/mode_design/print_layouts/canvas_print_layout.cc
   trunk/glom/mode_design/script_library/dialog_script_library.cc
   trunk/glom/mode_design/users/dialog_groups_list.cc
   trunk/glom/mode_design/users/dialog_users_list.cc
   trunk/glom/mode_find/box_data_list_find.cc
   trunk/glom/navigation/box_tables.cc
   trunk/glom/python_embed/glom_python.cc
   trunk/glom/translation/dialog_identify_original.cc
   trunk/glom/translation/window_translations.cc
   trunk/glom/utility_widgets/adddel/adddel.cc
   trunk/glom/utility_widgets/adddel/adddel_withbuttons.cc
   trunk/glom/utility_widgets/adddel/eggcolumnchooser/eggcolumnchooserdialog.c
   trunk/glom/utility_widgets/buttonglom.cc
   trunk/glom/utility_widgets/datawidget.cc
   trunk/glom/utility_widgets/db_adddel/db_adddel.cc
   trunk/glom/utility_widgets/db_adddel/db_adddel_withbuttons.cc
   trunk/glom/utility_widgets/db_adddel/glom_db_treemodel.cc
   trunk/glom/utility_widgets/dialog_choose_id.cc
   trunk/glom/utility_widgets/filechooserdialog_saveextras.cc

Modified: trunk/glom/Makefile.am
==============================================================================
--- trunk/glom/Makefile.am	(original)
+++ trunk/glom/Makefile.am	Mon Mar 30 12:01:39 2009
@@ -51,6 +51,7 @@
                dialog_progress_creating.h dialog_progress_creating.cc \
                box_reports.h box_reports.cc \
                xsl_utils.h xsl_utils.cc \
+               utils_ui.h utils_ui.cc \
                variablesmap.h variablesmap.cc \
                signal_reemitter.h glade_utils.h glade_utils.cc
 

Modified: trunk/glom/application.cc
==============================================================================
--- trunk/glom/application.cc	(original)
+++ trunk/glom/application.cc	Mon Mar 30 12:01:39 2009
@@ -31,12 +31,9 @@
 #include <glom/utility_widgets/filechooserdialog_saveextras.h>
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 
-#include <libglom/utils.h>
+#include <glom/utils_ui.h>
 #include <glom/glade_utils.h>
 
-//#include <libglom/connectionpool_backends/postgres_central.h>
-//#include <libglom/connectionpool_backends/postgres_self.h>
-
 #include <cstdio>
 #include <memory> //For std::auto_ptr<>
 #include <giomm.h>
@@ -107,6 +104,7 @@
   m_ui_save_extra_newdb_hosting_mode(Document_Glom::DEFAULT_HOSTED),
 
 #endif // !GLOM_ENABLE_CLIENT_ONLY
+  m_avahi_progress_dialog(0),
   m_show_sql_debug(false)
 {
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
@@ -143,6 +141,14 @@
   //Hide the toolbar because it doesn't contain anything useful for this app.
   m_HandleBox_Toolbar.hide();
   
+  //Install UI hooks for this:
+  ConnectionPool* connection_pool = ConnectionPool::get_instance();
+  if(!connection_pool)
+    connection_pool->set_avahi_publish_callbacks(
+      sigc::mem_fun(*this, &App_Glom::on_connection_avahi_begin),
+      sigc::mem_fun(*this, &App_Glom::on_connection_avahi_progress),
+      sigc::mem_fun(*this, &App_Glom::on_connection_avahi_done) );     
+  
   global_application = this;
 }
 
@@ -155,6 +161,44 @@
     delete m_window_translations;
   }
 #endif // !GLOM_ENABLE_CLIENT_ONLY
+
+  if(m_avahi_progress_dialog)
+  {
+    delete m_avahi_progress_dialog;
+    m_avahi_progress_dialog = 0;
+  }
+}
+
+void App_Glom::on_connection_avahi_begin()
+{
+  //Create the dialog:
+  if(m_avahi_progress_dialog)
+  {
+    delete m_avahi_progress_dialog;
+    m_avahi_progress_dialog = 0;
+  }
+
+  m_avahi_progress_dialog = new Gtk::MessageDialog(Utils::bold_message(_("Glom: Generating Encryption Certificates")), true, Gtk::MESSAGE_INFO);
+  m_avahi_progress_dialog->set_secondary_text(_("Please wait while Glom prepares your system for publishing over the network."));
+  m_avahi_progress_dialog->set_transient_for(*this);
+  m_avahi_progress_dialog->show();
+}
+
+void App_Glom::on_connection_avahi_progress()
+{
+  //Allow GTK+ to process events, so that the UI is responsive:
+  while(Gtk::Main::events_pending())
+   Gtk::Main::iteration();
+}
+
+void App_Glom::on_connection_avahi_done()
+{
+  //Delete the dialog:
+  if(m_avahi_progress_dialog)
+  {
+    delete m_avahi_progress_dialog;
+    m_avahi_progress_dialog = 0;
+  }
 }
 
 bool App_Glom::init(const Glib::ustring& document_uri)

Modified: trunk/glom/application.h
==============================================================================
--- trunk/glom/application.h	(original)
+++ trunk/glom/application.h	Mon Mar 30 12:01:39 2009
@@ -117,6 +117,10 @@
 
   bool recreate_database(bool& user_cancelled); //return indicates success.
   void stop_self_hosting_of_document_database();
+  
+  void on_connection_avahi_begin();
+  void on_connection_avahi_progress();
+  void on_connection_avahi_done();
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 
 #ifndef G_OS_WIN32
@@ -190,6 +194,8 @@
   //so we can use them again when connecting directly to the database:
   Glib::ustring m_temp_username, m_temp_password;
 
+  Gtk::MessageDialog* m_avahi_progress_dialog;
+  
   bool m_show_sql_debug;
 };
 

Modified: trunk/glom/base_db.cc
==============================================================================
--- trunk/glom/base_db.cc	(original)
+++ trunk/glom/base_db.cc	Mon Mar 30 12:01:39 2009
@@ -36,7 +36,7 @@
 //#endif // !GLOM_ENABLE_CLIENT_ONLY
 
 //#include "reports/dialog_layout_report.h"
-#include <libglom/utils.h>
+#include <glom/utils_ui.h>
 #include <glom/glade_utils.h>
 #include <libglom/data_structure/glomconversions.h>
 #include <libglom/data_structure/parameternamegenerator.h>
@@ -155,7 +155,7 @@
 
 bool Base_DB::handle_error()
 {
-  return ConnectionPool::handle_error();
+  return ConnectionPool::handle_error_cerr_only();
 }
 
 //static:

Modified: trunk/glom/base_db_table_data.cc
==============================================================================
--- trunk/glom/base_db_table_data.cc	(original)
+++ trunk/glom/base_db_table_data.cc	Mon Mar 30 12:01:39 2009
@@ -22,6 +22,7 @@
 #include <libglom/data_structure/glomconversions.h>
 #include <glom/application.h>
 #include "python_embed/glom_python.h"
+#include <glom/utils_ui.h>
 #include <sstream>
 #include <glibmm/i18n.h>
 

Modified: trunk/glom/box_withbuttons.cc
==============================================================================
--- trunk/glom/box_withbuttons.cc	(original)
+++ trunk/glom/box_withbuttons.cc	Mon Mar 30 12:01:39 2009
@@ -19,7 +19,8 @@
  */
 
 #include "box_withbuttons.h"
-#include "application.h" //App_Glom.
+#include <glom/application.h> //App_Glom.
+#include <glom/utils_ui.h>
 #include <libglom/appstate.h>
 //#include <libgnomeui/gnome-app-helper.h>
 

Modified: trunk/glom/dialog_glom.cc
==============================================================================
--- trunk/glom/dialog_glom.cc	(original)
+++ trunk/glom/dialog_glom.cc	Mon Mar 30 12:01:39 2009
@@ -18,7 +18,8 @@
  * Boston, MA 02111-1307, USA.
  */
  
-#include "dialog_glom.h"
+#include <glom/dialog_glom.h>
+#include <glom/utils_ui.h>
 
 namespace Glom
 {

Modified: trunk/glom/dialog_invalid_data.cc
==============================================================================
--- trunk/glom/dialog_invalid_data.cc	(original)
+++ trunk/glom/dialog_invalid_data.cc	Mon Mar 30 12:01:39 2009
@@ -20,7 +20,7 @@
  
 #include "dialog_invalid_data.h"
 #include <libglom/data_structure/glomconversions.h>
-#include <libglom/utils.h>
+#include <glom/utils_ui.h>
 #include <glom/glade_utils.h>
 
 namespace Glom
@@ -48,7 +48,7 @@
   refXml->get_widget_derived("dialog_data_invalid_format", dialog);
   dialog->set_example_data(glom_type);
   //dialog->set_transient_for(*this);
-  int response = Glom::Utils::dialog_run_with_help(dialog, "dialog_data_invalid_format");
+  const int response = Glom::Utils::dialog_run_with_help(dialog, "dialog_data_invalid_format");
   
   delete dialog;
   return (response == 2); //The glade file has a response of 2 for the Revert button.

Modified: trunk/glom/dialog_new_self_hosted_connection.cc
==============================================================================
--- trunk/glom/dialog_new_self_hosted_connection.cc	(original)
+++ trunk/glom/dialog_new_self_hosted_connection.cc	Mon Mar 30 12:01:39 2009
@@ -31,8 +31,7 @@
 : Gtk::Dialog(cobject),
   Base_DB(),
   m_entry_user(0),
-  m_entry_password(0),
-  m_dialog_progess_connection_initialize(0)
+  m_entry_password(0)
 {
   builder->get_widget("entry_user", m_entry_user);
   builder->get_widget("entry_password", m_entry_password);
@@ -41,54 +40,16 @@
 
 Dialog_NewSelfHostedConnection::~Dialog_NewSelfHostedConnection()
 {
-  if(m_dialog_progess_connection_initialize)
-  {
-    delete m_dialog_progess_connection_initialize;
-    m_dialog_progess_connection_initialize = 0;
-  }
 }
 
-void Dialog_NewSelfHostedConnection::on_connection_initialization_progress()
+Glib::ustring Dialog_NewSelfHostedConnection::get_user() const
 {
-  if(!m_dialog_progess_connection_initialize)
-    m_dialog_progess_connection_initialize = Utils::get_and_show_pulse_dialog(_("Creating Database Data"), this);
-        
-  m_dialog_progess_connection_initialize->pulse();
+  return m_entry_user->get_text();
 }
 
-bool Dialog_NewSelfHostedConnection::create_self_hosted()
+Glib::ustring Dialog_NewSelfHostedConnection::get_password() const
 {
-  //std::cout << "debug: Dialog_NewSelfHostedConnection::connect_to_server_with_connection_settings()" << std::endl;
-
-  //TODO: BusyCursor busy_cursor(get_app_window());
-
- 
-  ConnectionPool* connection_pool = ConnectionPool::get_instance();
-  if(connection_pool)
-  {
-    //Set the connection details in the ConnectionPool singleton.
-    //The ConnectionPool will now use these every time it tries to connect.
-
-    const Document_Glom* document = get_document();
-    if(document)
-    {
-      // Create the files needed to self-host a database:
-      //connection_pool->set_self_hosted() has already been called.
-      connection_pool->set_user(m_entry_user->get_text());
-      connection_pool->set_password(m_entry_password->get_text());
-      //std::cout << "debug: Dialog_NewSelfHostedConnection::create_self_hosted() user=" << m_entry_user->get_text() << ", password=" << m_entry_password->get_text() << std::endl;
-      const bool created = connection_pool->initialize(
-        sigc::mem_fun(*this, &Dialog_NewSelfHostedConnection::on_connection_initialization_progress) );
-      if(!created)
-      {
-        return false;
-      }
-
-      return true;
-    }
-  }
-
-  return false;
+  return m_entry_password->get_text();
 }
 
 void Dialog_NewSelfHostedConnection::load_from_document()

Modified: trunk/glom/dialog_new_self_hosted_connection.h
==============================================================================
--- trunk/glom/dialog_new_self_hosted_connection.h	(original)
+++ trunk/glom/dialog_new_self_hosted_connection.h	Mon Mar 30 12:01:39 2009
@@ -31,8 +31,6 @@
 namespace Glom
 {
 
-class Dialog_ProgressCreating;
-
 class Dialog_NewSelfHostedConnection
   : public Gtk::Dialog,
     public Base_DB
@@ -43,19 +41,17 @@
 
   bool check_password();
 
-  bool create_self_hosted();
+  Glib::ustring get_user() const;
+  Glib::ustring get_password() const;
 
   virtual void load_from_document(); //override
 
 
 private:
-  void on_connection_initialization_progress();
-  
+
   Gtk::Entry* m_entry_user;
   Gtk::Entry* m_entry_password;
   Gtk::Entry* m_entry_password_confirm;
-  
-  Dialog_ProgressCreating* m_dialog_progess_connection_initialize;
 };
 
 } //namespace Glom

Modified: trunk/glom/filechooser_export.cc
==============================================================================
--- trunk/glom/filechooser_export.cc	(original)
+++ trunk/glom/filechooser_export.cc	Mon Mar 30 12:01:39 2009
@@ -20,7 +20,7 @@
 
 #include "filechooser_export.h"
 #include "mode_data/dialog_layout_export.h"
-#include <libglom/utils.h>
+#include <glom/utils_ui.h>
 #include <glom/glade_utils.h>
 #include <gtkmm/stock.h>
 #include <glibmm/i18n.h>

Modified: trunk/glom/frame_glom.cc
==============================================================================
--- trunk/glom/frame_glom.cc	(original)
+++ trunk/glom/frame_glom.cc	Mon Mar 30 12:01:39 2009
@@ -20,10 +20,10 @@
 
 #include <libglom/libglom_config.h> // For GLOM_ENABLE_SQLITE, GLOM_ENABLE_CLIENT_ONLY
 
-#include "frame_glom.h"
-#include "application.h"
-#include "dialog_import_csv.h"
-#include "dialog_import_csv_progress.h"
+#include <glom/frame_glom.h>
+#include <glom/application.h>
+#include <glom/dialog_import_csv.h>
+#include <glom/dialog_import_csv_progress.h>
 #include <libglom/appstate.h>
 
 #include <libglom/connectionpool.h>
@@ -48,7 +48,7 @@
 #include "relationships_overview/dialog_relationships_overview.h"
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 
-#include <libglom/utils.h>
+#include <glom/utils_ui.h>
 #include <glom/glade_utils.h>
 #include <libglom/data_structure/glomconversions.h>
 #include <libglom/data_structure/layout/report_parts/layoutitem_summary.h>
@@ -103,6 +103,7 @@
   m_dialog_relationships_overview(0),
 #endif // !GLOM_ENABLE_CLIENT_ONLY
   m_pDialogConnection(0),
+  m_dialog_progess_connection_initialize(0),
   m_dialog_progess_connection_startup(0),
   m_dialog_progess_connection_cleanup(0)
 {
@@ -180,6 +181,12 @@
     m_pDialogConnection = 0;
   }
   
+  if(m_dialog_progess_connection_initialize)
+  {
+    delete m_dialog_progess_connection_initialize;
+    m_dialog_progess_connection_initialize = 0;
+  }
+  
   if(m_dialog_progess_connection_startup)
   {
     delete m_dialog_progess_connection_startup;
@@ -1706,6 +1713,15 @@
   }
 }
 
+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();
+}
+
+
 void Frame_Glom::on_connection_startup_progress()
 {
   if(!m_dialog_progess_connection_startup)
@@ -1722,6 +1738,34 @@
   m_dialog_progess_connection_cleanup->pulse();
 }
 
+bool Frame_Glom::handle_connection_initialize_errors(ConnectionPool::InitErrors error)
+{
+  Glib::ustring title;
+  Glib::ustring message;
+  
+  if(error == ConnectionPool::Backend::INITERROR_NONE)
+    return true;
+  else if(error == ConnectionPool::Backend::INITERROR_DIRECTORY_ALREADY_EXISTS)
+  {
+    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)
+  {
+    title = _("Could Not Create Directory");
+    message = _("There was an error when attempting to create the directory for the new database files.");
+  }
+  else if(error == ConnectionPool::Backend::INITERROR_COULD_NOT_START_SERVER)
+  {
+    title = _("Could Not Start Database Server");
+    message = _("There was an error when attempting to start the database server.");
+  }
+  
+  Utils::show_ok_dialog(title, message, *get_app_window(), Gtk::MESSAGE_ERROR);
+  
+  return false;
+}
+
 bool Frame_Glom::connection_request_password_and_choose_new_database_name()
 {
   Document_Glom* document = dynamic_cast<Document_Glom*>(get_document());
@@ -1778,7 +1822,7 @@
       bool keep_trying = true;
       while(keep_trying)
       {
-        response = Glom::Utils::dialog_run_with_help(dialog, "dialog_new_self_hosted_connection");
+        response = Utils::dialog_run_with_help(dialog, "dialog_new_self_hosted_connection");
 
         //Check the password is acceptable:
         if(response == Gtk::RESPONSE_OK)
@@ -1797,24 +1841,34 @@
       dialog->hide();
  
       // Create the requested self-hosting database:
-      bool created = false;
       if(response == Gtk::RESPONSE_OK)
       {
-        created = dialog->create_self_hosted();
-        if(!created)
+        //Set the connection details in the ConnectionPool singleton.
+        //The ConnectionPool will now use these every time it tries to connect.
+        connection_pool->set_user(dialog->get_user());
+        connection_pool->set_password(dialog->get_password());
+      
+        const bool initialized = handle_connection_initialize_errors( connection_pool->initialize(
+          sigc::mem_fun(*this, &Frame_Glom::on_connection_initialize_progress) ) );
+
+        if(m_dialog_progess_connection_initialize)
+        {
+          delete m_dialog_progess_connection_initialize;
+          m_dialog_progess_connection_initialize = 0;
+        }
+
+        if(!initialized)
           return false;
 
-      //Put the details into m_pDialogConnection too, because that's what we use to connect.
-      //This is a bit of a hack:
+        //Put the details into m_pDialogConnection too, because that's what we use to connect.
+        //This is a bit of a hack:
         m_pDialogConnection->set_self_hosted_user_and_password(connection_pool->get_user(), connection_pool->get_password());
       }
 
       remove_view(dialog);
 
-    //std::cout << "DEBUG: after dialog->create_self_hosted(). The database cluster should now exist." << std::endl;
+      //std::cout << "DEBUG: after connection_pool->initialize(). The database cluster should now exist." << std::endl;
 
-      if(!created)
-        return false; // The user cancelled
 #else
       // Self-hosted postgres not supported in client only mode
       g_assert_not_reached();
@@ -1835,7 +1889,7 @@
         // We are not self-hosting, but we also call initialize() for
         // consistency (the backend will ignore it anyway).
         ConnectionPool::SlotProgress slot_ignored;
-        if(!connection_pool->initialize(slot_ignored))
+        if(!handle_connection_initialize_errors( connection_pool->initialize(slot_ignored)) )
           return false;
       }
       else
@@ -1851,7 +1905,8 @@
   case Document_Glom::HOSTING_MODE_SQLITE:
     {
       // sqlite
-      if(!connection_pool->initialize(get_app_window()))
+      ConnectionPool::SlotProgress slot_ignored;
+      if(!handle_connection_initialize_errors( connection_pool->initialize(slot_ignored)) )
         return false;
 
       m_pDialogConnection->load_from_document(); //Get good defaults.
@@ -2251,7 +2306,20 @@
   print->set_canvas(&canvas);
 
   print->set_track_print_status();
-  print->set_default_page_setup(print_layout->get_page_setup());
+
+  //TODO: Put this in a utility function.
+  Glib::RefPtr<Gtk::PageSetup> page_setup;
+  const Glib::ustring key_file_text = print_layout->get_page_setup();
+  if(!key_file_text.empty())
+  {
+    Glib::KeyFile key_file;
+    key_file.load_from_data(key_file_text);
+    //TODO: Use this when gtkmm and GTK+ have been fixed: page_setup = Gtk::PageSetup::create(key_file);
+    page_setup = Glib::wrap(gtk_page_setup_new_from_key_file(key_file.gobj(), NULL, NULL));
+  }
+  
+  print->set_default_page_setup(page_setup);
+  
   //print->set_print_settings(m_refSettings);
 
   //print->signal_done().connect(sigc::bind(sigc::mem_fun(*this,

Modified: trunk/glom/frame_glom.h
==============================================================================
--- trunk/glom/frame_glom.h	(original)
+++ trunk/glom/frame_glom.h	Mon Mar 30 12:01:39 2009
@@ -218,9 +218,11 @@
   void on_dialog_add_related_table_response(int response);
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 
+  void on_connection_initialize_progress();
   void on_connection_startup_progress();
   void on_connection_cleanup_progress();
   void cleanup_connection();
+  bool handle_connection_initialize_errors(ConnectionPool::InitErrors error);
   
   //Member data:
   Glib::ustring m_table_name;
@@ -268,6 +270,7 @@
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 
   Dialog_Connection* m_pDialogConnection;
+  Dialog_ProgressCreating* m_dialog_progess_connection_initialize;
   Dialog_ProgressCreating* m_dialog_progess_connection_startup;
   Dialog_ProgressCreating* m_dialog_progess_connection_cleanup;
 };

Added: trunk/glom/glade_utils.cc
==============================================================================
--- (empty file)
+++ trunk/glom/glade_utils.cc	Mon Mar 30 12:01:39 2009
@@ -0,0 +1,68 @@
+/* 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 <glom/glade_utils.h>
+#include <glibmm/i18n.h>
+
+namespace Glom
+{
+
+namespace Utils
+{
+
+
+Dialog_ProgressCreating* get_and_show_pulse_dialog(const Glib::ustring& message, Gtk::Window* parent_window)
+{
+  if(!parent_window)
+    std::cerr << "debug: Glom: get_and_show_pulse_dialog(): parent_window is NULL" << std::endl;
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  Glib::RefPtr<Gtk::Builder> refXml = Gtk::Builder::create_from_file(Utils::get_glade_file_path("glom.glade"), "window_progress");
+#else
+  std::auto_ptr<Glib::Error> error;
+  Glib::RefPtr<Gtk::Builder> refXml = Gtk::Builder::create_from_file(Utils::get_glade_file_path("glom.glade"), "window_progress", "", error);
+  if(error.get())
+    return 0;
+#endif
+
+  if(refXml)
+  {
+    Dialog_ProgressCreating* dialog_progress = 0;
+    refXml->get_widget_derived("window_progress", dialog_progress);
+    if(dialog_progress)
+    {
+      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;
+    }
+  }
+
+  return 0;
+}
+
+} //namespace Utils
+} //namespace Glom
+

Modified: trunk/glom/layout_item_dialogs/dialog_group_by.cc
==============================================================================
--- trunk/glom/layout_item_dialogs/dialog_group_by.cc	(original)
+++ trunk/glom/layout_item_dialogs/dialog_group_by.cc	Mon Mar 30 12:01:39 2009
@@ -18,8 +18,9 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include "dialog_group_by.h"
+#include <glom/layout_item_dialogs/dialog_group_by.h>
 #include <libglom/data_structure/glomconversions.h>
+#include <glom/utils_ui.h>
 #include <glom/glade_utils.h>
 #include <sstream> //For stringstream
 #include <glibmm/i18n.h>

Modified: trunk/glom/libglom/connectionpool.cc
==============================================================================
--- trunk/glom/libglom/connectionpool.cc	(original)
+++ trunk/glom/libglom/connectionpool.cc	Mon Mar 30 12:01:39 2009
@@ -24,8 +24,6 @@
 #include <libglom/document/document_glom.h>
 #include <libglom/utils.h>
 //#include <libgdamm/connectionevent.h>
-#include <gtkmm/main.h>
-#include <gtkmm/messagedialog.h>
 #include <glibmm/i18n.h>
 
 #ifndef G_OS_WIN32
@@ -40,10 +38,6 @@
 # define DATADIR GLOM_SAVE_DATADIR
 #endif
 
-#ifdef GLOM_ENABLE_MAEMO
-#include <hildonmm/note.h>
-#endif
-
 #include <signal.h> //To catch segfaults
 
 #ifndef GLOM_ENABLE_CLIENT_ONLY
@@ -525,7 +519,7 @@
 }
 
 //static
-bool ConnectionPool::handle_error(bool cerr_only)
+bool ConnectionPool::handle_error_cerr_only()
 {
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
   sharedptr<SharedConnection> sharedconnection = get_and_connect();
@@ -557,25 +551,6 @@
         }
       }
 
-      //For debugging only:
-      //Gtk::Dialog* dialog = 0;
-      //dialog->run(); //Force a crash.
-
-      if(!cerr_only)
-      {
-#ifdef GLOM_ENABLE_MAEMO
-        Hildon::Note dialog(Hildon::NOTE_TYPE_INFORMATION, error_details);
-#else
-        Gtk::MessageDialog dialog(Utils::bold_message(_("Internal error")), true, Gtk::MESSAGE_WARNING );
-        dialog.set_secondary_text(error_details);
-#endif
-        //TODO: dialog.set_transient_for(*get_application());
-        dialog.run(); //TODO: This segfaults in gtk_window_set_modal() when this method is run a second time, for instance if there are two database errors.
-#ifdef GLOM_CONNECTION_DEBUG
-        std::cout << "debug: after Internal Error dialog run()." << std::endl;
-#endif
-      }
-
       return true; //There really was an error.
     }
   }
@@ -780,58 +755,14 @@
 }
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 
-bool ConnectionPool::initialize(const SlotProgress& slot_progress)
+ConnectionPool::InitErrors ConnectionPool::initialize(const SlotProgress& slot_progress)
 {
   if(m_backend.get())
     return m_backend->initialize(slot_progress, get_user(), get_password());
   else
-    return false;
-}
-
-bool ConnectionPool::check_user_is_not_root()
-{
-  Glib::ustring message;
-#ifdef G_OS_WIN32
-  try
-  {
-    if(pgwin32_is_admin())
-    {
-      message = _("You seem to be running Glom as a user with administrator privileges. Glom may not be run with such privileges for security reasons.\nPlease login to your system as a normal user.");
-    }
-  }
-  catch(const std::runtime_error& ex)
-  {
-    message = ex.what();
-  }
-#else
-  //std::cout << "ConnectionPool::check_user_is_not_root(): geteuid()=" << geteuid() << ", getgid()=" << getgid() << std::endl;
-
-  //This is very linux-specific. We should ifdef this out for other platforms.
-  if(geteuid() == 0)
-  {
-    //Warn the user:
-    message = _("You seem to be running Glom as root. Glom may not be run as root.\nPlease login to your system as a normal user.");
-  }
-#endif
-
-  if(!message.empty())
-  {
-#ifndef GLOM_ENABLE_MAEMO
-    Gtk::MessageDialog dialog(Utils::bold_message(_("Running As Root")), true /* use_markup */, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true /* modal */);
-    dialog.set_secondary_text(message);
-    dialog.run();
-#else
-    Hildon::Note note(Hildon::NOTE_TYPE_INFORMATION, message);
-    note.run();
-#endif
-
-    return false; /* Is root. Bad. */
-  }
-
-  return true; /* Not root. It's OK. */
+    return Backend::INITERROR_OTHER;
 }
 
-
 #ifndef GLOM_ENABLE_CLIENT_ONLY
 Document_Glom* ConnectionPool::get_document()
 {
@@ -902,45 +833,34 @@
 void ConnectionPool::on_epc_progress_begin(const gchar* /* title */, gpointer user_data)
 {
   //We ignore the title parameter because there is no way that libepc could know what Glom wants to say.
- 
+  
   ConnectionPool* connection_pool = (ConnectionPool*)user_data;
-
-  //Create the dialog:
-  if(connection_pool->m_dialog_epc_progress)
-  {
-    delete connection_pool->m_dialog_epc_progress;
-    connection_pool->m_dialog_epc_progress = 0;
-  }
-
-  Gtk::MessageDialog* message_dialog = new Gtk::MessageDialog(Utils::bold_message(_("Glom: Generating Encryption Certificates")), true, Gtk::MESSAGE_INFO);
-  message_dialog->set_secondary_text(_("Please wait while Glom prepares your system for publishing over the network."));
-  message_dialog->show();
-
-  connection_pool->m_dialog_epc_progress = message_dialog; 
+  if(connection_pool)
+    connection_pool->m_epc_slot_begin();
 }
 
-void ConnectionPool::on_epc_progress_update(gdouble /* progress */, const gchar* /* message */, gpointer /* user_data */)
+void ConnectionPool::on_epc_progress_update(gdouble /* progress */, const gchar* /* message */, gpointer user_data)
 {
   //We ignore the title parameter because there is no way that libepc could know what Glom wants to say.
   //TODO: Show the progress in a ProgressBar.
 
-  //ConnectionPool* connection_pool = (ConnectionPool*)user_data;
-
-  //Allow GTK+ to process events, so that the UI is responsive:
-  while(Gtk::Main::events_pending())
-   Gtk::Main::iteration();
+  ConnectionPool* connection_pool = (ConnectionPool*)user_data;
+  if(connection_pool)
+    connection_pool->m_epc_slot_progress();
 }
 
 void ConnectionPool::on_epc_progress_end(gpointer user_data)
 {
   ConnectionPool* connection_pool = (ConnectionPool*)user_data;
+  if(connection_pool)
+    connection_pool->m_epc_slot_done();
+}
 
-  //Delete the dialog:
-  if(connection_pool->m_dialog_epc_progress)
-  {
-    delete connection_pool->m_dialog_epc_progress;
-    connection_pool->m_dialog_epc_progress = 0;
-  }
+void ConnectionPool::set_avahi_publish_callbacks(const type_void_slot& slot_begin, const type_void_slot& slot_progress, const type_void_slot& slot_done)
+{
+  m_epc_slot_begin = slot_begin;
+  m_epc_slot_progress = slot_progress;
+  m_epc_slot_done = slot_done; 
 }
 
 

Modified: trunk/glom/libglom/connectionpool.h
==============================================================================
--- trunk/glom/libglom/connectionpool.h	(original)
+++ trunk/glom/libglom/connectionpool.h	Mon Mar 30 12:01:39 2009
@@ -88,7 +88,7 @@
   //ConnectionPool(const ConnectionPool& src);
   virtual ~ConnectionPool();
   //ConnectionPool& operator=(const ConnectionPool& src);
-
+  
 public:
   typedef ConnectionPoolBackends::Backend Backend;
   typedef Backend::type_vecConstFields type_vecConstFields;
@@ -100,6 +100,18 @@
 
   /// Delete the singleton so it doesn't show up as leaked memory in, for instance, valgrind.
   static void delete_instance();
+  
+  typedef sigc::slot<void> type_void_slot;
+  
+  /** Set callbacks that will be called to show UI while starting to advertise 
+   * on the network via Avahi.
+   *
+   * @param slot_begin Show an explanatory message.
+   * @param slot_progress Show a pulse progress and/or keep the UI updating.
+   * @param slot_done Stop showing the message.
+   */ 
+  void set_avahi_publish_callbacks(const type_void_slot& slot_begin, const type_void_slot& slot_progress, const type_void_slot& slot_done);
+  
 
   bool get_ready_to_connect() const;
   void set_ready_to_connect(bool val = true);
@@ -152,13 +164,15 @@
   /** This callback should show UI to indicate that work is still happening.
    * For instance, a pulsing ProgressBar.
    */
-  typedef sigc::slot<void> SlotProgress;
+  typedef Backend::SlotProgress SlotProgress;
+ 
+  typedef Backend::InitErrors InitErrors;
   
   /** Do one-time initialization, such as  creating required database
    * files on disk for later use by their own  database server instance.
    * @param parent_window A parent window to use as the transient window when displaying errors.
    */
-  bool initialize(const SlotProgress& slot_progress);
+  InitErrors initialize(const SlotProgress& slot_progress);
 
   /** Start a database server instance for the exisiting database files.
    * @param parent_window The parent window (transient for) of any dialogs shown during this operation.
@@ -214,12 +228,7 @@
 #endif // !G_OS_WIN32
 
   //Show the gda error in a dialog.
-  static bool handle_error(bool cerr_only = false);
-
-  /** Postgres can't be started as root. initdb complains.
-   * So just prevent this in general. It is safer anyway.
-   */
-  static bool check_user_is_not_root();
+  static bool handle_error_cerr_only();
 
 private:
   void on_sharedconnection_finished();
@@ -261,6 +270,8 @@
 #ifndef GLOM_ENABLE_CLIENT_ONLY
   SlotGetDocument m_slot_get_document;
 #endif
+
+  type_void_slot m_epc_slot_begin, m_epc_slot_progress, m_epc_slot_done;
 };
 
 } //namespace Glom

Modified: trunk/glom/libglom/connectionpool_backends/backend.cc
==============================================================================
--- trunk/glom/libglom/connectionpool_backends/backend.cc	(original)
+++ trunk/glom/libglom/connectionpool_backends/backend.cc	Mon Mar 30 12:01:39 2009
@@ -45,9 +45,9 @@
 namespace ConnectionPoolBackends
 {
 
-bool Backend::initialize(const SlotProgress& /* slot_progress */, const Glib::ustring& /* initial_username */, const Glib::ustring& /* password */)
+Backend::InitErrors Backend::initialize(const SlotProgress& /* slot_progress */, const Glib::ustring& /* initial_username */, const Glib::ustring& /* password */)
 {
-  return true;
+  return INITERROR_NONE;
 }
 
 bool Backend::startup(const SlotProgress& /* slot_progress */)

Modified: trunk/glom/libglom/connectionpool_backends/backend.h
==============================================================================
--- trunk/glom/libglom/connectionpool_backends/backend.h	(original)
+++ trunk/glom/libglom/connectionpool_backends/backend.h	Mon Mar 30 12:01:39 2009
@@ -26,8 +26,6 @@
 #include <libglom/sharedptr.h>
 #include <libglom/data_structure/field.h>
 
-#include <gtkmm/window.h>
-
 #include <memory>
 
 namespace Glom
@@ -69,6 +67,15 @@
   virtual ~Backend() {}
   typedef std::vector<sharedptr<const Field> > type_vecConstFields;
 
+  enum InitErrors
+  {
+     INITERROR_NONE,
+     INITERROR_DIRECTORY_ALREADY_EXISTS,
+     INITERROR_COULD_NOT_CREATE_DIRECTORY,
+     INITERROR_COULD_NOT_START_SERVER,
+     INITERROR_OTHER
+  };
+  
 protected:
   /** Helper functions for backend implementations to use, so that these don't
    * need to worry whether glibmm was compiled with exceptions or not.
@@ -105,14 +112,14 @@
    * For instance, a pulsing ProgressBar.
    */
   typedef sigc::slot<void> SlotProgress;
-
+  
   /** This method is called for one-time initialization of the database
-   * storage. No need to implement this function if the data is centrally
-   * hosted, not managed by Glom.
+   * storage. There is no need to implement this function if the data is centrally
+   * hosted rather than hosted by Glom.
    *
    * @slot_progress A callback to call while the work is still happening.
    */
-  virtual bool initialize(const SlotProgress& slot_progress, const Glib::ustring& initial_username, const Glib::ustring& password);
+  virtual InitErrors initialize(const SlotProgress& slot_progress, const Glib::ustring& initial_username, const Glib::ustring& password);
 
   /** This method is called before the backend is used otherwise. This can
    * be used to start a self-hosted database server. There is no need to implement

Modified: trunk/glom/libglom/connectionpool_backends/postgres.cc
==============================================================================
--- trunk/glom/libglom/connectionpool_backends/postgres.cc	(original)
+++ trunk/glom/libglom/connectionpool_backends/postgres.cc	Mon Mar 30 12:01:39 2009
@@ -24,13 +24,6 @@
 #include <libglom/utils.h>
 #include <glibmm/i18n.h>
 
-#ifdef GLOM_ENABLE_MAEMO
-# include <hildonmm/note.h>
-#else
-# include <gtkmm/messagedialog.h>
-#endif
-
-
 // Uncomment to see debug messages
 // #define GLOM_CONNECTION_DEBUG
 
@@ -426,7 +419,7 @@
 }
 #endif
 
-bool Postgres::check_postgres_gda_client_is_available_with_warning()
+bool Postgres::check_postgres_gda_client_is_available()
 {
   //This API is horrible.
   //See libgda bug http://bugzilla.gnome.org/show_bug.cgi?id=575754
@@ -451,17 +444,6 @@
     while(iter->move_next());
   }
 
-  const Glib::ustring message = _("Your installation of Glom is not complete, because the PostgreSQL libgda provider is not available on your system. This provider is needed to access Postgres database servers.\n\nPlease report this bug to your vendor, or your system administrator so it can be corrected.");
-#ifndef GLOM_ENABLE_MAEMO
-  /* The Postgres provider was not found, so warn the user: */
-  Gtk::MessageDialog dialog(Utils::bold_message(_("Incomplete Glom Installation")), true /* use_markup */, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true /* modal */);
-  dialog.set_secondary_text(message);
-  dialog.run();
-#else
-  Hildon::Note note(Hildon::NOTE_TYPE_INFORMATION, message);
-  note.run();
-#endif
-
   return false;
 }
 

Modified: trunk/glom/libglom/connectionpool_backends/postgres.h
==============================================================================
--- trunk/glom/libglom/connectionpool_backends/postgres.h	(original)
+++ trunk/glom/libglom/connectionpool_backends/postgres.h	Mon Mar 30 12:01:39 2009
@@ -54,7 +54,7 @@
    *
    * @results True if everything is OK.
    */
-  static bool check_postgres_gda_client_is_available_with_warning();
+  static bool check_postgres_gda_client_is_available();
 
 private:
   virtual Field::sql_format get_sql_format() const { return Field::SQL_FORMAT_POSTGRES; }

Modified: trunk/glom/libglom/connectionpool_backends/postgres_self.cc
==============================================================================
--- trunk/glom/libglom/connectionpool_backends/postgres_self.cc	(original)
+++ trunk/glom/libglom/connectionpool_backends/postgres_self.cc	Mon Mar 30 12:01:39 2009
@@ -66,32 +66,6 @@
   return result;
 }
 
-static std::string get_path_to_postgres_executable(const std::string& program)
-{
-#ifdef G_OS_WIN32
-  // Add the .exe extension on Windows:
-  std::string real_program = program + EXEEXT;
-    
-  // Have a look at the bin directory of the application executable first.
-  // The installer installs postgres there. postgres needs to be installed
-  // in a directory called bin for its relocation stuff to work, so that
-  // it finds the share data in share. Unfortunately it does not look into
-  // share/postgresql which would be nice to separate the postgres stuff
-  // from the other shared data. We can perhaps still change this later by
-  // building postgres with another prefix than /local/pgsql.
-  gchar* installation_directory = g_win32_get_package_installation_directory_of_module(NULL);
-  std::string test = Glib::build_filename(installation_directory, Glib::build_filename("bin", real_program));
-  g_free(installation_directory);
-
-  if(Glib::file_test(test, Glib::FILE_TEST_IS_EXECUTABLE))
-    return test;
-
-  // Look in PATH otherwise
-  return Glib::find_program_in_path(real_program);
-#else // G_OS_WIN32
-  return Glib::build_filename(POSTGRES_UTILS_PATH, program + EXEEXT);
-#endif // !G_OS_WIN32
-  }
 } // anonymous namespace
 
 namespace Glom
@@ -122,6 +96,34 @@
 {
 }
 
+
+std::string PostgresSelfHosted::get_path_to_postgres_executable(const std::string& program)
+{
+#ifdef G_OS_WIN32
+  // Add the .exe extension on Windows:
+  std::string real_program = program + EXEEXT;
+    
+  // Have a look at the bin directory of the application executable first.
+  // The installer installs postgres there. postgres needs to be installed
+  // in a directory called bin for its relocation stuff to work, so that
+  // it finds the share data in share. Unfortunately it does not look into
+  // share/postgresql which would be nice to separate the postgres stuff
+  // from the other shared data. We can perhaps still change this later by
+  // building postgres with another prefix than /local/pgsql.
+  gchar* installation_directory = g_win32_get_package_installation_directory_of_module(NULL);
+  std::string test = Glib::build_filename(installation_directory, Glib::build_filename("bin", real_program));
+  g_free(installation_directory);
+
+  if(Glib::file_test(test, Glib::FILE_TEST_IS_EXECUTABLE))
+    return test;
+
+  // Look in PATH otherwise
+  return Glib::find_program_in_path(real_program);
+#else // G_OS_WIN32
+  return Glib::build_filename(POSTGRES_UTILS_PATH, program + EXEEXT);
+#endif // !G_OS_WIN32
+}
+
 void PostgresSelfHosted::set_self_hosting_data_uri(const std::string& data_uri)
 {
   if(m_self_hosting_data_uri != data_uri)
@@ -142,55 +144,6 @@
   return m_port;
 }
 
-// Message to packagers:
-// If your Glom package does not depend on PostgreSQL, for some reason, 
-// then your distro-specific patch should uncomment this #define.
-// and implement ConnectionPool::install_posgres().
-// But please, just make your Glom package depend on PostgreSQL instead, 
-// because this is silly.
-//
-//#define DISTRO_SPECIFIC_POSTGRES_INSTALL_IMPLEMENTED 1
-
-bool PostgresSelfHosted::check_postgres_is_available_with_warning()
-{
-  //EXEEXT is defined in the Makefile.am
-  const std::string binpath = get_path_to_postgres_executable("postgres");
-
-  // TODO: At least on Windows we should probably also check for initdb and
-  // pg_ctl. Perhaps it would also be a good idea to access these files as
-  // long as glom runs so they cannot be (re)moved.
-  if(!binpath.empty())
-  {
-    const Glib::ustring uri_binpath = Glib::filename_to_uri(binpath);
-    if(Utils::file_exists(uri_binpath))
-      return true;
-  }
-
-  #ifdef DISTRO_SPECIFIC_POSTGRES_INSTALL_IMPLEMENTED
-
-  //Show message to the user about the broken installation:
-  //This is a packaging bug, but it would probably annoy packagers to mention that in the dialog:
-  Gtk::MessageDialog dialog(Utils::bold_message(_("Incomplete Glom Installation")), true /* use_markup */, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_NONE, true /* modal */);
-  dialog.set_secondary_text(_("Your installation of Glom is not complete, because PostgreSQL is not available on your system. PostgreSQL is needed for self-hosting of Glom databases.\n\nYou may now install PostgreSQL to complete the Glom installation."));
-  dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
-  dialog.add_button(_("Install PostgreSQL"), Gtk::RESPONSE_OK);
-  const int response = dialog.run();
-  if(response != Gtk::RESPONSE_OK)
-    return false; //Failure. Glom should now quit.
-  else
-    return install_postgres(&dialog);
-
-  #else  //DISTRO_SPECIFIC_POSTGRES_INSTALL_IMPLEMENTED
-
-  //Show message to the user about the broken installation:
-  Gtk::MessageDialog dialog(Utils::bold_message(_("Incomplete Glom Installation")), true /* use_markup */, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true /* modal */);
-  dialog.set_secondary_text(_("Your installation of Glom is not complete, because PostgreSQL is not available on your system. PostgreSQL is needed for self-hosting of Glom databases.\n\nPlease report this bug to your vendor, or your system administrator so it can be corrected."));
-  dialog.run();
-  return false;
-
-  #endif //DISTRO_SPECIFIC_POSTGRES_INSTALL_IMPLEMENTED
-}
-
 /** Try to install postgres on the distro, though this will require a
  * distro-specific patch to the implementation.
  */
@@ -229,14 +182,18 @@
 #endif // #if 0
 }
 
-bool PostgresSelfHosted::initialize(const SlotProgress& slot_progress, const Glib::ustring& initial_username, const Glib::ustring& password)
+Backend::InitErrors PostgresSelfHosted::initialize(const SlotProgress& slot_progress, const Glib::ustring& initial_username, const Glib::ustring& password)
 {
-  Gtk::Window* parent_window = 0; //TODO: Replace the dialog with some callback or exception?
-  
   if(m_self_hosting_data_uri.empty())
   {
     std::cerr << "PostgresSelfHosted::initialize: m_self_hosting_data_uri is empty." << std::endl;
-    return false;
+    return INITERROR_OTHER;
+  }
+  
+  if(initial_username.empty())
+  {
+    std::cerr << "PostgresSelfHosted::initialize(). Username was empty while attempting to create self-hosting database" << std::endl;
+    return INITERROR_OTHER;
   }
 
   //Get the filepath of the directory that we should create:
@@ -244,14 +201,7 @@
   //std::cout << "debug: dbdir_uri=" << dbdir_uri << std::endl;
 
   if(directory_exists_uri(dbdir_uri))
-  { 
-    if(parent_window)
-    {
-      Utils::show_ok_dialog(_("Directory Already Exists"), _("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."), *parent_window, Gtk::MESSAGE_ERROR);
-    }
-    
-    return false;
-  }
+    return INITERROR_DIRECTORY_ALREADY_EXISTS;
 
   const std::string dbdir = Glib::filename_from_uri(dbdir_uri);
   //std::cout << "debug: dbdir=" << dbdir << std::endl;
@@ -264,13 +214,8 @@
   {
     std::cerr << "Error from g_mkdir_with_parents() while trying to create directory: " << dbdir << std::endl;
     perror("Error from g_mkdir_with_parents");
-
-    if(parent_window)
-    {
-       Utils::show_ok_dialog(_("Could Not Create Directory"), _("There was an error when attempting to create the directory for the new database files."), *parent_window, Gtk::MESSAGE_ERROR);
-    }
-
-    return false;
+    
+    return INITERROR_COULD_NOT_CREATE_DIRECTORY;
   }
 
   //Create the config directory:
@@ -281,12 +226,7 @@
     std::cerr << "Error from g_mkdir_with_parents() while trying to create directory: " << dbdir_config << std::endl;
     perror("Error from g_mkdir_with_parents");
 
-    if(parent_window)
-    {
-       Utils::show_ok_dialog(_("Could Not Create Configuration Directory"), _("There was an error when attempting to create the configuration directory for the new database files."), *parent_window, Gtk::MESSAGE_ERROR);
-    }
-
-    return false;
+    return INITERROR_COULD_NOT_CREATE_DIRECTORY;
   }
 
   //Create these files: environment  pg_hba.conf  pg_ident.conf  start.conf
@@ -305,11 +245,6 @@
 
   
   // initdb creates a new postgres database cluster:
-  if(initial_username.empty())
-  {
-    std::cerr << "PostgresSelfHosted::initialize(). Username was empty while attempting to create self-hosting database" << std::endl;
-    return false;
-  }
 
   //Get file:// URI for the tmp/ directory:
   const std::string temp_pwfile = Glib::build_filename(Glib::get_tmp_dir(), "glom_initdb_pwfile");
@@ -333,7 +268,7 @@
   const int temp_pwfile_removed = g_remove(temp_pwfile.c_str()); //Of course, we don't want this to stay around. It would be a security risk.
   g_assert(temp_pwfile_removed == 0);
  
-  return result;
+  return result ? INITERROR_NONE : INITERROR_COULD_NOT_START_SERVER;
 }
 
 bool PostgresSelfHosted::startup(const SlotProgress& slot_progress)

Modified: trunk/glom/libglom/connectionpool_backends/postgres_self.h
==============================================================================
--- trunk/glom/libglom/connectionpool_backends/postgres_self.h	(original)
+++ trunk/glom/libglom/connectionpool_backends/postgres_self.h	Mon Mar 30 12:01:39 2009
@@ -54,20 +54,15 @@
    */
   int get_port() const;
 
-  /** Check whether PostgreSQL is really available for self-hosting,
-   * in case the distro package has incorrect dependencies.
-   *
-   * @results True if everything is OK.
-   */
-  static bool check_postgres_is_available_with_warning();
-
   /** Try to install postgres on the distro, though this will require a
    * distro-specific patch to the implementation.
    */
   static bool install_postgres(const SlotProgress& slot_progress);
 
+  static std::string get_path_to_postgres_executable(const std::string& program);
+
 private:
-  virtual bool initialize(const SlotProgress& slot_progress, const Glib::ustring& initial_username, const Glib::ustring& password);
+  virtual InitErrors initialize(const SlotProgress& slot_progress, const Glib::ustring& initial_username, const Glib::ustring& password);
 
   virtual bool startup(const SlotProgress& slot_progress);
   virtual void cleanup(const SlotProgress& slot_progress);

Modified: trunk/glom/libglom/data_structure/layout/layoutitem_image.cc
==============================================================================
--- trunk/glom/libglom/data_structure/layout/layoutitem_image.cc	(original)
+++ trunk/glom/libglom/data_structure/layout/layoutitem_image.cc	Mon Mar 30 12:01:39 2009
@@ -79,11 +79,6 @@
   return m_image;
 }
 
-Glib::RefPtr<Gdk::Pixbuf> LayoutItem_Image::get_image_as_pixbuf() const
-{
-  return Conversions::get_pixbuf_for_gda_value(m_image);
-}
-
 void LayoutItem_Image::set_image(const Gnome::Gda::Value& image)
 {
   m_image = image;

Modified: trunk/glom/libglom/data_structure/layout/layoutitem_image.h
==============================================================================
--- trunk/glom/libglom/data_structure/layout/layoutitem_image.h	(original)
+++ trunk/glom/libglom/data_structure/layout/layoutitem_image.h	Mon Mar 30 12:01:39 2009
@@ -54,8 +54,6 @@
    */
   Gnome::Gda::Value get_image() const;
 
-  Glib::RefPtr<Gdk::Pixbuf> get_image_as_pixbuf() const;
-
   /** Set the image that will be shown on each record.
    */
   void set_image(const Gnome::Gda::Value& image);
@@ -63,8 +61,8 @@
   //Saves the image to a temporary file and provides the file URI.
   Glib::ustring create_local_image_uri() const;
 
-private:
-
+//private:
+//This is public, for performance:
   Gnome::Gda::Value m_image;
 };
 

Modified: trunk/glom/libglom/data_structure/print_layout.cc
==============================================================================
--- trunk/glom/libglom/data_structure/print_layout.cc	(original)
+++ trunk/glom/libglom/data_structure/print_layout.cc	Mon Mar 30 12:01:39 2009
@@ -36,8 +36,7 @@
   m_layout_group(src.m_layout_group),
   m_show_table_title(src.m_show_table_title)
 {
-  if(src.m_page_setup)
-    m_page_setup = src.m_page_setup->copy();
+  m_page_setup = src.m_page_setup;
 }
 
 PrintLayout& PrintLayout::operator=(const PrintLayout& src)
@@ -46,11 +45,8 @@
 
   m_layout_group = src.m_layout_group;
   m_show_table_title = src.m_show_table_title;
-
-  m_page_setup.reset();
-  if(src.m_page_setup)
-    m_page_setup = src.m_page_setup->copy();
-
+  m_page_setup = src.m_page_setup;
+  
   return *this;
 }
 
@@ -64,21 +60,15 @@
   m_show_table_title = show_table_title;
 }
 
-void PrintLayout::set_page_setup(const Glib::RefPtr<Gtk::PageSetup>& page_setup)
+void PrintLayout::set_page_setup(const std::string& page_setup)
 {
   m_page_setup = page_setup;
 }
 
-Glib::RefPtr<Gtk::PageSetup> PrintLayout::get_page_setup()
+std::string PrintLayout::get_page_setup() const
 {
   return m_page_setup;
 }
 
-Glib::RefPtr<const Gtk::PageSetup> PrintLayout::get_page_setup() const
-{
-  return m_page_setup;
-}
-
-
 } //namespace Glom
 

Modified: trunk/glom/libglom/data_structure/print_layout.h
==============================================================================
--- trunk/glom/libglom/data_structure/print_layout.h	(original)
+++ trunk/glom/libglom/data_structure/print_layout.h	Mon Mar 30 12:01:39 2009
@@ -24,7 +24,6 @@
 #include "translatable_item.h"
 #include "layout/report_parts/layoutitem_groupby.h"
 #include <glibmm/ustring.h>
-#include <gtkmm/pagesetup.h>
 
 namespace Glom
 {
@@ -41,14 +40,18 @@
 
   sharedptr<LayoutGroup> m_layout_group;
 
-  void set_page_setup(const Glib::RefPtr<Gtk::PageSetup>& page_setup);
-  Glib::RefPtr<Gtk::PageSetup> get_page_setup();
-  Glib::RefPtr<const Gtk::PageSetup> get_page_setup() const;
+  /** Sets the Page Setup as it would be created by a Gtk::PageSetup.
+   */
+  void set_page_setup(const std::string& page_setup);
+
+  /** Returns the Page Setup as it would be created by a Gtk::PageSetup.   
+   */
+  std::string get_page_setup() const;
 
 private:
   bool m_show_table_title;
 
-  Glib::RefPtr<Gtk::PageSetup> m_page_setup;
+  std::string m_page_setup;
 };
 
 } //namespace Glom

Modified: trunk/glom/libglom/document/document_glom.cc
==============================================================================
--- trunk/glom/libglom/document/document_glom.cc	(original)
+++ trunk/glom/libglom/document/document_glom.cc	Mon Mar 30 12:01:39 2009
@@ -34,6 +34,7 @@
 #include <libglom/standard_table_prefs_fields.h>
 #include <giomm.h>
 #include <libglom/busy_cursor.h>
+#include <gtkmm/pagesetup.h>
 
 #include <libglom/connectionpool.h>
 
@@ -2692,16 +2693,8 @@
                 print_layout->set_show_table_title(show_table_title);
 
                 //Page Setup:
-                Glib::RefPtr<Gtk::PageSetup> page_setup;
                 const Glib::ustring key_file_text = get_child_text_node(node, GLOM_NODE_PAGE_SETUP);
-                if(!key_file_text.empty())
-                {
-                  Glib::KeyFile key_file;
-                  key_file.load_from_data(key_file_text);
-                  //TODO: Use this when gtkmm and GTK+ have been fixed: page_setup = Gtk::PageSetup::create(key_file);
-                  page_setup = Glib::wrap(gtk_page_setup_new_from_key_file(key_file.gobj(), NULL, NULL));
-                }
-                print_layout->set_page_setup(page_setup);
+                print_layout->set_page_setup(key_file_text);
 
                 //Layout Groups:
                 const xmlpp::Element* nodeGroups = get_node_child_named(node, GLOM_NODE_DATA_LAYOUT_GROUPS);
@@ -3418,14 +3411,11 @@
           set_node_attribute_value_as_bool(nodePrintLayout, GLOM_ATTRIBUTE_REPORT_SHOW_TABLE_TITLE, print_layout->get_show_table_title());
 
           //Page Setup:
-          Glib::RefPtr<const Gtk::PageSetup> page_setup =  print_layout->get_page_setup();
-          if(page_setup)
+          const std::string page_setup = print_layout->get_page_setup();
+          if(!page_setup.empty())
           {
-            Glib::KeyFile key_file;
-            page_setup->save_to_key_file(key_file);
-            
             xmlpp::Element* child = nodePrintLayout->add_child(GLOM_NODE_PAGE_SETUP);
-            child->add_child_text(key_file.to_data());
+            child->add_child_text(page_setup);
           }
 
           xmlpp::Element* nodeGroups = nodePrintLayout->add_child(GLOM_NODE_DATA_LAYOUT_GROUPS);

Modified: trunk/glom/libglom/python_embed/py_glom_relatedrecord.cc
==============================================================================
--- trunk/glom/libglom/python_embed/py_glom_relatedrecord.cc	(original)
+++ trunk/glom/libglom/python_embed/py_glom_relatedrecord.cc	Mon Mar 30 12:01:39 2009
@@ -248,7 +248,7 @@
             else if(!datamodel)
             {
               g_warning("RelatedRecord_tp_as_mapping_getitem(): The datamodel was null.");
-              ConnectionPool::handle_error(true /* cerr only */);
+              ConnectionPool::handle_error_cerr_only();
               RelatedRecord_HandlePythonError();
             }
             else
@@ -352,7 +352,7 @@
         else if(!datamodel)
         {
           g_warning("RelatedRecord_generic_aggregate(): The datamodel was null.");
-          ConnectionPool::handle_error(true /* cerr only */);
+          ConnectionPool::handle_error_cerr_only();
           RelatedRecord_HandlePythonError();
         }
         else

Modified: trunk/glom/libglom/spawn_with_feedback.cc
==============================================================================
--- trunk/glom/libglom/spawn_with_feedback.cc	(original)
+++ trunk/glom/libglom/spawn_with_feedback.cc	Mon Mar 30 12:01:39 2009
@@ -381,7 +381,7 @@
     sigc::bind(sigc::ptr_fun(&on_spawn_info_finished), sigc::ref(mainloop) ) );
 
   // Pulse two times a second:
-  Glib::signal_timeout().connect(
+  sigc::connection timeout_connection = Glib::signal_timeout().connect(
     sigc::bind_return( slot_progress, true),
     500);
   slot_progress(); //Make sure it is called at least once.
@@ -389,6 +389,9 @@
   //Block until signal_finished is called.
   mainloop->run();
 
+  //Stop the timeout callback:
+  timeout_connection.disconnect();
+  
   int return_status = false;
   const bool returned = Impl::spawn_async_end(info, NULL, NULL, &return_status);
   if(!returned)
@@ -522,11 +525,13 @@
   {
     //Sleep for a bit more, because I think that pg_ctl sometimes reports success too early.
     Glib::RefPtr<Glib::MainLoop> mainloop = Glib::MainLoop::create(false);
-    Glib::signal_timeout().connect(
+    sigc::connection connection_timeout = Glib::signal_timeout().connect(
      sigc::bind(sigc::ptr_fun(&on_timeout_delay), sigc::ref(mainloop)), 
      3000);
     mainloop->run();
 
+    connection_timeout.disconnect();
+    
     return true;
   }
   else

Modified: trunk/glom/libglom/utils.cc
==============================================================================
--- trunk/glom/libglom/utils.cc	(original)
+++ trunk/glom/libglom/utils.cc	Mon Mar 30 12:01:39 2009
@@ -26,7 +26,6 @@
 #include <libglom/data_structure/glomconversions.h>
 
 #include <glibmm/i18n.h>
-#include <gtkmm/messagedialog.h>
 
 #include <giomm.h>
 
@@ -47,51 +46,6 @@
 
 #include <stack>
 
-#ifdef GLOM_ENABLE_MAEMO
-//We use different spacings on Maemo because the screen is smaller:
-const unsigned int Glom::Utils::DEFAULT_SPACING_LARGE =  1;
-const unsigned int Glom::Utils::DEFAULT_SPACING_SMALL =  1;
-#else
-const unsigned int Glom::Utils::DEFAULT_SPACING_LARGE = 12;
-const unsigned int Glom::Utils::DEFAULT_SPACING_SMALL =  6;
-#endif //GLOM_ENABLE_MAEMO
-
-namespace
-{
-
-// Basically copied from libgnome (gnome-help.c, Copyright (C) 2001 Sid Vicious
-// Copyright (C) 2001 Jonathan Blandford <jrb alum mit edu>), but C++ified
-std::string locate_help_file(const std::string& path, const std::string& doc_name)
-{
-  // g_get_language_names seems not to be wrapped by glibmm
-  const char* const* lang_list = g_get_language_names ();
-
-  for(unsigned int j = 0; lang_list[j] != NULL; ++j)
-  {
-    const char* lang = lang_list[j];
-
-    /* This has to be a valid language AND a language with
-     * no encoding postfix.  The language will come up without
-     * encoding next. */
-    if(lang == NULL || strchr(lang, '.') != NULL)
-      continue;
-
-    const char* exts[] = { "", ".xml", ".docbook", ".sgml", ".html", NULL };
-    for(unsigned i = 0; exts[i] != NULL; ++i)
-    {
-      std::string name = doc_name + exts[i];
-      std::string full = Glib::build_filename(path, Glib::build_filename(lang, name));
-
-      if(Glib::file_test(full, Glib::FILE_TEST_EXISTS))
-        return full;
-    }
-  }
-
-  return std::string();
-}
-
-}
-
 namespace Glom
 {
 
@@ -816,130 +770,6 @@
   return str;
 }
 
-/* Run dialog and response on Help if appropriate */
-
-int Utils::dialog_run_with_help(Gtk::Dialog* dialog, const Glib::ustring& id)
-{
-  int result = dialog->run();
-  while (result == Gtk::RESPONSE_HELP)
-  {
-    show_help(id);
-    result = dialog->run();
-  }
-
-  dialog->hide();
-  return result;
-}
-
-/*
- * Help::show_help(const std::string& id)
- *
- * Launch a help browser with the glom help and load the given id if given
- * If the help cannot be found an error dialog will be shown
- */
-
-void Utils::show_help(const Glib::ustring& id)
-{
-  // TODO_maemo: Show help on maemo by some other means
-#ifndef GLOM_ENABLE_MAEMO
-  GError* err = 0;
-  const gchar* pId;
-  if(id.length())
-  {
-    pId = id.c_str();
-  }
-  else
-  {
-    pId = 0;
-  }
-
-  try
-  {
-    const char* path = DATADIR "/gnome/help/glom";
-    std::string help_file = locate_help_file(path, "glom.xml");
-    if(help_file.empty())
-    {
-      throw std::runtime_error(_("No help file available"));
-    }
-    else
-    {
-      std::string uri = "ghelp:" + help_file;
-      if(pId) { uri += "?"; uri += pId; }
-
-      // g_app_info_launch_default_for_uri seems not to be wrapped by giomm
-      if(!g_app_info_launch_default_for_uri(uri.c_str(), NULL, &err))
-      {
-        std::string message(err->message);
-        g_error_free(err);
-        throw std::runtime_error(message);
-      }
-    }
-  }
-  catch(const std::exception& ex)
-  {
-    const Glib::ustring message = _("Could not display help: ") + Glib::ustring(ex.what());
-    Gtk::MessageDialog dialog(message, false, Gtk::MESSAGE_ERROR);
-    dialog.run();
-  }
-#endif
-}
-
-void Utils::show_ok_dialog(const Glib::ustring& title, const Glib::ustring& message, Gtk::Window* parent, Gtk::MessageType message_type)
-{
-#ifdef GLOM_ENABLE_MAEMO
-  // TODO_maemo: Map message_type to a senseful stock_id?
-  Hildon::Note dialog(Hildon::NOTE_TYPE_INFORMATION, parent, message);
-#else
-  Gtk::MessageDialog dialog("<b>" + title + "</b>", true /* markup */, message_type, Gtk::BUTTONS_OK);
-  dialog.set_secondary_text(message);
-  if(parent)
-    dialog.set_transient_for(*parent);
-#endif
-
-  dialog.run();
-}
-
-void Utils::show_ok_dialog(const Glib::ustring& title, const Glib::ustring& message, Gtk::Window& parent, Gtk::MessageType message_type)
-{
-  show_ok_dialog(title, message, &parent, message_type);
-}
-
-namespace
-{
-
-static void on_window_hide(Glib::RefPtr<Glib::MainLoop> main_loop, sigc::connection handler_connection)
-{
-  handler_connection.disconnect(); //This should release a main_loop reference.
-  main_loop->quit();
-
-  //main_loop should be destroyed soon, because nothing else is using it.
-}
-
-} //anonymous namespace.
-
-void Utils::show_window_until_hide(Gtk::Window* window)
-{
-  if(!window)
-    return;
-
-  Glib::RefPtr<Glib::MainLoop> main_loop = Glib::MainLoop::create(false /* not running */);
-
-  //Stop the main_loop when the window is hidden:
-  sigc::connection handler_connection; //TODO: There seems to be a crash if this is on the same line.
-  handler_connection = window->signal_hide().connect( 
-    sigc::bind(
-      sigc::ptr_fun(&on_window_hide),
-      main_loop, handler_connection
-    ) );
-  
-  window->show();
-  main_loop->run(); //Run and block until it is stopped by the hide signal handler.
-}
-
-Glib::ustring Utils::bold_message(const Glib::ustring& message)
-{
-  return "<b>" + message + "</b>";
-}
 
 
 bool Utils::file_exists(const Glib::ustring& uri)

Modified: trunk/glom/libglom/utils.h
==============================================================================
--- trunk/glom/libglom/utils.h	(original)
+++ trunk/glom/libglom/utils.h	Mon Mar 30 12:01:39 2009
@@ -26,9 +26,6 @@
 
 #include <libglom/data_structure/layout/layoutitem_field.h>
 
-#include <gtkmm/dialog.h>
-#include <gtkmm/messagedialog.h>
-
 namespace Glom
 {
 
@@ -39,12 +36,6 @@
 namespace Utils
 {
 
-///A standard widget spacing:
-extern const unsigned int DEFAULT_SPACING_LARGE;
-
-///A standard widget spacing:
-extern const unsigned int DEFAULT_SPACING_SMALL;
-
 Glib::ustring trim_whitespace(const Glib::ustring& text);
 
 Glib::ustring string_replace(const Glib::ustring& src, const Glib::ustring search_for, const Glib::ustring& replace_with);
@@ -97,22 +88,6 @@
 
 Glib::ustring string_remove_suffix(const Glib::ustring& str, const Glib::ustring& suffix, bool case_sensitive = true);
 
-int dialog_run_with_help(Gtk::Dialog* dialog, const Glib::ustring& id = Glib::ustring());
-
-/** This is a replacement for gnome_help_display(), 
- * to avoid the libgnome dependency.
- * TODO: GTK+ should have a function for this soon.
- */
-void show_help(const Glib::ustring& id = Glib::ustring());
-
-void show_ok_dialog(const Glib::ustring& title, const Glib::ustring& message, Gtk::Window& parent, Gtk::MessageType message_type);
-void show_ok_dialog(const Glib::ustring& title, const Glib::ustring& message, Gtk::Window* parent, Gtk::MessageType message_type);
-
-void show_window_until_hide(Gtk::Window* window);
-
-/// For instance, to create bold primary text for a dialog box, without marking the markup for translation.
-Glib::ustring bold_message(const Glib::ustring& message);
-
 bool file_exists(const Glib::ustring& uri);
 
 } //namespace Utils

Modified: trunk/glom/main.cc
==============================================================================
--- trunk/glom/main.cc	(original)
+++ trunk/glom/main.cc	Mon Mar 30 12:01:39 2009
@@ -25,6 +25,7 @@
 
 //#include <gnome.h>
 #include <gtkmm/main.h>
+#include <gtkmm/messagedialog.h>
 #include <giomm.h>
 
 // For postgres availability checks:
@@ -46,10 +47,12 @@
 
 #ifdef GLOM_ENABLE_MAEMO
 #include <hildonmm/init.h>
+#include <hildonmm/note.h>
 #endif
 
-#include "application.h"
+#include <glom/application.h>
 #include <glom/glade_utils.h>
+#include <glom/utils_ui.h>
 
 #ifndef G_OS_WIN32
 #include <fontconfig/fontconfig.h> //For cleanup.
@@ -98,6 +101,107 @@
   add_entry(entry_version, m_arg_debug_sql);
 }
 
+#ifdef GLOM_ENABLE_POSTGRESQL
+bool check_user_is_not_root()
+{
+  Glib::ustring message;
+#ifdef G_OS_WIN32
+  try
+  {
+    if(pgwin32_is_admin())
+    {
+      message = _("You seem to be running Glom as a user with administrator privileges. Glom may not be run with such privileges for security reasons.\nPlease login to your system as a normal user.");
+    }
+  }
+  catch(const std::runtime_error& ex)
+  {
+    message = ex.what();
+  }
+#else
+  //std::cout << "ConnectionPool::check_user_is_not_root(): geteuid()=" << geteuid() << ", getgid()=" << getgid() << std::endl;
+
+  //This is very linux-specific. We should ifdef this out for other platforms.
+  if(geteuid() == 0)
+  {
+    //Warn the user:
+    message = _("You seem to be running Glom as root. Glom may not be run as root.\nPlease login to your system as a normal user.");
+  }
+#endif
+
+  if(!message.empty())
+  {
+#ifndef GLOM_ENABLE_MAEMO
+    Gtk::MessageDialog dialog(Utils::bold_message(_("Running As Root")), true /* use_markup */, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true /* modal */);
+    dialog.set_secondary_text(message);
+    dialog.run();
+#else
+    Hildon::Note note(Hildon::NOTE_TYPE_INFORMATION, message);
+    note.run();
+#endif
+
+    return false; /* Is root. Bad. */
+  }
+
+  return true; /* Not root. It's OK. */
+}
+
+#ifndef GLOM_ENABLE_CLIENT_ONLY
+// Message to packagers:
+// If your Glom package does not depend on PostgreSQL, for some reason, 
+// then your distro-specific patch should uncomment this #define.
+// and implement ConnectionPool::install_posgres().
+// But please, just make your Glom package depend on PostgreSQL instead, 
+// because this is silly.
+//
+//#define DISTRO_SPECIFIC_POSTGRES_INSTALL_IMPLEMENTED 1
+
+/** Check whether PostgreSQL is really available for self-hosting,
+ * in case the distro package has incorrect dependencies.
+ *
+ * @results True if everything is OK.
+ */
+bool check_postgres_is_available_with_warning()
+{
+  const std::string binpath = Glom::ConnectionPoolBackends::PostgresSelfHosted::get_path_to_postgres_executable("postgres");
+
+  // TODO: At least on Windows we should probably also check for initdb and
+  // pg_ctl. Perhaps it would also be a good idea to access these files as
+  // long as glom runs so they cannot be (re)moved.
+  if(!binpath.empty())
+  {
+    const Glib::ustring uri_binpath = Glib::filename_to_uri(binpath);
+    if(Utils::file_exists(uri_binpath))
+      return true;
+  }
+
+  #ifdef DISTRO_SPECIFIC_POSTGRES_INSTALL_IMPLEMENTED
+
+  //Show message to the user about the broken installation:
+  //This is a packaging bug, but it would probably annoy packagers to mention that in the dialog:
+  Gtk::MessageDialog dialog(Utils::bold_message(_("Incomplete Glom Installation")), true /* use_markup */, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_NONE, true /* modal */);
+  dialog.set_secondary_text(_("Your installation of Glom is not complete, because PostgreSQL is not available on your system. PostgreSQL is needed for self-hosting of Glom databases.\n\nYou may now install PostgreSQL to complete the Glom installation."));
+  dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
+  dialog.add_button(_("Install PostgreSQL"), Gtk::RESPONSE_OK);
+  const int response = dialog.run();
+  if(response != Gtk::RESPONSE_OK)
+    return false; //Failure. Glom should now quit.
+  else
+    return install_postgres(&dialog);
+
+  #else  //DISTRO_SPECIFIC_POSTGRES_INSTALL_IMPLEMENTED
+
+  //Show message to the user about the broken installation:
+  Gtk::MessageDialog dialog(Utils::bold_message(_("Incomplete Glom Installation")), true /* use_markup */, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true /* modal */);
+  dialog.set_secondary_text(_("Your installation of Glom is not complete, because PostgreSQL is not available on your system. PostgreSQL is needed for self-hosting of Glom databases.\n\nPlease report this bug to your vendor, or your system administrator so it can be corrected."));
+  dialog.run();
+  return false;
+
+  #endif //DISTRO_SPECIFIC_POSTGRES_INSTALL_IMPLEMENTED
+}
+#endif //GLOM_ENABLE_CLIENT_ONLY
+
+#endif //GLOM_ENABLE_POSTGRESQL
+
 } //namespace Glom
 
 #ifndef G_OS_WIN32
@@ -256,22 +360,35 @@
     //input_uri = "file:///home/murrayc/cvs/gnome212/glom/examples/example_smallbusiness.glom";
 
 #ifdef GLOM_ENABLE_POSTGRESQL
-    bool install_complete = false;
-#ifndef GLOM_ENABLE_CLIENT_ONLY
-    //Check that PostgreSQL is really available:
-    install_complete = Glom::ConnectionPoolBackends::PostgresSelfHosted::check_postgres_is_available_with_warning();
-    if(!install_complete)
-      return -1; //There is no point in going further because the most useful Glom functionality will not work without Postgres. Only a very cut-down Glom client would be useful without self-hosting.
-#endif // !GLOM_ENABLE_CLIENT_ONLY
 
     //Check that the libgda postgres provider is really available:
-    install_complete = Glom::ConnectionPoolBackends::Postgres::check_postgres_gda_client_is_available_with_warning();
+    bool install_complete = Glom::ConnectionPoolBackends::Postgres::check_postgres_gda_client_is_available();
     if(!install_complete)
+    {
+      /* The Postgres provider was not found, so warn the user: */
+      const Glib::ustring message = _("Your installation of Glom is not complete, because the PostgreSQL libgda provider is not available on your system. This provider is needed to access Postgres database servers.\n\nPlease report this bug to your vendor, or your system administrator so it can be corrected.");
+      
+      #ifndef GLOM_ENABLE_MAEMO
+      Gtk::MessageDialog dialog(Glom::Utils::bold_message(_("Incomplete Glom Installation")), true /* use_markup */, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true /* modal */);
+      dialog.set_secondary_text(message);
+      dialog.run();
+      #else
+      Hildon::Note note(Hildon::NOTE_TYPE_INFORMATION, message);
+      note.run();
+      #endif
+      
       return -1; //There is no point in going further because Glom would not be able to connect to any Postgres servers.
+    }
 
+    #ifndef GLOM_ENABLE_CLIENT_ONLY
+    //Check that the postgres executable is really available:
+    if(!Glom::check_postgres_is_available_with_warning())
+      return -1; //There is no point in going further because the most useful Glom functionality will not work without Postgres. Only a very cut-down Glom client would be useful without self-hosting.
+    #endif // !GLOM_ENABLE_CLIENT_ONLY
+      
     // Postgres can't be started as root. initdb complains.
     // So just prevent this in general. It is safer anyway.
-    if(!Glom::ConnectionPool::check_user_is_not_root())
+    if(!Glom::check_user_is_not_root())
       return -1;
 #endif //GLOM_ENABLE_POSTGRESQL
 

Modified: trunk/glom/mode_data/box_data.cc
==============================================================================
--- trunk/glom/mode_data/box_data.cc	(original)
+++ trunk/glom/mode_data/box_data.cc	Mon Mar 30 12:01:39 2009
@@ -22,7 +22,7 @@
 
 #include "box_data.h"
 #include <libglom/data_structure/glomconversions.h>
-#include <libglom/utils.h>
+#include <glom/utils_ui.h>
 #include <libglom/data_structure/layout/layoutitem_field.h>
 #include <glom/glom_privs.h>
 #include "../python_embed/glom_python.h"

Modified: trunk/glom/mode_data/box_data_calendar_related.cc
==============================================================================
--- trunk/glom/mode_data/box_data_calendar_related.cc	(original)
+++ trunk/glom/mode_data/box_data_calendar_related.cc	Mon Mar 30 12:01:39 2009
@@ -18,8 +18,9 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include "box_data_calendar_related.h"
-#include "dialog_layout_calendar_related.h"
+#include <glom/mode_data/box_data_calendar_related.h>
+#include <glom/mode_data/dialog_layout_calendar_related.h>
+#include <glom/utils_ui.h>
 #include <glom/application.h>
 #include <libglom/data_structure/glomconversions.h>
 #include <glom/frame_glom.h> //For show_ok_dialog()

Modified: trunk/glom/mode_data/box_data_details.cc
==============================================================================
--- trunk/glom/mode_data/box_data_details.cc	(original)
+++ trunk/glom/mode_data/box_data_details.cc	Mon Mar 30 12:01:39 2009
@@ -18,17 +18,17 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include "box_data_details.h"
-#include "../frame_glom.h" //For show_ok_dialog().
+#include <glom/mode_data/box_data_details.h>
+#include <glom/frame_glom.h> //For show_ok_dialog().
 #include <libglom/data_structure/field.h>
 #include <libglom/data_structure/relationship.h>
 #include <libglom/data_structure/glomconversions.h>
-#include "dialog_layout_details.h"
+#include <glom/mode_data/dialog_layout_details.h>
 #include <glom/glade_utils.h>
-#include <libglom/utils.h>
+#include <glom/utils_ui.h>
 #include <glom/glom_privs.h>
-#include "../xsl_utils.h"
-#include "../python_embed/glom_python.h"
+#include <glom/xsl_utils.h>
+#include <glom/python_embed/glom_python.h>
 #include <sstream> //For stringstream
 #include <glibmm/i18n.h>
 

Modified: trunk/glom/mode_data/box_data_list_related.cc
==============================================================================
--- trunk/glom/mode_data/box_data_list_related.cc	(original)
+++ trunk/glom/mode_data/box_data_list_related.cc	Mon Mar 30 12:01:39 2009
@@ -19,11 +19,11 @@
  */
 
 #include <glom/mode_data/box_data_list_related.h>
-#include "dialog_layout_list_related.h"
+#include <glom/mode_data/dialog_layout_list_related.h>
 #include <libglom/data_structure/glomconversions.h>
 #include <glom/glade_utils.h>
 #include <glom/frame_glom.h> //For show_ok_dialog()
-#include <libglom/utils.h> //For bold_message()).
+#include <glom/utils_ui.h> //For bold_message()).
 #include <glibmm/i18n.h>
 
 namespace Glom

Modified: trunk/glom/mode_data/box_data_portal.cc
==============================================================================
--- trunk/glom/mode_data/box_data_portal.cc	(original)
+++ trunk/glom/mode_data/box_data_portal.cc	Mon Mar 30 12:01:39 2009
@@ -18,11 +18,11 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include "box_data_portal.h"
+#include <glom/mode_data/box_data_portal.h>
 #include <libglom/data_structure/glomconversions.h>
 #include <glom/glade_utils.h>
 #include <glom/frame_glom.h> //For show_ok_dialog()
-#include <libglom/utils.h> //For bold_message()).
+#include <glom/utils_ui.h> //For bold_message()).
 #include <glibmm/i18n.h>
 
 namespace Glom

Modified: trunk/glom/mode_data/dialog_layout_details.cc
==============================================================================
--- trunk/glom/mode_data/dialog_layout_details.cc	(original)
+++ trunk/glom/mode_data/dialog_layout_details.cc	Mon Mar 30 12:01:39 2009
@@ -18,14 +18,14 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include "dialog_layout_details.h"
-#include "dialog_choose_relationship.h"
-#include "../layout_item_dialogs/dialog_buttonscript.h"
-#include "../layout_item_dialogs/dialog_notebook.h"
+#include <glom/mode_data/dialog_layout_details.h>
+#include <glom/mode_data/dialog_choose_relationship.h>
+#include <glom/layout_item_dialogs/dialog_buttonscript.h>
+#include <glom/layout_item_dialogs/dialog_notebook.h>
 #include <glom/glade_utils.h>
-#include "../frame_glom.h" //For show_ok_dialog()
+#include <glom/frame_glom.h> //For show_ok_dialog()
 //#include <libgnome/gnome-i18n.h>
-#include <libglom/utils.h> //For bold_message()).
+#include <glom/utils_ui.h> //For bold_message()).
 #include <glibmm/i18n.h>
 #include <sstream> //For stringstream
 
@@ -555,7 +555,7 @@
     {
       dialog->set_script(button, m_table_name);
       dialog->set_transient_for(*this);
-      int response = Glom::Utils::dialog_run_with_help(dialog, "window_button_script");
+      const int response = Glom::Utils::dialog_run_with_help(dialog, "window_button_script");
       dialog->hide();
       if(response == Gtk::RESPONSE_OK)
       {

Modified: trunk/glom/mode_data/flowtablewithfields.cc
==============================================================================
--- trunk/glom/mode_data/flowtablewithfields.cc	(original)
+++ trunk/glom/mode_data/flowtablewithfields.cc	Mon Mar 30 12:01:39 2009
@@ -32,11 +32,11 @@
 #include <libglom/data_structure/glomconversions.h>
 #include <glom/glade_utils.h>
 #include <glom/mode_data/box_data_list_related.h>
-#include "dialog_choose_relationship.h"
-#include <libglom/utils.h> //For bold_message()).
-#include <glibmm/i18n.h>
+#include <glom/mode_data/dialog_choose_relationship.h>
+#include <glom/utils_ui.h> //For bold_message()).
 #include <libglom/data_structure/layout/layoutitem_placeholder.h>
 #include <glom/signal_reemitter.h>
+#include <glibmm/i18n.h>
 
 namespace Glom
 {

Modified: trunk/glom/mode_design/dialog_fields.cc
==============================================================================
--- trunk/glom/mode_design/dialog_fields.cc	(original)
+++ trunk/glom/mode_design/dialog_fields.cc	Mon Mar 30 12:01:39 2009
@@ -21,7 +21,7 @@
 #include "dialog_fields.h"
 #include "../box_db_table.h"
 //#include <libgnome/gnome-i18n.h>
-#include <libglom/utils.h> //For bold_message()).
+#include <glom/utils_ui.h> //For bold_message()).
 #include <glibmm/i18n.h>
 
 namespace Glom

Modified: trunk/glom/mode_design/dialog_relationships.cc
==============================================================================
--- trunk/glom/mode_design/dialog_relationships.cc	(original)
+++ trunk/glom/mode_design/dialog_relationships.cc	Mon Mar 30 12:01:39 2009
@@ -21,7 +21,7 @@
 #include "dialog_relationships.h"
 #include "../box_db_table.h"
 //#include <libgnome/gnome-i18n.h>
-#include <libglom/utils.h> //For bold_message()).
+#include <glom/utils_ui.h> //For bold_message()).
 #include <glibmm/i18n.h>
 
 namespace Glom

Modified: trunk/glom/mode_design/fields/box_db_table_definition.cc
==============================================================================
--- trunk/glom/mode_design/fields/box_db_table_definition.cc	(original)
+++ trunk/glom/mode_design/fields/box_db_table_definition.cc	Mon Mar 30 12:01:39 2009
@@ -21,7 +21,7 @@
 #include "box_db_table_definition.h"
 #include <glom/frame_glom.h>
 #include <glom/glade_utils.h>
-#include <libglom/utils.h> //For bold_message()).
+#include <glom/utils_ui.h> //For bold_message()).
 #include <libglom/libglom_config.h>
 #include <glibmm/i18n.h>
 

Modified: trunk/glom/mode_design/fields/dialog_fielddefinition.cc
==============================================================================
--- trunk/glom/mode_design/fields/dialog_fielddefinition.cc	(original)
+++ trunk/glom/mode_design/fields/dialog_fielddefinition.cc	Mon Mar 30 12:01:39 2009
@@ -21,6 +21,7 @@
 #include "dialog_fielddefinition.h"
 #include "dialog_fieldcalculation.h"
 #include <glom/glade_utils.h>
+#include <glom/utils_ui.h>
 #include "../../box_db_table.h"
 //#include <libgnome/gnome-i18n.h>
 #include <glibmm/i18n.h>
@@ -384,7 +385,7 @@
       m_Field->set_calculation( m_pTextView_Calculation->get_buffer()->get_text() );
       dialog->set_field(m_Field, m_table_name);
       //TODO: dialog.set_transient_for(*get_app_window());
-      int response = Glom::Utils::dialog_run_with_help(dialog, "window_field_calculation");
+      const int response = Glom::Utils::dialog_run_with_help(dialog, "window_field_calculation");
       if(response == Gtk::RESPONSE_OK)
       {
         m_pTextView_Calculation->get_buffer()->set_text( dialog->get_field()->get_calculation() );

Modified: trunk/glom/mode_design/print_layouts/canvas_layout_item.cc
==============================================================================
--- trunk/glom/mode_design/print_layouts/canvas_layout_item.cc	(original)
+++ trunk/glom/mode_design/print_layouts/canvas_layout_item.cc	Mon Mar 30 12:01:39 2009
@@ -193,7 +193,7 @@
     if(image)
     {
       Glib::RefPtr<CanvasImageMovable> canvas_item = CanvasImageMovable::create();
-      Glib::RefPtr<Gdk::Pixbuf> pixbuf = image->get_image_as_pixbuf();
+      Glib::RefPtr<Gdk::Pixbuf> pixbuf = Conversions::get_pixbuf_for_gda_value(image->m_image);
       if(pixbuf)
         canvas_item->set_image(pixbuf);
       else

Modified: trunk/glom/mode_design/print_layouts/canvas_print_layout.cc
==============================================================================
--- trunk/glom/mode_design/print_layouts/canvas_print_layout.cc	(original)
+++ trunk/glom/mode_design/print_layouts/canvas_print_layout.cc	Mon Mar 30 12:01:39 2009
@@ -20,7 +20,7 @@
  */
 
 #include "canvas_print_layout.h"
-#include <libglom/utils.h> //For bold_message()).
+#include <glom/utils_ui.h> //For bold_message()).
 #include <gtkmm/stock.h>
 #include <glom/mode_design/print_layouts/dialog_text_formatting.h>
 #include <glom/mode_data/dialog_layout_list_related.h>
@@ -79,8 +79,14 @@
   add_layout_group(print_layout->m_layout_group, true /* is top-level */);
 
   Glib::RefPtr<Gtk::PageSetup> page_setup;
-  if(print_layout->get_page_setup())
-    page_setup = print_layout->get_page_setup()->copy();
+  const Glib::ustring key_file_text = print_layout->get_page_setup();
+  if(!key_file_text.empty())
+  {
+    Glib::KeyFile key_file;
+    key_file.load_from_data(key_file_text);
+    //TODO: Use this when gtkmm and GTK+ have been fixed: page_setup = Gtk::PageSetup::create(key_file);
+    page_setup = Glib::wrap(gtk_page_setup_new_from_key_file(key_file.gobj(), NULL, NULL));
+  }
 
   set_page_setup(page_setup);
 
@@ -91,7 +97,12 @@
 {
   sharedptr<PrintLayout> result = sharedptr<PrintLayout>::create();
   fill_layout_group(result->m_layout_group);
-  result->set_page_setup(m_page_setup);
+
+  //Page Setup:
+  Glib::KeyFile key_file;
+  m_page_setup->save_to_key_file(key_file);
+  result->set_page_setup(key_file.to_data());
+
   return result;
 }
 

Modified: trunk/glom/mode_design/script_library/dialog_script_library.cc
==============================================================================
--- trunk/glom/mode_design/script_library/dialog_script_library.cc	(original)
+++ trunk/glom/mode_design/script_library/dialog_script_library.cc	Mon Mar 30 12:01:39 2009
@@ -23,6 +23,7 @@
 #include "../../python_embed/glom_python.h"
 #include <libglom/data_structure/glomconversions.h>
 #include <glom/glade_utils.h>
+#include <glom/utils_ui.h>
 #include <glom/mode_design/script_library/dialog_new_script.h>
 #include <gtksourceviewmm/sourcelanguagemanager.h>
 #include <glom/application.h>

Modified: trunk/glom/mode_design/users/dialog_groups_list.cc
==============================================================================
--- trunk/glom/mode_design/users/dialog_groups_list.cc	(original)
+++ trunk/glom/mode_design/users/dialog_groups_list.cc	Mon Mar 30 12:01:39 2009
@@ -26,7 +26,7 @@
 #include <glom/glade_utils.h>
 #include <glom/glom_privs.h>
 //#include <libgnome/gnome-i18n.h>
-#include <libglom/utils.h> //For bold_message()).
+#include <glom/utils_ui.h> //For bold_message()).
 #include <glibmm/i18n.h>
 
 namespace Glom

Modified: trunk/glom/mode_design/users/dialog_users_list.cc
==============================================================================
--- trunk/glom/mode_design/users/dialog_users_list.cc	(original)
+++ trunk/glom/mode_design/users/dialog_users_list.cc	Mon Mar 30 12:01:39 2009
@@ -23,7 +23,7 @@
 #include "dialog_choose_user.h"
 #include <glom/glom_privs.h>
 #include <glom/glade_utils.h>
-#include <libglom/utils.h> //For bold_message()).
+#include <glom/utils_ui.h> //For bold_message()).
 //#include <libgnome/gnome-i18n.h>
 #include <glibmm/i18n.h>
 

Modified: trunk/glom/mode_find/box_data_list_find.cc
==============================================================================
--- trunk/glom/mode_find/box_data_list_find.cc	(original)
+++ trunk/glom/mode_find/box_data_list_find.cc	Mon Mar 30 12:01:39 2009
@@ -18,7 +18,8 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include "box_data_list_find.h"
+#include <glom/mode_find/box_data_list_find.h>
+#include <glom/utils_ui.h>
 #include <glibmm/i18n.h>
 
 namespace Glom

Modified: trunk/glom/navigation/box_tables.cc
==============================================================================
--- trunk/glom/navigation/box_tables.cc	(original)
+++ trunk/glom/navigation/box_tables.cc	Mon Mar 30 12:01:39 2009
@@ -18,8 +18,8 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include "box_tables.h"
-#include <libglom/utils.h> //For bold_message()).
+#include <glom/navigation/box_tables.h>
+#include <glom/utils_ui.h> //For bold_message()).
 #include <glom/application.h>
 #include <glibmm/i18n.h>
 

Modified: trunk/glom/python_embed/glom_python.cc
==============================================================================
--- trunk/glom/python_embed/glom_python.cc	(original)
+++ trunk/glom/python_embed/glom_python.cc	Mon Mar 30 12:01:39 2009
@@ -296,8 +296,7 @@
         //Deal with the various possible return types:
         bool object_is_gda_value = false;
 
-        GValue value;
-        memset(&value, 0, sizeof(GValue));
+        GValue value = {0, {{0}}};
         const int test = pygda_value_from_pyobject(&value, pyResult);
 
         if(test == 0) //-1 means error.

Modified: trunk/glom/translation/dialog_identify_original.cc
==============================================================================
--- trunk/glom/translation/dialog_identify_original.cc	(original)
+++ trunk/glom/translation/dialog_identify_original.cc	Mon Mar 30 12:01:39 2009
@@ -20,7 +20,7 @@
 
 #include "dialog_identify_original.h"
 #include <libglom/data_structure/iso_codes.h>
-#include <libglom/utils.h> //For bold_message()).
+#include <glom/utils_ui.h> //For bold_message()).
 #include <glibmm/i18n.h>
 
 namespace Glom

Modified: trunk/glom/translation/window_translations.cc
==============================================================================
--- trunk/glom/translation/window_translations.cc	(original)
+++ trunk/glom/translation/window_translations.cc	Mon Mar 30 12:01:39 2009
@@ -22,7 +22,7 @@
 #include "combobox_locale.h"
 #include "dialog_identify_original.h"
 #include "dialog_copy_translation.h"
-#include <libglom/utils.h> //For bold_message()).
+#include <glom/utils_ui.h> //For bold_message()).
 #include <libglom/utils.h>
 #include <glom/glade_utils.h>
 

Modified: trunk/glom/utility_widgets/adddel/adddel.cc
==============================================================================
--- trunk/glom/utility_widgets/adddel/adddel.cc	(original)
+++ trunk/glom/utility_widgets/adddel/adddel.cc	Mon Mar 30 12:01:39 2009
@@ -20,13 +20,14 @@
 
 #include <libglom/libglom_config.h> // For GLOM_ENABLE_MAEMO
 
-#include "adddel.h"
+#include <glom/utility_widgets/adddel/adddel.h>
 #include <algorithm> //For std::find.
 #include <glibmm/i18n.h>
-#include "../cellrendererlist/cellrendererlist.h"
-#include "treeviewcolumn_glom.h"
+#include <glom/utility_widgets/cellrendererlist/cellrendererlist.h>
+#include <glom/utility_widgets/adddel/treeviewcolumn_glom.h>
 #include <libglom/data_structure/glomconversions.h>
-#include "../../dialog_invalid_data.h"
+#include <glom/dialog_invalid_data.h>
+#include <glom/utils_ui.h>
 #include <libglom/utils.h>
 //#include <glom/bakery/app_gtk.h>
 #include <iostream> //For debug output.

Modified: trunk/glom/utility_widgets/adddel/adddel_withbuttons.cc
==============================================================================
--- trunk/glom/utility_widgets/adddel/adddel_withbuttons.cc	(original)
+++ trunk/glom/utility_widgets/adddel/adddel_withbuttons.cc	Mon Mar 30 12:01:39 2009
@@ -18,8 +18,9 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include <libglom/utils.h>
 #include "adddel_withbuttons.h"
+#include <glom/utils_ui.h>
+
 //#include <libgnome/gnome-i18n.h>
 
 namespace Glom

Modified: trunk/glom/utility_widgets/adddel/eggcolumnchooser/eggcolumnchooserdialog.c
==============================================================================
--- trunk/glom/utility_widgets/adddel/eggcolumnchooser/eggcolumnchooserdialog.c	(original)
+++ trunk/glom/utility_widgets/adddel/eggcolumnchooser/eggcolumnchooserdialog.c	Mon Mar 30 12:01:39 2009
@@ -108,7 +108,7 @@
 {
 	GtkTreePath *path;
 	GtkTreeIter iter;
-	GValue value = { 0, 0 };
+	GValue value = {0, {{0}}};
 	GtkTreeModel *model = GTK_TREE_MODEL (dialog->column_model);
 	
 	path = gtk_tree_path_new_from_string (path_str);

Modified: trunk/glom/utility_widgets/buttonglom.cc
==============================================================================
--- trunk/glom/utility_widgets/buttonglom.cc	(original)
+++ trunk/glom/utility_widgets/buttonglom.cc	Mon Mar 30 12:01:39 2009
@@ -18,11 +18,12 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include "buttonglom.h"
+#include <glom/utility_widgets/buttonglom.h>
 #include <gtkmm/messagedialog.h>
 #include <glom/application.h>
 #include <glom/glade_utils.h>
 #include <glom/utility_widgets/dialog_layoutitem_properties.h>
+#include <glom/utils_ui.h>
 #ifndef GLOM_ENABLE_CLIENT_ONLY
 #include <glom/layout_item_dialogs/dialog_buttonscript.h>
 #endif

Modified: trunk/glom/utility_widgets/datawidget.cc
==============================================================================
--- trunk/glom/utility_widgets/datawidget.cc	(original)
+++ trunk/glom/utility_widgets/datawidget.cc	Mon Mar 30 12:01:39 2009
@@ -32,7 +32,7 @@
 #include "dialog_choose_id.h"
 #include "dialog_choose_date.h"
 #include "../layout_item_dialogs/dialog_field_layout.h"
-#include <libglom/utils.h>
+#include <glom/utils_ui.h>
 #include <glom/glade_utils.h>
 #include <glibmm/i18n.h>
 

Modified: trunk/glom/utility_widgets/db_adddel/db_adddel.cc
==============================================================================
--- trunk/glom/utility_widgets/db_adddel/db_adddel.cc	(original)
+++ trunk/glom/utility_widgets/db_adddel/db_adddel.cc	Mon Mar 30 12:01:39 2009
@@ -24,13 +24,13 @@
 #include "../cellrendererlist/cellrendererlist.h"
 #include "db_treeviewcolumn_glom.h"
 #include <libglom/data_structure/glomconversions.h>
-#include "../../dialog_invalid_data.h"
-#include "../../application.h"
-#include <libglom/utils.h>
+#include <glom/dialog_invalid_data.h>
+#include <glom/application.h>
+#include <glom/utils_ui.h>
 #include "cellrenderer_buttonimage.h"
 #include "cellrenderer_buttontext.h"
 #include <glom/utility_widgets/imageglom.h> //For ImageGlom::scale_keeping_ratio().
-//#include "../cellrendererlist.h"
+
 #include <iostream> //For debug output.
 #include <gtk/gtktreeview.h>
 #include <gtk/gtkstock.h>
@@ -648,7 +648,7 @@
      {
        Gtk::CellRendererPixbuf* pixbuf_renderer = Gtk::manage( new Gtk::CellRendererPixbuf() );
 
-       Glib::RefPtr<Gdk::Pixbuf> pixbuf = item_image->get_image_as_pixbuf();
+       Glib::RefPtr<Gdk::Pixbuf> pixbuf = Conversions::get_pixbuf_for_gda_value(item_image->m_image);
        if(pixbuf)
          pixbuf_renderer->set_property("pixbuf", pixbuf);
        else

Modified: trunk/glom/utility_widgets/db_adddel/db_adddel_withbuttons.cc
==============================================================================
--- trunk/glom/utility_widgets/db_adddel/db_adddel_withbuttons.cc	(original)
+++ trunk/glom/utility_widgets/db_adddel/db_adddel_withbuttons.cc	Mon Mar 30 12:01:39 2009
@@ -19,7 +19,7 @@
  */
 
 #include "db_adddel_withbuttons.h"
-//#include <libgnome/gnome-i18n.h>
+#include <glom/utils_ui.h>
 
 namespace Glom
 {
@@ -31,9 +31,6 @@
   m_Button_Edit(Gtk::Stock::OPEN)
 {
   m_HBox.set_spacing(Utils::DEFAULT_SPACING_SMALL);
-  //m_Button_Add.set_border_width(Utils::DEFAULT_SPACING_SMALL);
-  //m_Button_Del.set_border_width(Utils::DEFAULT_SPACING_SMALL);
-  //m_Button_Edit.set_border_width(Utils::DEFAULT_SPACING_SMALL);
 
   setup_buttons();
   pack_start(m_HBox, Gtk::PACK_SHRINK);

Modified: trunk/glom/utility_widgets/db_adddel/glom_db_treemodel.cc
==============================================================================
--- trunk/glom/utility_widgets/db_adddel/glom_db_treemodel.cc	(original)
+++ trunk/glom/utility_widgets/db_adddel/glom_db_treemodel.cc	Mon Mar 30 12:01:39 2009
@@ -563,7 +563,7 @@
       m_data_model_columns_count = m_columns_count;
 
       std::cerr << "DbTreeModel::refresh_from_database(): error executing SQL: " << sql_query << std::endl;
-      ConnectionPool::handle_error();
+      ConnectionPool::handle_error_cerr_only();
       return false; //No records were found.
     }
     else

Modified: trunk/glom/utility_widgets/dialog_choose_id.cc
==============================================================================
--- trunk/glom/utility_widgets/dialog_choose_id.cc	(original)
+++ trunk/glom/utility_widgets/dialog_choose_id.cc	Mon Mar 30 12:01:39 2009
@@ -21,7 +21,7 @@
 #include <libglom/libglom_config.h> // For GLOM_ENABLE_MAEMO
 
 #include "dialog_choose_id.h"
-#include <libglom/utils.h> //For bold_message()).
+#include <glom/utils_ui.h> //For bold_message()).
 //#include <libgnome/gnome-i18n.h>
 #include <glibmm/i18n.h>
 

Modified: trunk/glom/utility_widgets/filechooserdialog_saveextras.cc
==============================================================================
--- trunk/glom/utility_widgets/filechooserdialog_saveextras.cc	(original)
+++ trunk/glom/utility_widgets/filechooserdialog_saveextras.cc	Mon Mar 30 12:01:39 2009
@@ -19,7 +19,7 @@
  */
 
 #include <glom/utility_widgets/filechooserdialog_saveextras.h>
-#include <libglom/utils.h>
+#include <glom/utils_ui.h>
 #include <gtkmm/alignment.h>
 #include <libglom/utils.h> //For bold_message()).
 #include <glibmm/i18n.h>

Added: trunk/glom/utils_ui.cc
==============================================================================
--- (empty file)
+++ trunk/glom/utils_ui.cc	Mon Mar 30 12:01:39 2009
@@ -0,0 +1,215 @@
+/* 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 <config.h> // For GLOM_ENABLE_MAEMO
+
+#include <glom/utils_ui.h>
+#include <libglom/connectionpool.h>
+#include <libglom/data_structure/layout/report_parts/layoutitem_fieldsummary.h>
+#include <libglom/data_structure/glomconversions.h>
+
+#include <glibmm/i18n.h>
+#include <gtkmm/messagedialog.h>
+
+#include <giomm.h>
+
+#ifdef GLOM_ENABLE_MAEMO
+#include <hildonmm/note.h>
+#endif
+
+#include <string.h> // for strchr
+#include <sstream> //For stringstream
+
+#include <iostream>
+#include <fstream>
+
+#include <locale>     // for locale, time_put
+#include <ctime>     // for struct tm
+#include <iostream>   // for cout, endl
+#include <iomanip>
+
+#include <stack>
+
+namespace
+{
+
+// Basically copied from libgnome (gnome-help.c, Copyright (C) 2001 Sid Vicious
+// Copyright (C) 2001 Jonathan Blandford <jrb alum mit edu>), but C++ified
+std::string locate_help_file(const std::string& path, const std::string& doc_name)
+{
+  // g_get_language_names seems not to be wrapped by glibmm
+  const char* const* lang_list = g_get_language_names ();
+
+  for(unsigned int j = 0; lang_list[j] != NULL; ++j)
+  {
+    const char* lang = lang_list[j];
+
+    /* This has to be a valid language AND a language with
+     * no encoding postfix.  The language will come up without
+     * encoding next. */
+    if(lang == NULL || strchr(lang, '.') != NULL)
+      continue;
+
+    const char* exts[] = { "", ".xml", ".docbook", ".sgml", ".html", NULL };
+    for(unsigned i = 0; exts[i] != NULL; ++i)
+    {
+      std::string name = doc_name + exts[i];
+      std::string full = Glib::build_filename(path, Glib::build_filename(lang, name));
+
+      if(Glib::file_test(full, Glib::FILE_TEST_EXISTS))
+        return full;
+    }
+  }
+
+  return std::string();
+}
+
+} //anonymous namespace
+
+namespace Glom
+{
+
+/* Run dialog and response on Help if appropriate */
+
+int Utils::dialog_run_with_help(Gtk::Dialog* dialog, const Glib::ustring& id)
+{
+  int result = dialog->run();
+  while (result == Gtk::RESPONSE_HELP)
+  {
+    show_help(id);
+    result = dialog->run();
+  }
+
+  dialog->hide();
+  return result;
+}
+
+/*
+ * Help::show_help(const std::string& id)
+ *
+ * Launch a help browser with the glom help and load the given id if given
+ * If the help cannot be found an error dialog will be shown
+ */
+
+void Utils::show_help(const Glib::ustring& id)
+{
+  // TODO_maemo: Show help on maemo by some other means
+#ifndef GLOM_ENABLE_MAEMO
+  GError* err = 0;
+  const gchar* pId;
+  if(id.length())
+  {
+    pId = id.c_str();
+  }
+  else
+  {
+    pId = 0;
+  }
+
+  try
+  {
+    const char* path = DATADIR "/gnome/help/glom";
+    std::string help_file = locate_help_file(path, "glom.xml");
+    if(help_file.empty())
+    {
+      throw std::runtime_error(_("No help file available"));
+    }
+    else
+    {
+      std::string uri = "ghelp:" + help_file;
+      if(pId) { uri += "?"; uri += pId; }
+
+      // g_app_info_launch_default_for_uri seems not to be wrapped by giomm
+      if(!g_app_info_launch_default_for_uri(uri.c_str(), NULL, &err))
+      {
+        std::string message(err->message);
+        g_error_free(err);
+        throw std::runtime_error(message);
+      }
+    }
+  }
+  catch(const std::exception& ex)
+  {
+    const Glib::ustring message = _("Could not display help: ") + Glib::ustring(ex.what());
+    Gtk::MessageDialog dialog(message, false, Gtk::MESSAGE_ERROR);
+    dialog.run();
+  }
+#endif
+}
+
+void Utils::show_ok_dialog(const Glib::ustring& title, const Glib::ustring& message, Gtk::Window* parent, Gtk::MessageType message_type)
+{
+#ifdef GLOM_ENABLE_MAEMO
+  // TODO_maemo: Map message_type to a senseful stock_id?
+  Hildon::Note dialog(Hildon::NOTE_TYPE_INFORMATION, parent, message);
+#else
+  Gtk::MessageDialog dialog("<b>" + title + "</b>", true /* markup */, message_type, Gtk::BUTTONS_OK);
+  dialog.set_secondary_text(message);
+  if(parent)
+    dialog.set_transient_for(*parent);
+#endif
+
+  dialog.run();
+}
+
+void Utils::show_ok_dialog(const Glib::ustring& title, const Glib::ustring& message, Gtk::Window& parent, Gtk::MessageType message_type)
+{
+  show_ok_dialog(title, message, &parent, message_type);
+}
+
+namespace
+{
+
+static void on_window_hide(Glib::RefPtr<Glib::MainLoop> main_loop, sigc::connection handler_connection)
+{
+  handler_connection.disconnect(); //This should release a main_loop reference.
+  main_loop->quit();
+
+  //main_loop should be destroyed soon, because nothing else is using it.
+}
+
+} //anonymous namespace.
+
+void Utils::show_window_until_hide(Gtk::Window* window)
+{
+  if(!window)
+    return;
+
+  Glib::RefPtr<Glib::MainLoop> main_loop = Glib::MainLoop::create(false /* not running */);
+
+  //Stop the main_loop when the window is hidden:
+  sigc::connection handler_connection; //TODO: There seems to be a crash if this is on the same line.
+  handler_connection = window->signal_hide().connect( 
+    sigc::bind(
+      sigc::ptr_fun(&on_window_hide),
+      main_loop, handler_connection
+    ) );
+  
+  window->show();
+  main_loop->run(); //Run and block until it is stopped by the hide signal handler.
+}
+
+Glib::ustring Utils::bold_message(const Glib::ustring& message)
+{
+  return "<b>" + message + "</b>";
+}
+
+
+} //namespace Glom

Added: trunk/glom/utils_ui.h
==============================================================================
--- (empty file)
+++ trunk/glom/utils_ui.h	Mon Mar 30 12:01:39 2009
@@ -0,0 +1,71 @@
+/* Glom
+ *
+ * Copyright (C) 2001-2009 Openismus GmbH
+ *
+ * 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.
+ */
+
+#ifndef GLOM_UTILS_UI_H
+#define GLOM_UTILS_UI_H
+
+#include <libglom/data_structure/field.h>
+#include <libglom/data_structure/numeric_format.h>
+
+#include <libglom/data_structure/layout/layoutitem_field.h>
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/messagedialog.h>
+
+namespace Glom
+{
+
+namespace Utils
+{
+
+enum DefaultSpacings
+{
+  #ifdef GLOM_ENABLE_MAEMO
+  //We use different spacings on Maemo because the screen is smaller:
+  DEFAULT_SPACING_LARGE = 1,
+  DEFAULT_SPACING_SMALL = 1
+  #else
+  DEFAULT_SPACING_LARGE = 12,
+  DEFAULT_SPACING_SMALL = 6
+  #endif //GLOM_ENABLE_MAEMO
+};
+
+int dialog_run_with_help(Gtk::Dialog* dialog, const Glib::ustring& id = Glib::ustring());
+
+/** This is a replacement for gnome_help_display(), 
+ * to avoid the libgnome dependency.
+ * TODO: GTK+ should have a function for this soon.
+ */
+void show_help(const Glib::ustring& id = Glib::ustring());
+
+void show_ok_dialog(const Glib::ustring& title, const Glib::ustring& message, Gtk::Window& parent, Gtk::MessageType message_type);
+void show_ok_dialog(const Glib::ustring& title, const Glib::ustring& message, Gtk::Window* parent, Gtk::MessageType message_type);
+
+void show_window_until_hide(Gtk::Window* window);
+
+/// For instance, to create bold primary text for a dialog box, without marking the markup for translation.
+Glib::ustring bold_message(const Glib::ustring& message);
+
+} //namespace Utils
+
+} //namespace Glom
+
+#endif //GLOM_UTILS_UI_H
+



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