gnucash unstable: Set a parent window for the options dialogs.
John Ralls
jralls at code.gnucash.org
Fri Oct 27 19:23:32 EDT 2017
Updated via https://github.com/Gnucash/gnucash/commit/d22b098d (commit)
from https://github.com/Gnucash/gnucash/commit/5157d8b5 (commit)
commit d22b098dff105d0e79e6cc58ba2c9b37558c5c2b
Author: John Ralls <jralls at ceridwen.us>
Date: Fri Oct 27 16:23:02 2017 -0700
Set a parent window for the options dialogs.
So they pop up centered on the GnuCash window instead of
on the wrong monitor.
diff --git a/gnucash/gnome-utils/dialog-options.c b/gnucash/gnome-utils/dialog-options.c
index 48c53a7..9d6768f 100644
--- a/gnucash/gnome-utils/dialog-options.c
+++ b/gnucash/gnome-utils/dialog-options.c
@@ -2125,9 +2125,9 @@ refresh_handler (GHashTable *changes, gpointer user_data)
*
*/
GNCOptionWin *
-gnc_options_dialog_new(gchar *title)
+gnc_options_dialog_new(gchar *title, GtkWindow *parent)
{
- return gnc_options_dialog_new_modal(FALSE, title, NULL);
+ return gnc_options_dialog_new_modal(FALSE, title, NULL, parent);
}
/* gnc_options_dialog_new_modal:
@@ -2145,7 +2145,8 @@ gnc_options_dialog_new(gchar *title)
*/
GNCOptionWin *
gnc_options_dialog_new_modal(gboolean modal, gchar *title,
- const char *component_class)
+ const char *component_class,
+ GtkWindow *parent)
{
GNCOptionWin *retval;
GtkBuilder *builder;
@@ -2160,7 +2161,7 @@ gnc_options_dialog_new_modal(gboolean modal, gchar *title,
// Set the style context for this dialog so it can be easily manipulated with css
gnc_widget_set_style_context (GTK_WIDGET(retval->dialog), "GncOptionsDialog");
-
+ gtk_window_set_transient_for (GTK_WINDOW (retval->dialog), parent);
/* Page List */
{
GtkTreeView *view;
diff --git a/gnucash/gnome-utils/dialog-options.h b/gnucash/gnome-utils/dialog-options.h
index cfbe013..1ed60c1 100644
--- a/gnucash/gnome-utils/dialog-options.h
+++ b/gnucash/gnome-utils/dialog-options.h
@@ -36,8 +36,9 @@ typedef struct gnc_option_win GNCOptionWin;
typedef void (* GNCOptionWinCallback)(GNCOptionWin *, gpointer data);
GNCOptionWin * gnc_options_dialog_new_modal(gboolean modal, gchar *title,
- const char *component_class);
-GNCOptionWin * gnc_options_dialog_new(gchar *title);
+ const char *component_class,
+ GtkWindow *parent);
+GNCOptionWin * gnc_options_dialog_new(gchar *title, GtkWindow *parent);
GNCOptionWin * gnc_options_dialog_new_w_dialog(gchar *title, GtkWidget *dialog);
void gnc_options_dialog_destroy(GNCOptionWin * win);
void gnc_options_register_stocks (void);
diff --git a/gnucash/gnome-utils/dialog-utils.c b/gnucash/gnome-utils/dialog-utils.c
index 36a9935..73c0ca0 100644
--- a/gnucash/gnome-utils/dialog-utils.c
+++ b/gnucash/gnome-utils/dialog-utils.c
@@ -676,10 +676,8 @@ gnc_new_book_option_display (GtkWidget *parent)
GtkWidget *window;
gint result = GTK_RESPONSE_HELP;
- window = gnc_book_options_dialog_cb (TRUE, _( "New Book Options"));
- if (parent)
- gtk_window_set_transient_for (GTK_WINDOW(window), GTK_WINDOW(parent));
-
+ window = gnc_book_options_dialog_cb (TRUE, _( "New Book Options"),
+ GTK_WINDOW (parent));
if (window)
{
/* close dialog and proceed unless help button selected */
diff --git a/gnucash/gnome-utils/gnc-main-window.c b/gnucash/gnome-utils/gnc-main-window.c
index ea67b82..862403f 100644
--- a/gnucash/gnome-utils/gnc-main-window.c
+++ b/gnucash/gnome-utils/gnc-main-window.c
@@ -4056,7 +4056,7 @@ show_handler (const char *class_name, gint component_id,
}
GtkWidget *
-gnc_book_options_dialog_cb (gboolean modal, gchar *title)
+gnc_book_options_dialog_cb (gboolean modal, gchar *title, GtkWindow* parent)
{
QofBook *book = gnc_get_current_book ();
GNCOptionDB *options;
@@ -4073,9 +4073,10 @@ gnc_book_options_dialog_cb (gboolean modal, gchar *title)
{
return NULL;
}
- optionwin = gnc_options_dialog_new_modal (modal,
- (title ? title : _( "Book Options")),
- DIALOG_BOOK_OPTIONS_CM_CLASS);
+ optionwin = gnc_options_dialog_new_modal (
+ modal,
+ (title ? title : _( "Book Options")),
+ DIALOG_BOOK_OPTIONS_CM_CLASS, parent);
gnc_options_dialog_build_contents (optionwin, options);
gnc_options_dialog_set_book_options_help_cb (optionwin);
@@ -4094,7 +4095,7 @@ gnc_book_options_dialog_cb (gboolean modal, gchar *title)
static void
gnc_main_window_cmd_file_properties (GtkAction *action, GncMainWindow *window)
{
- gnc_book_options_dialog_cb (FALSE, NULL);
+ gnc_book_options_dialog_cb (FALSE, NULL, GTK_WINDOW (window));
}
static void
diff --git a/gnucash/gnome-utils/gnc-main-window.h b/gnucash/gnome-utils/gnc-main-window.h
index c414617..46f01bf 100644
--- a/gnucash/gnome-utils/gnc-main-window.h
+++ b/gnucash/gnome-utils/gnc-main-window.h
@@ -417,10 +417,14 @@ void gnc_main_window_show_all_windows(void);
*
* @param title Title of the dialog; "Book Options" if NULL.
*
+ * @param parent The toplevel GdkWindow with which the dialog will
+ * be transient for.
+ *
* @return A pointer to the GtkWidget for the dialog that can be used
* when started in modal mode.
**/
-GtkWidget *gnc_book_options_dialog_cb (gboolean modal, gchar *title);
+GtkWidget *gnc_book_options_dialog_cb (gboolean modal, gchar *title,
+ GtkWindow *parent);
/**
* Processes selected options in the Book Options dialog: checks book_currency
diff --git a/gnucash/gnome-utils/gnome-utils.i b/gnucash/gnome-utils/gnome-utils.i
index 24d85cf..bafde30 100644
--- a/gnucash/gnome-utils/gnome-utils.i
+++ b/gnucash/gnome-utils/gnome-utils.i
@@ -49,7 +49,7 @@ SCM scm_init_sw_gnome_utils_module (void);
%import "base-typemaps.i"
-GNCOptionWin * gnc_options_dialog_new(gchar *title);
+GNCOptionWin * gnc_options_dialog_new(gchar *title, GtkWindow* parent);
void gnc_options_dialog_destroy(GNCOptionWin * win);
void gnc_options_dialog_build_contents(GNCOptionWin *propertybox,
GNCOptionDB *odb);
diff --git a/gnucash/gnome/assistant-hierarchy.c b/gnucash/gnome/assistant-hierarchy.c
index 5a6d25d..dae9afb 100644
--- a/gnucash/gnome/assistant-hierarchy.c
+++ b/gnucash/gnome/assistant-hierarchy.c
@@ -1174,9 +1174,9 @@ book_options_dialog_close_cb(GNCOptionWin * optionwin,
}
static void
-assistant_insert_book_options_page (hierarchy_data *data)
+assistant_insert_book_options_page (hierarchy_data *data, GtkWindow* parent)
{
- GtkWidget *options, *parent;
+ GtkWidget *options;
GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_box_set_homogeneous (GTK_BOX (vbox), FALSE);
@@ -1186,7 +1186,8 @@ assistant_insert_book_options_page (hierarchy_data *data)
gnc_option_db_clean (data->options);
data->optionwin = gnc_options_dialog_new_modal (TRUE, _("New Book Options"),
- DIALOG_BOOK_OPTIONS_CM_CLASS);
+ DIALOG_BOOK_OPTIONS_CM_CLASS,
+ parent);
gnc_options_dialog_build_contents_full (data->optionwin, data->options, FALSE);
gnc_options_dialog_set_close_cb (data->optionwin,
@@ -1195,7 +1196,6 @@ assistant_insert_book_options_page (hierarchy_data *data)
gnc_options_dialog_set_new_book_option_values (data->options);
options = gnc_options_dialog_notebook (data->optionwin);
- parent = gtk_widget_get_parent (options);
g_object_ref (options);
gtk_container_remove (GTK_CONTAINER(parent), options);
@@ -1278,7 +1278,7 @@ gnc_create_hierarchy_assistant (gboolean use_defaults, GncHierarchyAssistantFini
/* Book options page - only on new books */
if (data->new_book)
- assistant_insert_book_options_page (data);
+ assistant_insert_book_options_page (data, GTK_WINDOW (tree_view));
/* Final Accounts Page */
data->final_account_tree_container = GTK_WIDGET(gtk_builder_get_object (builder, "final_account_tree_box"));
diff --git a/gnucash/report/report-gnome/dialog-report-column-view.c b/gnucash/report/report-gnome/dialog-report-column-view.c
index f7a8e18..d351ca4 100644
--- a/gnucash/report/report-gnome/dialog-report-column-view.c
+++ b/gnucash/report/report-gnome/dialog-report-column-view.c
@@ -309,7 +309,7 @@ gnc_column_view_edit_options(SCM options, SCM view)
gnc_column_view_edit * r = g_new0(gnc_column_view_edit, 1);
GtkBuilder *builder;
- r->optwin = gnc_options_dialog_new(NULL);
+ r->optwin = gnc_options_dialog_new(NULL, NULL);
/* Hide the generic dialog page list. */
gtk_widget_hide(gnc_options_page_list(r->optwin));
diff --git a/gnucash/report/report-gnome/dialog-report-style-sheet.c b/gnucash/report/report-gnome/dialog-report-style-sheet.c
index a3005b1..f2fbb97 100644
--- a/gnucash/report/report-gnome/dialog-report-style-sheet.c
+++ b/gnucash/report/report-gnome/dialog-report-style-sheet.c
@@ -157,9 +157,10 @@ gnc_style_sheet_dialog_create(StyleSheetDialog * ss,
ss_info * ssinfo = g_new0(ss_info, 1);
GtkWidget * window;
gchar * title;
+ GtkWindow * parent = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (ss->list_view)));
title = g_strdup_printf(_("HTML Style Sheet Properties: %s"), name);
- ssinfo->odialog = gnc_options_dialog_new(title);
+ ssinfo->odialog = gnc_options_dialog_new(title, parent);
ssinfo->odb = gnc_option_db_new(scm_options);
ssinfo->stylesheet = sheet_info;
ssinfo->row_ref = row_ref;
diff --git a/gnucash/report/report-gnome/gnc-plugin-page-report.c b/gnucash/report/report-gnome/gnc-plugin-page-report.c
index 7cdd98e..a0fe927 100644
--- a/gnucash/report/report-gnome/gnc-plugin-page-report.c
+++ b/gnucash/report/report-gnome/gnc-plugin-page-report.c
@@ -1663,12 +1663,12 @@ static void
gnc_plugin_page_report_options_cb( GtkAction *action, GncPluginPageReport *report )
{
GncPluginPageReportPrivate *priv;
-
+ GtkWindow *parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (report)));
priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(report);
if (priv->cur_report == SCM_BOOL_F)
return;
- if (gnc_report_edit_options (priv->cur_report))
+ if (gnc_report_edit_options (priv->cur_report, parent))
gnc_plugin_page_report_add_edited_report(priv, priv->cur_report);
}
diff --git a/gnucash/report/report-gnome/window-report.c b/gnucash/report/report-gnome/window-report.c
index 93e525c..82e2bc2 100644
--- a/gnucash/report/report-gnome/window-report.c
+++ b/gnucash/report/report-gnome/window-report.c
@@ -88,7 +88,7 @@ gnc_options_dialog_apply_cb(GNCOptionWin * propertybox,
results = gnc_option_db_commit (win->db);
for (iter = results; iter; iter = iter->next)
{
- GtkWidget *dialog = gtk_message_dialog_new(NULL,
+ GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW (win->win),
0,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
@@ -156,7 +156,8 @@ gnc_report_raise_editor(SCM report)
GtkWidget *
-gnc_report_window_default_params_editor(SCM options, SCM report)
+gnc_report_window_default_params_editor(SCM options, SCM report,
+ GtkWindow *parent)
{
SCM get_report_type = scm_c_eval_string("gnc:report-type");
SCM get_template = scm_c_eval_string("gnc:find-report-template");
@@ -190,7 +191,7 @@ gnc_report_window_default_params_editor(SCM options, SCM report)
}
/* Don't forget to translate the window title */
- prm->win = gnc_options_dialog_new((gchar*) (title && *title ? _(title) : ""));
+ prm->win = gnc_options_dialog_new((gchar*) (title && *title ? _(title) : ""), parent);
g_free ((gpointer *) title);
@@ -214,7 +215,7 @@ gnc_report_window_default_params_editor(SCM options, SCM report)
}
gboolean
-gnc_report_edit_options(SCM report)
+gnc_report_edit_options(SCM report, GtkWindow *parent)
{
SCM set_editor = scm_c_eval_string("gnc:report-set-editor-widget!");
SCM get_options = scm_c_eval_string("gnc:report-options");
@@ -244,7 +245,7 @@ gnc_report_edit_options(SCM report)
if (g_strcmp0 (rpt_type, "d8ba4a2e89e8479ca9f6eccdeb164588") == 0)
options_widget = gnc_column_view_edit_options (options, report);
else
- options_widget = gnc_report_window_default_params_editor (options, report);
+ options_widget = gnc_report_window_default_params_editor (options, report, parent);
g_free (rpt_type);
}
@@ -323,7 +324,7 @@ gnc_html_options_url_cb (const char *location, const char *label,
return FALSE;
}
- gnc_report_edit_options (report);
+ gnc_report_edit_options (report, NULL);
return TRUE;
}
diff --git a/gnucash/report/report-gnome/window-report.h b/gnucash/report/report-gnome/window-report.h
index ee7b9db..4e3e475 100644
--- a/gnucash/report/report-gnome/window-report.h
+++ b/gnucash/report/report-gnome/window-report.h
@@ -33,13 +33,13 @@ typedef struct gnc_report_window_s gnc_report_window;
/** PROTOTYPES ******************************************************/
// scm-exposed
-GtkWidget * gnc_report_window_default_params_editor(SCM options, SCM report);
+GtkWidget * gnc_report_window_default_params_editor(SCM options, SCM report, GtkWindow *parent);
// called from multiple places
// [gnome-business/dialog-invoice.c;gnome/window-register.c]; and
// scm-exposed; 3-liner which calls gnc_main_window_open_report after handling busy-cursor.
void reportWindow(int id);
-gboolean gnc_report_edit_options(SCM report);
+gboolean gnc_report_edit_options(SCM report, GtkWindow *parent);
// module[/plugin]-init
void gnc_report_init (void);
diff --git a/po/POTFILES.in b/po/POTFILES.in
index eaf0f39..bced61f 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -464,6 +464,7 @@ gnucash/report/standard-reports/budget-barchart.scm
gnucash/report/standard-reports/budget-flow.scm
gnucash/report/standard-reports/budget-income-statement.scm
gnucash/report/standard-reports/budget.scm
+gnucash/report/standard-reports/cashflow-barchart.scm
gnucash/report/standard-reports/cash-flow.scm
gnucash/report/standard-reports/category-barchart.scm
gnucash/report/standard-reports/daily-reports.scm
Summary of changes:
gnucash/gnome-utils/dialog-options.c | 9 +++++----
gnucash/gnome-utils/dialog-options.h | 5 +++--
gnucash/gnome-utils/dialog-utils.c | 6 ++----
gnucash/gnome-utils/gnc-main-window.c | 11 ++++++-----
gnucash/gnome-utils/gnc-main-window.h | 6 +++++-
gnucash/gnome-utils/gnome-utils.i | 2 +-
gnucash/gnome/assistant-hierarchy.c | 10 +++++-----
gnucash/report/report-gnome/dialog-report-column-view.c | 2 +-
gnucash/report/report-gnome/dialog-report-style-sheet.c | 3 ++-
gnucash/report/report-gnome/gnc-plugin-page-report.c | 4 ++--
gnucash/report/report-gnome/window-report.c | 13 +++++++------
gnucash/report/report-gnome/window-report.h | 4 ++--
po/POTFILES.in | 1 +
13 files changed, 42 insertions(+), 34 deletions(-)
More information about the gnucash-changes
mailing list