[glom] dialog_run_with_help(): Get the help ID from the class.



commit 48b9b8ca0d54afdad0e1c65418a78b4aa300166d
Author: Murray Cumming <murrayc murrayc com>
Date:   Sat Apr 10 16:17:08 2010 +0200

    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().

 ChangeLog                                          |   35 ++++++++++++-------
 glom/application.cc                                |    6 ++--
 glom/base_db.cc                                    |    6 ++--
 glom/dialog_invalid_data.cc                        |    2 +-
 glom/frame_glom.cc                                 |   16 ++++----
 glom/mode_data/buttonglom.cc                       |    2 +-
 glom/mode_data/datawidget/datawidget.cc            |    2 +-
 glom/mode_design/fields/dialog_fielddefinition.cc  |    2 +-
 glom/mode_design/layout/dialog_layout_details.cc   |    2 +-
 .../layout/layout_item_dialogs/dialog_group_by.cc  |    4 +-
 .../script_library/dialog_script_library.cc        |    2 +-
 .../mode_design/translation/window_translations.cc |    4 +-
 glom/mode_design/users/dialog_groups_list.cc       |    4 +-
 glom/mode_design/users/dialog_users_list.cc        |    6 ++--
 glom/utils_ui.cc                                   |    2 +-
 glom/utils_ui.h                                    |   16 +++++++++
 16 files changed, 68 insertions(+), 43 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 078af1f..de458a1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,27 @@
 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>
 
diff --git a/glom/application.cc b/glom/application.cc
index 5f146dc..ca5e2cf 100644
--- a/glom/application.cc
+++ b/glom/application.cc
@@ -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)
diff --git a/glom/base_db.cc b/glom/base_db.cc
index cf5145b..3aa2a32 100644
--- a/glom/base_db.cc
+++ b/glom/base_db.cc
@@ -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)
   {
diff --git a/glom/dialog_invalid_data.cc b/glom/dialog_invalid_data.cc
index db4c769..f7829f8 100644
--- a/glom/dialog_invalid_data.cc
+++ b/glom/dialog_invalid_data.cc
@@ -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.
diff --git a/glom/frame_glom.cc b/glom/frame_glom.cc
index 8213b50..1b18545 100644
--- a/glom/frame_glom.cc
+++ b/glom/frame_glom.cc
@@ -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();
     }
 
diff --git a/glom/mode_data/buttonglom.cc b/glom/mode_data/buttonglom.cc
index beff876..7c6c183 100644
--- a/glom/mode_data/buttonglom.cc
+++ b/glom/mode_data/buttonglom.cc
@@ -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)
   {
diff --git a/glom/mode_data/datawidget/datawidget.cc b/glom/mode_data/datawidget/datawidget.cc
index fdd68a7..15a5a93 100644
--- a/glom/mode_data/datawidget/datawidget.cc
+++ b/glom/mode_data/datawidget/datawidget.cc
@@ -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)
     {
diff --git a/glom/mode_design/fields/dialog_fielddefinition.cc b/glom/mode_design/fields/dialog_fielddefinition.cc
index 19b4a97..e3fbd27 100644
--- a/glom/mode_design/fields/dialog_fielddefinition.cc
+++ b/glom/mode_design/fields/dialog_fielddefinition.cc
@@ -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() );
diff --git a/glom/mode_design/layout/dialog_layout_details.cc b/glom/mode_design/layout/dialog_layout_details.cc
index 3bf858c..477abff 100644
--- a/glom/mode_design/layout/dialog_layout_details.cc
+++ b/glom/mode_design/layout/dialog_layout_details.cc
@@ -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)
   {
diff --git a/glom/mode_design/layout/layout_item_dialogs/dialog_group_by.cc b/glom/mode_design/layout/layout_item_dialogs/dialog_group_by.cc
index 570b860..0089315 100644
--- a/glom/mode_design/layout/layout_item_dialogs/dialog_group_by.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/dialog_group_by.cc
@@ -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())
     {
diff --git a/glom/mode_design/script_library/dialog_script_library.cc b/glom/mode_design/script_library/dialog_script_library.cc
index 80c7224..ac2f6ea 100644
--- a/glom/mode_design/script_library/dialog_script_library.cc
+++ b/glom/mode_design/script_library/dialog_script_library.cc
@@ -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;
diff --git a/glom/mode_design/translation/window_translations.cc b/glom/mode_design/translation/window_translations.cc
index c7e69b5..15b2026 100644
--- a/glom/mode_design/translation/window_translations.cc
+++ b/glom/mode_design/translation/window_translations.cc
@@ -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)
diff --git a/glom/mode_design/users/dialog_groups_list.cc b/glom/mode_design/users/dialog_groups_list.cc
index 503309f..4668074 100644
--- a/glom/mode_design/users/dialog_groups_list.cc
+++ b/glom/mode_design/users/dialog_groups_list.cc
@@ -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;
diff --git a/glom/mode_design/users/dialog_users_list.cc b/glom/mode_design/users/dialog_users_list.cc
index ba368a3..579199e 100644
--- a/glom/mode_design/users/dialog_users_list.cc
+++ b/glom/mode_design/users/dialog_users_list.cc
@@ -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)
diff --git a/glom/utils_ui.cc b/glom/utils_ui.cc
index 5e7f734..090470e 100644
--- a/glom/utils_ui.cc
+++ b/glom/utils_ui.cc
@@ -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.
diff --git a/glom/utils_ui.h b/glom/utils_ui.h
index 0d0cecc..274b4b3 100644
--- a/glom/utils_ui.h
+++ b/glom/utils_ui.h
@@ -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(), 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]