[glom] C++11: Use a to_utype() template method instead of static_cast<int>.



commit 74989e9840ef9e5afbb30a6e6da6dc7ce487d1c6
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Aug 21 18:17:13 2015 +0200

    C++11: Use a to_utype() template method instead of static_cast<int>.
    
    As suggested in Item 10 of
    Effective Modern C++ by Scott Meyers.

 glom/appwindow.cc                                  |   12 ++++++------
 glom/bakery/appwindow_withdoc.cc                   |    3 ++-
 glom/bakery/dialog_offersave.cc                    |    7 ++++---
 glom/box_withbuttons.cc                            |   14 +++++++-------
 glom/filechooser_export.cc                         |    2 +-
 glom/frame_glom.cc                                 |    4 ++--
 glom/glom_create_from_example.cc                   |    2 +-
 glom/libglom/connectionpool.cc                     |    2 +-
 glom/libglom/data_structure/field.cc               |    4 ++--
 glom/libglom/data_structure/fieldtypes.cc          |    5 +++--
 glom/libglom/data_structure/glomconversions.cc     |    6 +++---
 glom/libglom/db_utils.cc                           |    8 ++++----
 glom/libglom/document/bakery/document.cc           |    7 ++++---
 glom/libglom/document/document.cc                  |    2 +-
 glom/libglom/test_avahi_publisher.cc               |    2 +-
 glom/libglom/utils.h                               |    7 +++++++
 glom/mode_data/box_data_calendar_related.cc        |    8 ++++----
 glom/mode_data/box_data_details.cc                 |   10 +++++-----
 glom/mode_data/box_data_list_related.cc            |    4 ++--
 glom/mode_data/box_data_portal.cc                  |    4 ++--
 glom/mode_data/datawidget/datawidget.cc            |    2 +-
 glom/mode_data/db_adddel/db_adddel.cc              |    2 +-
 glom/mode_data/db_adddel/db_adddel_withbuttons.cc  |    2 +-
 glom/mode_data/flowtablewithfields.cc              |   14 +++++++-------
 glom/mode_design/fields/box_db_table_definition.cc |    2 +-
 .../print_layouts/window_print_layout_edit.cc      |    2 +-
 glom/mode_find/box_data_list_find.cc               |    2 +-
 glom/utility_widgets/adddel/adddel.cc              |    2 +-
 glom/utility_widgets/adddel/adddel_withbuttons.cc  |    9 +++++----
 .../utility_widgets/canvas/canvas_group_movable.cc |    3 ++-
 .../canvas/canvas_group_resizable.cc               |    3 ++-
 glom/utility_widgets/canvas/canvas_rect_movable.cc |    3 ++-
 .../utility_widgets/canvas/canvas_table_movable.cc |    3 ++-
 .../filechooserdialog_saveextras.cc                |    8 ++++----
 glom/utility_widgets/notebook_noframe.cc           |    7 ++++---
 glom/window_boxholder.cc                           |    2 +-
 .../python/test_python_execute_func_with_record.cc |    2 +-
 tests/test_selfhosting_utils.cc                    |    8 ++++----
 38 files changed, 103 insertions(+), 86 deletions(-)
---
diff --git a/glom/appwindow.cc b/glom/appwindow.cc
index 91ccfe9..949967a 100644
--- a/glom/appwindow.cc
+++ b/glom/appwindow.cc
@@ -348,7 +348,7 @@ void AppWindow::init_menus()
   m_action_menu_developer_usermode =
     m_refActionGroup_Developer->add_action_radio_integer("usermode",
       sigc::mem_fun(*this, &AppWindow::on_menu_developer_usermode),
-      static_cast<int>(AppState::userlevels::OPERATOR) );
+      Utils::to_utype(AppState::userlevels::OPERATOR) );
 
   action = m_refActionGroup_Developer->add_action("database-preferences",
     sigc::mem_fun(*m_pFrame, &Frame_Glom::on_menu_developer_database_preferences) );
@@ -524,7 +524,7 @@ void AppWindow::on_menu_developer_usermode(int parameter)
   if(!m_pFrame)
     return;
 
-  const bool developer = parameter == static_cast<int>(AppState::userlevels::DEVELOPER);
+  const bool developer = parameter == Utils::to_utype(AppState::userlevels::DEVELOPER);
 
   bool changed = false;
   if(developer)
@@ -570,7 +570,7 @@ static bool hostname_is_localhost(const Glib::ustring& hostname)
 
 void AppWindow::ui_warning_load_failed(int failure_code)
 {
-  if(failure_code == static_cast<int>(Document::LoadFailureCodes::NOT_FOUND))
+  if(failure_code == Utils::to_utype(Document::LoadFailureCodes::NOT_FOUND))
   {
     //TODO: Put this in the generic bakery code.
     ui_warning(_("Open Failed"),
@@ -580,7 +580,7 @@ void AppWindow::ui_warning_load_failed(int failure_code)
     //but the initial/welcome dialog doesn't yet update its list when the
     //recent history changes.
   }
-  else if(failure_code == static_cast<int>(Document::load_failure_codes::FILE_VERSION_TOO_NEW))
+  else if(failure_code == Utils::to_utype(Document::load_failure_codes::FILE_VERSION_TOO_NEW))
   {
     ui_warning(_("Open Failed"),
       _("The document could not be opened because it was created or modified by a newer version of Glom."));
@@ -837,7 +837,7 @@ bool AppWindow::check_document_hosting_mode_is_supported(Document* document)
     default:
     {
       //on_document_load() should have checked for this already, informing the user.
-      std::cerr << G_STRFUNC << ": Unhandled hosting mode: " << 
static_cast<int>(document->get_hosting_mode()) << std::endl;
+      std::cerr << G_STRFUNC << ": Unhandled hosting mode: " << 
Utils::to_utype(document->get_hosting_mode()) << std::endl;
      g_assert_not_reached();
      break;
     }
@@ -1328,7 +1328,7 @@ bool AppWindow::offer_new_or_existing()
 #endif
       case Dialog_ExistingOrNew::Action::NONE:
       default:
-        std::cerr << G_STRFUNC << ": Unhandled action: " << static_cast<int>(dialog->get_action()) << 
std::endl;
+        std::cerr << G_STRFUNC << ": Unhandled action: " << Utils::to_utype(dialog->get_action()) << 
std::endl;
         g_assert_not_reached();
         break;
       }
diff --git a/glom/bakery/appwindow_withdoc.cc b/glom/bakery/appwindow_withdoc.cc
index d902df9..f991d20 100644
--- a/glom/bakery/appwindow_withdoc.cc
+++ b/glom/bakery/appwindow_withdoc.cc
@@ -19,6 +19,7 @@
 #include "config.h"
 #include <glom/bakery/appwindow_withdoc.h>
 #include <glom/bakery/dialog_offersave.h>
+#include <libglom/utils.h>
 #include <giomm/file.h>
 #include <algorithm>
 #include <glibmm/i18n-lib.h>
@@ -150,7 +151,7 @@ bool AppWindow_WithDoc::open_document(const Glib::ustring& file_uri)
       ui_warning_load_failed(failure_code);
 
     //Make sure that non-existant files are removed from the history list:
-    if(failure_code == static_cast<int>(Document::LoadFailureCodes::NOT_FOUND))
+    if(failure_code == Glom::Utils::to_utype(Document::LoadFailureCodes::NOT_FOUND))
       document_history_remove(file_uri);
 
     //re-initialize document.
diff --git a/glom/bakery/dialog_offersave.cc b/glom/bakery/dialog_offersave.cc
index 9b9934f..95d6c9e 100644
--- a/glom/bakery/dialog_offersave.cc
+++ b/glom/bakery/dialog_offersave.cc
@@ -20,6 +20,7 @@
 #include <gtkmm/box.h>
 #include <glom/bakery/dialog_offersave.h>
 #include <glom/appwindow.h>
+#include <libglom/utils.h>
 #include <glibmm/convert.h> 
 #include <glibmm/i18n-lib.h>
 
@@ -52,9 +53,9 @@ Dialog_OfferSave::Dialog_OfferSave(const Glib::ustring& file_uri)
   
   set_secondary_text(get_confirmation_message(file_uri));
 
-  add_button(_("Discard"), static_cast<int>(enumButtons::Discard));
-  auto cancel_button = add_button(_("_Cancel"), static_cast<int>(enumButtons::Cancel));
-  add_button(_("_Save"), static_cast<int>(enumButtons::Save));
+  add_button(_("Discard"), Glom::Utils::to_utype(enumButtons::Discard));
+  auto cancel_button = add_button(_("_Cancel"), Glom::Utils::to_utype(enumButtons::Cancel));
+  add_button(_("_Save"), Glom::Utils::to_utype(enumButtons::Save));
 
   // Otherwise Discard has focus initially which seems inconvenient:
   cancel_button->grab_focus();
diff --git a/glom/box_withbuttons.cc b/glom/box_withbuttons.cc
index 79924b3..de66f81 100644
--- a/glom/box_withbuttons.cc
+++ b/glom/box_withbuttons.cc
@@ -32,13 +32,13 @@ namespace Glom
 
 Box_WithButtons::Box_WithButtons()
 : Gtk::Box(Gtk::ORIENTATION_VERTICAL),
-  m_Box_Buttons(Gtk::ORIENTATION_HORIZONTAL, static_cast<int>(UiUtils::DefaultSpacings::SMALL)),
+  m_Box_Buttons(Gtk::ORIENTATION_HORIZONTAL, Utils::to_utype(UiUtils::DefaultSpacings::SMALL)),
   m_Button_Cancel(_("_Cancel"))
 {
   //m_pDocument = nullptr;
 
-  //set_border_width(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
-  set_spacing(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
+  //set_border_width(Utils::to_utype(UiUtils::DefaultSpacings::SMALL));
+  set_spacing(Utils::to_utype(UiUtils::DefaultSpacings::SMALL));
 
   //Connect signals:
   m_Button_Cancel.signal_clicked().connect(sigc::mem_fun(*this, &Box_WithButtons::on_Button_Cancel));
@@ -46,13 +46,13 @@ Box_WithButtons::Box_WithButtons()
 
 Box_WithButtons::Box_WithButtons(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& /* builder */)
 : Gtk::Box(cobject),
-  m_Box_Buttons(Gtk::ORIENTATION_HORIZONTAL, static_cast<int>(UiUtils::DefaultSpacings::SMALL)),
+  m_Box_Buttons(Gtk::ORIENTATION_HORIZONTAL, Utils::to_utype(UiUtils::DefaultSpacings::SMALL)),
   m_Button_Cancel(_("_Cancel"))
 {
   //m_pDocument = nullptr;
 
-  //set_border_width(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
-  set_spacing(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
+  //set_border_width(Utils::to_utype(UiUtils::DefaultSpacings::SMALL));
+  set_spacing(Utils::to_utype(UiUtils::DefaultSpacings::SMALL));
 
   //Connect signals:
   m_Button_Cancel.signal_clicked().connect(sigc::mem_fun(*this, &Box_WithButtons::on_Button_Cancel));
@@ -60,7 +60,7 @@ Box_WithButtons::Box_WithButtons(BaseObjectType* cobject, const Glib::RefPtr<Gtk
 
 Box_WithButtons::Box_WithButtons(BaseObjectType* cobject)
 : Gtk::Box(cobject),
-  m_Box_Buttons(Gtk::ORIENTATION_HORIZONTAL, static_cast<int>(UiUtils::DefaultSpacings::SMALL)),
+  m_Box_Buttons(Gtk::ORIENTATION_HORIZONTAL, Utils::to_utype(UiUtils::DefaultSpacings::SMALL)),
   m_Button_Cancel(_("_Cancel"))
 {
 }
diff --git a/glom/filechooser_export.cc b/glom/filechooser_export.cc
index 1a86538..a257751 100644
--- a/glom/filechooser_export.cc
+++ b/glom/filechooser_export.cc
@@ -29,7 +29,7 @@ namespace Glom
 
 FileChooser_Export::FileChooser_Export()
 : Gtk::FileChooserDialog(_("Export to File"), Gtk::FILE_CHOOSER_ACTION_SAVE),
-  m_extra_widget(Gtk::ORIENTATION_HORIZONTAL, static_cast<int>(UiUtils::DefaultSpacings::SMALL)),
+  m_extra_widget(Gtk::ORIENTATION_HORIZONTAL, Utils::to_utype(UiUtils::DefaultSpacings::SMALL)),
 #ifndef GLOM_ENABLE_CLIENT_ONLY
   m_button_format(_("Define Data _Format"), true /* use mnenomic */),
   m_pDialogLayout(nullptr),
diff --git a/glom/frame_glom.cc b/glom/frame_glom.cc
index 9f317e8..05ae3ad 100644
--- a/glom/frame_glom.cc
+++ b/glom/frame_glom.cc
@@ -75,7 +75,7 @@ Frame_Glom::Frame_Glom(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>
 : PlaceHolder(cobject, builder),
   m_pLabel_Table_DataMode(nullptr),
   m_pLabel_Table_FindMode(nullptr),
-  m_Box_RecordsCount(Gtk::ORIENTATION_HORIZONTAL, static_cast<int>(UiUtils::DefaultSpacings::SMALL)),
+  m_Box_RecordsCount(Gtk::ORIENTATION_HORIZONTAL, Utils::to_utype(UiUtils::DefaultSpacings::SMALL)),
   m_Button_FindAll(_("Find All")),
   m_stack_mode(nullptr),
   m_pBox_Tables(nullptr),
@@ -107,7 +107,7 @@ Frame_Glom::Frame_Glom(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>
 
   //QuickFind widgets:
   //We don't use Glade for these, so it easier to modify them for the Maemo port.
-  m_pBox_QuickFind = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 
static_cast<int>(UiUtils::DefaultSpacings::SMALL)));
+  m_pBox_QuickFind = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 
Utils::to_utype(UiUtils::DefaultSpacings::SMALL)));
   Gtk::Label* label = Gtk::manage(new Gtk::Label(_("Quick _search:"), true));
   m_pBox_QuickFind->pack_start(*label, Gtk::PACK_SHRINK);
 
diff --git a/glom/glom_create_from_example.cc b/glom/glom_create_from_example.cc
index b7ed492..84c9ee9 100644
--- a/glom/glom_create_from_example.cc
+++ b/glom/glom_create_from_example.cc
@@ -506,7 +506,7 @@ int main(int argc, char* argv[])
   const auto started = connection_pool->startup( sigc::ptr_fun(&on_startup_progress) );
   if(started != Glom::ConnectionPool::Backend::StartupErrors::NONE)
   {
-    std::cerr << G_STRFUNC << ": connection_pool->startup(): result=" << static_cast<int>(started) << 
std::endl;
+    std::cerr << G_STRFUNC << ": connection_pool->startup(): result=" << Glom::Utils::to_utype(started) << 
std::endl;
     cleanup();
   }
   g_assert(started == Glom::ConnectionPool::Backend::StartupErrors::NONE);
diff --git a/glom/libglom/connectionpool.cc b/glom/libglom/connectionpool.cc
index e6bfc90..fbe3e18 100644
--- a/glom/libglom/connectionpool.cc
+++ b/glom/libglom/connectionpool.cc
@@ -185,7 +185,7 @@ void ConnectionPool::setup_from_document(const Document* document)
 
   default:
     //on_document_load() should have checked for this already, informing the user.
-    std::cerr << G_STRFUNC << ": Unhandled hosting mode: " << static_cast<int>(document->get_hosting_mode()) 
<< std::endl;
+    std::cerr << G_STRFUNC << ": Unhandled hosting mode: " << Utils::to_utype(document->get_hosting_mode()) 
<< std::endl;
     g_assert_not_reached();
     break;
   }
diff --git a/glom/libglom/data_structure/field.cc b/glom/libglom/data_structure/field.cc
index 0ea0082..247b562 100644
--- a/glom/libglom/data_structure/field.cc
+++ b/glom/libglom/data_structure/field.cc
@@ -557,7 +557,7 @@ Glib::ustring Field::get_sql_type() const
 
     if(strType == "unknowntype")
     {
-      std::cerr << G_STRFUNC << ": returning unknowntype for field name=" << get_name() << ", glom_type=" << 
static_cast<int>(get_glom_type()) << ", gda_type=" << (int)m_field_info->get_g_type() << std::endl;
+      std::cerr << G_STRFUNC << ": returning unknowntype for field name=" << get_name() << ", glom_type=" << 
Utils::to_utype(get_glom_type()) << ", gda_type=" << (int)m_field_info->get_g_type() << std::endl;
     }
 
     return strType;
@@ -617,7 +617,7 @@ GType Field::get_gda_type_for_glom_type(Field::glom_field_type glom_type)
 
   if(ideal_gda_type == G_TYPE_NONE)
   {
-    std::cerr << G_STRFUNC << ": Returning G_TYPE_NONE for glom_type=" << static_cast<int>(glom_type) << 
std::endl;
+    std::cerr << G_STRFUNC << ": Returning G_TYPE_NONE for glom_type=" << Utils::to_utype(glom_type) << 
std::endl;
   }
 
   //std::cout << "debug: " << G_STRFUNC << ": returning: " << g_type_name(ideal_gda_type) << std::endl;
diff --git a/glom/libglom/data_structure/fieldtypes.cc b/glom/libglom/data_structure/fieldtypes.cc
index 35fc951..13d452f 100644
--- a/glom/libglom/data_structure/fieldtypes.cc
+++ b/glom/libglom/data_structure/fieldtypes.cc
@@ -22,6 +22,7 @@
 #include <iostream> //For debug output
 #include <libgda/gda-util.h> // For gda_g_type_to_string
 #include <libglom/connectionpool.h>
+#include <libglom/utils.h>
 
 namespace Glom
 {
@@ -68,7 +69,7 @@ FieldTypes::FieldTypes(const Glib::RefPtr<Gnome::Gda::Connection>& gda_connectio
 
       for(int i = 0; i < rows; ++i)
       {
-        const auto value_name = 
data_model_tables->get_value_at(static_cast<int>(GlomGdaDataModelTypesColumns::NAME), i);
+        const auto value_name = 
data_model_tables->get_value_at(Utils::to_utype(GlomGdaDataModelTypesColumns::NAME), i);
 
         //Get the types's string representation:
         Glib::ustring schema_type_string;
@@ -77,7 +78,7 @@ FieldTypes::FieldTypes(const Glib::RefPtr<Gnome::Gda::Connection>& gda_connectio
         
         if(!schema_type_string.empty())
         {
-          const auto value_gdatype = 
data_model_tables->get_value_at(static_cast<int>(GlomGdaDataModelTypesColumns::GTYPE), i);
+          const auto value_gdatype = 
data_model_tables->get_value_at(Utils::to_utype(GlomGdaDataModelTypesColumns::GTYPE), i);
           if(value_gdatype.get_value_type() == G_TYPE_STRING)
           {
             auto type_string = value_gdatype.get_string();
diff --git a/glom/libglom/data_structure/glomconversions.cc b/glom/libglom/data_structure/glomconversions.cc
index 2e1c5c5..c1988ce 100644
--- a/glom/libglom/data_structure/glomconversions.cc
+++ b/glom/libglom/data_structure/glomconversions.cc
@@ -577,12 +577,12 @@ Glib::ustring Conversions::get_text_for_gda_value(Field::glom_field_type glom_ty
     //- UI-visible strings, but images should never be shown as text in the UI. 
     //- Values in SQL queries, but we only do that for clauses (where/sort/order) 
     //  which should never use image values.
-    std::cerr << G_STRFUNC << ": Unexpected enumType::IMAGE field type: " << static_cast<int>(glom_type) << 
std::endl;
+    std::cerr << G_STRFUNC << ": Unexpected enumType::IMAGE field type: " << Utils::to_utype(glom_type) << 
std::endl;
     return Glib::ustring();
   }
   else
   {
-    std::cerr << G_STRFUNC << ": Unexpected glom field type: " << static_cast<int>(glom_type) << std::endl;
+    std::cerr << G_STRFUNC << ": Unexpected glom field type: " << Utils::to_utype(glom_type) << std::endl;
     return value.to_string();
   }
 }
@@ -695,7 +695,7 @@ Gnome::Gda::Value Conversions::parse_value(Field::glom_field_type glom_type, con
   {
     //This function is only used for :
     //- UI-visible strings, but images should never be entered as text in the UI. 
-    std::cerr << G_STRFUNC << ": Unexpected enumType::IMAGE field type: " << static_cast<int>(glom_type) << 
std::endl;
+    std::cerr << G_STRFUNC << ": Unexpected enumType::IMAGE field type: " << Utils::to_utype(glom_type) << 
std::endl;
     return Gnome::Gda::Value();
   }
 
diff --git a/glom/libglom/db_utils.cc b/glom/libglom/db_utils.cc
index 314df15..a5f9af8 100644
--- a/glom/libglom/db_utils.cc
+++ b/glom/libglom/db_utils.cc
@@ -907,7 +907,7 @@ type_vec_fields get_fields_for_table_from_database(const Glib::ustring& table_na
         Glib::RefPtr<Gnome::Gda::Column> field_info = Gnome::Gda::Column::create();
 
         //Get the field name:
-        const auto value_name = 
data_model_fields->get_value_at(static_cast<int>(GlomGdaDataModelFieldColumns::NAME), row);
+        const auto value_name = 
data_model_fields->get_value_at(Utils::to_utype(GlomGdaDataModelFieldColumns::NAME), row);
         if(value_name.get_value_type() ==  G_TYPE_STRING)
         {
           if(value_name.get_string().empty())
@@ -920,7 +920,7 @@ type_vec_fields get_fields_for_table_from_database(const Glib::ustring& table_na
         }
 
         //Get the field type:
-        const auto value_fieldtype = 
data_model_fields->get_value_at(static_cast<int>(GlomGdaDataModelFieldColumns::GTYPE), row);
+        const auto value_fieldtype = 
data_model_fields->get_value_at(Utils::to_utype(GlomGdaDataModelFieldColumns::GTYPE), row);
         if(value_fieldtype.get_value_type() ==  G_TYPE_STRING)
         {
           const auto type_string = value_fieldtype.get_string();
@@ -931,12 +931,12 @@ type_vec_fields get_fields_for_table_from_database(const Glib::ustring& table_na
 
         //Get the default value:
         const Gnome::Gda::Value value_defaultvalue =
-          data_model_fields->get_value_at(static_cast<int>(GlomGdaDataModelFieldColumns::DEFAULTVALUE), row);
+          data_model_fields->get_value_at(Utils::to_utype(GlomGdaDataModelFieldColumns::DEFAULTVALUE), row);
         if(value_defaultvalue.get_value_type() ==  G_TYPE_STRING)
           field_info->set_default_value(value_defaultvalue);
 
         //Get whether it can be null:
-        const auto value_notnull = 
data_model_fields->get_value_at(static_cast<int>(GlomGdaDataModelFieldColumns::NOTNULL), row);
+        const auto value_notnull = 
data_model_fields->get_value_at(Utils::to_utype(GlomGdaDataModelFieldColumns::NOTNULL), row);
         if(value_notnull.get_value_type() ==  G_TYPE_BOOLEAN)
           field_info->set_allow_null(value_notnull.get_boolean());
 
diff --git a/glom/libglom/document/bakery/document.cc b/glom/libglom/document/bakery/document.cc
index ec66642..c956d53 100644
--- a/glom/libglom/document/bakery/document.cc
+++ b/glom/libglom/document/bakery/document.cc
@@ -18,6 +18,7 @@
 
 #include "config.h"
 #include <libglom/document/bakery/document.h>
+#include <libglom/utils.h>
 #include <giomm/file.h>
 #include <iostream>
 #include <glibmm/i18n-lib.h>
@@ -115,7 +116,7 @@ bool Document::get_modified() const
 bool Document::load(int& failure_code)
 {
   //Initialize the output parameter:
-  failure_code = static_cast<int>(LoadFailureCodes::NONE);
+  failure_code = Glom::Utils::to_utype(LoadFailureCodes::NONE);
 
   auto bTest = read_from_disk(failure_code);
   if(bTest)
@@ -204,7 +205,7 @@ bool Document::save_before()
 
 bool Document::read_from_disk(int& failure_code)
 {
-  failure_code = static_cast<int>(LoadFailureCodes::NONE);
+  failure_code = Glom::Utils::to_utype(LoadFailureCodes::NONE);
 
   m_strContents.erase();
 
@@ -227,7 +228,7 @@ bool Document::read_from_disk(int& failure_code)
 
 
     if(ex.code() == Gio::Error::NOT_FOUND)
-      failure_code = static_cast<int>(LoadFailureCodes::NOT_FOUND);
+      failure_code = Glom::Utils::to_utype(LoadFailureCodes::NOT_FOUND);
     //  std::cout << "  File not found: " << m_file_uri << std::endl;
 
     // If the operation was not successful, print the error and abort
diff --git a/glom/libglom/document/document.cc b/glom/libglom/document/document.cc
index 9b5321a..78d651a 100644
--- a/glom/libglom/document/document.cc
+++ b/glom/libglom/document/document.cc
@@ -2558,7 +2558,7 @@ bool Document::load_after(int& failure_code)
       if(m_document_format_version > get_latest_known_document_format_version())
       {
         std::cerr << G_STRFUNC << ": Loading failed because format_version=" << m_document_format_version << 
", but latest known format version is " << get_latest_known_document_format_version() << std::endl;
-        failure_code = static_cast<int>(load_failure_codes::FILE_VERSION_TOO_NEW);
+        failure_code = Utils::to_utype(load_failure_codes::FILE_VERSION_TOO_NEW);
         return false;
       }
 
diff --git a/glom/libglom/test_avahi_publisher.cc b/glom/libglom/test_avahi_publisher.cc
index ed1cd42..bcee7df 100644
--- a/glom/libglom/test_avahi_publisher.cc
+++ b/glom/libglom/test_avahi_publisher.cc
@@ -28,7 +28,7 @@ private:
 
 
 TestWindow::TestWindow()
-: m_box(Gtk::ORIENTATION_VERTICAL, static_cast<int>(Glom::UiUtils::DefaultSpacings::SMALL)),
+: m_box(Gtk::ORIENTATION_VERTICAL, Utils::to_utype(Glom::UiUtils::DefaultSpacings::SMALL)),
   m_button_start("Start"),
   m_button_stop("Stop"),
   m_avahi_publisher(nullptr)
diff --git a/glom/libglom/utils.h b/glom/libglom/utils.h
index c98c007..d12dcf7 100644
--- a/glom/libglom/utils.h
+++ b/glom/libglom/utils.h
@@ -255,6 +255,13 @@ bool script_check_for_pygtk2(const Glib::ustring& script);
  */
 bool get_resource_exists(const std::string& resource_path);
 
+template<typename E>
+constexpr typename std::underlying_type<E>::type
+to_utype(E enumerator) noexcept
+{
+  return static_cast<typename std::underlying_type<E>::type>(enumerator);
+}
+
 } //namespace Utils
 
 } //namespace Glom
diff --git a/glom/mode_data/box_data_calendar_related.cc b/glom/mode_data/box_data_calendar_related.cc
index 1e25ad8..f729c84 100644
--- a/glom/mode_data/box_data_calendar_related.cc
+++ b/glom/mode_data/box_data_calendar_related.cc
@@ -39,8 +39,8 @@ Box_Data_Calendar_Related::Box_Data_Calendar_Related()
   set_size_request(400, -1); //An arbitrary default.
 
   m_Frame.add(m_calendar);
-  m_calendar.set_margin_start(static_cast<int>(UiUtils::DefaultSpacings::LARGE));
-  m_calendar.set_margin_top(static_cast<int>(UiUtils::DefaultSpacings::SMALL));   
+  m_calendar.set_margin_start(Utils::to_utype(UiUtils::DefaultSpacings::LARGE));
+  m_calendar.set_margin_top(Utils::to_utype(UiUtils::DefaultSpacings::SMALL));   
   m_calendar.show();
 
   //m_calendar.set_show_details();
@@ -101,8 +101,8 @@ bool Box_Data_Calendar_Related::init_db_details(const Glib::ustring& parent_tabl
     m_Label.set_markup(UiUtils::bold_message(title));
     m_Label.show();
 
-    m_calendar.set_margin_start(static_cast<int>(UiUtils::DefaultSpacings::LARGE));
-    m_calendar.set_margin_top(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
+    m_calendar.set_margin_start(Utils::to_utype(UiUtils::DefaultSpacings::LARGE));
+    m_calendar.set_margin_top(Utils::to_utype(UiUtils::DefaultSpacings::SMALL));
   }
   else
   {
diff --git a/glom/mode_data/box_data_details.cc b/glom/mode_data/box_data_details.cc
index a6ae6f2..59377ae 100644
--- a/glom/mode_data/box_data_details.cc
+++ b/glom/mode_data/box_data_details.cc
@@ -40,7 +40,7 @@ namespace Glom
 {
 
 Box_Data_Details::Box_Data_Details(bool bWithNavButtons /* = true */)
-: m_hbox_content(Gtk::ORIENTATION_HORIZONTAL, static_cast<int>(UiUtils::DefaultSpacings::SMALL)),
+: m_hbox_content(Gtk::ORIENTATION_HORIZONTAL, Utils::to_utype(UiUtils::DefaultSpacings::SMALL)),
   m_show_toolbar(false),
   m_hbox_buttons(Gtk::ORIENTATION_HORIZONTAL),
   m_Button_New(_("_Add"), true),
@@ -58,19 +58,19 @@ Box_Data_Details::Box_Data_Details(bool bWithNavButtons /* = true */)
   m_layout_name = "details";
 
   m_hbox_buttons.set_layout(Gtk::BUTTONBOX_END);
-  m_hbox_buttons.set_spacing(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
+  m_hbox_buttons.set_spacing(Utils::to_utype(UiUtils::DefaultSpacings::SMALL));
 
   add_view(&m_FlowTable); //Allow this to access the document too.
 
   m_FlowTable.set_lines(1); //Sub-groups will have multiple columns (by default, there is one sub-group, 
with 2 columns).
 
-  m_FlowTable.set_horizontal_spacing(static_cast<int>(UiUtils::DefaultSpacings::SMALL)); //The default 
anyway.
-  m_FlowTable.set_vertical_spacing(static_cast<int>(UiUtils::DefaultSpacings::SMALL)); //The default anyway.
+  m_FlowTable.set_horizontal_spacing(Utils::to_utype(UiUtils::DefaultSpacings::SMALL)); //The default anyway.
+  m_FlowTable.set_vertical_spacing(Utils::to_utype(UiUtils::DefaultSpacings::SMALL)); //The default anyway.
 
   //m_strHint = _("When you change the data in a field the database is updated immediately.\n Click [New] to 
add a new record.\n Leave automatic ID fields empty - they will be filled for you.");
 
 
-  //m_ScrolledWindow.set_border_width(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
+  //m_ScrolledWindow.set_border_width(Utils::to_utype(UiUtils::DefaultSpacings::SMALL));
 
   // Allow vertical scrolling, but never scroll horizontally:
   m_ScrolledWindow.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
diff --git a/glom/mode_data/box_data_list_related.cc b/glom/mode_data/box_data_list_related.cc
index 7268664..181ce0d 100644
--- a/glom/mode_data/box_data_list_related.cc
+++ b/glom/mode_data/box_data_list_related.cc
@@ -102,8 +102,8 @@ bool Box_Data_List_Related::init_db_details(const Glib::ustring& parent_table, b
     if(!(m_Frame.get_label_widget()))
       m_Frame.set_label_widget(m_Label);
 
-    m_AddDel.set_margin_start(static_cast<int>(UiUtils::DefaultSpacings::LARGE));
-    m_AddDel.set_margin_top(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
+    m_AddDel.set_margin_start(Utils::to_utype(UiUtils::DefaultSpacings::LARGE));
+    m_AddDel.set_margin_top(Utils::to_utype(UiUtils::DefaultSpacings::SMALL));
 
   }
   else
diff --git a/glom/mode_data/box_data_portal.cc b/glom/mode_data/box_data_portal.cc
index 00575ef..1406ecb 100644
--- a/glom/mode_data/box_data_portal.cc
+++ b/glom/mode_data/box_data_portal.cc
@@ -43,8 +43,8 @@ Box_Data_Portal::Box_Data_Portal()
   m_Label.show();
 
   //The AddDel or Calendar is added to this:
-  //They must use child.set_margin_start(static_cast<int>(UiUtils::DefaultSpacings::LARGE)) and
-  //child.set_margin_top(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
+  //They must use child.set_margin_start(Utils::to_utype(UiUtils::DefaultSpacings::LARGE)) and
+  //child.set_margin_top(Utils::to_utype(UiUtils::DefaultSpacings::SMALL));
   add(m_Frame);
 
   m_layout_name = "list_portal"; //Replaced by derived classes.
diff --git a/glom/mode_data/datawidget/datawidget.cc b/glom/mode_data/datawidget/datawidget.cc
index cda4cf5..ea17c4e 100644
--- a/glom/mode_data/datawidget/datawidget.cc
+++ b/glom/mode_data/datawidget/datawidget.cc
@@ -197,7 +197,7 @@ DataWidget::DataWidget(const std::shared_ptr<LayoutItem_Field>& field, const Gli
     if(with_extra_widgets)
     {
       hbox_parent = Gtk::manage( new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL) ); //We put the child (and any 
extra stuff) in this:
-      hbox_parent->set_spacing(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
+      hbox_parent->set_spacing(Utils::to_utype(UiUtils::DefaultSpacings::SMALL));
 
       hbox_parent->pack_start(*m_child);
       hbox_parent->show();
diff --git a/glom/mode_data/db_adddel/db_adddel.cc b/glom/mode_data/db_adddel/db_adddel.cc
index 466ac75..d93b3d7 100644
--- a/glom/mode_data/db_adddel/db_adddel.cc
+++ b/glom/mode_data/db_adddel/db_adddel.cc
@@ -65,7 +65,7 @@ DbAddDel::DbAddDel()
   set_prevent_user_signals();
   set_ignore_treeview_signals(true);
 
-  set_spacing(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
+  set_spacing(Utils::to_utype(UiUtils::DefaultSpacings::SMALL));
 
   //Start with a useful default TreeModel:
   //set_columns_count(1);
diff --git a/glom/mode_data/db_adddel/db_adddel_withbuttons.cc 
b/glom/mode_data/db_adddel/db_adddel_withbuttons.cc
index 5d1d93e..970a45d 100644
--- a/glom/mode_data/db_adddel/db_adddel_withbuttons.cc
+++ b/glom/mode_data/db_adddel/db_adddel_withbuttons.cc
@@ -33,7 +33,7 @@ DbAddDel_WithButtons::DbAddDel_WithButtons()
   m_Button_Add(_("_Add"), true)
 {
   m_ButtonBox.set_layout(Gtk::BUTTONBOX_END);
-  m_ButtonBox.set_spacing(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
+  m_ButtonBox.set_spacing(Utils::to_utype(UiUtils::DefaultSpacings::SMALL));
 
   setup_buttons();
   pack_start(m_ButtonBox, Gtk::PACK_SHRINK);
diff --git a/glom/mode_data/flowtablewithfields.cc b/glom/mode_data/flowtablewithfields.cc
index 842b9c4..cfdc1a5 100644
--- a/glom/mode_data/flowtablewithfields.cc
+++ b/glom/mode_data/flowtablewithfields.cc
@@ -203,11 +203,11 @@ void FlowTableWithFields::add_layout_group(const std::shared_ptr<LayoutGroup>& g
       const int BASE_INDENT = 3;
       
       //std::cout << "title= " << group_title << ", with_indent=" << with_indent << std::endl;
-      event_box->set_margin_top(static_cast<int>(Glom::UiUtils::DefaultSpacings::SMALL));
+      event_box->set_margin_top(Utils::to_utype(Glom::UiUtils::DefaultSpacings::SMALL));
 
       if(with_indent) 
       {
-        event_box->set_margin_start(static_cast<int>(Glom::UiUtils::DefaultSpacings::SMALL) + BASE_INDENT);
+        event_box->set_margin_start(Utils::to_utype(Glom::UiUtils::DefaultSpacings::SMALL) + BASE_INDENT);
       }
       else
       {
@@ -373,7 +373,7 @@ void FlowTableWithFields::add_layout_notebook(const std::shared_ptr<LayoutItem_N
       {
         //Add a Related Records list for this portal:
         Box_Data_List_Related* portal_box = create_related(portal, false /* no label, because it's in the 
tab instead. */);
-        //portal_box->set_border_width(static_cast<int>(Glom::UiUtils::DefaultSpacings::SMALL)); It has 
margins around the frame's child widget instead.
+        //portal_box->set_border_width(Utils::to_utype(Glom::UiUtils::DefaultSpacings::SMALL)); It has 
margins around the frame's child widget instead.
         portal_box->show();
         notebook_widget->append_page(*portal_box, *tab_label);
 
@@ -405,10 +405,10 @@ void FlowTableWithFields::add_layout_notebook(const std::shared_ptr<LayoutItem_N
         //Put some space between the page child and the page edges.
         //This doesn't work (probably because we haven't implemented it in our custom container),
         //so we use GtkWidget margins instead. TODO: What's the difference.
-        event_box->set_margin_start(static_cast<int>(Glom::UiUtils::DefaultSpacings::SMALL));
-        event_box->set_margin_end(static_cast<int>(Glom::UiUtils::DefaultSpacings::SMALL));
-        event_box->set_margin_top(static_cast<int>(Glom::UiUtils::DefaultSpacings::SMALL));
-        event_box->set_margin_bottom(static_cast<int>(Glom::UiUtils::DefaultSpacings::SMALL));
+        event_box->set_margin_start(Utils::to_utype(Glom::UiUtils::DefaultSpacings::SMALL));
+        event_box->set_margin_end(Utils::to_utype(Glom::UiUtils::DefaultSpacings::SMALL));
+        event_box->set_margin_top(Utils::to_utype(Glom::UiUtils::DefaultSpacings::SMALL));
+        event_box->set_margin_bottom(Utils::to_utype(Glom::UiUtils::DefaultSpacings::SMALL));
 
         notebook_widget->append_page(*event_box, *tab_label);
 
diff --git a/glom/mode_design/fields/box_db_table_definition.cc 
b/glom/mode_design/fields/box_db_table_definition.cc
index d5a7285..6ef277a 100644
--- a/glom/mode_design/fields/box_db_table_definition.cc
+++ b/glom/mode_design/fields/box_db_table_definition.cc
@@ -215,7 +215,7 @@ void Box_DB_Table_Definition::on_adddel_add(const Gtk::TreeModel::iterator& row)
       Document* pDoc = static_cast<Document*>(get_document());
       if(pDoc)
       {
-        std::cout << static_cast<int>(field->get_glom_type()) << std::endl;
+        std::cout << Utils::to_utype(field->get_glom_type()) << std::endl;
         Document::type_vec_fields vecFields = pDoc->get_table_fields(m_table_name);
         vecFields.push_back(field);
         pDoc->set_table_fields(m_table_name, vecFields);
diff --git a/glom/mode_design/print_layouts/window_print_layout_edit.cc 
b/glom/mode_design/print_layouts/window_print_layout_edit.cc
index ae45ba6..5fee727 100644
--- a/glom/mode_design/print_layouts/window_print_layout_edit.cc
+++ b/glom/mode_design/print_layouts/window_print_layout_edit.cc
@@ -416,7 +416,7 @@ std::shared_ptr<LayoutItem> Window_PrintLayout_Edit::create_empty_item(PrintLayo
   }
   else
   {
-    std::cerr << G_STRFUNC << ": Unhandled item type: " << static_cast<int>(item_type) << std::endl;
+    std::cerr << G_STRFUNC << ": Unhandled item type: " << Utils::to_utype(item_type) << std::endl;
   }
 
   //Set a default text style and size:
diff --git a/glom/mode_find/box_data_list_find.cc b/glom/mode_find/box_data_list_find.cc
index 3169a13..2909a24 100644
--- a/glom/mode_find/box_data_list_find.cc
+++ b/glom/mode_find/box_data_list_find.cc
@@ -26,7 +26,7 @@ namespace Glom
 {
 
 Box_Data_List_Find::Box_Data_List_Find()
-: m_HBox(Gtk::ORIENTATION_HORIZONTAL, static_cast<int>(Glom::UiUtils::DefaultSpacings::SMALL))
+: m_HBox(Gtk::ORIENTATION_HORIZONTAL, Utils::to_utype(Glom::UiUtils::DefaultSpacings::SMALL))
 {
   //m_strHint = _("Enter the search criteria and click [Find]\n Glom will then change to Data mode to 
display the results.");
 
diff --git a/glom/utility_widgets/adddel/adddel.cc b/glom/utility_widgets/adddel/adddel.cc
index d3f4963..b1fb35a 100644
--- a/glom/utility_widgets/adddel/adddel.cc
+++ b/glom/utility_widgets/adddel/adddel.cc
@@ -100,7 +100,7 @@ void AddDel::init()
   set_prevent_user_signals();
   set_ignore_treeview_signals();
 
-  set_spacing(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
+  set_spacing(Utils::to_utype(UiUtils::DefaultSpacings::SMALL));
 
   m_bAllowUserActions = true;
 
diff --git a/glom/utility_widgets/adddel/adddel_withbuttons.cc 
b/glom/utility_widgets/adddel/adddel_withbuttons.cc
index d9b7eef..c7cde9c 100644
--- a/glom/utility_widgets/adddel/adddel_withbuttons.cc
+++ b/glom/utility_widgets/adddel/adddel_withbuttons.cc
@@ -20,6 +20,7 @@
 
 #include "adddel_withbuttons.h"
 #include <glom/utils_ui.h>
+#include <libglom/utils.h>
 #include <glibmm/i18n.h>
 
 //#include <libgnome/gnome-i18n.h>
@@ -49,11 +50,11 @@ AddDel_WithButtons::AddDel_WithButtons(BaseObjectType* cobject, const Glib::RefP
 void AddDel_WithButtons::init()
 {
   m_ButtonBox.set_layout(Gtk::BUTTONBOX_END);
-  m_ButtonBox.set_spacing(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
+  m_ButtonBox.set_spacing(Utils::to_utype(UiUtils::DefaultSpacings::SMALL));
 
-  //m_Button_Add.set_border_width(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
-  //m_Button_Del.set_border_width(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
-  //m_Button_Edit.set_border_width(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
+  //m_Button_Add.set_border_width(Utils::to_utype(UiUtils::DefaultSpacings::SMALL));
+  //m_Button_Del.set_border_width(Utils::to_utype(UiUtils::DefaultSpacings::SMALL));
+  //m_Button_Edit.set_border_width(Utils::to_utype(UiUtils::DefaultSpacings::SMALL));
 
   setup_buttons();
   pack_start(m_ButtonBox, Gtk::PACK_SHRINK);
diff --git a/glom/utility_widgets/canvas/canvas_group_movable.cc 
b/glom/utility_widgets/canvas/canvas_group_movable.cc
index 1a3b138..11e7cfc 100644
--- a/glom/utility_widgets/canvas/canvas_group_movable.cc
+++ b/glom/utility_widgets/canvas/canvas_group_movable.cc
@@ -22,6 +22,7 @@
 #include "canvas_rect_movable.h"
 #include "canvas_line_movable.h"
 #include "canvas_text_movable.h"
+#include "libglom/utils.h"
 #include <goocanvasmm/canvas.h>
 #include <gdkmm/cursor.h>
 #include <iostream>
@@ -212,7 +213,7 @@ void CanvasGroupMovable::snap_position(double& x, double& y) const
   double offset_y_min = 0;
 
   //Try snapping each corner, to choose the one that snapped closest:
-  for(int i = static_cast<int>(Corners::TOP_LEFT); i < static_cast<int>(Corners::COUNT); ++i)
+  for(int i = Utils::to_utype(Corners::TOP_LEFT); i < Utils::to_utype(Corners::COUNT); ++i)
   {
     const Corners corner = (Corners)i;
     double temp_x = x;
diff --git a/glom/utility_widgets/canvas/canvas_group_resizable.cc 
b/glom/utility_widgets/canvas/canvas_group_resizable.cc
index b2266d0..b5b185b 100644
--- a/glom/utility_widgets/canvas/canvas_group_resizable.cc
+++ b/glom/utility_widgets/canvas/canvas_group_resizable.cc
@@ -22,6 +22,7 @@
 #include "canvas_rect_movable.h"
 #include "canvas_line_movable.h"
 #include <glom/utility_widgets/canvas/canvas_table_movable.h>
+#include <libglom/utils.h>
 #include <goocanvasmm/canvas.h>
 #include <goocanvasrect.h>
 #include <goocanvasgroup.h>
@@ -925,7 +926,7 @@ void CanvasGroupResizable::snap_position(double& x, double& y) const
   double offset_y_min = 0;
 
   //Try snapping each corner, to choose the one that snapped closest:
-  for(int i = 0; i < static_cast<int>(Corners::COUNT); ++i)
+  for(int i = 0; i < Utils::to_utype(Corners::COUNT); ++i)
   {
     const Corners corner = (Corners)i;
     double temp_x = x;
diff --git a/glom/utility_widgets/canvas/canvas_rect_movable.cc 
b/glom/utility_widgets/canvas/canvas_rect_movable.cc
index a1d3760..7c970ec 100644
--- a/glom/utility_widgets/canvas/canvas_rect_movable.cc
+++ b/glom/utility_widgets/canvas/canvas_rect_movable.cc
@@ -19,6 +19,7 @@
  */
 
 #include "canvas_rect_movable.h"
+#include <libglom/utils.h>
 #include <goocanvasmm/canvas.h>
 #include <gdkmm/cursor.h>
 #include <iostream>
@@ -139,7 +140,7 @@ void CanvasRectMovable::snap_position_all_corners(double& x, double& y) const
   double offset_y_min = 0;
 
   //Try snapping each corner, to choose the one that snapped closest:
-  for(int i = static_cast<int>(Corners::TOP_LEFT); i < static_cast<int>(Corners::COUNT); ++i)
+  for(int i = Utils::to_utype(Corners::TOP_LEFT); i < Utils::to_utype(Corners::COUNT); ++i)
   {
     const Corners corner = (Corners)i;
     double temp_x = x;
diff --git a/glom/utility_widgets/canvas/canvas_table_movable.cc 
b/glom/utility_widgets/canvas/canvas_table_movable.cc
index a6833f6..d3e58e6 100644
--- a/glom/utility_widgets/canvas/canvas_table_movable.cc
+++ b/glom/utility_widgets/canvas/canvas_table_movable.cc
@@ -19,6 +19,7 @@
  */
 
 #include "canvas_table_movable.h"
+#include <libglom/utils.h>
 #include <goocanvasmm/canvas.h>
 #include <gdkmm/cursor.h>
 #include <iostream>
@@ -157,7 +158,7 @@ void CanvasTableMovable::snap_position(double& x, double& y) const
   double offset_y_min = 0;
 
   //Try snapping each corner, to choose the one that snapped closest:
-  for(int i = static_cast<int>(Corners::TOP_LEFT); i < static_cast<int>(Corners::COUNT); ++i)
+  for(int i = Utils::to_utype(Corners::TOP_LEFT); i < Utils::to_utype(Corners::COUNT); ++i)
   {
     const Corners corner = (Corners)i;
     double temp_x = x;
diff --git a/glom/utility_widgets/filechooserdialog_saveextras.cc 
b/glom/utility_widgets/filechooserdialog_saveextras.cc
index 6106311..9143a16 100644
--- a/glom/utility_widgets/filechooserdialog_saveextras.cc
+++ b/glom/utility_widgets/filechooserdialog_saveextras.cc
@@ -86,9 +86,9 @@ void FileChooserDialog_SaveExtras::create_child_widgets()
   frame->set_shadow_type(Gtk::SHADOW_NONE);
   frame->show();
 
-  Gtk::Box* vbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL, 
static_cast<int>(UiUtils::DefaultSpacings::SMALL)));
-  vbox->set_margin_start(static_cast<int>(UiUtils::DefaultSpacings::LARGE));
-  vbox->set_margin_top(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
+  Gtk::Box* vbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL, 
Utils::to_utype(UiUtils::DefaultSpacings::SMALL)));
+  vbox->set_margin_start(Utils::to_utype(UiUtils::DefaultSpacings::LARGE));
+  vbox->set_margin_top(Utils::to_utype(UiUtils::DefaultSpacings::SMALL));
   frame->add(*vbox);
   vbox->show();
 
@@ -100,7 +100,7 @@ void FileChooserDialog_SaveExtras::create_child_widgets()
   label_newdb->set_valign(Gtk::ALIGN_CENTER);
   label_newdb->show();
 
-  Gtk::Box* box_label = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 
static_cast<int>(UiUtils::DefaultSpacings::LARGE)));
+  Gtk::Box* box_label = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 
Utils::to_utype(UiUtils::DefaultSpacings::LARGE)));
   Gtk::Label* label_title = Gtk::manage(new Gtk::Label(_("_Title:"), true));
   box_label->pack_start(*label_title, Gtk::PACK_SHRINK);
   label_title->show();
diff --git a/glom/utility_widgets/notebook_noframe.cc b/glom/utility_widgets/notebook_noframe.cc
index 74b000c..f820641 100644
--- a/glom/utility_widgets/notebook_noframe.cc
+++ b/glom/utility_widgets/notebook_noframe.cc
@@ -20,6 +20,7 @@
 
 #include "notebook_noframe.h"
 #include <glom/utils_ui.h>
+#include <libglom/utils.h>
 #include <gtkmm/label.h>
 #include <gtkmm/togglebutton.h>
 #include <glibmm/i18n.h>
@@ -31,10 +32,10 @@ namespace Glom
 NotebookNoFrame::NotebookNoFrame()
 {
   set_orientation(Gtk::ORIENTATION_VERTICAL);
-  set_spacing(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
+  set_spacing(Utils::to_utype(UiUtils::DefaultSpacings::SMALL));
 
   m_box_top.set_orientation(Gtk::ORIENTATION_HORIZONTAL);
-  m_box_top.set_spacing(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
+  m_box_top.set_spacing(Utils::to_utype(UiUtils::DefaultSpacings::SMALL));
   m_box_top.pack_start(m_box_action_left, Gtk::PACK_SHRINK);
   m_box_top.pack_start(m_box_tabs);
   m_box_top.pack_end(m_box_action_right, Gtk::PACK_SHRINK);
@@ -48,7 +49,7 @@ NotebookNoFrame::NotebookNoFrame()
     m_box_pages.property_visible_child().signal_changed().connect(
       sigc::mem_fun(*this, &NotebookNoFrame::on_visible_child_changed));
 
-  //m_box_tabs.set_spacing(static_cast<int>(UiUtils::DefaultSpacings::SMALL));
+  //m_box_tabs.set_spacing(Utils::to_utype(UiUtils::DefaultSpacings::SMALL));
 
   m_box_tabs.show();
 
diff --git a/glom/window_boxholder.cc b/glom/window_boxholder.cc
index da8e07e..b9f1420 100644
--- a/glom/window_boxholder.cc
+++ b/glom/window_boxholder.cc
@@ -36,7 +36,7 @@ Window_BoxHolder::Window_BoxHolder(Box_WithButtons* pBox, const Glib::ustring& t
 
   pBox->signal_cancelled.connect(sigc::mem_fun(*this, &Window_BoxHolder::on_box_cancelled));
 
-  set_border_width(static_cast<int>(UiUtils::DefaultSpacings::LARGE));
+  set_border_width(Utils::to_utype(UiUtils::DefaultSpacings::LARGE));
   add(*pBox);
 
   pBox->show();
diff --git a/tests/python/test_python_execute_func_with_record.cc 
b/tests/python/test_python_execute_func_with_record.cc
index 5fd610c..a041126 100644
--- a/tests/python/test_python_execute_func_with_record.cc
+++ b/tests/python/test_python_execute_func_with_record.cc
@@ -75,7 +75,7 @@ int main()
     connection_pool->startup( sigc::ptr_fun(&on_startup_progress) );
   if(started != Glom::ConnectionPool::Backend::StartupErrors::NONE)
   {
-    std::cerr << G_STRFUNC << ": connection_pool->startup(): result=" << static_cast<int>(started) << 
std::endl;
+    std::cerr << G_STRFUNC << ": connection_pool->startup(): result=" << Glom::Utils::to_utype(started) << 
std::endl;
   }
   g_assert(started == Glom::ConnectionPool::Backend::StartupErrors::NONE);
 
diff --git a/tests/test_selfhosting_utils.cc b/tests/test_selfhosting_utils.cc
index 6ba5baf..a988253 100644
--- a/tests/test_selfhosting_utils.cc
+++ b/tests/test_selfhosting_utils.cc
@@ -162,7 +162,7 @@ bool test_selfhost(Glom::Document& document, const Glib::ustring& user, const Gl
   const auto started = connection_pool->startup( sigc::ptr_fun(&on_startup_progress) );
   if(started != Glom::ConnectionPool::Backend::StartupErrors::NONE)
   {
-    std::cerr << G_STRFUNC << ": connection_pool->startup(): result=" << static_cast<int>(started) << 
std::endl;
+    std::cerr << G_STRFUNC << ": connection_pool->startup(): result=" << Glom::Utils::to_utype(started) << 
std::endl;
     test_selfhosting_cleanup();
     return false;
   }
@@ -177,7 +177,7 @@ bool test_create_and_selfhost_new_empty(Glom::Document& document, Glom::Document
     (hosting_mode != Glom::Document::HostingMode::MYSQL_SELF) &&
     (hosting_mode != Glom::Document::HostingMode::SQLITE) )
   {
-    std::cerr << G_STRFUNC << ": This test function does not support the specified hosting_mode: " << 
static_cast<int>(hosting_mode) << std::endl;
+    std::cerr << G_STRFUNC << ": This test function does not support the specified hosting_mode: " << 
Glom::Utils::to_utype(hosting_mode) << std::endl;
     return false;
   }
 
@@ -349,7 +349,7 @@ bool test_create_and_selfhost_from_uri(const Glib::ustring& example_file_uri, Gl
     (hosting_mode != Glom::Document::HostingMode::MYSQL_SELF) &&
     (hosting_mode != Glom::Document::HostingMode::SQLITE) )
   {
-    std::cerr << G_STRFUNC << ": This test function does not support the specified hosting_mode: " << 
static_cast<int>(hosting_mode) << std::endl;
+    std::cerr << G_STRFUNC << ": This test function does not support the specified hosting_mode: " << 
Glom::Utils::to_utype(hosting_mode) << std::endl;
     return false;
   }
 
@@ -375,7 +375,7 @@ bool test_create_and_selfhost_from_data(const Glib::ustring& example_file_conten
     (hosting_mode != Glom::Document::HostingMode::MYSQL_SELF) &&
     (hosting_mode != Glom::Document::HostingMode::SQLITE) )
   {
-    std::cerr << G_STRFUNC << ": This test function does not support the specified hosting_mode: " << 
static_cast<int>(hosting_mode) << std::endl;
+    std::cerr << G_STRFUNC << ": This test function does not support the specified hosting_mode: " << 
Glom::Utils::to_utype(hosting_mode) << std::endl;
     return false;
   }
 



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