[gnc-plugin-page-report.c] set dialog parent properly

This commit is contained in:
Christopher Lam 2020-08-14 22:23:00 +08:00
parent 79476ba6dc
commit d1976fc7fe

View File

@ -1426,7 +1426,7 @@ gnc_plugin_page_report_stop_cb( GtkAction *action, GncPluginPageReport *report )
/* Returns SCM_BOOL_F if cancel. Returns SCM_BOOL_T if html. /* Returns SCM_BOOL_F if cancel. Returns SCM_BOOL_T if html.
* Otherwise returns pair from export_types. */ * Otherwise returns pair from export_types. */
static SCM static SCM
gnc_get_export_type_choice (SCM export_types) gnc_get_export_type_choice (SCM export_types, GtkWindow *parent)
{ {
GList * choices = NULL; GList * choices = NULL;
gboolean bad = FALSE; gboolean bad = FALSE;
@ -1469,9 +1469,9 @@ gnc_get_export_type_choice (SCM export_types)
choices = g_list_prepend (choices, g_strdup (_("HTML"))); choices = g_list_prepend (choices, g_strdup (_("HTML")));
choice = gnc_choose_radio_option_dialog choice = gnc_choose_radio_option_dialog
(NULL, _("Choose export format"), (GTK_WIDGET (parent), _("Choose export format"),
_("Choose the export format for this report:"), _("Choose the export format for this report:"),
NULL, 0, choices); NULL, 0, choices);
} }
else else
choice = -1; choice = -1;
@ -1494,7 +1494,7 @@ gnc_get_export_type_choice (SCM export_types)
} }
static char * static char *
gnc_get_export_filename (SCM choice) gnc_get_export_filename (SCM choice, GtkWindow *parent)
{ {
char * filepath; char * filepath;
GStatBuf statbuf; GStatBuf statbuf;
@ -1513,8 +1513,8 @@ gnc_get_export_filename (SCM choice)
title = g_strdup_printf (_("Save %s To File"), type); title = g_strdup_printf (_("Save %s To File"), type);
default_dir = gnc_get_default_directory(GNC_PREFS_GROUP_REPORT); default_dir = gnc_get_default_directory(GNC_PREFS_GROUP_REPORT);
filepath = gnc_file_dialog (gnc_ui_get_main_window (NULL), filepath = gnc_file_dialog (parent, title, NULL, default_dir,
title, NULL, default_dir, GNC_FILE_DIALOG_EXPORT); GNC_FILE_DIALOG_EXPORT);
if (filepath != NULL) // test for cancel pressed if (filepath != NULL) // test for cancel pressed
{ {
@ -1541,7 +1541,7 @@ gnc_get_export_filename (SCM choice)
/* %s is the strerror(3) string of the error that occurred. */ /* %s is the strerror(3) string of the error that occurred. */
const char *format = _("You cannot save to that filename.\n\n%s"); const char *format = _("You cannot save to that filename.\n\n%s");
gnc_error_dialog (NULL, format, strerror(errno)); gnc_error_dialog (parent, format, strerror(errno));
g_free(filepath); g_free(filepath);
return NULL; return NULL;
} }
@ -1551,7 +1551,7 @@ gnc_get_export_filename (SCM choice)
{ {
const char *message = _("You cannot save to that file."); const char *message = _("You cannot save to that file.");
gnc_error_dialog (NULL, "%s", message); gnc_error_dialog (parent, "%s", message);
g_free(filepath); g_free(filepath);
return NULL; return NULL;
} }
@ -1561,7 +1561,7 @@ gnc_get_export_filename (SCM choice)
const char *format = _("The file %s already exists. " const char *format = _("The file %s already exists. "
"Are you sure you want to overwrite it?"); "Are you sure you want to overwrite it?");
if (!gnc_verify_dialog (NULL, FALSE, format, filepath)) if (!gnc_verify_dialog (parent, FALSE, format, filepath))
{ {
g_free(filepath); g_free(filepath);
return NULL; return NULL;
@ -1642,6 +1642,8 @@ gnc_plugin_page_report_export_cb( GtkAction *action, GncPluginPageReport *report
SCM export_thunk; SCM export_thunk;
gboolean result; gboolean result;
SCM choice; SCM choice;
GtkWindow *parent = GTK_WINDOW (gnc_plugin_page_get_window
(GNC_PLUGIN_PAGE (report)));
priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(report); priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(report);
export_types = scm_call_1 (scm_c_eval_string ("gnc:report-export-types"), export_types = scm_call_1 (scm_c_eval_string ("gnc:report-export-types"),
@ -1651,14 +1653,14 @@ gnc_plugin_page_report_export_cb( GtkAction *action, GncPluginPageReport *report
priv->cur_report); priv->cur_report);
if (scm_is_list (export_types) && scm_is_procedure (export_thunk)) if (scm_is_list (export_types) && scm_is_procedure (export_thunk))
choice = gnc_get_export_type_choice (export_types); choice = gnc_get_export_type_choice (export_types, parent);
else else
choice = SCM_BOOL_T; choice = SCM_BOOL_T;
if (choice == SCM_BOOL_F) if (choice == SCM_BOOL_F)
return; return;
filepath = gnc_get_export_filename (choice); filepath = gnc_get_export_filename (choice, parent);
if (!filepath) if (!filepath)
return; return;
@ -1681,7 +1683,7 @@ gnc_plugin_page_report_export_cb( GtkAction *action, GncPluginPageReport *report
{ {
const char *fmt = _("Could not open the file %s. " const char *fmt = _("Could not open the file %s. "
"The error is: %s"); "The error is: %s");
gnc_error_dialog( NULL, fmt, filepath ? filepath : "(null)", gnc_error_dialog (parent, fmt, filepath ? filepath : "(null)",
strerror (errno) ? strerror (errno) : "" ); strerror (errno) ? strerror (errno) : "" );
} }