[glom/glom-1-20] 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/glom-1-20] Button scripts and Field Calculations: Test button: Check for pygtk2.
- Date: Mon, 6 Feb 2012 11:36:49 +0000 (UTC)
commit 26426c825b17ac68b2273f7bafce74707c5c331f
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 d87ef02..fb95708 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 d326f00..f08a291 100644
--- a/glom/mode_data/box_data.cc
+++ b/glom/mode_data/box_data.cc
@@ -351,12 +351,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 8a4a848..d0a132d 100644
--- a/glom/mode_design/fields/dialog_fieldcalculation.cc
+++ b/glom/mode_design/fields/dialog_fieldcalculation.cc
@@ -112,6 +112,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 f5b285c..d043a48 100644
--- a/glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.cc
@@ -104,6 +104,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 b279e73..51ae462 100644
--- a/glom/utils_ui.cc
+++ b/glom/utils_ui.cc
@@ -533,4 +533,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]