Commit 42ab9898 authored by Murray Cumming's avatar Murray Cumming
Browse files

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.
parent e9334643
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.
......
......@@ -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);
......
......@@ -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();
......
......@@ -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;
......
......@@ -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
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment