[glom] Base_DB::handle_error(): Take a parent Gtk::Window.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Base_DB::handle_error(): Take a parent Gtk::Window.
- Date: Tue, 17 Jun 2014 07:25:46 +0000 (UTC)
commit aeccb4f018585942a78d1060c460a40bd8c22c0d
Author: Murray Cumming <murrayc murrayc com>
Date: Tue Jun 17 09:10:14 2014 +0200
Base_DB::handle_error(): Take a parent Gtk::Window.
This was always a good idea, and now its more noticeable because
GTK+ outputs a message about missing transient windows.
glom/base_db.cc | 29 ++++++++++++++++-------------
glom/base_db.h | 4 ++--
glom/box_db_table.cc | 8 ++++++++
glom/box_db_table.h | 6 +++++-
glom/mode_data/box_data.cc | 10 ++++++++++
glom/mode_data/box_data.h | 3 +++
glom/mode_data/db_adddel/db_adddel.cc | 15 +++++++++++++--
glom/mode_data/db_adddel/db_adddel.h | 3 +++
8 files changed, 60 insertions(+), 18 deletions(-)
---
diff --git a/glom/base_db.cc b/glom/base_db.cc
index aea05fe..1cffa84 100644
--- a/glom/base_db.cc
+++ b/glom/base_db.cc
@@ -115,23 +115,28 @@ sharedptr<SharedConnection> Base_DB::connect_to_server(Gtk::Window* parent_windo
return ConnectionPool::get_and_connect();
}
-void Base_DB::handle_error(const Glib::Exception& ex)
+void Base_DB::handle_error(const Glib::Exception& ex, Gtk::Window* parent)
{
std::cerr << G_STRFUNC << ": Internal Error (Base_DB::handle_error()): exception type=" <<
typeid(ex).name() << ", ex.what()=" << ex.what() << std::endl;
Gtk::MessageDialog dialog(UiUtils::bold_message(_("Internal error")), true, Gtk::MESSAGE_WARNING );
dialog.set_secondary_text(ex.what());
- //TODO: dialog.set_transient_for(*get_appwindow());
+
+ if(parent)
+ dialog.set_transient_for(*parent);
+
dialog.run();
}
-void Base_DB::handle_error(const std::exception& ex)
+void Base_DB::handle_error(const std::exception& ex, Gtk::Window* parent)
{
std::cerr << G_STRFUNC << ": Internal Error (Base_DB::handle_error()): exception type=" <<
typeid(ex).name() << ", ex.what()=" << ex.what() << std::endl;
Gtk::MessageDialog dialog(UiUtils::bold_message(_("Internal error")), true, Gtk::MESSAGE_WARNING );
dialog.set_secondary_text(ex.what());
- //TODO: dialog.set_transient_for(*get_appwindow());
+
+ if(parent)
+ dialog.set_transient_for(*parent);
dialog.run();
}
@@ -256,7 +261,7 @@ namespace
}
}
-sharedptr<Field> Base_DB::change_column(const Glib::ustring& table_name, const sharedptr<const Field>&
field_old, const sharedptr<const Field>& field, Gtk::Window* /* parent_window */) const
+sharedptr<Field> Base_DB::change_column(const Glib::ustring& table_name, const sharedptr<const Field>&
field_old, const sharedptr<const Field>& field, Gtk::Window* parent_window) const
{
ConnectionPool* connection_pool = ConnectionPool::get_instance();
sharedptr<Field> result = check_field_change_constraints(field_old, field);
@@ -267,16 +272,14 @@ sharedptr<Field> Base_DB::change_column(const Glib::ustring& table_name, const s
}
catch(const Glib::Error& ex)
{
- handle_error(ex);
-// Gtk::MessageDialog window(*parent_window, UiUtils::bold_message(ex.what()), true, Gtk::MESSAGE_ERROR,
Gtk::BUTTONS_OK);
-// window.run();
+ handle_error(ex, parent_window);
return sharedptr<Field>();
}
return result;
}
-bool Base_DB::change_columns(const Glib::ustring& table_name, const type_vec_const_fields& old_fields,
type_vec_fields& fields, Gtk::Window* /* parent_window */) const
+bool Base_DB::change_columns(const Glib::ustring& table_name, const type_vec_const_fields& old_fields,
type_vec_fields& fields, Gtk::Window* parent_window) const
{
g_assert(old_fields.size() == fields.size());
@@ -295,7 +298,7 @@ bool Base_DB::change_columns(const Glib::ustring& table_name, const type_vec_con
}
catch(const Glib::Error& ex)
{
- handle_error(ex);
+ handle_error(ex, parent_window);
// Gtk::MessageDialog window(*parent_window, UiUtils::bold_message(ex.what()), true, Gtk::MESSAGE_ERROR,
Gtk::BUTTONS_OK);
// window.run();
return false;
@@ -970,7 +973,7 @@ bool Base_DB::set_field_value_in_database(const LayoutFieldInRecord& field_in_re
return set_field_value_in_database(field_in_record, Gtk::TreeModel::iterator(), field_value,
use_current_calculations, parent_window);
}
-bool Base_DB::set_field_value_in_database(const LayoutFieldInRecord& layoutfield_in_record, const
Gtk::TreeModel::iterator& row, const Gnome::Gda::Value& field_value, bool use_current_calculations,
Gtk::Window* /* parent_window */)
+bool Base_DB::set_field_value_in_database(const LayoutFieldInRecord& layoutfield_in_record, const
Gtk::TreeModel::iterator& row, const Gnome::Gda::Value& field_value, bool use_current_calculations,
Gtk::Window* parent_window)
{
Document* document = get_document();
g_assert(document);
@@ -1011,12 +1014,12 @@ bool Base_DB::set_field_value_in_database(const LayoutFieldInRecord& layoutfield
}
catch(const Glib::Exception& ex)
{
- handle_error(ex);
+ handle_error(ex, parent_window);
return false;
}
catch(const std::exception& ex)
{
- handle_error(ex);
+ handle_error(ex, parent_window);
return false;
}
diff --git a/glom/base_db.h b/glom/base_db.h
index 1251fb0..2b9016e 100644
--- a/glom/base_db.h
+++ b/glom/base_db.h
@@ -302,8 +302,8 @@ protected:
bool disable_user(const Glib::ustring& user);
- static void handle_error(const Glib::Exception& ex);
- static void handle_error(const std::exception& ex); //TODO_port: This is probably useless now.
+ static void handle_error(const Glib::Exception& ex, Gtk::Window* parent);
+ static void handle_error(const std::exception& ex, Gtk::Window* parent); //TODO_port: This is probably
useless now.
static bool handle_error();
protected:
diff --git a/glom/box_db_table.cc b/glom/box_db_table.cc
index d922c8d..cf3f9e6 100644
--- a/glom/box_db_table.cc
+++ b/glom/box_db_table.cc
@@ -50,7 +50,15 @@ Gtk::Window* Box_DB_Table::get_app_window()
return dynamic_cast<Gtk::Window*>(get_toplevel());
}
+void Box_DB_Table::handle_error(const Glib::Exception& ex)
+{
+ Base_DB::handle_error(ex, get_app_window());
+}
+void Box_DB_Table::handle_error(const std::exception& ex)
+{
+ Base_DB::handle_error(ex, get_app_window());
+}
} //namespace Glom
diff --git a/glom/box_db_table.h b/glom/box_db_table.h
index 31d1d97..62ad6d6 100644
--- a/glom/box_db_table.h
+++ b/glom/box_db_table.h
@@ -40,7 +40,11 @@ public:
Box_DB_Table();
Box_DB_Table(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& builder);
virtual ~Box_DB_Table();
-
+
+protected:
+ void handle_error(const Glib::Exception& ex);
+ void handle_error(const std::exception& ex); //TODO_port: This is probably useless now.
+
Gtk::Window* get_app_window();
const Gtk::Window* get_app_window() const;
};
diff --git a/glom/mode_data/box_data.cc b/glom/mode_data/box_data.cc
index cff3ffc..d196d0f 100644
--- a/glom/mode_data/box_data.cc
+++ b/glom/mode_data/box_data.cc
@@ -378,4 +378,14 @@ void Box_Data::execute_button_script(const sharedptr<const LayoutItem_Button>& l
}
}
+void Box_Data::handle_error(const Glib::Exception& ex)
+{
+ Base_DB::handle_error(ex, get_app_window());
+}
+
+void Box_Data::handle_error(const std::exception& ex)
+{
+ Base_DB::handle_error(ex, get_app_window());
+}
+
} //namespace Glom
diff --git a/glom/mode_data/box_data.h b/glom/mode_data/box_data.h
index 7a2a8d1..5f7972f 100644
--- a/glom/mode_data/box_data.h
+++ b/glom/mode_data/box_data.h
@@ -127,6 +127,9 @@ protected:
virtual void prepare_layout_dialog(Dialog_Layout* dialog) = 0;
#endif // !GLOM_ENABLE_CLIENT_ONLY
+ void handle_error(const Glib::Exception& ex);
+ void handle_error(const std::exception& ex); //TODO_port: This is probably useless now.
+
Gtk::Button m_Button_Find; //only used by _Find sub-classes. Should be MI.
Gtk::Label m_Label_FindStatus;
diff --git a/glom/mode_data/db_adddel/db_adddel.cc b/glom/mode_data/db_adddel/db_adddel.cc
index 000e275..3c4775d 100644
--- a/glom/mode_data/db_adddel/db_adddel.cc
+++ b/glom/mode_data/db_adddel/db_adddel.cc
@@ -2228,7 +2228,7 @@ void DbAddDel::user_changed(const Gtk::TreeModel::iterator& row, guint col)
}
catch(const Glib::Exception& ex)
{
- handle_error(ex);
+ handle_error(ex, get_app_window());
//Replace with correct values.
if(primary_key_field)
@@ -2240,7 +2240,7 @@ void DbAddDel::user_changed(const Gtk::TreeModel::iterator& row, guint col)
}
catch(const std::exception& ex)
{
- handle_error(ex);
+ handle_error(ex, get_app_window());
//Replace with correct values.
if(primary_key_field)
@@ -2453,5 +2453,16 @@ void DbAddDel::treeview_delete_all_columns()
m_treeviewcolumn_button = 0;
}
+const Gtk::Window* DbAddDel::get_app_window() const
+{
+ DbAddDel* nonconst = const_cast<DbAddDel*>(this);
+ return nonconst->get_app_window();
+}
+
+Gtk::Window* DbAddDel::get_app_window()
+{
+ return dynamic_cast<Gtk::Window*>(get_toplevel());
+}
+
} //namespace Glom
diff --git a/glom/mode_data/db_adddel/db_adddel.h b/glom/mode_data/db_adddel/db_adddel.h
index b794ae4..221c55b 100644
--- a/glom/mode_data/db_adddel/db_adddel.h
+++ b/glom/mode_data/db_adddel/db_adddel.h
@@ -434,6 +434,9 @@ private:
void treeview_delete_all_columns();
+ Gtk::Window* get_app_window();
+ const Gtk::Window* get_app_window() const;
+
bool m_find_mode;
bool m_allow_only_one_related_record;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]