Commit 48b9b8ca authored by Murray Cumming's avatar Murray Cumming
Browse files

dialog_run_with_help(): Get the help ID from the class.

  * glom/utils_ui.h: dialog_run_with_help(): Add a templated version that uses
  the static glade_id member, to avoid repeating this in the source code.
* Several .cc files: Remove the ID parameter from most uses of
dialog_run_with_help().
parent 8364855d
1.14.0:
 
2010-04-10 Murray Cumming <murrayc@murrayc-x61>
dialog_run_with_help(): Get the help ID from the class.
* glom/utils_ui.h: dialog_run_with_help(): Add a templated version that uses
the static glade_id member, to avoid repeating this in the source code.
* Several .cc files: Remove the ID parameter from most uses of
dialog_run_with_help().
2010-04-10 Murray Cumming <murrayc@murrayc.com>
Glade instantiation: Simplify, make more robust, and test.
* glom/glade_utils.h: get_glade_widget_derived_with_warning(),
get_glade_developer_widget_derived_with_warning(): Add method overloads that
don't take an ID. These require the class to have a static glade_id member.
This associates the IDs with the class, instead of being in other files,
to avoid duplication and to avoid using the wrong ones.
* Many files: Use these new methods, to avoid mentioning glade IDs.
* tests/test_glade_derived_instantiation.cc: Try to instantiate all the known
derived glade dialogs.
2010-04-10 Murray Cumming <murrayc@murrayc.com>
 
Glade files: Move a client-only dialog to the correct file.
......@@ -22,19 +44,6 @@
* glom/base_db.cc: offer_item_formatting(): Remove a useless use of
Gtk::Builder.
2010-04-10 Murray Cumming <murrayc@murrayc.com>
Glade instantiation: Simplify, make more robust, and test.
* glom/glade_utils.h: get_glade_widget_derived_with_warning(),
get_glade_developer_widget_derived_with_warning(): Add method overloads that
don't take an ID. These require the class to have a static glade_id member.
This associates the IDs with the class, instead of being in other files,
to avoid duplication and to avoid using the wrong ones.
* Many files: Use these new methods, to avoid mentioning glade IDs.
* tests/test_glade_derived_instantiation.cc: Try to instantiate all the known
derived glade dialogs.
2010-04-10 Murray Cumming <murrayc@murrayc.com>
 
......
......@@ -717,7 +717,7 @@ void Application::open_browsed_document(const EpcServiceInfo* server, const Glib
dialog_connection->set_transient_for(*this);
dialog_connection->set_connect_to_browsed();
dialog_connection->set_database_name(service_name);
const int response = Glom::Utils::dialog_run_with_help(dialog_connection, "dialog_connection");
const int response = Glom::Utils::dialog_run_with_help(dialog_connection);
dialog_connection->hide();
if(response != Gtk::RESPONSE_OK)
keep_trying = false;
......@@ -1397,7 +1397,7 @@ bool Application::offer_new_or_existing()
bool ask_again = true;
while(ask_again)
{
const int response_id = Utils::dialog_run_with_help(dialog.get(), "dialog_existing_or_new");
const int response_id = Utils::dialog_run_with_help(dialog_raw);
dialog->hide();
if(response_id == Gtk::RESPONSE_ACCEPT)
......@@ -2424,7 +2424,7 @@ void Application::on_menu_developer_changelanguage()
dialog->set_icon_name("glom");
dialog->set_transient_for(*this);
const int response = Glom::Utils::dialog_run_with_help(dialog, "dialog_change_language");
const int response = Glom::Utils::dialog_run_with_help(dialog);
dialog->hide();
if(response == Gtk::RESPONSE_OK)
......
......@@ -1932,7 +1932,7 @@ sharedptr<LayoutItem_Text> Base_DB::offer_textobject(const sharedptr<LayoutItem_
dialog->set_transient_for(*transient_for);
dialog->set_textobject(start_textobject, Glib::ustring(), show_title);
const int response = Glom::Utils::dialog_run_with_help(dialog, "window_textobject");
const int response = Glom::Utils::dialog_run_with_help(dialog);
dialog->hide();
if(response == Gtk::RESPONSE_OK)
{
......@@ -1956,7 +1956,7 @@ sharedptr<LayoutItem_Image> Base_DB::offer_imageobject(const sharedptr<LayoutIte
dialog->set_transient_for(*transient_for);
dialog->set_imageobject(start_imageobject, Glib::ustring(), show_title);
const int response = Glom::Utils::dialog_run_with_help(dialog, "window_imageobject");
const int response = Glom::Utils::dialog_run_with_help(dialog);
dialog->hide();
if(response == Gtk::RESPONSE_OK)
{
......@@ -1981,7 +1981,7 @@ sharedptr<LayoutItem_Notebook> Base_DB::offer_notebook(const sharedptr<LayoutIte
dialog->set_notebook(start_notebook);
//dialog->set_transient_for(*this);
const int response = Glom::Utils::dialog_run_with_help(dialog, "dialog_notebook");
const int response = Glom::Utils::dialog_run_with_help(dialog);
dialog->hide();
if(response == Gtk::RESPONSE_OK)
{
......
......@@ -38,7 +38,7 @@ bool glom_show_dialog_invalid_data(Field::glom_field_type glom_type)
Utils::get_glade_widget_derived_with_warning(dialog);
dialog->set_example_data(glom_type);
//dialog->set_transient_for(*this);
const int response = Glom::Utils::dialog_run_with_help(dialog, "dialog_data_invalid_format");
const int response = Glom::Utils::dialog_run_with_help(dialog);
delete dialog;
return (response == 2); //The glade file has a response of 2 for the Revert button.
......
......@@ -902,7 +902,7 @@ void Frame_Glom::on_menu_file_import()
add_view(dialog);
dialog->import(file_chooser.get_uri(), m_table_name);
while(Glom::Utils::dialog_run_with_help(dialog, "dialog_import_csv") == Gtk::RESPONSE_ACCEPT)
while(Glom::Utils::dialog_run_with_help(dialog) == Gtk::RESPONSE_ACCEPT)
{
dialog->hide();
......@@ -1687,7 +1687,7 @@ void Frame_Glom::on_menu_developer_database_preferences()
add_view(dialog);
dialog->load_from_document();
Glom::Utils::dialog_run_with_help(dialog, "dialog_database_preferences");
Glom::Utils::dialog_run_with_help(dialog);
remove_view(dialog);
delete dialog;
......@@ -1751,7 +1751,7 @@ void Frame_Glom::on_menu_developer_relationships_overview()
m_dialog_relationships_overview->set_transient_for(*(get_app_window()));
m_dialog_relationships_overview->load_from_document();
Glom::Utils::dialog_run_with_help(m_dialog_relationships_overview, "dialog_relationships_overview");
Glom::Utils::dialog_run_with_help(m_dialog_relationships_overview);
remove_view(m_dialog_relationships_overview);
delete m_dialog_relationships_overview;
......@@ -1795,7 +1795,7 @@ void Frame_Glom::on_menu_developer_users()
add_view(dialog); //Give it access to the document.
dialog->load_from_document(); //Update the UI now that it has the document.
Glom::Utils::dialog_run_with_help(dialog, "window_groups");
Glom::Utils::dialog_run_with_help(dialog);
remove_view(dialog);
delete dialog;
......@@ -1879,7 +1879,7 @@ void Frame_Glom::on_menu_developer_script_library()
dialog->set_transient_for(*(get_app_window()));
add_view(dialog); //Give it access to the document.
dialog->load_from_document();
Glom::Utils::dialog_run_with_help(dialog, "dialog_script_library"); //TODO: Create the help section.
Glom::Utils::dialog_run_with_help(dialog); //TODO: Create the help section.
dialog->save_to_document();
remove_view(dialog);
delete dialog;
......@@ -2073,7 +2073,7 @@ bool Frame_Glom::connection_request_initial_password(Glib::ustring& user, Glib::
bool keep_trying = true;
while(keep_trying)
{
response = Utils::dialog_run_with_help(dialog, "dialog_new_self_hosted_connection");
response = Utils::dialog_run_with_help(dialog);
//Check the password is acceptable:
if(response == Gtk::RESPONSE_OK)
......@@ -2170,7 +2170,7 @@ bool Frame_Glom::connection_request_password_and_choose_new_database_name()
m_pDialogConnection->load_from_document(); //Get good defaults.
m_pDialogConnection->set_transient_for(*get_app_window());
const int response = Glom::Utils::dialog_run_with_help(m_pDialogConnection, "dialog_connection");
const int response = Glom::Utils::dialog_run_with_help(m_pDialogConnection);
m_pDialogConnection->hide();
if(response == Gtk::RESPONSE_OK)
......@@ -2441,7 +2441,7 @@ bool Frame_Glom::connection_request_password_and_attempt(bool& database_not_foun
if(m_pDialogConnection)
{
response = Glom::Utils::dialog_run_with_help(m_pDialogConnection, "dialog_connection");
response = Glom::Utils::dialog_run_with_help(m_pDialogConnection);
m_pDialogConnection->hide();
}
......
......@@ -69,7 +69,7 @@ void ButtonGlom::on_menu_properties_activate()
sharedptr<LayoutItem_Button> layout_item =
sharedptr<LayoutItem_Button>::cast_dynamic(get_layout_item());
dialog->set_script(layout_item, m_table_name);
const int response = Glom::Utils::dialog_run_with_help(dialog, "window_button_script");
const int response = Glom::Utils::dialog_run_with_help(dialog);
dialog->hide();
if(response == Gtk::RESPONSE_OK)
{
......
......@@ -652,7 +652,7 @@ void DataWidget::on_button_choose_date()
dialog->set_transient_for(*parent);
dialog->set_date_chosen(get_value());
const int response = Glom::Utils::dialog_run_with_help(dialog, "dialog_choose_date");
const int response = Glom::Utils::dialog_run_with_help(dialog);
dialog->hide();
if(response == Gtk::RESPONSE_OK)
{
......
......@@ -378,7 +378,7 @@ void Dialog_FieldDefinition::on_button_edit_calculation()
m_Field->set_calculation( m_pTextView_Calculation->get_buffer()->get_text() );
dialog->set_field(m_Field, m_table_name);
//TODO: dialog.set_transient_for(*get_app_window());
const int response = Glom::Utils::dialog_run_with_help(dialog, "window_field_calculation");
const int response = Glom::Utils::dialog_run_with_help(dialog);
if(response == Gtk::RESPONSE_OK)
{
m_pTextView_Calculation->get_buffer()->set_text( dialog->get_field()->get_calculation() );
......
......@@ -555,7 +555,7 @@ sharedptr<LayoutItem_Button> Dialog_Layout_Details::offer_button_script_edit(con
Glom::Utils::get_glade_widget_derived_with_warning(dialog);
dialog->set_script(button, m_table_name);
dialog->set_transient_for(*this);
const int response = Glom::Utils::dialog_run_with_help(dialog, "window_button_script");
const int response = Glom::Utils::dialog_run_with_help(dialog);
dialog->hide();
if(response == Gtk::RESPONSE_OK)
{
......
......@@ -141,7 +141,7 @@ void Dialog_GroupBy::on_button_field_sort_by()
{
m_dialog_choose_sort_fields->set_fields(m_table_name, m_layout_item->get_fields_sort_by());
const int response = Glom::Utils::dialog_run_with_help(m_dialog_choose_sort_fields, "dialog_groupby_sort_fields");
const int response = Glom::Utils::dialog_run_with_help(m_dialog_choose_sort_fields);
m_dialog_choose_sort_fields->hide();
if(response == Gtk::RESPONSE_OK && m_dialog_choose_sort_fields->get_modified())
{
......@@ -164,7 +164,7 @@ void Dialog_GroupBy::on_button_secondary_fields()
{
m_dialog_choose_secondary_fields->set_fields(m_table_name, m_layout_item->m_group_secondary_fields->m_list_items);
const int response = Glom::Utils::dialog_run_with_help(m_dialog_choose_secondary_fields, "dialog_groupby_secondary_fields");
const int response = Glom::Utils::dialog_run_with_help(m_dialog_choose_secondary_fields);
m_dialog_choose_secondary_fields->hide();
if(response == Gtk::RESPONSE_OK && m_dialog_choose_secondary_fields->get_modified())
{
......
......@@ -98,7 +98,7 @@ void Dialog_ScriptLibrary::on_button_add()
Utils::get_glade_widget_derived_with_warning(dialog);
dialog->set_icon_name("glom");
dialog->set_transient_for(*this);
const int response = Glom::Utils::dialog_run_with_help(dialog, "dialog_new_script");
const int response = Glom::Utils::dialog_run_with_help(dialog);
dialog->hide();
if(response != Gtk::RESPONSE_OK)
return;
......
......@@ -140,7 +140,7 @@ void Window_Translations::on_button_identify()
dialog->load_from_document(); //Doesn't seem to happen otherwise.
dialog->set_icon_name("glom");
dialog->set_transient_for(*this);
const int response = Glom::Utils::dialog_run_with_help(dialog, "dialog_translation_identify_original");
const int response = Glom::Utils::dialog_run_with_help(dialog);
dialog->hide();
if(response == Gtk::RESPONSE_OK)
......@@ -362,7 +362,7 @@ void Window_Translations::on_button_copy_translation()
Utils::get_glade_widget_derived_with_warning(dialog);
dialog->set_icon_name("glom");
dialog->set_transient_for(*this);
const int response = Glom::Utils::dialog_run_with_help(dialog, "dialog_translation_copy");
const int response = Glom::Utils::dialog_run_with_help(dialog);
dialog->hide();
if(response == Gtk::RESPONSE_OK)
......
......@@ -243,7 +243,7 @@ void Dialog_GroupsList::on_button_group_new()
dialog->set_icon_name("glom");
dialog->set_transient_for(*this);
const int response = Glom::Utils::dialog_run_with_help(dialog, "dialog_new_group");
const int response = Glom::Utils::dialog_run_with_help(dialog);
const Glib::ustring group_name = dialog->m_entry_name->get_text();
......@@ -300,7 +300,7 @@ void Dialog_GroupsList::on_button_group_users()
dialog->set_group(group_name);
Glom::Utils::dialog_run_with_help(dialog, "window_groups");
Glom::Utils::dialog_run_with_help(dialog);
remove_view(dialog);
delete dialog;
......
......@@ -189,7 +189,7 @@ void Dialog_UsersList::on_button_user_add()
//Fill it with the list of users:
dialog->set_user_list( Privs::get_database_users() );
const int response = Glom::Utils::dialog_run_with_help(dialog, "dialog_choose_user");
const int response = Glom::Utils::dialog_run_with_help(dialog);
const Glib::ustring user = dialog->get_user();
......@@ -233,7 +233,7 @@ void Dialog_UsersList::on_button_user_new()
bool keep_trying = true;
while(keep_trying)
{
response = Glom::Utils::dialog_run_with_help(dialog, "dialog_user");
response = Glom::Utils::dialog_run_with_help(dialog);
//Check the password is acceptable:
if(response == Gtk::RESPONSE_OK)
......@@ -295,7 +295,7 @@ void Dialog_UsersList::on_button_user_edit()
bool keep_trying = true;
while(keep_trying)
{
response = Glom::Utils::dialog_run_with_help(dialog, "dialog_user");
response = Glom::Utils::dialog_run_with_help(dialog);
//Check the password is acceptable:
if(response == Gtk::RESPONSE_OK)
......
......@@ -94,7 +94,7 @@ namespace Glom
// Run dialog and response on Help if appropriate.
int Utils::dialog_run_with_help(Gtk::Dialog* dialog, const Glib::ustring& id)
{
int result = dialog->run();
const int result = dialog->run();
//Maemo has no help system since Maemo 5,
//so we hide the buttons in anyway.
......
......@@ -52,8 +52,24 @@ enum DefaultSpacings
#endif //GLOM_ENABLE_MAEMO
};
/**
* Show the dialog, blocking until there is a non-help response,
* showing the appropriate help page if the help button is clicked.
*/
int dialog_run_with_help(Gtk::Dialog* dialog, const Glib::ustring& id = Glib::ustring());
/**
* Show the dialog, blocking until there is a non-help response,
* showing the appropriate help page if the help button is clicked.
* This requires the dialog class to have a static
* glade_id member variable, which we reuse as the help ID.
*/
template<class T_Dialog>
int dialog_run_with_help(T_Dialog* dialog)
{
return dialog_run_with_help(dialog, T_Dialog::glade_id);
}
// Maemo has no help system since Maemo 5 (Fremantle).
#ifndef GLOM_ENABLE_MAEMO
/** This is a replacement for gnome_help_display(),
......
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