[glom] Button scripts and Field Calculations: Test button: Check for pygtk2.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Button scripts and Field Calculations: Test button: Check for pygtk2.
- Date: Sun, 5 Feb 2012 20:55:00 +0000 (UTC)
commit 42ab98987c3ef79b2dbaa9b7c94f78d07e5eed6a
Author: Murray Cumming <murrayc murrayc com>
Date: Sun Feb 5 21:53:10 2012 +0100
Button scripts and Field Calculations: Test button: Check for pygtk2.
* glom/mode_data/box_data.cc: :execute_button_script(): Move the
warning UI into
* glom/utils_ui.[h|cc]: a new script_check_for_pygtk2_with_warning()
method.
* glom/mode_design/fields/dialog_fieldcalculation.cc: on_button_test():
* glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.cc:
on_button_test_script(): Use the new function here.
ChangeLog | 12 ++++++++++++
glom/mode_data/box_data.cc | 6 +-----
glom/mode_design/fields/dialog_fieldcalculation.cc | 3 +++
.../layout_item_dialogs/dialog_buttonscript.cc | 2 ++
glom/utils_ui.cc | 12 ++++++++++++
glom/utils_ui.h | 5 +++++
6 files changed, 35 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 650bcc2..b00b0ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2012-02-05 Murray Cumming <murrayc murrayc com>
+
+ Button scripts and Field Calculations: Test button: Check for pygtk2.
+
+ * glom/mode_data/box_data.cc: :execute_button_script(): Move the
+ warning UI into
+ * glom/utils_ui.[h|cc]: a new script_check_for_pygtk2_with_warning()
+ method.
+ * glom/mode_design/fields/dialog_fieldcalculation.cc: on_button_test():
+ * glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.cc:
+ on_button_test_script(): Use the new function here.
+
2012-02-03 Murray Cumming <murrayc murrayc com>
Button scripts: Check and warn about pygtk2 instead of crashing.
diff --git a/glom/mode_data/box_data.cc b/glom/mode_data/box_data.cc
index c3c701b..ca00dd7 100644
--- a/glom/mode_data/box_data.cc
+++ b/glom/mode_data/box_data.cc
@@ -353,12 +353,8 @@ Glib::ustring Box_Data::get_layout_name() const
void Box_Data::execute_button_script(const sharedptr<const LayoutItem_Button>& layout_item, const Gnome::Gda::Value& primary_key_value)
{
const Glib::ustring script = layout_item->get_script();
- if(!Utils::script_check_for_pygtk2(script))
- {
- Utils::show_ok_dialog(_("Script Uses PyGTK 2"),
- _("Glom cannot run this script because it uses pygtk 2, but Glom uses GTK+ 3, and attempting to use pygtk 2 would cause Glom to crash."), *get_app_window(), Gtk::MESSAGE_ERROR);
+ if(!Utils::script_check_for_pygtk2_with_warning(script, get_app_window()))
return;
- }
const sharedptr<Field> field_primary_key = get_field_primary_key();
const type_map_fields field_values = get_record_field_values_for_calculation(m_table_name, field_primary_key, primary_key_value);
diff --git a/glom/mode_design/fields/dialog_fieldcalculation.cc b/glom/mode_design/fields/dialog_fieldcalculation.cc
index a882b34..ce2e1a1 100644
--- a/glom/mode_design/fields/dialog_fieldcalculation.cc
+++ b/glom/mode_design/fields/dialog_fieldcalculation.cc
@@ -113,6 +113,9 @@ void Dialog_FieldCalculation::on_button_test()
if(!check_for_return_statement(calculation))
return;
+ if(!Utils::script_check_for_pygtk2_with_warning(calculation, this))
+ return;
+
type_map_fields field_values;
Document* document = get_document();
diff --git a/glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.cc b/glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.cc
index 92bc4a4..3164a59 100644
--- a/glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.cc
@@ -105,6 +105,8 @@ void Dialog_ButtonScript::get_script(const sharedptr<LayoutItem_Button>& script)
void Dialog_ButtonScript::on_button_test_script()
{
const Glib::ustring calculation = m_text_view_script->get_buffer()->get_text();
+ if(!Utils::script_check_for_pygtk2_with_warning(calculation, this))
+ return;
type_map_fields field_values;
diff --git a/glom/utils_ui.cc b/glom/utils_ui.cc
index ed6adfd..25e8d39 100644
--- a/glom/utils_ui.cc
+++ b/glom/utils_ui.cc
@@ -534,4 +534,16 @@ std::string Utils::get_icon_path(const Glib::ustring& filename)
#endif
}
+bool Utils::script_check_for_pygtk2_with_warning(const Glib::ustring& script, Gtk::Window* parent_window)
+{
+ if(!Utils::script_check_for_pygtk2(script))
+ {
+ Utils::show_ok_dialog(_("Script Uses PyGTK 2"),
+ _("Glom cannot run this script because it uses pygtk 2, but Glom uses GTK+ 3, and attempting to use pygtk 2 would cause Glom to crash."), parent_window, Gtk::MESSAGE_ERROR);
+ return false;
+ }
+
+ return true;
+}
+
} //namespace Glom
diff --git a/glom/utils_ui.h b/glom/utils_ui.h
index 5febc5e..d37da5b 100644
--- a/glom/utils_ui.h
+++ b/glom/utils_ui.h
@@ -98,6 +98,11 @@ void show_report_in_browser(const std::string& filepath, Gtk::Window* parent_win
std::string get_icon_path(const Glib::ustring& filename);
+/** Runs libglom's Utils::script_check_for_pygtk2() and shows
+ * a warning dialog if necessary.
+ */
+bool script_check_for_pygtk2_with_warning(const Glib::ustring& script, Gtk::Window* parent_window);
+
} //namespace Utils
} //namespace Glom
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]