gnucash maint: Multiple changes pushed

Robert Fewell bobit at code.gnucash.org
Thu Dec 10 06:30:37 EST 2020


Updated	 via  https://github.com/Gnucash/gnucash/commit/66cdce8d (commit)
	 via  https://github.com/Gnucash/gnucash/commit/2c82ad5f (commit)
	 via  https://github.com/Gnucash/gnucash/commit/8c253854 (commit)
	from  https://github.com/Gnucash/gnucash/commit/743df212 (commit)



commit 66cdce8d51d0ef62016294663b69e7ded7b8ef5d
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Tue Nov 24 16:29:55 2020 +0000

    Change the way the help button is setup for dialog-commodity

diff --git a/gnucash/gnome-utils/dialog-commodity.c b/gnucash/gnome-utils/dialog-commodity.c
index e38633c70..16cb1b4ac 100644
--- a/gnucash/gnome-utils/dialog-commodity.c
+++ b/gnucash/gnome-utils/dialog-commodity.c
@@ -106,9 +106,6 @@ struct commodity_window
 typedef struct select_commodity_window SelectCommodityWindow;
 typedef struct commodity_window CommodityWindow;
 
-static gnc_commodity_help_callback help_callback = NULL;
-
-
 /* The commodity selection window */
 static SelectCommodityWindow *
 gnc_ui_select_commodity_create(const gnc_commodity * orig_sel,
@@ -129,17 +126,6 @@ gboolean gnc_ui_commodity_dialog_to_object(CommodityWindow * w);
 static void gnc_ui_select_commodity_response_cb (GtkDialog * dialog, gint response, gpointer data);
 #endif
 
-
-/********************************************************************
- * gnc_ui_commodity_set_help_callback
- ********************************************************************/
-void
-gnc_ui_commodity_set_help_callback (gnc_commodity_help_callback cb)
-{
-    help_callback = cb;
-}
-
-
 /********************************************************************
  * gnc_ui_select_commodity_modal_full()
  ********************************************************************/
@@ -890,7 +876,6 @@ gnc_ui_build_commodity_dialog(const char * selected_namespace,
                               gboolean     edit)
 {
     CommodityWindow * retval = g_new0(CommodityWindow, 1);
-    GtkWidget *help_button;
     GtkWidget *box;
     GtkWidget *menu;
     GtkWidget *widget, *sec_label;
@@ -920,10 +905,6 @@ gnc_ui_build_commodity_dialog(const char * selected_namespace,
 
     retval->edit_commodity = NULL;
 
-    help_button = GTK_WIDGET(gtk_builder_get_object (builder, "help_button"));
-    if (!help_callback)
-        gtk_widget_hide (help_button);
-
     /* Get widget pointers */
     retval->fullname_entry = GTK_WIDGET(gtk_builder_get_object (builder, "fullname_entry"));
     retval->mnemonic_entry = GTK_WIDGET(gtk_builder_get_object (builder, "mnemonic_entry"));
@@ -1158,8 +1139,7 @@ gnc_ui_common_commodity_modal(gnc_commodity *commodity,
             break;
         case GTK_RESPONSE_HELP:
             DEBUG("case HELP");
-            if (help_callback)
-                help_callback ();
+            gnc_gnome_help (GTK_WINDOW(win->dialog), HF_HELP, HL_COMMODITY);
             break;
         default:	/* Cancel, Escape, Close, etc. */
             DEBUG("default: %d", value);
diff --git a/gnucash/gnome-utils/dialog-commodity.h b/gnucash/gnome-utils/dialog-commodity.h
index b2008342d..e51766ad9 100644
--- a/gnucash/gnome-utils/dialog-commodity.h
+++ b/gnucash/gnome-utils/dialog-commodity.h
@@ -57,16 +57,6 @@ typedef enum
 			       anything. */
 } dialog_commodity_mode;
 
-typedef void (* gnc_commodity_help_callback)(void);
-
-/** This function is used to set the action routine for the help
- *  button in the commodity dialog windows.  If the action routine is
- *  unset, the help button will not be visible to the user.
- *
- *  @param cb The function to be called when the user clicks the help
- *  button. */
-void gnc_ui_commodity_set_help_callback (gnc_commodity_help_callback cb);
-
 
 /** @name Commodity Selection */
 /** @{ */
diff --git a/gnucash/gnome-utils/gnc-gnome-utils.c b/gnucash/gnome-utils/gnc-gnome-utils.c
index a061ad572..a771f3525 100644
--- a/gnucash/gnome-utils/gnc-gnome-utils.c
+++ b/gnucash/gnome-utils/gnc-gnome-utils.c
@@ -144,12 +144,6 @@ gnc_options_dialog_set_style_sheet_options_help_cb (GNCOptionWin *win)
                                     NULL);
 }
 
-static void
-gnc_commodity_help_cb (void)
-{
-    gnc_gnome_help (NULL, HF_HELP, HL_COMMODITY);
-}
-
 /* gnc_configure_date_format
  *    sets dateFormat to the current value on the scheme side
  *
@@ -773,7 +767,6 @@ gnc_gui_init(void)
                                 gnc_gui_refresh_all,
                                 NULL);
 
-    gnc_ui_commodity_set_help_callback (gnc_commodity_help_cb);
     gnc_file_set_shutdown_callback (gnc_shutdown);
 
     gnc_options_dialog_set_global_help_cb (gnc_global_options_help_cb, NULL);

commit 2c82ad5f78b95db06b365a09ab67f2867cfedca9
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Tue Nov 24 16:10:14 2020 +0000

    Add parent widget to gnc_gnome_help function
    
    If there are any errors from starting help with gnc_gnome_help they are
    displayed with gnc_error_dialog which defaults to setting the parent
    window to that of GnuCash. This can be confusing if the dialog is
    behind another window, say the preference window as it would appear
    that Gnucash is unresponsive so add the GtkWindow parameter to
    gnc_gnome_help and populate appropriately.

diff --git a/gnucash/gnome-search/dialog-search.c b/gnucash/gnome-search/dialog-search.c
index 96e9cdc38..84f2c782b 100644
--- a/gnucash/gnome-search/dialog-search.c
+++ b/gnucash/gnome-search/dialog-search.c
@@ -653,7 +653,7 @@ search_cancel_cb (GtkButton *button, GNCSearchWindow *sw)
 static void
 search_help_cb (GtkButton *button, GNCSearchWindow *sw)
 {
-    gnc_gnome_help (HF_HELP, HL_FIND_TRANSACTIONS);
+    gnc_gnome_help (GTK_WINDOW(sw->dialog), HF_HELP, HL_FIND_TRANSACTIONS);
 }
 
 static void
diff --git a/gnucash/gnome-utils/dialog-account.c b/gnucash/gnome-utils/dialog-account.c
index 3b69abded..cd2da43f4 100644
--- a/gnucash/gnome-utils/dialog-account.c
+++ b/gnucash/gnome-utils/dialog-account.c
@@ -1020,11 +1020,11 @@ gnc_account_window_response_cb (GtkDialog *dialog,
         {
         case NEW_ACCOUNT:
             DEBUG("new acct dialog, HELP");
-            gnc_gnome_help(HF_HELP, HL_ACC);
+            gnc_gnome_help (GTK_WINDOW(dialog), HF_HELP, HL_ACC);
             break;
         case EDIT_ACCOUNT:
             DEBUG("edit acct dialog, HELP");
-            gnc_gnome_help(HF_HELP, HL_ACCEDIT);
+            gnc_gnome_help (GTK_WINDOW(dialog), HF_HELP, HL_ACCEDIT);
             break;
         default:
             g_assert_not_reached ();
diff --git a/gnucash/gnome-utils/dialog-book-close.c b/gnucash/gnome-utils/dialog-book-close.c
index 9b16222a6..147ab6c0c 100644
--- a/gnucash/gnome-utils/dialog-book-close.c
+++ b/gnucash/gnome-utils/dialog-book-close.c
@@ -279,7 +279,7 @@ gnc_book_close_response_cb(GtkDialog *dialog, gint response, GtkDialog *unused)
     switch (response)
     {
     case GTK_RESPONSE_HELP:
-        gnc_gnome_help(HF_HELP, HL_CLOSE_BOOK);
+        gnc_gnome_help (GTK_WINDOW(dialog), HF_HELP, HL_CLOSE_BOOK);
         break;
     case GTK_RESPONSE_OK:
         cbw->close_date = gnc_date_edit_get_date(GNC_DATE_EDIT(cbw->close_date_widget));
diff --git a/gnucash/gnome-utils/dialog-file-access.c b/gnucash/gnome-utils/dialog-file-access.c
index 733cbf95c..8fc898ecc 100644
--- a/gnucash/gnome-utils/dialog-file-access.c
+++ b/gnucash/gnome-utils/dialog-file-access.c
@@ -125,7 +125,7 @@ gnc_ui_file_access_response_cb(GtkDialog *dialog, gint response, GtkDialog *unus
     switch ( response )
     {
     case GTK_RESPONSE_HELP:
-        gnc_gnome_help( HF_HELP, HL_GLOBPREFS );
+        gnc_gnome_help (GTK_WINDOW(dialog), HF_HELP, HL_GLOBPREFS );
         break;
 
     case GTK_RESPONSE_OK:
diff --git a/gnucash/gnome-utils/dialog-preferences.c b/gnucash/gnome-utils/dialog-preferences.c
index 149b51bb3..072a46879 100644
--- a/gnucash/gnome-utils/dialog-preferences.c
+++ b/gnucash/gnome-utils/dialog-preferences.c
@@ -1197,7 +1197,7 @@ gnc_preferences_response_cb (GtkDialog *dialog, gint response, GtkDialog *unused
     switch (response)
     {
     case GTK_RESPONSE_HELP:
-        gnc_gnome_help (HF_HELP, HL_GLOBPREFS);
+        gnc_gnome_help (GTK_WINDOW(dialog), HF_HELP, HL_GLOBPREFS);
         break;
 
     case GTK_RESPONSE_DELETE_EVENT:
diff --git a/gnucash/gnome-utils/gnc-gnome-utils.c b/gnucash/gnome-utils/gnc-gnome-utils.c
index ba95c7c48..a061ad572 100644
--- a/gnucash/gnome-utils/gnc-gnome-utils.c
+++ b/gnucash/gnome-utils/gnc-gnome-utils.c
@@ -90,13 +90,13 @@ gnc_gnome_utils_init (void)
 static void
 gnc_global_options_help_cb (GNCOptionWin *win, gpointer dat)
 {
-    gnc_gnome_help (HF_HELP, HL_GLOBPREFS);
+    gnc_gnome_help (GTK_WINDOW(gnc_options_dialog_widget (win)), HF_HELP, HL_GLOBPREFS);
 }
 
 static void
 gnc_book_options_help_cb (GNCOptionWin *win, gpointer dat)
 {
-    gnc_gnome_help (HF_HELP, HL_BOOK_OPTIONS);
+    gnc_gnome_help (GTK_WINDOW(gnc_options_dialog_widget (win)), HF_HELP, HL_BOOK_OPTIONS);
 }
 
 void
@@ -133,7 +133,7 @@ gnc_options_dialog_set_new_book_option_values (GNCOptionDB *odb)
 static void
 gnc_style_sheet_options_help_cb (GNCOptionWin *win, gpointer dat)
 {
-    gnc_gnome_help (HF_HELP, HL_STYLE_SHEET);
+    gnc_gnome_help (GTK_WINDOW(gnc_options_dialog_widget (win)), HF_HELP, HL_STYLE_SHEET);
 }
 
 void
@@ -147,7 +147,7 @@ gnc_options_dialog_set_style_sheet_options_help_cb (GNCOptionWin *win)
 static void
 gnc_commodity_help_cb (void)
 {
-    gnc_gnome_help (HF_HELP, HL_COMMODITY);
+    gnc_gnome_help (NULL, HF_HELP, HL_COMMODITY);
 }
 
 /* gnc_configure_date_format
@@ -240,7 +240,7 @@ gnc_add_css_file (void)
  * ?anchor varient, see https://gitlab.gnome.org/GNOME/yelp/issues/116
  */
 static gchar *
-gnc_gnome_help_yelp_anchor_fix (const char *file_name, const char *anchor)
+gnc_gnome_help_yelp_anchor_fix (GtkWindow *parent, const char *file_name, const char *anchor)
 {
     const gchar * const *sdatadirs = g_get_system_data_dirs ();
     const gchar * const *langs = g_get_language_names ();
@@ -261,7 +261,7 @@ gnc_gnome_help_yelp_anchor_fix (const char *file_name, const char *anchor)
 
     if (!help_path)
     {
-        gnc_error_dialog (NULL, "%s\n%s", _(msg_no_help_found), _(msg_no_help_reason));
+        gnc_error_dialog (parent, "%s\n%s", _(msg_no_help_found), _(msg_no_help_reason));
         PERR("Unable to find 'gnome/help' directory");
         return NULL;
     }
@@ -283,7 +283,7 @@ gnc_gnome_help_yelp_anchor_fix (const char *file_name, const char *anchor)
         uri = g_strconcat ("ghelp:", full_path, "?", anchor, NULL);
     else
     {
-        gnc_error_dialog (NULL, "%s\n%s", _(msg_no_help_found), _(msg_no_help_reason));
+        gnc_error_dialog (parent, "%s\n%s", _(msg_no_help_found), _(msg_no_help_reason));
         PERR("Unable to find valid help language directory");
         return NULL;
     }
@@ -298,7 +298,7 @@ gnc_gnome_help_yelp_anchor_fix (const char *file_name, const char *anchor)
  * toolkit.
  */
 void
-gnc_gnome_help (const char *dir, const char *detail)
+gnc_gnome_help (GtkWindow *parent, const char *dir, const char *detail)
 {
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     NSString *subdir = [NSString stringWithUTF8String: dir];
@@ -339,9 +339,9 @@ gnc_gnome_help (const char *dir, const char *detail)
                   componentsJoinedByString: @"-"];
         if (![[NSFileManager defaultManager] fileExistsAtPath: docs_dir])
         {
-            gnc_error_dialog(NULL, "%s\n%s\n%s: %s", _(msg_no_help_found),
-                             _(msg_no_help_reason),
-                             _(msg_no_help_location), [docs_dir UTF8String]);
+            gnc_error_dialog (parent, "%s\n%s\n%s: %s", _(msg_no_help_found),
+                              _(msg_no_help_reason),
+                              _(msg_no_help_location), [docs_dir UTF8String]);
             [pool release];
             return;
         }
@@ -431,13 +431,13 @@ gnc_gnome_help (const char *dir, const char *detail)
         [[NSWorkspace sharedWorkspace] openURL: url];
     else
     {
-       gnc_error_dialog(NULL, "%s\n%s", _(msg_no_help_found), _(msg_no_help_reason));
+       gnc_error_dialog (parent, "%s\n%s", _(msg_no_help_found), _(msg_no_help_reason));
     }
     [pool release];
 }
 #elif defined G_OS_WIN32 /* G_OS_WIN32 */
 void
-gnc_gnome_help (const char *file_name, const char *anchor)
+gnc_gnome_help (GtkWindow *parent, const char *file_name, const char *anchor)
 {
     const gchar * const *lang;
     gchar *pkgdatadir, *fullpath, *found = NULL;
@@ -459,7 +459,7 @@ gnc_gnome_help (const char *file_name, const char *anchor)
 
     if (!found)
     {
-        gnc_error_dialog (NULL, "%s\n%s", _(msg_no_help_found), _(msg_no_help_reason));
+        gnc_error_dialog (parent, "%s\n%s", _(msg_no_help_found), _(msg_no_help_reason));
     }
     else
     {
@@ -469,14 +469,14 @@ gnc_gnome_help (const char *file_name, const char *anchor)
 }
 #else
 void
-gnc_gnome_help (const char *file_name, const char *anchor)
+gnc_gnome_help (GtkWindow *parent, const char *file_name, const char *anchor)
 {
     GError *error = NULL;
     gchar *uri = NULL;
     gboolean success = TRUE;
 
     if (anchor)
-        uri = gnc_gnome_help_yelp_anchor_fix (file_name, anchor);
+        uri = gnc_gnome_help_yelp_anchor_fix (parent, file_name, anchor);
     else
         uri = g_strconcat ("ghelp:", file_name, NULL);
 
@@ -491,7 +491,7 @@ gnc_gnome_help (const char *file_name, const char *anchor)
 
     g_assert(error != NULL);
     {
-        gnc_error_dialog(NULL, "%s\n%s", _(msg_no_help_found), _(msg_no_help_reason));
+        gnc_error_dialog (parent, "%s\n%s", _(msg_no_help_found), _(msg_no_help_reason));
     }
     PERR ("%s", error->message);
     g_error_free(error);
diff --git a/gnucash/gnome-utils/gnc-gnome-utils.h b/gnucash/gnome-utils/gnc-gnome-utils.h
index 6c10f991d..f7f45b819 100644
--- a/gnucash/gnome-utils/gnc-gnome-utils.h
+++ b/gnucash/gnome-utils/gnc-gnome-utils.h
@@ -53,11 +53,13 @@ void gnc_add_css_file (void);
  *  This routine will display an error message
  *  if it can't find the help file or can't open the help browser.
  *
+ *  @param parent The parent window for any dialogs.
+ *
  *  @param file_name The name of the help file.
  *
  *  @param anchor The anchor the help browser should scroll to.
  */
-void gnc_gnome_help (const char *file_name,
+void gnc_gnome_help (GtkWindow *parent, const char *file_name,
                      const char *anchor);
 /** Launch the default browser and open the provided URI.
  */
diff --git a/gnucash/gnome-utils/gnc-main-window.c b/gnucash/gnome-utils/gnc-main-window.c
index c88c1d234..f0dece611 100644
--- a/gnucash/gnome-utils/gnc-main-window.c
+++ b/gnucash/gnome-utils/gnc-main-window.c
@@ -4529,13 +4529,13 @@ gnc_main_window_cmd_window_raise (GtkAction *action,
 static void
 gnc_main_window_cmd_help_tutorial (GtkAction *action, GncMainWindow *window)
 {
-    gnc_gnome_help (HF_GUIDE, NULL);
+    gnc_gnome_help (GTK_WINDOW(window), HF_GUIDE, NULL);
 }
 
 static void
 gnc_main_window_cmd_help_contents (GtkAction *action, GncMainWindow *window)
 {
-    gnc_gnome_help (HF_HELP, NULL);
+    gnc_gnome_help (GTK_WINDOW(window), HF_HELP, NULL);
 }
 
 /** This is a helper function to find a data file and suck it into
diff --git a/gnucash/gnome-utils/gnc-ui.h b/gnucash/gnome-utils/gnc-ui.h
index c8263abac..6be6192db 100644
--- a/gnucash/gnome-utils/gnc-ui.h
+++ b/gnucash/gnome-utils/gnc-ui.h
@@ -106,7 +106,7 @@ gnc_error_dialog (GtkWindow *parent,
 
 
 extern void
-gnc_gnome_help (const char *file_name, const char *target_link);
+gnc_gnome_help (GtkWindow *parent, const char *file_name, const char *target_link);
 
 int      gnc_choose_radio_option_dialog (GtkWidget *parent,
         const char *title,
diff --git a/gnucash/gnome/dialog-custom-report.c b/gnucash/gnome/dialog-custom-report.c
index f0d52c11d..f2af3b0ef 100644
--- a/gnucash/gnome/dialog-custom-report.c
+++ b/gnucash/gnome/dialog-custom-report.c
@@ -107,7 +107,8 @@ custom_report_dialog_close_cb(GtkWidget* widget, gpointer data)
 void
 custom_report_help_cb (GtkWidget *widget, gpointer data)
 {
-    gnc_gnome_help(HF_HELP, HL_USAGE_CUSTOMREP);
+    CustomReportDialog *crd = data;
+    gnc_gnome_help (GTK_WINDOW(crd->dialog), HF_HELP, HL_USAGE_CUSTOMREP);
 }
 
 void
diff --git a/gnucash/gnome/dialog-customer.c b/gnucash/gnome/dialog-customer.c
index e47229fd2..fbd3cc0de 100644
--- a/gnucash/gnome/dialog-customer.c
+++ b/gnucash/gnome/dialog-customer.c
@@ -390,7 +390,8 @@ gnc_customer_window_cancel_cb (GtkWidget *widget, gpointer data)
 void
 gnc_customer_window_help_cb (GtkWidget *widget, gpointer data)
 {
-    gnc_gnome_help(HF_HELP, HL_USAGE_CUSTOMER);
+    CustomerWindow *cw = data;
+    gnc_gnome_help (GTK_WINDOW(cw->dialog), HF_HELP, HL_USAGE_CUSTOMER);
 }
 
 void
diff --git a/gnucash/gnome/dialog-employee.c b/gnucash/gnome/dialog-employee.c
index d204e6e59..91b49eff6 100644
--- a/gnucash/gnome/dialog-employee.c
+++ b/gnucash/gnome/dialog-employee.c
@@ -248,7 +248,8 @@ gnc_employee_window_cancel_cb (GtkWidget *widget, gpointer data)
 void
 gnc_employee_window_help_cb (GtkWidget *widget, gpointer data)
 {
-    gnc_gnome_help(HF_HELP, HL_USAGE_EMPLOYEE);
+    EmployeeWindow *ew = data;
+    gnc_gnome_help (GTK_WINDOW(ew->dialog), HF_HELP, HL_USAGE_EMPLOYEE);
 }
 
 void
diff --git a/gnucash/gnome/dialog-invoice.c b/gnucash/gnome/dialog-invoice.c
index 81a82e6aa..ac97a53ff 100644
--- a/gnucash/gnome/dialog-invoice.c
+++ b/gnucash/gnome/dialog-invoice.c
@@ -544,13 +544,13 @@ gnc_invoice_window_help_cb (GtkWidget *widget, gpointer data)
     switch(owner_type)
     {
         case GNC_OWNER_CUSTOMER:
-           gnc_gnome_help (HF_HELP, HL_USAGE_INVOICE);
+           gnc_gnome_help (GTK_WINDOW(iw->dialog), HF_HELP, HL_USAGE_INVOICE);
            break;
         case GNC_OWNER_VENDOR:
-           gnc_gnome_help (HF_HELP, HL_USAGE_BILL);
+           gnc_gnome_help (GTK_WINDOW(iw->dialog), HF_HELP, HL_USAGE_BILL);
            break;
         default:
-           gnc_gnome_help (HF_HELP, HL_USAGE_VOUCHER);
+           gnc_gnome_help (GTK_WINDOW(iw->dialog), HF_HELP, HL_USAGE_VOUCHER);
            break;
     }
 }
diff --git a/gnucash/gnome/dialog-job.c b/gnucash/gnome/dialog-job.c
index e698261bb..7925e2132 100644
--- a/gnucash/gnome/dialog-job.c
+++ b/gnucash/gnome/dialog-job.c
@@ -202,7 +202,8 @@ gnc_job_window_cancel_cb (GtkWidget *widget, gpointer data)
 void
 gnc_job_window_help_cb (GtkWidget *widget, gpointer data)
 {
-    gnc_gnome_help (HF_HELP, HL_USAGE_JOB);
+    JobWindow *jw = data;
+    gnc_gnome_help (GTK_WINDOW(jw->dialog), HF_HELP, HL_USAGE_JOB);
 }
 
 
diff --git a/gnucash/gnome/dialog-new-user.c b/gnucash/gnome/dialog-new-user.c
index 99ae316e9..ef1aebd18 100644
--- a/gnucash/gnome/dialog-new-user.c
+++ b/gnucash/gnome/dialog-new-user.c
@@ -122,7 +122,7 @@ gnc_ui_new_user_ok_cb (GtkWidget * widget, gpointer data)
     }
     else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (new_user->tutorial_button)))
     {
-        gnc_gnome_help (HF_GUIDE, NULL);
+        gnc_gnome_help (GTK_WINDOW(new_user->window), HF_GUIDE, NULL);
         gncp_new_user_finish ();
     }
     gtk_widget_destroy (new_user->window);
diff --git a/gnucash/gnome/dialog-order.c b/gnucash/gnome/dialog-order.c
index c75f09ff1..e4918d8be 100644
--- a/gnucash/gnome/dialog-order.c
+++ b/gnucash/gnome/dialog-order.c
@@ -232,7 +232,8 @@ gnc_order_window_cancel_cb (GtkWidget *widget, gpointer data)
 void
 gnc_order_window_help_cb (GtkWidget *widget, gpointer data)
 {
-    gnc_gnome_help(HF_HELP, HL_USAGE_BILL);
+    OrderWindow *ow = data;
+    gnc_gnome_help (GTK_WINDOW(ow->dialog), HF_HELP, HL_USAGE_BILL);
 }
 
 void
diff --git a/gnucash/gnome/dialog-print-check.c b/gnucash/gnome/dialog-print-check.c
index 21a57cd28..da96d5829 100644
--- a/gnucash/gnome/dialog-print-check.c
+++ b/gnucash/gnome/dialog-print-check.c
@@ -2675,7 +2675,7 @@ gnc_ui_print_check_response_cb(GtkDialog *dialog,
     switch (response)
     {
     case GTK_RESPONSE_HELP:
-        gnc_gnome_help(HF_HELP, HL_PRINTCHECK);
+        gnc_gnome_help (GTK_WINDOW(dialog), HF_HELP, HL_PRINTCHECK);
         return;
 
     case GTK_RESPONSE_OK:
diff --git a/gnucash/gnome/dialog-sx-editor.c b/gnucash/gnome/dialog-sx-editor.c
index 4eda90060..e19b5ef8e 100644
--- a/gnucash/gnome/dialog-sx-editor.c
+++ b/gnucash/gnome/dialog-sx-editor.c
@@ -230,7 +230,7 @@ editor_cancel_button_clicked_cb( GtkButton *b, GncSxEditorDialog *sxed )
 static void
 editor_help_button_clicked_cb(GtkButton *b, GncSxEditorDialog *sxed)
 {
-    gnc_gnome_help(HF_HELP, HL_SXEDITOR);
+    gnc_gnome_help (GTK_WINDOW(sxed->dialog), HF_HELP, HL_SXEDITOR);
 }
 
 
diff --git a/gnucash/gnome/dialog-sx-editor2.c b/gnucash/gnome/dialog-sx-editor2.c
index 1d4268e41..a13e8e034 100644
--- a/gnucash/gnome/dialog-sx-editor2.c
+++ b/gnucash/gnome/dialog-sx-editor2.c
@@ -227,7 +227,7 @@ editor_cancel_button_clicked_cb (GtkButton *b, GncSxEditorDialog2 *sxed)
 static void
 editor_help_button_clicked_cb (GtkButton *b, GncSxEditorDialog2 *sxed)
 {
-    gnc_gnome_help (HF_HELP, HL_SXEDITOR);
+    gnc_gnome_help (GTK_WINDOW(sxed->dialog), HF_HELP, HL_SXEDITOR);
 }
 
 
diff --git a/gnucash/gnome/dialog-vendor.c b/gnucash/gnome/dialog-vendor.c
index 1c547baa7..0d24ace42 100644
--- a/gnucash/gnome/dialog-vendor.c
+++ b/gnucash/gnome/dialog-vendor.c
@@ -261,7 +261,8 @@ gnc_vendor_window_cancel_cb (GtkWidget *widget, gpointer data)
 void
 gnc_vendor_window_help_cb (GtkWidget *widget, gpointer data)
 {
-    gnc_gnome_help(HF_HELP, HL_USAGE_VENDOR);
+    VendorWindow *vw = data;
+    gnc_gnome_help (GTK_WINDOW(vw->dialog), HF_HELP, HL_USAGE_VENDOR);
 }
 
 void
diff --git a/gnucash/gnome/gnc-plugin-report-system.c b/gnucash/gnome/gnc-plugin-report-system.c
index 0fbcc024f..f261df7a0 100644
--- a/gnucash/gnome/gnc-plugin-report-system.c
+++ b/gnucash/gnome/gnc-plugin-report-system.c
@@ -244,9 +244,9 @@ gnc_report_system_help_url_cb (const char *location, const char *label,
     g_return_val_if_fail (location != NULL, FALSE);
 
     if (label && (*label != '\0'))
-        gnc_gnome_help (location, label);
+        gnc_gnome_help (GTK_WINDOW(result->parent), location, label);
     else
-        gnc_gnome_help (location, NULL);
+        gnc_gnome_help (GTK_WINDOW(result->parent), location, NULL);
     return TRUE;
 }
 
diff --git a/gnucash/gnome/window-reconcile.c b/gnucash/gnome/window-reconcile.c
index e08913f37..2e8318ab0 100644
--- a/gnucash/gnome/window-reconcile.c
+++ b/gnucash/gnome/window-reconcile.c
@@ -1153,7 +1153,8 @@ gnc_reconcile_window_get_current_split(RecnWindow *recnData)
 static void
 gnc_ui_reconcile_window_help_cb(GtkWidget *widget, gpointer data)
 {
-    gnc_gnome_help(HF_HELP, HL_RECNWIN);
+    RecnWindow *recnData = data;
+    gnc_gnome_help (GTK_WINDOW(recnData->window), HF_HELP, HL_RECNWIN);
 }
 
 
diff --git a/gnucash/gnome/window-reconcile2.c b/gnucash/gnome/window-reconcile2.c
index 688761409..191713165 100644
--- a/gnucash/gnome/window-reconcile2.c
+++ b/gnucash/gnome/window-reconcile2.c
@@ -1101,7 +1101,8 @@ gnc_reconcile_window_get_current_split (RecnWindow2 *recnData)
 static void
 gnc_ui_reconcile_window_help_cb (GtkWidget *widget, gpointer data)
 {
-    gnc_gnome_help (HF_HELP, HL_RECNWIN);
+    RecnWindow2 *recnData = data;
+    gnc_gnome_help (GTK_WINDOW(recnData->window), HF_HELP, HL_RECNWIN);
 }
 
 
diff --git a/gnucash/import-export/bi-import/dialog-bi-import-gui.c b/gnucash/import-export/bi-import/dialog-bi-import-gui.c
index c0cf435bc..943869e01 100644
--- a/gnucash/import-export/bi-import/dialog-bi-import-gui.c
+++ b/gnucash/import-export/bi-import/dialog-bi-import-gui.c
@@ -252,7 +252,8 @@ gnc_bi_import_gui_cancel_cb (GtkWidget *widget, gpointer data)
 void
 gnc_bi_import_gui_help_cb (GtkWidget *widget, gpointer data)
 {
-    gnc_gnome_help (HF_GUIDE, HL_IMPORT_BC);
+    BillImportGui *gui = data;
+    gnc_gnome_help (GTK_WINDOW(gui->dialog), HF_GUIDE, HL_IMPORT_BC);
 }
 
 static void
diff --git a/gnucash/import-export/customer-import/dialog-customer-import-gui.c b/gnucash/import-export/customer-import/dialog-customer-import-gui.c
index b34d9fac3..9de88127b 100644
--- a/gnucash/import-export/customer-import/dialog-customer-import-gui.c
+++ b/gnucash/import-export/customer-import/dialog-customer-import-gui.c
@@ -228,7 +228,8 @@ gnc_customer_import_gui_cancel_cb (GtkWidget *widget, gpointer data)
 void
 gnc_customer_import_gui_help_cb (GtkWidget *widget, gpointer data)
 {
-    gnc_gnome_help (HF_GUIDE, HL_IMPORT_CUST);
+    CustomerImportGui *gui = data;
+    gnc_gnome_help (GTK_WINDOW(gui->dialog), HF_GUIDE, HL_IMPORT_CUST);
 }
 
 static void

commit 8c2538546bee0290d01a04883ad6d61bb7804362
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sun Nov 22 13:40:34 2020 +0000

    Bug 128772 - Account Help Button does not work
    
    When pressing the help button, the following uri is created...
    ghelp:gnucash-help?acct-create and used to open the gnome help app.
    
    This segfaults in the '?' as ghelp:gnucash-help does work.
    
    To fix this use the full path to the help files.

diff --git a/gnucash/gnome-utils/gnc-gnome-utils.c b/gnucash/gnome-utils/gnc-gnome-utils.c
index b750a011f..ba95c7c48 100644
--- a/gnucash/gnome-utils/gnc-gnome-utils.c
+++ b/gnucash/gnome-utils/gnc-gnome-utils.c
@@ -236,6 +236,61 @@ gnc_add_css_file (void)
     g_object_unref (provider_fallback);
 }
 
+/* This function fixes an issue with yelp that it does not work with the
+ * ?anchor varient, see https://gitlab.gnome.org/GNOME/yelp/issues/116
+ */
+static gchar *
+gnc_gnome_help_yelp_anchor_fix (const char *file_name, const char *anchor)
+{
+    const gchar * const *sdatadirs = g_get_system_data_dirs ();
+    const gchar * const *langs = g_get_language_names ();
+    gchar *lookfor = g_strconcat ("gnome/help/", file_name, NULL);
+    gchar *help_path = NULL;
+    gchar *help_file = NULL;
+    gchar *full_path = NULL;
+    gchar *uri = NULL;
+
+    for (; *sdatadirs; sdatadirs++)
+    {
+        gchar *filepath = g_build_filename (*sdatadirs, lookfor, NULL);
+        if (g_file_test (filepath, G_FILE_TEST_EXISTS))
+            help_path = g_strdup (filepath);
+        g_free (filepath);
+    }
+    g_free (lookfor);
+
+    if (!help_path)
+    {
+        gnc_error_dialog (NULL, "%s\n%s", _(msg_no_help_found), _(msg_no_help_reason));
+        PERR("Unable to find 'gnome/help' directory");
+        return NULL;
+    }
+
+    // add the file extension, currently .xml
+    help_file = g_strconcat (file_name, ".xml", NULL);
+
+    for (; *langs; langs++)
+    {
+        gchar *filename = g_build_filename (help_path, *langs, help_file, NULL);
+        if (g_file_test (filename, G_FILE_TEST_EXISTS))
+            full_path = g_strdup (filename);
+        g_free (filename);
+    }
+    g_free (help_path);
+    g_free (help_file);
+
+    if (full_path)
+        uri = g_strconcat ("ghelp:", full_path, "?", anchor, NULL);
+    else
+    {
+        gnc_error_dialog (NULL, "%s\n%s", _(msg_no_help_found), _(msg_no_help_reason));
+        PERR("Unable to find valid help language directory");
+        return NULL;
+    }
+    g_free (full_path);
+    return uri;
+}
+
 #ifdef MAC_INTEGRATION
 
 /* Don't be alarmed if this function looks strange to you: It's
@@ -418,16 +473,17 @@ gnc_gnome_help (const char *file_name, const char *anchor)
 {
     GError *error = NULL;
     gchar *uri = NULL;
-    gboolean success;
+    gboolean success = TRUE;
 
     if (anchor)
-        uri = g_strconcat ("ghelp:", file_name, "?", anchor, NULL);
+        uri = gnc_gnome_help_yelp_anchor_fix (file_name, anchor);
     else
         uri = g_strconcat ("ghelp:", file_name, NULL);
 
     DEBUG ("Attempting to opening help uri %s", uri);
 
-    success = gtk_show_uri_on_window (NULL, uri, gtk_get_current_event_time (), &error);
+    if (uri)
+        success = gtk_show_uri_on_window (NULL, uri, gtk_get_current_event_time (), &error);
 
     g_free (uri);
     if (success)



Summary of changes:
 gnucash/gnome-search/dialog-search.c               |  2 +-
 gnucash/gnome-utils/dialog-account.c               |  4 +-
 gnucash/gnome-utils/dialog-book-close.c            |  2 +-
 gnucash/gnome-utils/dialog-commodity.c             | 22 +----
 gnucash/gnome-utils/dialog-commodity.h             | 10 ---
 gnucash/gnome-utils/dialog-file-access.c           |  2 +-
 gnucash/gnome-utils/dialog-preferences.c           |  2 +-
 gnucash/gnome-utils/gnc-gnome-utils.c              | 93 +++++++++++++++++-----
 gnucash/gnome-utils/gnc-gnome-utils.h              |  4 +-
 gnucash/gnome-utils/gnc-main-window.c              |  4 +-
 gnucash/gnome-utils/gnc-ui.h                       |  2 +-
 gnucash/gnome/dialog-custom-report.c               |  3 +-
 gnucash/gnome/dialog-customer.c                    |  3 +-
 gnucash/gnome/dialog-employee.c                    |  3 +-
 gnucash/gnome/dialog-invoice.c                     |  6 +-
 gnucash/gnome/dialog-job.c                         |  3 +-
 gnucash/gnome/dialog-new-user.c                    |  2 +-
 gnucash/gnome/dialog-order.c                       |  3 +-
 gnucash/gnome/dialog-print-check.c                 |  2 +-
 gnucash/gnome/dialog-sx-editor.c                   |  2 +-
 gnucash/gnome/dialog-sx-editor2.c                  |  2 +-
 gnucash/gnome/dialog-vendor.c                      |  3 +-
 gnucash/gnome/gnc-plugin-report-system.c           |  4 +-
 gnucash/gnome/window-reconcile.c                   |  3 +-
 gnucash/gnome/window-reconcile2.c                  |  3 +-
 .../import-export/bi-import/dialog-bi-import-gui.c |  3 +-
 .../customer-import/dialog-customer-import-gui.c   |  3 +-
 27 files changed, 113 insertions(+), 82 deletions(-)



More information about the gnucash-changes mailing list