diff --git a/CMakeLists.txt b/CMakeLists.txt index bf9732fe32..205fbcd113 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,6 +73,23 @@ OPTION (AUTOTOOLS_IN_DIST "Add autotools support to distribution tarballs." ON) # These are also settable from the command line in a similar way. SET(GNUCASH_BUILD_ID "" CACHE STRING "Overrides the GnuCash build identification (Build ID) which defaults to a description of the vcs commit from which gnucash is built. Distributions may want to insert a package management based version number instead") + +# Check that all of the absolute install paths are inside +# ${CMAKE_INSTALL_PREFIX}. If they're not, disable binreloc as it +# won't be able to find paths that aren't relative to the location of +# the executable. +foreach(install_dir ${CMAKE_INSTALL_FULL_BINDIR} + ${CMAKE_INSTALL_FULL_SYSCONFDIR} ${CMAKE_INSTALL_FULL_DATAROOTDIR} + ${CMAKE_INSTALL_FULL_DATADIR} ${CMAKE_INSTALL_FULL_LIBDIR}) + string(FIND ${install_dir} ${CMAKE_INSTALL_PREFIX} in_prefix) + if(in_prefix EQUAL -1) + set(ENABLE_BINRELOC OFF) + message(WARNING "${install_dir} is set outside of the intallation prefix ${CMAKE_INSTALL_PREFIX}. That will break relocation so ENABLE_BINRELOC is set to off. With relocation disabled GnuCash will run only in its configured install location. You must set GNC_UNINSTALLED=1 and GNC_BUILDDIR=/path/to/builddir to run from the build directory. GnuCash will not run from a DESTDIR.") + break() + endif() +endforeach() + +# GnuCash installs two files in ${CMAKE_INSTALL_SYSCONFDIR} SET(BINDIR ${CMAKE_INSTALL_BINDIR} CACHE STRING "user executables") SET(SYSCONFDIR ${CMAKE_INSTALL_SYSCONFDIR} CACHE STRING "read-only single-machine data") SET(DATAROOTDIR ${CMAKE_INSTALL_DATAROOTDIR} CACHE STRING "read-only arch.-independent data root") @@ -82,7 +99,7 @@ SET(LOCALEDIR ${DATAROOTDIR}/locale CACHE STRING "locale-dependent data") SET(GNC_HELPDIR ${DATADIR} CACHE STRING "where to store help files") SET(DATADIRNAME share) SET(GNC_SYSTEM_XDG_DATA_DIRS /usr/local/share /usr/share) -SET(GNC_DBD_DIR ${CMAKE_PREFIX_PATH}/lib/dbd CACHE PATH "specify location of libdbi drivers") +SET(GNC_DBD_DIR ${CMAKE_PREFIX_LIBDIR}/dbd CACHE PATH "specify location of libdbi drivers") SET(PKGLIBDIR ${CMAKE_INSTALL_LIBDIR}/gnucash) SET(TEST_MYSQL_URL "" CACHE STRING "MySQL database URL for testing") SET(TEST_PGSQL_URL "" CACHE STRING "PgSQL database URL for testing") diff --git a/gnucash/gnome-search/dialog-search.c b/gnucash/gnome-search/dialog-search.c index badc97d804..12e922fcd4 100644 --- a/gnucash/gnome-search/dialog-search.c +++ b/gnucash/gnome-search/dialog-search.c @@ -162,13 +162,13 @@ gnc_search_callback_button_execute (GNCSearchCallbackButton *cb, sw->selected_item_list = g_list_reverse(sw->selected_item_list); // Call the callback - (cb->cb_multiselect_fn)(sw->selected_item_list, sw->user_data); + (cb->cb_multiselect_fn)(GTK_WINDOW (sw->dialog), sw->selected_item_list, sw->user_data); } else { // No, stick to the single-item callback if (cb->cb_fcn) - (cb->cb_fcn)(&(sw->selected_item), sw->user_data); + (cb->cb_fcn)(GTK_WINDOW (sw->dialog), &(sw->selected_item), sw->user_data); } } @@ -234,11 +234,11 @@ gnc_search_dialog_select_cb (GtkButton *button, GNCSearchWindow *sw) if (sw->selected_item == NULL && sw->allow_clear == FALSE) { char *msg = _("You must select an item from the list"); - gnc_error_dialog (sw->dialog, "%s", msg); + gnc_error_dialog (GTK_WINDOW (sw->dialog), "%s", msg); return; } - (sw->selected_cb)(sw->selected_item, sw->select_arg); + (sw->selected_cb)(GTK_WINDOW (sw->dialog), sw->selected_item, sw->select_arg); gnc_search_dialog_destroy (sw); } @@ -637,7 +637,7 @@ search_new_item_cb (GtkButton *button, GNCSearchWindow *sw) g_return_if_fail (sw->new_item_cb); - res = (sw->new_item_cb)(sw->user_data); + res = (sw->new_item_cb)(GTK_WINDOW (sw->dialog), sw->user_data); if (res) { @@ -1300,7 +1300,8 @@ gnc_search_dialog_raise (GNCSearchWindow *sw) } GNCSearchWindow * -gnc_search_dialog_create (QofIdTypeConst obj_type, const gchar *title, +gnc_search_dialog_create (GtkWindow *parent, + QofIdTypeConst obj_type, const gchar *title, GList *param_list, GList *display_list, QofQuery *start_query, QofQuery *show_start_query, @@ -1345,6 +1346,7 @@ gnc_search_dialog_create (QofIdTypeConst obj_type, const gchar *title, gnc_search_dialog_init_widgets (sw, title); if (sw->prefs_group) gnc_restore_window_size(sw->prefs_group, GTK_WINDOW(sw->dialog)); + gtk_window_set_transient_for(GTK_WINDOW(sw->dialog), parent); gtk_widget_show(sw->dialog); // Set the style context for this dialog so it can be easily manipulated with css @@ -1465,7 +1467,7 @@ get_display_list (QofIdTypeConst type) static void -do_nothing (gpointer *a, gpointer b) +do_nothing (GtkWindow *dialog, gpointer *a, gpointer b) { return; } @@ -1494,7 +1496,7 @@ gnc_search_dialog_test (void) display = get_display_list (GNC_ID_SPLIT); /* FIXME: All this does is leak. */ - gnc_search_dialog_create (GNC_ID_SPLIT, _("Find Transaction"), + gnc_search_dialog_create (NULL, GNC_ID_SPLIT, _("Find Transaction"), params, display, NULL, NULL, buttons, NULL, NULL, NULL, NULL, NULL, NULL, NULL); diff --git a/gnucash/gnome-search/dialog-search.h b/gnucash/gnome-search/dialog-search.h index ec3bc28d5b..c94eb4facc 100644 --- a/gnucash/gnome-search/dialog-search.h +++ b/gnucash/gnome-search/dialog-search.h @@ -40,7 +40,7 @@ typedef struct _GNCSearchWindow GNCSearchWindow; * result will be a pointer to the selected item (if one is selected) * and the callback may change the value. */ -typedef void (*GNCSearchCallback) (gpointer *obj_p, gpointer user_data); +typedef void (*GNCSearchCallback) (GtkWindow *dialog, gpointer *obj_p, gpointer user_data); typedef void (*GNCSearchResultCB) (QofQuery *query, gpointer user_data, gpointer *result); @@ -50,7 +50,7 @@ typedef void (*GNCSearchResultCB) (QofQuery *query, gpointer user_data, * will be added to the query, but not selected. This means the GncGUID * must be set. */ -typedef gpointer (*GNCSearchNewItemCB) (gpointer user_data); +typedef gpointer (*GNCSearchNewItemCB) (GtkWindow *dialog, gpointer user_data); /* Free the general user_data object */ typedef void (*GNCSearchFree) (gpointer user_data); @@ -59,15 +59,17 @@ typedef void (*GNCSearchFree) (gpointer user_data); * button. The search dialog will close when this callback function * returns. */ -typedef void (*GNCSearchSelectedCB) (gpointer selected_object, +typedef void (*GNCSearchSelectedCB) (GtkWindow *dialog, + gpointer selected_object, gpointer user_data); /** This callback is called when (if) the user clicks the 'select' * button. The search dialog will close when this callback function * returns. */ -typedef void (*GNCSearchMultiSelectedCB) (GList *list_of_selected_objects, - gpointer user_data); +typedef void (*GNCSearchMultiSelectedCB) (GtkWindow *dialog, + GList *list_of_selected_objects, + gpointer user_data); typedef struct { @@ -103,7 +105,8 @@ typedef struct * the dialog will use the obj_type instead. */ GNCSearchWindow * -gnc_search_dialog_create (QofIdTypeConst obj_type, const gchar *title, +gnc_search_dialog_create (GtkWindow *parent, + QofIdTypeConst obj_type, const gchar *title, GList *param_list, GList *display_list, QofQuery *start_query, QofQuery *show_start_query, diff --git a/gnucash/gnome-search/gnc-general-search.c b/gnucash/gnome-search/gnc-general-search.c index 9bc30c5397..c0d4f2b358 100644 --- a/gnucash/gnome-search/gnc-general-search.c +++ b/gnucash/gnome-search/gnc-general-search.c @@ -39,6 +39,7 @@ #include "gnc-component-manager.h" #include "qof.h" #include "gnc-general-search.h" +#include "gnc-ui.h" #define GNCGENERALSEARCH_CLASS "gnc-general-search-widget" @@ -217,7 +218,7 @@ refresh_handler (GHashTable *changes, gpointer data) /* The user has selected from the search dialog */ static void -new_item_selected_cb (gpointer item, gpointer user_data) +new_item_selected_cb (GtkWindow *dialog, gpointer item, gpointer user_data) { GNCGeneralSearch *gsl = user_data; gnc_general_search_set_selected (gsl, item); @@ -250,7 +251,7 @@ search_cb(GtkButton * button, gpointer user_data) return; } - sw = (priv->search_cb)(gsl->selected_item, priv->user_data); + sw = (priv->search_cb)(gnc_ui_get_gtk_window (GTK_WIDGET (button)), gsl->selected_item, priv->user_data); /* NULL means nothing to 'select' */ if (sw == NULL) @@ -284,7 +285,7 @@ search_cb(GtkButton * button, gpointer user_data) * @param comp_iter The iter in the completion's temporary model * that represents the user selected match. * - * @param cbe A pointer to a currency entry widget. */ + * @param gsl A pointer to a currency entry widget. */ static gboolean gnc_gsl_match_selected_cb (GtkEntryCompletion *completion, GtkTreeModel *comp_model, diff --git a/gnucash/gnome-search/gnc-general-search.h b/gnucash/gnome-search/gnc-general-search.h index adba80809f..dc514639d7 100644 --- a/gnucash/gnome-search/gnc-general-search.h +++ b/gnucash/gnome-search/gnc-general-search.h @@ -51,7 +51,7 @@ * it actually returns a search-window, then this widget will set up the * appropriate callbacks to the search window to obtain selections. */ -typedef GNCSearchWindow *(*GNCSearchCB) (gpointer start, gpointer user_data); +typedef GNCSearchWindow *(*GNCSearchCB) (GtkWindow *parent, gpointer start, gpointer user_data); typedef struct { diff --git a/gnucash/gnome-utils/assistant-xml-encoding.c b/gnucash/gnome-utils/assistant-xml-encoding.c index f38b5e8627..0e04e23f12 100644 --- a/gnucash/gnome-utils/assistant-xml-encoding.c +++ b/gnucash/gnome-utils/assistant-xml-encoding.c @@ -1132,7 +1132,7 @@ cleanup_parse_file: } if (message) { - gnc_error_dialog (data->assistant, "%s", message); + gnc_error_dialog (GTK_WINDOW (data->assistant), "%s", message); } if (!success) gxi_session_destroy (data); @@ -1306,7 +1306,7 @@ gxi_add_encoding (GncXmlImportData *data, gpointer encoding_ptr) if (g_list_find (data->encodings, encoding_ptr)) { message = _("This encoding has been added to the list already."); - gnc_error_dialog (data->encodings_dialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (data->encodings_dialog), "%s", message); return; } @@ -1317,7 +1317,7 @@ gxi_add_encoding (GncXmlImportData *data, gpointer encoding_ptr) g_iconv_close (iconv); g_free (enc_string); message = _("This is an invalid encoding."); - gnc_error_dialog (data->encodings_dialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (data->encodings_dialog), "%s", message); return; } g_iconv_close (iconv); diff --git a/gnucash/gnome-utils/dialog-account.c b/gnucash/gnome-utils/dialog-account.c index 24f63e11ce..3c2a59d63e 100644 --- a/gnucash/gnome-utils/dialog-account.c +++ b/gnucash/gnome-utils/dialog-account.c @@ -467,7 +467,7 @@ gnc_ui_to_account(AccountWindow *aw) if (!gnc_account_create_opening_balance (account, balance, date, aw->book)) { const char *message = _("Could not create opening balance."); - gnc_error_dialog(aw->dialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (aw->dialog), "%s", message); } } else @@ -756,7 +756,7 @@ gnc_common_ok (AccountWindow *aw) if (g_strcmp0(name, "") == 0) { const char *message = _("The account must be given a name."); - gnc_error_dialog(aw->dialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (aw->dialog), "%s", message); LEAVE("bad name"); return FALSE; } @@ -782,7 +782,7 @@ gnc_common_ok (AccountWindow *aw) !guid_equal(&aw->account, xaccAccountGetGUID (account))) { const char *message = _("There is already an account with that name."); - gnc_error_dialog(aw->dialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (aw->dialog), "%s", message); LEAVE("duplicate name"); return FALSE; } @@ -791,7 +791,7 @@ gnc_common_ok (AccountWindow *aw) if (!gnc_filter_parent_accounts(parent, aw)) { const char *message = _("You must choose a valid parent account."); - gnc_error_dialog(aw->dialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (aw->dialog), "%s", message); LEAVE("invalid parent"); return FALSE; } @@ -800,7 +800,7 @@ gnc_common_ok (AccountWindow *aw) if (aw->type == ACCT_TYPE_INVALID) { const char *message = _("You must select an account type."); - gnc_error_dialog(aw->dialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (aw->dialog), "%s", message); LEAVE("invalid type"); return FALSE; } @@ -810,7 +810,7 @@ gnc_common_ok (AccountWindow *aw) { const char *message = _("The selected account type is incompatible with " "the one of the selected parent."); - gnc_error_dialog(aw->dialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (aw->dialog), "%s", message); LEAVE("incompatible types"); return FALSE; } @@ -821,7 +821,7 @@ gnc_common_ok (AccountWindow *aw) if (!commodity) { const char *message = _("You must choose a commodity."); - gnc_error_dialog(aw->dialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (aw->dialog), "%s", message); LEAVE("invalid commodity"); return FALSE; } @@ -878,7 +878,7 @@ gnc_new_account_ok (AccountWindow *aw) { const char *message = _("You must enter a valid opening balance " "or leave it blank."); - gnc_error_dialog(aw->dialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (aw->dialog), "%s", message); LEAVE(" "); return; } @@ -902,7 +902,7 @@ gnc_new_account_ok (AccountWindow *aw) { const char *message = _("You must select a transfer account or choose" " the opening balances equity account."); - gnc_error_dialog(aw->dialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (aw->dialog), "%s", message); LEAVE(" "); return; } diff --git a/gnucash/gnome-utils/dialog-book-close.c b/gnucash/gnome-utils/dialog-book-close.c index dab1930b93..2d23e41da0 100644 --- a/gnucash/gnome-utils/dialog-book-close.c +++ b/gnucash/gnome-utils/dialog-book-close.c @@ -297,14 +297,14 @@ gnc_book_close_response_cb(GtkDialog *dialog, gint response, GtkDialog *unused) if (!income_acct) { - gnc_error_dialog(cbw->dialog, "%s", + gnc_error_dialog(GTK_WINDOW (cbw->dialog), "%s", _("Please select an Equity account to hold the total Period Income.")); break; } if (!expense_acct) { - gnc_error_dialog(cbw->dialog, "%s", + gnc_error_dialog(GTK_WINDOW (cbw->dialog), "%s", _("Please select an Equity account to hold the total Period Expense.")); break; } diff --git a/gnucash/gnome-utils/dialog-commodity.c b/gnucash/gnome-utils/dialog-commodity.c index e9aa51fb7e..3179b7aeba 100644 --- a/gnucash/gnome-utils/dialog-commodity.c +++ b/gnucash/gnome-utils/dialog-commodity.c @@ -1282,8 +1282,8 @@ gnc_ui_commodity_dialog_to_object(CommodityWindow * w) gnc_commodity_commit_edit(c); return TRUE; } - gnc_warning_dialog(w->dialog, "%s", - _("You may not create a new national currency.")); + gnc_warning_dialog (GTK_WINDOW (w->dialog), "%s", + _("You may not create a new national currency.")); return FALSE; } @@ -1292,10 +1292,10 @@ gnc_ui_commodity_dialog_to_object(CommodityWindow * w) */ if (g_utf8_collate(name_space, GNC_COMMODITY_NS_TEMPLATE) == 0) { - gnc_warning_dialog (w->dialog, - _("%s is a reserved commodity type." + gnc_warning_dialog (GTK_WINDOW (w->dialog), + _("%s is a reserved commodity type." " Please use something else."), GNC_COMMODITY_NS_TEMPLATE); - return FALSE; + return FALSE; } if (fullname && fullname[0] && @@ -1308,7 +1308,7 @@ gnc_ui_commodity_dialog_to_object(CommodityWindow * w) if ((!w->edit_commodity && c) || (w->edit_commodity && c && (c != w->edit_commodity))) { - gnc_warning_dialog (w->dialog, "%s", _("That commodity already exists.")); + gnc_warning_dialog (GTK_WINDOW (w->dialog), "%s", _("That commodity already exists.")); g_free(name_space); return FALSE; } @@ -1356,10 +1356,10 @@ gnc_ui_commodity_dialog_to_object(CommodityWindow * w) } else { - gnc_warning_dialog(w->dialog, "%s", - _("You must enter a non-empty \"Full name\", " - "\"Symbol/abbreviation\", " - "and \"Type\" for the commodity.")); + gnc_warning_dialog (GTK_WINDOW (w->dialog), "%s", + _("You must enter a non-empty \"Full name\", " + "\"Symbol/abbreviation\", " + "and \"Type\" for the commodity.")); g_free(name_space); return FALSE; } diff --git a/gnucash/gnome-utils/dialog-file-access.c b/gnucash/gnome-utils/dialog-file-access.c index 7cd36f30ff..c641b8aaf4 100644 --- a/gnucash/gnome-utils/dialog-file-access.c +++ b/gnucash/gnome-utils/dialog-file-access.c @@ -144,15 +144,15 @@ gnc_ui_file_access_response_cb(GtkDialog *dialog, gint response, GtkDialog *unus gboolean open_readonly = faw->readonly_checkbutton ? gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(faw->readonly_checkbutton)) : FALSE; - gnc_file_open_file( url, open_readonly ); + gnc_file_open_file (gnc_ui_get_main_window (GTK_WIDGET (dialog)), url, open_readonly); } else if ( faw->type == FILE_ACCESS_SAVE_AS ) { - gnc_file_do_save_as( url ); + gnc_file_do_save_as (gnc_ui_get_main_window (GTK_WIDGET (dialog)), url); } else if ( faw->type == FILE_ACCESS_EXPORT ) { - gnc_file_do_export( url ); + gnc_file_do_export (gnc_ui_get_main_window (GTK_WIDGET (dialog)), url); } break; @@ -240,7 +240,7 @@ get_default_database( void ) } static void -gnc_ui_file_access( int type ) +gnc_ui_file_access (GtkWindow *parent, int type) { FileAccessWindow *faw; GtkBuilder* builder; @@ -275,6 +275,7 @@ gnc_ui_file_access( int type ) builder = gtk_builder_new(); gnc_builder_add_from_file (builder, "dialog-file-access.glade", "file_access_dialog" ); faw->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "file_access_dialog" )); + gtk_window_set_transient_for (GTK_WINDOW (faw->dialog), parent); g_object_set_data_full( G_OBJECT(faw->dialog), "FileAccessWindow", faw, g_free ); // Set the style context for this dialog so it can be easily manipulated with css @@ -446,21 +447,21 @@ gnc_ui_file_access( int type ) } void -gnc_ui_file_access_for_open( void ) +gnc_ui_file_access_for_open (GtkWindow *parent) { - gnc_ui_file_access( FILE_ACCESS_OPEN ); + gnc_ui_file_access (parent, FILE_ACCESS_OPEN); } void -gnc_ui_file_access_for_save_as( void ) +gnc_ui_file_access_for_save_as (GtkWindow *parent) { - gnc_ui_file_access( FILE_ACCESS_SAVE_AS ); + gnc_ui_file_access (parent, FILE_ACCESS_SAVE_AS); } void -gnc_ui_file_access_for_export( void ) +gnc_ui_file_access_for_export (GtkWindow *parent) { - gnc_ui_file_access( FILE_ACCESS_EXPORT ); + gnc_ui_file_access (parent, FILE_ACCESS_EXPORT); } diff --git a/gnucash/gnome-utils/dialog-file-access.h b/gnucash/gnome-utils/dialog-file-access.h index 8dd61abc6e..bf8cb38b00 100644 --- a/gnucash/gnome-utils/dialog-file-access.h +++ b/gnucash/gnome-utils/dialog-file-access.h @@ -34,9 +34,9 @@ * loading/open and for saving. */ -void gnc_ui_file_access_for_open( void ); -void gnc_ui_file_access_for_save_as( void ); -void gnc_ui_file_access_for_export( void ); +void gnc_ui_file_access_for_open (GtkWindow *parent); +void gnc_ui_file_access_for_save_as (GtkWindow *parent); +void gnc_ui_file_access_for_export (GtkWindow *parent); /** @} */ diff --git a/gnucash/gnome-utils/dialog-options.c b/gnucash/gnome-utils/dialog-options.c index 9d6768fba9..c184208fd4 100644 --- a/gnucash/gnome-utils/dialog-options.c +++ b/gnucash/gnome-utils/dialog-options.c @@ -834,7 +834,7 @@ gnc_option_changed_gain_loss_account_widget_cb (GtkTreeSelection *selection, "the placeholder account by clicking on the arrow " \ "to the left.)"); - gnc_error_dialog(NULL, "%s", message); + gnc_error_dialog (gnc_ui_get_gtk_window (book_currency_data->default_gain_loss_account_widget), "%s", message); if (book_currency_data->prior_gain_loss_account) { (gnc_tree_view_account_set_selected_account diff --git a/gnucash/gnome-utils/dialog-preferences.c b/gnucash/gnome-utils/dialog-preferences.c index cb5e976b3d..b3ba114656 100644 --- a/gnucash/gnome-utils/dialog-preferences.c +++ b/gnucash/gnome-utils/dialog-preferences.c @@ -193,7 +193,7 @@ gnc_account_separator_validate_cb (GtkEntry *entry, GdkEvent *event, GtkWidget * if (conflict_msg) { - gnc_warning_dialog(dialog, "%s", conflict_msg); + gnc_warning_dialog (GTK_WINDOW (dialog), "%s", conflict_msg); g_free ( conflict_msg ); } g_free (separator); diff --git a/gnucash/gnome-utils/dialog-query-view.c b/gnucash/gnome-utils/dialog-query-view.c index 824755fb19..4052b6bdc0 100644 --- a/gnucash/gnome-utils/dialog-query-view.c +++ b/gnucash/gnome-utils/dialog-query-view.c @@ -85,7 +85,7 @@ gnc_dialog_query_run_callback (GNCDisplayViewButton *cb, gpointer item, return; if (cb->cb_fcn) - (cb->cb_fcn)(item, dqv->user_data); + (cb->cb_fcn)(GTK_WINDOW (dqv->dialog), item, dqv->user_data); } static void @@ -177,7 +177,7 @@ gnc_dialog_query_view_close (GtkButton *button, DialogQueryView *dqv) /* PUBLIC INTERFACES */ DialogQueryView * -gnc_dialog_query_view_new (GList *param_list, Query *q) +gnc_dialog_query_view_new (GtkWindow *parent, GList *param_list, Query *q) { GtkBuilder *builder; DialogQueryView *dqv; @@ -191,6 +191,7 @@ gnc_dialog_query_view_new (GList *param_list, Query *q) /* Grab the dialog, save the dialog info */ dqv->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "query_view_dialog")); g_object_set_data (G_OBJECT (dqv->dialog), "dialog-info", dqv); + gtk_window_set_transient_for(GTK_WINDOW(dqv->dialog), parent); // Set the style context for this dialog so it can be easily manipulated with css gnc_widget_set_style_context (GTK_WIDGET(dqv->dialog), "GncQueryViewDialog"); @@ -313,7 +314,7 @@ void gnc_dialog_query_view_destroy (DialogQueryView *dqv) } DialogQueryView * -gnc_dialog_query_view_create (GList *param_list, Query *q, +gnc_dialog_query_view_create (GtkWindow *parent, GList *param_list, Query *q, const char *title, const char *label, gboolean abs, gboolean inv_sort, gint sort_column, GtkSortType order, @@ -324,7 +325,7 @@ gnc_dialog_query_view_create (GList *param_list, Query *q, if (!param_list || !q) return NULL; - dqv = gnc_dialog_query_view_new (param_list, q); + dqv = gnc_dialog_query_view_new (parent, param_list, q); if (!dqv) return NULL; diff --git a/gnucash/gnome-utils/dialog-query-view.h b/gnucash/gnome-utils/dialog-query-view.h index 4aefded1ef..88c83756ac 100644 --- a/gnucash/gnome-utils/dialog-query-view.h +++ b/gnucash/gnome-utils/dialog-query-view.h @@ -31,7 +31,7 @@ typedef struct _DialogQueryView DialogQueryView; -typedef void (*GNCDisplayViewCB)(gpointer obj, gpointer user_data); +typedef void (*GNCDisplayViewCB)(GtkWindow *dialog, gpointer obj, gpointer user_data); typedef struct { const char *label; @@ -39,7 +39,7 @@ typedef struct } GNCDisplayViewButton; DialogQueryView * -gnc_dialog_query_view_new (GList *param_list, Query *q); +gnc_dialog_query_view_new (GtkWindow *parent, GList *param_list, Query *q); void gnc_dialog_query_view_set_title (DialogQueryView *dqv, const char *title); void gnc_dialog_query_view_set_label (DialogQueryView *dqv, const char *label); @@ -53,7 +53,7 @@ void gnc_dialog_query_view_refresh (DialogQueryView *dqv); void gnc_dialog_query_view_destroy (DialogQueryView *dqv); DialogQueryView * -gnc_dialog_query_view_create (GList *param_list, Query *q, +gnc_dialog_query_view_create (GtkWindow *parent, GList *param_list, Query *q, const char *title, const char *label, gboolean abs, gboolean inv_sort, gint sort_column, GtkSortType order, diff --git a/gnucash/gnome-utils/dialog-tax-table.c b/gnucash/gnome-utils/dialog-tax-table.c index aa4dfbf76d..02741670ad 100644 --- a/gnucash/gnome-utils/dialog-tax-table.c +++ b/gnucash/gnome-utils/dialog-tax-table.c @@ -114,7 +114,7 @@ new_tax_table_ok_cb (NewTaxTable *ntt) if (name == NULL || *name == '\0') { message = _("You must provide a name for this Tax Table."); - gnc_error_dialog (ntt->dialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (ntt->dialog), "%s", message); return FALSE; } if (gncTaxTableLookupByName (ttw->book, name)) @@ -122,7 +122,7 @@ new_tax_table_ok_cb (NewTaxTable *ntt) message = g_strdup_printf(_( "You must provide a unique name for this Tax Table. " "Your choice \"%s\" is already in use."), name); - gnc_error_dialog (ntt->dialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (ntt->dialog), "%s", message); g_free (message); return FALSE; } @@ -135,7 +135,7 @@ new_tax_table_ok_cb (NewTaxTable *ntt) gnc_numeric_create (100, 1)) > 0) { message = _("Percentage amount must be between -100 and 100."); - gnc_error_dialog (ntt->dialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (ntt->dialog), "%s", message); return FALSE; } @@ -144,7 +144,7 @@ new_tax_table_ok_cb (NewTaxTable *ntt) if (acc == NULL) { message = _("You must choose a Tax Account."); - gnc_error_dialog (ntt->dialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (ntt->dialog), "%s", message); return FALSE; } @@ -563,12 +563,12 @@ tax_table_delete_table_cb (GtkButton *button, TaxTableWindow *ttw) char *message = g_strdup_printf (_("Tax table \"%s\" is in use. You cannot delete it."), gncTaxTableGetName (ttw->current_table)); - gnc_error_dialog (ttw->dialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (ttw->dialog), "%s", message); g_free (message); return; } - if (gnc_verify_dialog (ttw->dialog, FALSE, + if (gnc_verify_dialog (GTK_WINDOW (ttw->dialog), FALSE, _("Are you sure you want to delete \"%s\"?"), gncTaxTableGetName (ttw->current_table))) { @@ -611,11 +611,11 @@ tax_table_delete_entry_cb (GtkButton *button, TaxTableWindow *ttw) { char *message = _("You cannot remove the last entry from the tax table. " "Try deleting the tax table if you want to do that."); - gnc_error_dialog (ttw->dialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (ttw->dialog) , "%s", message); return; } - if (gnc_verify_dialog (ttw->dialog, FALSE, "%s", + if (gnc_verify_dialog (GTK_WINDOW (ttw->dialog), FALSE, "%s", _("Are you sure you want to delete this entry?"))) { /* Ok, let's remove it */ diff --git a/gnucash/gnome-utils/dialog-totd.c b/gnucash/gnome-utils/dialog-totd.c index 91e9e16033..0aa680eda4 100644 --- a/gnucash/gnome-utils/dialog-totd.c +++ b/gnucash/gnome-utils/dialog-totd.c @@ -34,6 +34,7 @@ #include "gnc-prefs.h" #include "gnc-gnome-utils.h" #include "gnc-engine.h" +#include "gnc-ui.h" #define GNC_PREFS_GROUP "dialogs.totd" #define GNC_PREF_CURRENT_TIP "current-tip" @@ -274,7 +275,8 @@ show_handler (const char *class_name, gint component_id, return(FALSE); } - gtk_window_present(GTK_WINDOW(totd_dialog->dialog)); + gtk_window_set_transient_for (GTK_WINDOW (totd_dialog->dialog), + gnc_ui_get_main_window (NULL)); LEAVE(" "); return(TRUE); } @@ -374,3 +376,17 @@ gnc_totd_dialog (GtkWindow *parent, gboolean startup) LEAVE(""); } + + + +/**************************************************** + * Set the totd dialog transient for the currently + * active main window. This will prevent the totd + * dialog from accidentally hiding behind a main + * window. + ****************************************************/ +void +gnc_totd_dialog_reparent (void) +{ + gnc_forall_gui_components(DIALOG_TOTD_CM_CLASS, show_handler, NULL); +} diff --git a/gnucash/gnome-utils/dialog-totd.h b/gnucash/gnome-utils/dialog-totd.h index 7a5ea73999..3e92936efb 100644 --- a/gnucash/gnome-utils/dialog-totd.h +++ b/gnucash/gnome-utils/dialog-totd.h @@ -26,5 +26,6 @@ #define DIALOG_TOTD_H void gnc_totd_dialog (GtkWindow *parent, gboolean startup); +void gnc_totd_dialog_reparent (void); #endif diff --git a/gnucash/gnome-utils/dialog-transfer.c b/gnucash/gnome-utils/dialog-transfer.c index e5fedbf99d..6ab6fb26ce 100644 --- a/gnucash/gnome-utils/dialog-transfer.c +++ b/gnucash/gnome-utils/dialog-transfer.c @@ -689,7 +689,7 @@ gnc_parse_error_dialog (XferDialog *xferData, const char *error_string) if (error_string == NULL) error_string = ""; - gnc_error_dialog (xferData->dialog, + gnc_error_dialog (GTK_WINDOW (xferData->dialog), "%s\n\n%s: %s.", error_string, _("Error"), parse_error_string); @@ -1417,7 +1417,7 @@ check_accounts (XferDialog* xferData, Account* from_account, const char *message = _("You must specify an account to transfer from, " "or to, or both, for this transaction. " "Otherwise, it will not be recorded."); - gnc_error_dialog(xferData->dialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (xferData->dialog), "%s", message); LEAVE("bad account"); return FALSE; } @@ -1426,7 +1426,7 @@ check_accounts (XferDialog* xferData, Account* from_account, { const char *message = _("You can't transfer from and to the same " "account!"); - gnc_error_dialog(xferData->dialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (xferData->dialog), "%s", message); LEAVE("same account"); return FALSE; } @@ -1442,7 +1442,7 @@ check_accounts (XferDialog* xferData, Account* from_account, name = gnc_account_get_full_name(from_account); else name = gnc_account_get_full_name(to_account); - gnc_error_dialog(xferData->dialog, placeholder_format, name); + gnc_error_dialog (GTK_WINDOW (xferData->dialog), placeholder_format, name); g_free(name); LEAVE("placeholder"); return FALSE; @@ -1454,7 +1454,7 @@ check_accounts (XferDialog* xferData, Account* from_account, _("You can't transfer from a non-currency account. " "Try reversing the \"from\" and \"to\" accounts " "and making the \"amount\" negative."); - gnc_error_dialog(xferData->dialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (xferData->dialog), "%s", message); LEAVE("non-currency"); return FALSE; } @@ -1703,7 +1703,7 @@ gnc_xfer_dialog_response_cb (GtkDialog *dialog, gint response, gpointer data) if (gnc_numeric_zero_p (amount)) { const char *message = _("You must enter an amount to transfer."); - gnc_error_dialog(xferData->dialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (xferData->dialog), "%s", message); LEAVE("invalid from amount"); return; } @@ -1823,7 +1823,7 @@ gnc_xfer_dialog_fetch (GtkButton *button, XferDialog *xferData) } scm_window = SWIG_NewPointerObj(xferData->dialog, - SWIG_TypeQuery("_p_GtkWidget"), 0); + SWIG_TypeQuery("_p_GtkWindow"), 0); if (scm_is_true (scm_not (book_scm))) { diff --git a/gnucash/gnome-utils/gnc-autosave.c b/gnucash/gnome-utils/gnc-autosave.c index 1aff29c85d..d2e5e54cfa 100644 --- a/gnucash/gnome-utils/gnc-autosave.c +++ b/gnucash/gnome-utils/gnc-autosave.c @@ -187,7 +187,7 @@ static gboolean autosave_timeout_cb(gpointer user_data) return FALSE; /* Store the current toplevel window for later use. */ - toplevel = gnc_ui_get_toplevel(); + toplevel = GTK_WIDGET (gnc_ui_get_main_window (NULL)); /* Lookup preference to show an explanatory dialog, if wanted. */ show_explanation = @@ -211,7 +211,7 @@ static gboolean autosave_timeout_cb(gpointer user_data) else g_debug("autosave_timeout_cb: toplevel is not a GNC_WINDOW\n"); - gnc_file_save(); + gnc_file_save (GTK_WINDOW (toplevel)); gnc_main_window_set_progressbar_window(NULL); diff --git a/gnucash/gnome-utils/gnc-file.c b/gnucash/gnome-utils/gnc-file.c index ff06c63a76..12d5e59764 100644 --- a/gnucash/gnome-utils/gnc-file.c +++ b/gnucash/gnome-utils/gnc-file.c @@ -76,7 +76,8 @@ static gint save_in_progress = 0; \********************************************************************/ char * -gnc_file_dialog (const char * title, +gnc_file_dialog (GtkWindow *parent, + const char * title, GList * filters, const char * starting_dir, GNCFileDialogType type @@ -124,7 +125,7 @@ gnc_file_dialog (const char * title, file_box = gtk_file_chooser_dialog_new( title, - NULL, + parent, action, _("_Cancel"), GTK_RESPONSE_CANCEL, NULL); @@ -139,10 +140,6 @@ gnc_file_dialog (const char * title, starting_dir); gtk_window_set_modal(GTK_WINDOW(file_box), TRUE); - /* - gtk_window_set_transient_for(GTK_WINDOW(file_box), - GTK_WINDOW(gnc_ui_get_toplevel())); - */ if (filters != NULL) { @@ -195,11 +192,11 @@ gnc_file_dialog (const char * title, gboolean -show_session_error (QofBackendError io_error, +show_session_error (GtkWindow *parent, + QofBackendError io_error, const char *newfile, GNCFileDialogType type) { - GtkWidget *parent = gnc_ui_get_toplevel(); GtkWidget *dialog; gboolean uh_oh = TRUE; const char *fmt, *label; @@ -306,7 +303,7 @@ show_session_error (QofBackendError io_error, break; } - dialog = gtk_message_dialog_new(GTK_WINDOW(parent), + dialog = gtk_message_dialog_new(parent, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, @@ -316,7 +313,7 @@ show_session_error (QofBackendError io_error, _("_Cancel"), GTK_RESPONSE_CANCEL, label, GTK_RESPONSE_YES, NULL); - if (parent == NULL) + if (!parent) gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), FALSE); response = gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); @@ -531,13 +528,13 @@ gnc_book_opened (void) } void -gnc_file_new (void) +gnc_file_new (GtkWindow *parent) { QofSession *session; /* If user attempts to start a new session before saving results of * the last one, prompt them to clean up their act. */ - if (!gnc_file_query_save (TRUE)) + if (!gnc_file_query_save (parent, TRUE)) return; if (gnc_current_session_exist()) @@ -568,9 +565,8 @@ gnc_file_new (void) } gboolean -gnc_file_query_save (gboolean can_cancel) +gnc_file_query_save (GtkWindow *parent, gboolean can_cancel) { - GtkWidget *parent = gnc_ui_get_toplevel(); QofBook *current_book; if (!gnc_current_session_exist()) @@ -595,7 +591,7 @@ gnc_file_query_save (gboolean can_cancel) time64 oldest_change; gint minutes; - dialog = gtk_message_dialog_new(GTK_WINDOW(parent), + dialog = gtk_message_dialog_new(parent, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, @@ -623,7 +619,7 @@ gnc_file_query_save (gboolean can_cancel) switch (response) { case GTK_RESPONSE_YES: - gnc_file_save (); + gnc_file_save (parent); /* Go check the loop condition. */ break; @@ -651,7 +647,7 @@ gnc_file_query_save (gboolean can_cancel) #define RESPONSE_READONLY 4 static gboolean -gnc_post_file_open (const char * filename, gboolean is_readonly) +gnc_post_file_open (GtkWindow *parent, const char * filename, gboolean is_readonly) { QofSession *current_session, *new_session; QofBook *new_book; @@ -677,7 +673,8 @@ RESTART: newfile = gnc_uri_normalize_uri ( filename, TRUE ); if (!newfile) { - show_session_error (ERR_FILEIO_FILE_NOT_FOUND, filename, + show_session_error (parent, + ERR_FILEIO_FILE_NOT_FOUND, filename, GNC_FILE_DIALOG_OPEN); return FALSE; } @@ -743,14 +740,14 @@ RESTART: if (ERR_BACKEND_BAD_URL == io_err) { gchar *directory; - show_session_error (io_err, newfile, GNC_FILE_DIALOG_OPEN); + show_session_error (parent, io_err, newfile, GNC_FILE_DIALOG_OPEN); io_err = ERR_BACKEND_NO_ERR; if (g_file_test (filename, G_FILE_TEST_IS_DIR)) directory = g_strdup (filename); else directory = gnc_get_default_directory (GNC_PREFS_GROUP_OPEN_SAVE); - filename = gnc_file_dialog (NULL, NULL, directory, + filename = gnc_file_dialog (parent, NULL, NULL, directory, GNC_FILE_DIALOG_OPEN); qof_session_destroy (new_session); new_session = NULL; @@ -780,12 +777,7 @@ RESTART: else displayname = g_strdup (newfile); - // Bug#467521: on Mac (and maybe Win?), the dialog will appear below the - // splash, but is modal, so we can't get rid of the splash... So, get - // rid of it now. - gnc_destroy_splash_screen(); - - dialog = gtk_message_dialog_new(NULL, + dialog = gtk_message_dialog_new(parent, 0, GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE, @@ -820,16 +812,10 @@ RESTART: break; case RESPONSE_READONLY: is_readonly = TRUE; - // re-enable the splash screen, file loading and display of - // reports may take some time - gnc_show_splash_screen(); /* user told us to open readonly. We do ignore locks (just as before), but now also force the opening. */ qof_session_begin (new_session, newfile, is_readonly, FALSE, TRUE); break; case RESPONSE_OPEN: - // re-enable the splash screen, file loading and display of - // reports may take some time - gnc_show_splash_screen(); /* user told us to ignore locks. So ignore them. */ qof_session_begin (new_session, newfile, TRUE, FALSE, FALSE); break; @@ -838,14 +824,14 @@ RESTART: * database so that the user will get a window that * they can click "Exit" on. */ - gnc_file_new (); + gnc_file_new (parent); break; } } /* if the database doesn't exist, ask the user ... */ else if ((ERR_BACKEND_NO_SUCH_DB == io_err)) { - if (FALSE == show_session_error (io_err, newfile, GNC_FILE_DIALOG_OPEN)) + if (!show_session_error (parent, io_err, newfile, GNC_FILE_DIALOG_OPEN)) { /* user told us to create a new database. Do it. We * shouldn't have to worry about locking or clobbering, @@ -867,7 +853,7 @@ RESTART: else { - uh_oh = show_session_error (io_err, newfile, GNC_FILE_DIALOG_OPEN); + uh_oh = show_session_error (parent, io_err, newfile, GNC_FILE_DIALOG_OPEN); } if (!uh_oh) @@ -914,14 +900,14 @@ RESTART: } } - uh_oh = show_session_error (io_err, newfile, GNC_FILE_DIALOG_OPEN); + uh_oh = show_session_error (parent, io_err, newfile, GNC_FILE_DIALOG_OPEN); /* Attempt to update the database if it's too old */ if ( !uh_oh && io_err == ERR_SQL_DB_TOO_OLD ) { gnc_window_show_progress(_("Re-saving user data..."), 0.0); qof_session_safe_save(new_session, gnc_window_show_progress); io_err = qof_session_get_error(new_session); - uh_oh = show_session_error(io_err, newfile, GNC_FILE_DIALOG_SAVE); + uh_oh = show_session_error(parent, io_err, newfile, GNC_FILE_DIALOG_SAVE); } /* Database is either too old and couldn't (or user didn't * want it to) be updated or it's too new. Mark it as @@ -940,7 +926,7 @@ RESTART: * The backend forgot to set an error. So make one up. */ if (!uh_oh && !new_root) { - uh_oh = show_session_error (ERR_BACKEND_MISC, newfile, + uh_oh = show_session_error (parent, ERR_BACKEND_MISC, newfile, GNC_FILE_DIALOG_OPEN); } @@ -956,7 +942,7 @@ RESTART: uh_oh = TRUE; // XXX: should pull out the file name here */ - gnc_error_dialog(gnc_ui_get_toplevel(), msg, ""); + gnc_error_dialog (parent, msg, ""); g_free (msg); } if (template_root != NULL) @@ -1052,14 +1038,14 @@ RESTART: * paths, never db uris. */ gboolean -gnc_file_open (void) +gnc_file_open (GtkWindow *parent) { const gchar * newfile; gchar *last = NULL; gchar *default_dir = NULL; gboolean result; - if (!gnc_file_query_save (TRUE)) + if (!gnc_file_query_save (parent, TRUE)) return FALSE; if ( last && gnc_uri_is_file_uri ( last ) ) @@ -1071,11 +1057,11 @@ gnc_file_open (void) else default_dir = gnc_get_default_directory(GNC_PREFS_GROUP_OPEN_SAVE); - newfile = gnc_file_dialog (_("Open"), NULL, default_dir, GNC_FILE_DIALOG_OPEN); + newfile = gnc_file_dialog (parent, _("Open"), NULL, default_dir, GNC_FILE_DIALOG_OPEN); g_free ( last ); g_free ( default_dir ); - result = gnc_post_file_open ( newfile, /*is_readonly*/ FALSE ); + result = gnc_post_file_open (parent, newfile, /*is_readonly*/ FALSE ); /* This dialogue can show up early in the startup process. If the * user fails to pick a file (by e.g. hitting the cancel button), we @@ -1087,14 +1073,14 @@ gnc_file_open (void) } gboolean -gnc_file_open_file (const char * newfile, gboolean open_readonly) +gnc_file_open_file (GtkWindow *parent, const char * newfile, gboolean open_readonly) { if (!newfile) return FALSE; - if (!gnc_file_query_save (TRUE)) + if (!gnc_file_query_save (parent, TRUE)) return FALSE; - return gnc_post_file_open (newfile, open_readonly); + return gnc_post_file_open (parent, newfile, open_readonly); } /* Note: this dialog will only be used when dbi is not enabled @@ -1102,7 +1088,7 @@ gnc_file_open_file (const char * newfile, gboolean open_readonly) * never db uris */ void -gnc_file_export (void) +gnc_file_export (GtkWindow *parent) { const char *filename; char *default_dir = NULL; /* Default to last open */ @@ -1120,13 +1106,14 @@ gnc_file_export (void) else default_dir = gnc_get_default_directory(GNC_PREFS_GROUP_EXPORT); - filename = gnc_file_dialog (_("Save"), NULL, default_dir, + filename = gnc_file_dialog (parent, + _("Save"), NULL, default_dir, GNC_FILE_DIALOG_SAVE); g_free ( last ); g_free ( default_dir ); if (!filename) return; - gnc_file_do_export( filename ); + gnc_file_do_export (parent, filename); LEAVE (" "); } @@ -1163,7 +1150,7 @@ check_file_path (const char *path) void -gnc_file_do_export(const char * filename) +gnc_file_do_export(GtkWindow *parent, const char * filename) { QofSession *current_session, *new_session; gboolean ok; @@ -1186,7 +1173,7 @@ gnc_file_do_export(const char * filename) norm_file = gnc_uri_normalize_uri ( filename, TRUE ); if (!norm_file) { - show_session_error (ERR_FILEIO_FILE_NOT_FOUND, filename, + show_session_error (parent, ERR_FILEIO_FILE_NOT_FOUND, filename, GNC_FILE_DIALOG_EXPORT); return; } @@ -1214,7 +1201,7 @@ gnc_file_do_export(const char * filename) { if (check_file_path (path)) { - show_session_error (ERR_FILEIO_RESERVED_WRITE, newfile, + show_session_error (parent, ERR_FILEIO_RESERVED_WRITE, newfile, GNC_FILE_DIALOG_SAVE); return; } @@ -1228,7 +1215,7 @@ gnc_file_do_export(const char * filename) if (strlen (oldfile) && (strcmp(oldfile, newfile) == 0)) { g_free (newfile); - show_session_error (ERR_FILEIO_WRITE_ERROR, filename, + show_session_error (parent, ERR_FILEIO_WRITE_ERROR, filename, GNC_FILE_DIALOG_EXPORT); return; } @@ -1262,7 +1249,7 @@ gnc_file_do_export(const char * filename) /* if file appears to be locked, ask the user ... */ if (ERR_BACKEND_LOCKED == io_err || ERR_BACKEND_READONLY == io_err) { - if (FALSE == show_session_error (io_err, newfile, GNC_FILE_DIALOG_EXPORT)) + if (!show_session_error (parent, io_err, newfile, GNC_FILE_DIALOG_EXPORT)) { /* user told us to ignore locks. So ignore them. */ qof_session_begin (new_session, newfile, TRUE, FALSE, FALSE); @@ -1296,7 +1283,7 @@ gnc_file_do_export(const char * filename) static gboolean been_here_before = FALSE; void -gnc_file_save (void) +gnc_file_save (GtkWindow *parent) { QofBackendError io_err; const char * newfile; @@ -1310,19 +1297,19 @@ gnc_file_save (void) if (!strlen (qof_session_get_url (session))) { - gnc_file_save_as (); + gnc_file_save_as (parent); return; } if (qof_book_is_readonly(qof_session_get_book(session))) { - gint response = gnc_ok_cancel_dialog(gnc_ui_get_toplevel(), + gint response = gnc_ok_cancel_dialog(parent, GTK_RESPONSE_CANCEL, _("The database was opened read-only. " "Do you want to save it to a different place?")); if (response == GTK_RESPONSE_OK) { - gnc_file_save_as (); + gnc_file_save_as (parent); } return; } @@ -1342,11 +1329,11 @@ gnc_file_save (void) if (ERR_BACKEND_NO_ERR != io_err) { newfile = qof_session_get_url(session); - show_session_error (io_err, newfile, GNC_FILE_DIALOG_SAVE); + show_session_error (parent, io_err, newfile, GNC_FILE_DIALOG_SAVE); if (been_here_before) return; been_here_before = TRUE; - gnc_file_save_as (); /* been_here prevents infinite recursion */ + gnc_file_save_as (parent); /* been_here prevents infinite recursion */ been_here_before = FALSE; return; } @@ -1362,7 +1349,7 @@ gnc_file_save (void) * never db uris. See gnc_file_do_save_as for that. */ void -gnc_file_save_as (void) +gnc_file_save_as (GtkWindow *parent) { const gchar *filename; gchar *default_dir = NULL; /* Default to last open */ @@ -1380,19 +1367,20 @@ gnc_file_save_as (void) else default_dir = gnc_get_default_directory(GNC_PREFS_GROUP_OPEN_SAVE); - filename = gnc_file_dialog (_("Save"), NULL, default_dir, + filename = gnc_file_dialog (parent, + _("Save"), NULL, default_dir, GNC_FILE_DIALOG_SAVE); g_free ( last ); g_free ( default_dir ); if (!filename) return; - gnc_file_do_save_as( filename ); + gnc_file_do_save_as (parent, filename); LEAVE (" "); } void -gnc_file_do_save_as (const char* filename) +gnc_file_do_save_as (GtkWindow *parent, const char* filename) { QofSession *new_session; QofSession *session; @@ -1417,7 +1405,7 @@ gnc_file_do_save_as (const char* filename) norm_file = gnc_uri_normalize_uri ( filename, TRUE ); if (!norm_file) { - show_session_error (ERR_FILEIO_FILE_NOT_FOUND, filename, + show_session_error (parent, ERR_FILEIO_FILE_NOT_FOUND, filename, GNC_FILE_DIALOG_SAVE); return; } @@ -1445,7 +1433,7 @@ gnc_file_do_save_as (const char* filename) { if (check_file_path (path)) { - show_session_error (ERR_FILEIO_RESERVED_WRITE, newfile, + show_session_error (parent, ERR_FILEIO_RESERVED_WRITE, newfile, GNC_FILE_DIALOG_SAVE); return; } @@ -1460,7 +1448,7 @@ gnc_file_do_save_as (const char* filename) if (strlen (oldfile) && (strcmp(oldfile, newfile) == 0)) { g_free (newfile); - gnc_file_save (); + gnc_file_save (parent); return; } @@ -1503,7 +1491,7 @@ gnc_file_do_save_as (const char* filename) /* if file appears to be locked, ask the user ... */ else if (ERR_BACKEND_LOCKED == io_err || ERR_BACKEND_READONLY == io_err) { - if (FALSE == show_session_error (io_err, newfile, GNC_FILE_DIALOG_SAVE)) + if (!show_session_error (parent, io_err, newfile, GNC_FILE_DIALOG_SAVE)) { /* user told us to ignore locks. So ignore them. */ qof_session_begin (new_session, newfile, TRUE, FALSE, FALSE); @@ -1515,7 +1503,7 @@ gnc_file_do_save_as (const char* filename) (ERR_BACKEND_NO_SUCH_DB == io_err) || (ERR_SQL_DB_TOO_OLD == io_err)) { - if (FALSE == show_session_error (io_err, newfile, GNC_FILE_DIALOG_SAVE)) + if (!show_session_error (parent, io_err, newfile, GNC_FILE_DIALOG_SAVE)) { /* user told us to create a new database. Do it. */ qof_session_begin (new_session, newfile, FALSE, TRUE, FALSE); @@ -1529,7 +1517,7 @@ gnc_file_do_save_as (const char* filename) io_err = qof_session_get_error (new_session); if (ERR_BACKEND_NO_ERR != io_err) { - show_session_error (io_err, newfile, GNC_FILE_DIALOG_SAVE); + show_session_error (parent, io_err, newfile, GNC_FILE_DIALOG_SAVE); xaccLogDisable(); qof_session_destroy (new_session); xaccLogEnable(); @@ -1575,7 +1563,7 @@ gnc_file_do_save_as (const char* filename) /* Well, poop. The save failed, so the new session is invalid and we * need to restore the old one. */ - show_session_error (io_err, newfile, GNC_FILE_DIALOG_SAVE); + show_session_error (parent, io_err, newfile, GNC_FILE_DIALOG_SAVE); qof_event_suspend(); qof_session_swap_data( new_session, session ); qof_session_destroy( new_session ); @@ -1604,7 +1592,7 @@ gnc_file_do_save_as (const char* filename) } void -gnc_file_revert (void) +gnc_file_revert (GtkWindow *parent) { QofSession *session; const gchar *fileurl, *filename, *tmp; @@ -1626,7 +1614,7 @@ gnc_file_revert (void) return; qof_book_mark_session_saved (qof_session_get_book (session)); - gnc_file_open_file (fileurl, qof_book_is_readonly(gnc_get_current_book()));} + gnc_file_open_file (parent, fileurl, qof_book_is_readonly(gnc_get_current_book()));} void gnc_file_quit (void) diff --git a/gnucash/gnome-utils/gnc-file.h b/gnucash/gnome-utils/gnc-file.h index 538096f00d..d32a0fb369 100644 --- a/gnucash/gnome-utils/gnc-file.h +++ b/gnucash/gnome-utils/gnc-file.h @@ -126,30 +126,34 @@ typedef enum GNC_FILE_DIALOG_EXPORT } GNCFileDialogType; -void gnc_file_new (void); -gboolean gnc_file_open (void); -void gnc_file_export(void); -void gnc_file_save (void); -void gnc_file_save_as (void); -void gnc_file_do_export(const char* filename); -void gnc_file_do_save_as(const char* filename); -void gnc_file_revert (void); +void gnc_file_new (GtkWindow *parent); +gboolean gnc_file_open (GtkWindow *parent); +void gnc_file_export(GtkWindow *parent); +void gnc_file_save (GtkWindow *parent); +void gnc_file_save_as (GtkWindow *parent); +void gnc_file_do_export(GtkWindow *parent, const char* filename); +void gnc_file_do_save_as(GtkWindow *parent, const char* filename); +void gnc_file_revert (GtkWindow *parent); /** Tell the user about errors in the backends */ -gboolean show_session_error (QofBackendError io_error, +gboolean show_session_error (GtkWindow *parent, + QofBackendError io_error, const char *newfile, GNCFileDialogType type); -char * gnc_file_dialog (const char * title, +char * gnc_file_dialog (GtkWindow *parent, + const char * title, GList * filters, const char * starting_dir, GNCFileDialogType type); -gboolean gnc_file_open_file (const char *filename, gboolean open_readonly); +gboolean gnc_file_open_file (GtkWindow *parent, + const char *filename, + gboolean open_readonly); -gboolean gnc_file_query_save (gboolean can_cancel); +gboolean gnc_file_query_save (GtkWindow *parent, gboolean can_cancel); void gnc_file_quit (void); diff --git a/gnucash/gnome-utils/gnc-gnome-utils.c b/gnucash/gnome-utils/gnc-gnome-utils.c index 85a934b307..efd6573605 100644 --- a/gnucash/gnome-utils/gnc-gnome-utils.c +++ b/gnucash/gnome-utils/gnc-gnome-utils.c @@ -736,7 +736,7 @@ gnc_gui_init(void) /* Load css configuration file */ gnc_add_css_file (); - gnc_totd_dialog(GTK_WINDOW(main_window), TRUE); + gnc_totd_dialog (gnc_get_splash_screen (), TRUE); LEAVE (""); return main_window; @@ -782,7 +782,7 @@ gnc_shutdown (int exit_status) { if (!gnome_is_terminating) { - if (gnc_file_query_save(FALSE)) + if (gnc_file_query_save (gnc_ui_get_main_window (NULL), FALSE)) { gnc_hook_run(HOOK_UI_SHUTDOWN, NULL); gnc_gui_shutdown(); diff --git a/gnucash/gnome-utils/gnc-gui-query.c b/gnucash/gnome-utils/gnc-gui-query.c index d8492e2009..9ada424de9 100644 --- a/gnucash/gnome-utils/gnc-gui-query.c +++ b/gnucash/gnome-utils/gnc-gui-query.c @@ -50,7 +50,7 @@ * Return: the result the user selected * \********************************************************************/ gint -gnc_ok_cancel_dialog(GtkWidget *parent, +gnc_ok_cancel_dialog(GtkWindow *parent, gint default_result, const gchar *format, ...) { @@ -59,12 +59,12 @@ gnc_ok_cancel_dialog(GtkWidget *parent, gchar *buffer; va_list args; - if (parent == NULL) - parent = gnc_ui_get_toplevel(); + if (!parent) + parent = gnc_ui_get_main_window (NULL); va_start(args, format); buffer = g_strdup_vprintf(format, args); - dialog = gtk_message_dialog_new (GTK_WINDOW(parent), + dialog = gtk_message_dialog_new (parent, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, @@ -73,7 +73,7 @@ gnc_ok_cancel_dialog(GtkWidget *parent, g_free(buffer); va_end(args); - if (parent == NULL) + if (!parent) gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), FALSE); gtk_dialog_set_default_response (GTK_DIALOG(dialog), default_result); @@ -99,7 +99,7 @@ gnc_ok_cancel_dialog(GtkWidget *parent, * string. * \********************************************************************/ gboolean -gnc_verify_dialog(GtkWidget *parent, gboolean yes_is_default, +gnc_verify_dialog(GtkWindow *parent, gboolean yes_is_default, const gchar *format, ...) { GtkWidget *dialog; @@ -107,12 +107,12 @@ gnc_verify_dialog(GtkWidget *parent, gboolean yes_is_default, gint result; va_list args; - if (parent == NULL) - parent = gnc_ui_get_toplevel(); + if (!parent) + parent = gnc_ui_get_main_window (NULL); va_start(args, format); buffer = g_strdup_vprintf(format, args); - dialog = gtk_message_dialog_new (GTK_WINDOW(parent), + dialog = gtk_message_dialog_new (parent, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, @@ -121,7 +121,7 @@ gnc_verify_dialog(GtkWidget *parent, gboolean yes_is_default, g_free(buffer); va_end(args); - if (parent == NULL) + if (!parent) gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), FALSE); gtk_dialog_set_default_response(GTK_DIALOG(dialog), @@ -131,6 +131,30 @@ gnc_verify_dialog(GtkWidget *parent, gboolean yes_is_default, return (result == GTK_RESPONSE_YES); } +static void +gnc_message_dialog_common (GtkWindow *parent, const gchar *format, GtkMessageType msg_type, va_list args) +{ + GtkWidget *dialog = NULL; + gchar *buffer; + + if (!parent) + parent = gnc_ui_get_main_window (NULL); + + buffer = g_strdup_vprintf(format, args); + dialog = gtk_message_dialog_new (parent, + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + msg_type, + GTK_BUTTONS_CLOSE, + "%s", + buffer); + g_free(buffer); + + if (!parent) + gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), FALSE); + + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); +} /********************************************************************\ * gnc_info_dialog * @@ -144,36 +168,19 @@ gnc_verify_dialog(GtkWidget *parent, gboolean yes_is_default, * Return: none * \********************************************************************/ void -gnc_info_dialog(GtkWidget *parent, const gchar *format, ...) +gnc_info_dialog (GtkWindow *parent, const gchar *format, ...) { - GtkWidget *dialog; - gchar *buffer; va_list args; - if (parent == NULL) - parent = gnc_ui_get_toplevel(); - va_start(args, format); - buffer = g_strdup_vprintf(format, args); - dialog = gtk_message_dialog_new (GTK_WINDOW(parent), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_INFO, - GTK_BUTTONS_CLOSE, - "%s", - buffer); + gnc_message_dialog_common (parent, format, GTK_MESSAGE_INFO, args); va_end(args); - - if (parent == NULL) - gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), FALSE); - - gtk_dialog_run(GTK_DIALOG(dialog)); - gtk_widget_destroy (dialog); } /********************************************************************\ - * gnc_warning_dialog_common * + * gnc_warning_dialog * * displays a warning dialog box * * * * Args: parent - the parent window * @@ -183,44 +190,20 @@ gnc_info_dialog(GtkWidget *parent, const gchar *format, ...) * string. * * Return: none * \********************************************************************/ -static void -gnc_warning_dialog_common(GtkWidget *parent, const gchar *format, va_list args) -{ - GtkWidget *dialog = NULL; - gchar *buffer; - - if (parent == NULL) - parent = GTK_WIDGET(gnc_ui_get_toplevel()); - - buffer = g_strdup_vprintf(format, args); - dialog = gtk_message_dialog_new (GTK_WINDOW(parent), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_CLOSE, - "%s", - buffer); - g_free(buffer); - - if (parent == NULL) - gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), FALSE); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); -} void -gnc_warning_dialog(GtkWidget *parent, const gchar *format, ...) +gnc_warning_dialog (GtkWindow *parent, const gchar *format, ...) { va_list args; va_start(args, format); - gnc_warning_dialog_common(parent, format, args); + gnc_message_dialog_common (parent, format, GTK_MESSAGE_WARNING, args); va_end(args); } /********************************************************************\ - * gnc_error_dialog_common * + * gnc_error_dialog * * displays an error dialog box * * * * Args: parent - the parent window * @@ -230,38 +213,12 @@ gnc_warning_dialog(GtkWidget *parent, const gchar *format, ...) * string. * * Return: none * \********************************************************************/ -static void -gnc_error_dialog_common(GtkWidget *parent, const gchar *format, va_list args) -{ - GtkWidget *dialog; - gchar *buffer; - - if (parent == NULL) - parent = GTK_WIDGET(gnc_ui_get_toplevel()); - - buffer = g_strdup_vprintf(format, args); - dialog = gtk_message_dialog_new (GTK_WINDOW(parent), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - "%s", - buffer); - g_free(buffer); - - if (parent == NULL) - gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), FALSE); - - gtk_dialog_run(GTK_DIALOG(dialog)); - gtk_widget_destroy (dialog); -} - -void -gnc_error_dialog(GtkWidget *parent, const gchar *format, ...) +void gnc_error_dialog (GtkWindow* parent, const char* format, ...) { va_list args; va_start(args, format); - gnc_error_dialog_common(parent, format, args); + gnc_message_dialog_common (parent, format, GTK_MESSAGE_ERROR, args); va_end(args); } diff --git a/gnucash/gnome-utils/gnc-gui-query.h b/gnucash/gnome-utils/gnc-gui-query.h index f026594573..e6b7fac5ed 100644 --- a/gnucash/gnome-utils/gnc-gui-query.h +++ b/gnucash/gnome-utils/gnc-gui-query.h @@ -24,12 +24,11 @@ #define QUERY_USER_H extern void -gnc_info_dialog(GtkWidget *parent, - const char *format, ...) G_GNUC_PRINTF (2, 3); - - -extern void -gnc_error_dialog(GtkWidget *parent, +gnc_info_dialog (GtkWindow *parent, const char *format, ...) G_GNUC_PRINTF (2, 3); + +void gnc_error_dialog (GtkWindow* parent, const char* format, ...) G_GNUC_PRINTF (2, 3); + + #endif diff --git a/gnucash/gnome-utils/gnc-main-window.c b/gnucash/gnome-utils/gnc-main-window.c index 862403fdf8..7b6670e013 100644 --- a/gnucash/gnome-utils/gnc-main-window.c +++ b/gnucash/gnome-utils/gnc-main-window.c @@ -720,8 +720,8 @@ gnc_main_window_restore_window (GncMainWindow *window, GncMainWindowSaveData *da if (active_windows) DEBUG("first window %p.", active_windows->data); window = gnc_main_window_new(); - gtk_widget_show(GTK_WIDGET(window)); } + gtk_widget_show(GTK_WIDGET(window)); priv = GNC_MAIN_WINDOW_GET_PRIVATE(window); @@ -952,6 +952,7 @@ gnc_main_window_restore_default_state(GncMainWindow *window) DEBUG("no saved state file"); if (!window) window = g_list_nth_data(active_windows, 0); + gtk_widget_show (GTK_WIDGET(window)); action = gnc_main_window_find_action(window, "ViewAccountTreeAction"); gtk_action_activate(action); } @@ -1293,7 +1294,7 @@ gnc_main_window_prompt_for_save (GtkWidget *window) switch (response) { case GTK_RESPONSE_APPLY: - gnc_file_save(); + gnc_file_save (GTK_WINDOW (window)); return FALSE; case GTK_RESPONSE_CLOSE: @@ -1600,14 +1601,13 @@ static guint gnc_statusbar_notification_messageid = 0; * statusbar by generate_statusbar_lastmodified_message. */ static gboolean statusbar_notification_off(gpointer user_data_unused) { - GtkWidget *widget = gnc_ui_get_toplevel(); + GncMainWindow *mainwindow = GNC_MAIN_WINDOW (gnc_ui_get_main_window (NULL)); //g_warning("statusbar_notification_off\n"); if (gnc_statusbar_notification_messageid == 0) return FALSE; - if (widget && GNC_IS_MAIN_WINDOW(widget)) + if (mainwindow) { - GncMainWindow *mainwindow = GNC_MAIN_WINDOW(widget); GtkWidget *statusbar = gnc_main_window_get_statusbar(GNC_WINDOW(mainwindow)); gtk_statusbar_remove(GTK_STATUSBAR(statusbar), 0, gnc_statusbar_notification_messageid); gnc_statusbar_notification_messageid = 0; @@ -2670,16 +2670,16 @@ GncMainWindow * gnc_main_window_new (void) { GncMainWindow *window; - GtkWidget *old_window; + GtkWindow *old_window; window = g_object_new (GNC_TYPE_MAIN_WINDOW, NULL); gtk_window_set_default_size(GTK_WINDOW(window), 800, 600); - old_window = gnc_ui_get_toplevel(); + old_window = gnc_ui_get_main_window (NULL); if (old_window) { gint width, height; - gtk_window_get_size (GTK_WINDOW (old_window), &width, &height); + gtk_window_get_size (old_window, &width, &height); gtk_window_resize (GTK_WINDOW (window), width, height); if ((gdk_window_get_state((gtk_widget_get_window (GTK_WIDGET(old_window)))) & GDK_WINDOW_STATE_MAXIMIZED) != 0) @@ -4554,19 +4554,41 @@ gnc_main_window_show_all_windows(void) #endif } -/** Get a pointer to the first active top level window or NULL - * if there is none. - * - * @return A pointer to a GtkWindow object. */ -GtkWidget * -gnc_ui_get_toplevel (void) +GtkWindow * +gnc_ui_get_gtk_window (GtkWidget *widget) +{ + GtkWidget *toplevel; + + if (!widget) + return NULL; + + toplevel = gtk_widget_get_toplevel (widget); + if (toplevel && GTK_IS_WINDOW (toplevel)) + return GTK_WINDOW (toplevel); + else + return NULL; +} + +GtkWindow * +gnc_ui_get_main_window (GtkWidget *widget) { GList *window; + GtkWindow *toplevel = gnc_ui_get_gtk_window (widget); + while (toplevel && !GNC_IS_MAIN_WINDOW (toplevel)) + toplevel = gtk_window_get_transient_for(toplevel); + + if (toplevel) + return toplevel; + for (window = active_windows; window; window = window->next) if (gtk_window_is_active (GTK_WINDOW (window->data))) return window->data; + for (window = active_windows; window; window = window->next) + if (gtk_widget_get_mapped (GTK_WIDGET(window->data))) + return window->data; + return NULL; } diff --git a/gnucash/gnome-utils/gnc-plugin-file-history.c b/gnucash/gnome-utils/gnc-plugin-file-history.c index 4b68e95e23..de911102df 100644 --- a/gnucash/gnome-utils/gnc-plugin-file-history.c +++ b/gnucash/gnome-utils/gnc-plugin-file-history.c @@ -696,7 +696,8 @@ gnc_plugin_file_history_cmd_open_file (GtkAction *action, filename = g_object_get_data(G_OBJECT(action), FILENAME_STRING); gnc_window_set_progressbar_window (GNC_WINDOW(data->window)); /* also opens new account page */ - gnc_file_open_file (filename, /*open_readonly*/ FALSE); + gnc_file_open_file (GTK_WINDOW (data->window), + filename, /*open_readonly*/ FALSE); gnc_window_set_progressbar_window (NULL); } diff --git a/gnucash/gnome-utils/gnc-splash.c b/gnucash/gnome-utils/gnc-splash.c index 1cb20b36d0..661bf4876e 100644 --- a/gnucash/gnome-utils/gnc-splash.c +++ b/gnucash/gnome-utils/gnc-splash.c @@ -206,3 +206,8 @@ gnc_update_splash_screen (const gchar *string, double percentage) gtk_main_iteration (); } } + +GtkWindow *gnc_get_splash_screen (void) +{ + return GTK_WINDOW(splash); +} diff --git a/gnucash/gnome-utils/gnc-splash.h b/gnucash/gnome-utils/gnc-splash.h index 61d3687c1c..c6819f45b3 100644 --- a/gnucash/gnome-utils/gnc-splash.h +++ b/gnucash/gnome-utils/gnc-splash.h @@ -22,10 +22,12 @@ #ifndef GNC_SPLASH_H #define GNC_SPLASH_H +#include void gnc_show_splash_screen (void); void gnc_destroy_splash_screen (void); void gnc_update_splash_screen (const gchar *string, double percentage); +GtkWindow *gnc_get_splash_screen (void); #define GNC_SPLASH_PERCENTAGE_UNKNOWN 101 diff --git a/gnucash/gnome-utils/gnc-tree-control-split-reg.c b/gnucash/gnome-utils/gnc-tree-control-split-reg.c index 4bf3c1b6e8..16abbd3be7 100644 --- a/gnucash/gnome-utils/gnc-tree-control-split-reg.c +++ b/gnucash/gnome-utils/gnc-tree-control-split-reg.c @@ -167,13 +167,13 @@ gnc_tree_control_split_reg_trans_open_and_warn (GncTreeViewSplitReg *view, Trans gboolean gtc_sr_trans_test_for_edit (GncTreeViewSplitReg *view, Transaction *trans) { - GtkWidget *window; + GtkWindow *window; Transaction *dirty_trans; /* Make sure we have stopped editing */ gnc_tree_view_split_reg_finish_edit (view); - window = gnc_tree_view_split_reg_get_parent (view); + window = gnc_ui_get_main_window (GTK_WIDGET (view)); /* Get dirty_trans */ dirty_trans = gnc_tree_view_split_reg_get_dirty_trans (view); @@ -354,7 +354,7 @@ void gnc_tree_control_split_reg_exchange_rate (GncTreeViewSplitReg *view) { GncTreeModelSplitReg *model; - GtkWidget *window; + GtkWindow *window; Account *anchor; Transaction *trans; Split *split = NULL; @@ -397,7 +397,7 @@ gnc_tree_control_split_reg_exchange_rate (GncTreeViewSplitReg *view) if (num_splits < 2) return; - window = gnc_tree_view_split_reg_get_parent (view); + window = gnc_ui_get_main_window (GTK_WIDGET (view)); /* Make sure we NEED this for this type of register */ if (!gnc_tree_util_split_reg_has_rate (view)) @@ -1078,7 +1078,7 @@ gnc_tree_control_split_reg_delete (GncTreeViewSplitReg *view, gpointer data) void gnc_tree_control_split_reg_reverse_current (GncTreeViewSplitReg *view) { - GtkWidget *window; + GtkWindow *window; Transaction *trans = NULL, *new_trans = NULL; GList *snode = NULL; @@ -1113,7 +1113,7 @@ gnc_tree_control_split_reg_reverse_current (GncTreeViewSplitReg *view) return; } - window = gnc_tree_view_split_reg_get_parent (view); + window = gnc_ui_get_main_window (GTK_WIDGET (view)); if (xaccTransGetReversedBy (trans)) { @@ -1167,7 +1167,7 @@ gboolean gnc_tree_control_split_reg_duplicate_current (GncTreeViewSplitReg *view) { GncTreeModelSplitReg *model; - GtkWidget *window; + GtkWindow *window; RowDepth depth; Transaction *trans; Split *blank_split; @@ -1228,7 +1228,7 @@ gnc_tree_control_split_reg_duplicate_current (GncTreeViewSplitReg *view) return FALSE; } - window = gnc_tree_view_split_reg_get_parent (view); + window = gnc_ui_get_main_window (GTK_WIDGET (view)); /* Ok, we are now ready to make the copy. */ if (depth == SPLIT3) @@ -1259,7 +1259,7 @@ gnc_tree_control_split_reg_duplicate_current (GncTreeViewSplitReg *view) else in_num = gnc_get_num_action (NULL, split); - if (!gnc_dup_trans_dialog (window, title, FALSE, + if (!gnc_dup_trans_dialog (GTK_WIDGET (window), title, FALSE, &date, in_num, &out_num, NULL, NULL)) { LEAVE("dup cancelled"); @@ -1334,7 +1334,7 @@ gnc_tree_control_split_reg_duplicate_current (GncTreeViewSplitReg *view) ? gnc_get_num_action (trans, NULL) : NULL); - if (!gnc_dup_trans_dialog (window, NULL, TRUE, + if (!gnc_dup_trans_dialog (GTK_WIDGET (window), NULL, TRUE, &date, in_num, &out_num, in_tnum, &out_tnum)) { LEAVE("dup cancelled"); @@ -1348,7 +1348,7 @@ gnc_tree_control_split_reg_duplicate_current (GncTreeViewSplitReg *view) gnc_gdate_set_time64 (&d, date); if (g_date_compare (&d, readonly_threshold) < 0) { - GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (window), + GtkWidget *dialog = gtk_message_dialog_new (window, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, @@ -1946,7 +1946,7 @@ gnc_tree_control_split_reg_recn_test (GncTreeViewSplitReg *view, GtkTreePath *sp Account * gnc_tree_control_split_reg_get_account_by_name (GncTreeViewSplitReg *view, const char *name) { - GtkWidget *window; + GtkWindow *window; const char *placeholder = _("The account %s does not allow transactions."); const char *missing = _("The account %s does not exist. " "Would you like to create it?"); @@ -1964,7 +1964,7 @@ gnc_tree_control_split_reg_get_account_by_name (GncTreeViewSplitReg *view, const if (!account) account = gnc_account_lookup_by_code (gnc_get_current_root_account(), name); - window = gnc_tree_view_split_reg_get_parent (view); + window = gnc_ui_get_main_window (GTK_WIDGET (view)); if (!account) { @@ -2106,9 +2106,9 @@ gnc_tree_control_split_reg_paste_trans (GncTreeViewSplitReg *view) //FIXME You can not paste from gl to a register, is this too simplistic if (clipboard_acct == NULL && anchor_acct != NULL) { - GtkWidget *window; + GtkWindow *window; - window = gnc_tree_view_split_reg_get_parent (view); + window = gnc_ui_get_main_window (GTK_WIDGET (view)); gnc_error_dialog (window, "%s", _("You can not paste from the general journal to a register.")); return; diff --git a/gnucash/gnome-utils/gnc-tree-util-split-reg.c b/gnucash/gnome-utils/gnc-tree-util-split-reg.c index dc46ff9b23..62360bc9bc 100644 --- a/gnucash/gnome-utils/gnc-tree-util-split-reg.c +++ b/gnucash/gnome-utils/gnc-tree-util-split-reg.c @@ -824,7 +824,7 @@ void gnc_tree_util_split_reg_set_value_for (GncTreeViewSplitReg *view, Transaction *trans, Split *split, gnc_numeric input, gboolean force) { // GncTreeModelSplitReg *model; - GtkWidget *window; + GtkWindow *window; // Account *anchor; // Account *acct = xaccSplitGetAccount (split); // gnc_commodity *currency; @@ -845,7 +845,7 @@ gnc_tree_util_split_reg_set_value_for (GncTreeViewSplitReg *view, Transaction *t return; } - window = gnc_tree_view_split_reg_get_parent (view); + window = gnc_ui_get_main_window (GTK_WIDGET (view)); if (gtu_sr_needs_exchange_rate (view, trans, split)) { diff --git a/gnucash/gnome-utils/gnc-ui.h b/gnucash/gnome-utils/gnc-ui.h index 18d21a0143..f817970353 100644 --- a/gnucash/gnome-utils/gnc-ui.h +++ b/gnucash/gnome-utils/gnc-ui.h @@ -79,27 +79,27 @@ /* Dialog windows ***************************************************/ extern gboolean -gnc_verify_dialog(GtkWidget *parent, - gboolean yes_is_default, - const char *format, ...) G_GNUC_PRINTF (3, 4); +gnc_verify_dialog (GtkWindow *parent, + gboolean yes_is_default, + const char *format, ...) G_GNUC_PRINTF (3, 4); extern gint -gnc_ok_cancel_dialog(GtkWidget *parent, - gint default_result, - const char *format, ...) G_GNUC_PRINTF (3, 4); +gnc_ok_cancel_dialog (GtkWindow *parent, + gint default_result, + const char *format, ...) G_GNUC_PRINTF (3, 4); extern void -gnc_warning_dialog(GtkWidget *parent, - const char *format, ...) G_GNUC_PRINTF (2, 3); +gnc_warning_dialog (GtkWindow *parent, + const char *format, ...) G_GNUC_PRINTF (2, 3); extern void -gnc_info_dialog(GtkWidget *parent, - const char *format, ...) G_GNUC_PRINTF (2, 3); - -extern void -gnc_error_dialog(GtkWidget *parent, +gnc_info_dialog (GtkWindow *parent, const char *format, ...) G_GNUC_PRINTF (2, 3); +extern void +gnc_error_dialog (GtkWindow *parent, + const char *format, ...) G_GNUC_PRINTF (2, 3); + extern void gnc_gnome_help (const char *file_name, const char *target_link); @@ -141,7 +141,34 @@ gboolean gnc_get_username_password (GtkWidget *parent, /* Managing the GUI Windows *****************************************/ -GtkWidget *gnc_ui_get_toplevel (void); +/** Get a pointer to the widget's immediate top level GtkWindow. This can be a dialog + * window or a GncMainWindow. If the widget is not a child of + * a GtkWindow (yet), NULL is returned. + * + * @param widget the widget to find a GtkWindow for. + * @return A pointer to a GtkWindow object or NULL if no toplevel was found. */ +GtkWindow *gnc_ui_get_gtk_window (GtkWidget *widget); + +/** Get a pointer to the final GncMainWindow widget is rooted + * in. If widget is a child of a GncMainWindow return that window. + * If it's a child of a dialog window recursively query the + * dialog's transient parent until the first parent that's a GncMainWindow + * and return that. If widget is NULL or not part of any GtkWindow, + * get a pointer to the first active top level window. If there is + * none, return the first mapped window. If there's no mapped window + * return NULL. + * + * An example of why searching for a GncMainWindow makes sense: suppose + * a user has opened a search dialog for vendors and in that dialog has + * clicked "View vendor invoices". This opens another search window in + * which the user can click "View/Edit bill". Clicking that button should + * open a new tab in the GncMainWindow from which the first search dialog + * was opened. + * + * @param widget the widget to find a GncMainWindow for. + * @return A pointer to a GtkWindow object. */ + +GtkWindow *gnc_ui_get_main_window (GtkWidget *widget); /* Changing the GUI Cursor ******************************************/ diff --git a/gnucash/gnome-utils/gnome-utils.i b/gnucash/gnome-utils/gnome-utils.i index bafde30935..5246cd8076 100644 --- a/gnucash/gnome-utils/gnome-utils.i +++ b/gnucash/gnome-utils/gnome-utils.i @@ -57,18 +57,18 @@ void gnc_options_dialog_set_scm_callbacks (GNCOptionWin *win, SCM apply_cb, SCM close_cb); gboolean -gnc_verify_dialog(GtkWidget *parent, gboolean yes_is_default, - const gchar *format, ...); +gnc_verify_dialog (GtkWindow *parent, gboolean yes_is_default, + const gchar *format, ...); void -gnc_warning_dialog(GtkWidget *parent, - const gchar *format, ...); +gnc_warning_dialog (GtkWindow *parent, + const gchar *format, ...); void -gnc_error_dialog(GtkWidget *parent, +gnc_error_dialog (GtkWindow *parent, + const char *format, ...); +void +gnc_info_dialog (GtkWindow *parent, const char *format, ...); -void -gnc_info_dialog(GtkWidget *parent, - const char *format, ...); void gnc_add_scm_extension (SCM extension); diff --git a/gnucash/gnome-utils/gtkbuilder/dialog-totd.glade b/gnucash/gnome-utils/gtkbuilder/dialog-totd.glade index 09aa5b61b8..4515ebca53 100644 --- a/gnucash/gnome-utils/gtkbuilder/dialog-totd.glade +++ b/gnucash/gnome-utils/gtkbuilder/dialog-totd.glade @@ -3,7 +3,6 @@ - True False 6 GnuCash Tip Of The Day diff --git a/gnucash/gnome/assistant-hierarchy.c b/gnucash/gnome/assistant-hierarchy.c index 66258b1f16..5f9a8736e6 100644 --- a/gnucash/gnome/assistant-hierarchy.c +++ b/gnucash/gnome/assistant-hierarchy.c @@ -58,6 +58,7 @@ #include "gnc-path.h" #include "gnc-gui-query.h" #include "gnc-tree-view-account.h" +#include "gnc-ui.h" #include "gnc-ui-util.h" #include "io-example-account.h" #include "top-level.h" @@ -1317,7 +1318,7 @@ static void after_assistant(void) { qof_book_mark_session_dirty(gnc_get_current_book()); - gnc_ui_file_access_for_save_as(); + gnc_ui_file_access_for_save_as (gnc_ui_get_main_window (NULL)); } static void diff --git a/gnucash/gnome/assistant-stock-split.c b/gnucash/gnome/assistant-stock-split.c index 758fd4b1b8..c5c4f8e0d9 100644 --- a/gnucash/gnome/assistant-stock-split.c +++ b/gnucash/gnome/assistant-stock-split.c @@ -410,7 +410,7 @@ gnc_stock_split_assistant_finish (GtkAssistant *assistant, pdb = gnc_pricedb_get_db (book); if (!gnc_pricedb_add_price (pdb, price)) - gnc_error_dialog (info->window, "%s", _("Error adding price.")); + gnc_error_dialog (GTK_WINDOW (info->window), "%s", _("Error adding price.")); } @@ -778,7 +778,7 @@ gnc_stock_split_dialog (GtkWidget *parent, Account * initial) if (fill_account_list (info, initial) == 0) { - gnc_warning_dialog (parent, "%s", _("You don't have any stock accounts with balances!")); + gnc_warning_dialog (GTK_WINDOW (parent), "%s", _("You don't have any stock accounts with balances!")); gnc_close_gui_component_by_data (ASSISTANT_STOCK_SPLIT_CM_CLASS, info); return; } diff --git a/gnucash/gnome/business-gnome-utils.c b/gnucash/gnome/business-gnome-utils.c index c4a85551a4..1c917b7572 100644 --- a/gnucash/gnome/business-gnome-utils.c +++ b/gnucash/gnome/business-gnome-utils.c @@ -189,14 +189,14 @@ typedef struct _invoice_select_info } GncISI; static GNCSearchWindow * -gnc_invoice_select_search_cb (gpointer start, gpointer isip) +gnc_invoice_select_search_cb (GtkWindow *parent, gpointer start, gpointer isip) { GncISI *isi = isip; if (!isi) return NULL; g_assert(isi->book); - return gnc_invoice_search (start, + return gnc_invoice_search (parent, start, isi->have_owner ? &isi->owner : NULL, isi->book); } diff --git a/gnucash/gnome/business-urls.c b/gnucash/gnome/business-urls.c index 9ba6240ad6..280cafc81d 100644 --- a/gnucash/gnome/business-urls.c +++ b/gnucash/gnome/business-urls.c @@ -95,7 +95,7 @@ customerCB (const char *location, const char *label, /* href="...:customer=" */ HANDLE_TYPE ("customer=", GNC_ID_CUSTOMER); customer = (GncCustomer *) entity; - gnc_ui_customer_edit (customer); + gnc_ui_customer_edit (result->parent, customer); return TRUE; } @@ -110,7 +110,7 @@ vendorCB (const char *location, const char *label, /* href="...:vendor=" */ HANDLE_TYPE ("vendor=", GNC_ID_VENDOR); vendor = (GncVendor *) entity; - gnc_ui_vendor_edit (vendor); + gnc_ui_vendor_edit (result->parent, vendor); return TRUE; } @@ -126,7 +126,7 @@ employeeCB (const char *location, const char *label, HANDLE_TYPE ("employee=", GNC_ID_EMPLOYEE); employee = (GncEmployee *) entity; - gnc_ui_employee_edit (employee); + gnc_ui_employee_edit (result->parent, employee); return TRUE; } @@ -141,7 +141,7 @@ invoiceCB (const char *location, const char *label, /* href="...:invoice=" */ HANDLE_TYPE ("invoice=", GNC_ID_INVOICE); invoice = (GncInvoice *) entity; - gnc_ui_invoice_edit (invoice); + gnc_ui_invoice_edit (result->parent, invoice); return TRUE; } @@ -156,7 +156,7 @@ jobCB (const char *location, const char *label, /* href="...:job=" */ HANDLE_TYPE ("job=", GNC_ID_JOB); job = (GncJob *) entity; - gnc_ui_job_edit (job); + gnc_ui_job_edit (result->parent, job); return TRUE; } @@ -306,7 +306,7 @@ ownerreportCB (const char *location, const char *label, } /* Ok, let's run this report */ - gnc_business_call_owner_report (&owner, acc); + gnc_business_call_owner_report (result->parent, &owner, acc); return TRUE; } diff --git a/gnucash/gnome/dialog-billterms.c b/gnucash/gnome/dialog-billterms.c index e88f7599e4..0a935d3e46 100644 --- a/gnucash/gnome/dialog-billterms.c +++ b/gnucash/gnome/dialog-billterms.c @@ -289,14 +289,14 @@ verify_term_ok (NewBillTerm *nbt) case GNC_TERM_TYPE_DAYS: if (days_due_daysdialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (nbt->dialog), "%s", message); result=FALSE; } break; case GNC_TERM_TYPE_PROXIMO: if (prox_due_daysdialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (nbt->dialog), "%s", message); result=FALSE; } break; @@ -324,7 +324,7 @@ new_billterm_ok_cb (NewBillTerm *nbt) if (name == NULL || *name == '\0') { message = _("You must provide a name for this Billing Term."); - gnc_error_dialog (nbt->dialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (nbt->dialog), "%s", message); return FALSE; } if (gncBillTermLookupByName (btw->book, name)) @@ -332,7 +332,7 @@ new_billterm_ok_cb (NewBillTerm *nbt) message = g_strdup_printf(_( "You must provide a unique name for this Billing Term. " "Your choice \"%s\" is already in use."), name); - gnc_error_dialog (nbt->dialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (nbt->dialog), "%s", message); g_free (message); return FALSE; } @@ -664,13 +664,13 @@ billterms_delete_term_cb (GtkButton *button, BillTermsWindow *btw) if (gncBillTermGetRefcount (btw->current_term) > 0) { - gnc_error_dialog (btw->dialog, + gnc_error_dialog (GTK_WINDOW (btw->dialog), _("Term \"%s\" is in use. You cannot delete it."), gncBillTermGetName (btw->current_term)); return; } - if (gnc_verify_dialog (btw->dialog, FALSE, + if (gnc_verify_dialog (GTK_WINDOW (btw->dialog), FALSE, _("Are you sure you want to delete \"%s\"?"), gncBillTermGetName (btw->current_term))) { diff --git a/gnucash/gnome/dialog-commodities.c b/gnucash/gnome/dialog-commodities.c index bcfb061f68..f4d0a51ef8 100644 --- a/gnucash/gnome/dialog-commodities.c +++ b/gnucash/gnome/dialog-commodities.c @@ -157,7 +157,7 @@ remove_clicked (CommoditiesDialog *cd) "at least one of your accounts. You may " "not delete it."); - gnc_warning_dialog (cd->dialog, "%s", message); + gnc_warning_dialog (GTK_WINDOW (cd->dialog), "%s", message); g_list_free (accounts); return; } diff --git a/gnucash/gnome/dialog-customer.c b/gnucash/gnome/dialog-customer.c index 6f262f64f0..60006577ad 100644 --- a/gnucash/gnome/dialog-customer.c +++ b/gnucash/gnome/dialog-customer.c @@ -115,8 +115,8 @@ typedef enum struct _customer_select_window { - QofBook * book; - QofQuery * q; + QofBook *book; + QofQuery *q; }; struct _customer_window @@ -279,14 +279,14 @@ static void gnc_ui_to_customer (CustomerWindow *cw, GncCustomer *cust) gnc_resume_gui_refresh (); } -static gboolean check_edit_amount (GtkWidget *dialog, GtkWidget *amount, +static gboolean check_edit_amount (GtkWidget *amount, gnc_numeric *min, gnc_numeric *max, const char * error_message) { if (!gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT (amount))) { if (error_message) - gnc_error_dialog (dialog, "%s", error_message); + gnc_error_dialog (gnc_ui_get_gtk_window (amount), "%s", error_message); return TRUE; } /* We've got a valid-looking number; check mix/max */ @@ -297,21 +297,21 @@ static gboolean check_edit_amount (GtkWidget *dialog, GtkWidget *amount, (max && gnc_numeric_compare (val, *max) > 0)) { if (error_message) - gnc_error_dialog (dialog, "%s", error_message); + gnc_error_dialog (gnc_ui_get_gtk_window (amount), "%s", error_message); return TRUE; } } return FALSE; } -static gboolean check_entry_nonempty (GtkWidget *dialog, GtkWidget *entry, +static gboolean check_entry_nonempty (GtkWidget *entry, const char * error_message) { const char *res = gtk_entry_get_text (GTK_ENTRY (entry)); if (g_strcmp0 (res, "") == 0) { if (error_message) - gnc_error_dialog (dialog, "%s", error_message); + gnc_error_dialog (gnc_ui_get_gtk_window (entry), "%s", error_message); return TRUE; } return FALSE; @@ -325,7 +325,7 @@ gnc_customer_window_ok_cb (GtkWidget *widget, gpointer data) gchar *string; /* Check for valid company name */ - if (check_entry_nonempty (cw->dialog, cw->company_entry, + if (check_entry_nonempty (cw->company_entry, _("You must enter a company name. " "If this customer is an individual (and not a company) " "you should enter the same value for:\nIdentification " @@ -333,13 +333,13 @@ gnc_customer_window_ok_cb (GtkWidget *widget, gpointer data) return; /* Make sure we have an address */ - if (check_entry_nonempty (cw->dialog, cw->addr1_entry, NULL) && - check_entry_nonempty (cw->dialog, cw->addr2_entry, NULL) && - check_entry_nonempty (cw->dialog, cw->addr3_entry, NULL) && - check_entry_nonempty (cw->dialog, cw->addr4_entry, NULL)) + if (check_entry_nonempty (cw->addr1_entry, NULL) && + check_entry_nonempty (cw->addr2_entry, NULL) && + check_entry_nonempty (cw->addr3_entry, NULL) && + check_entry_nonempty (cw->addr4_entry, NULL)) { const char *msg = _("You must enter a billing address."); - gnc_error_dialog (cw->dialog, "%s", msg); + gnc_error_dialog (gnc_ui_get_gtk_window (widget), "%s", msg); return; } @@ -347,12 +347,12 @@ gnc_customer_window_ok_cb (GtkWidget *widget, gpointer data) min = gnc_numeric_zero (); max = gnc_numeric_create (100, 1); - if (check_edit_amount (cw->dialog, cw->discount_amount, &min, &max, + if (check_edit_amount (cw->discount_amount, &min, &max, _("Discount percentage must be between 0-100 " "or you must leave it blank."))) return; - if (check_edit_amount (cw->dialog, cw->credit_amount, &min, NULL, + if (check_edit_amount (cw->credit_amount, &min, NULL, _("Credit must be a positive amount or " "you must leave it blank."))) return; @@ -528,7 +528,7 @@ find_handler (gpointer find_data, gpointer user_data) } static CustomerWindow * -gnc_customer_new_window (QofBook *bookp, GncCustomer *cust) +gnc_customer_new_window (GtkWindow *parent, QofBook *bookp, GncCustomer *cust) { CustomerWindow *cw; GtkBuilder *builder; @@ -549,6 +549,7 @@ gnc_customer_new_window (QofBook *bookp, GncCustomer *cust) find_handler, &customer_guid); if (cw) { + gtk_window_set_transient_for (GTK_WINDOW(cw->dialog), parent); gtk_window_present (GTK_WINDOW(cw->dialog)); return(cw); } @@ -574,6 +575,7 @@ gnc_customer_new_window (QofBook *bookp, GncCustomer *cust) gnc_builder_add_from_file (builder, "dialog-customer.glade", "taxtable_store"); gnc_builder_add_from_file (builder, "dialog-customer.glade", "customer_dialog"); cw->dialog = GTK_WIDGET (gtk_builder_get_object (builder, "customer_dialog")); + gtk_window_set_transient_for (GTK_WINDOW(cw->dialog), parent); // Set the style context for this dialog so it can be easily manipulated with css gnc_widget_set_style_context (GTK_WIDGET(cw->dialog), "GncCustomerDialog"); @@ -752,26 +754,26 @@ gnc_customer_new_window (QofBook *bookp, GncCustomer *cust) } CustomerWindow * -gnc_ui_customer_edit (GncCustomer *cust) +gnc_ui_customer_edit (GtkWindow *parent, GncCustomer *cust) { CustomerWindow *cw; if (!cust) return NULL; - cw = gnc_customer_new_window (gncCustomerGetBook(cust), cust); + cw = gnc_customer_new_window (parent, gncCustomerGetBook(cust), cust); return cw; } CustomerWindow * -gnc_ui_customer_new (QofBook *bookp) +gnc_ui_customer_new (GtkWindow *parent, QofBook *bookp) { CustomerWindow *cw; /* Make sure required options exist */ if (!bookp) return NULL; - cw = gnc_customer_new_window (bookp, NULL); + cw = gnc_customer_new_window (parent, bookp, NULL); return cw; } @@ -779,7 +781,7 @@ gnc_ui_customer_new (QofBook *bookp) /* Functions for customer selection widgets */ static void -invoice_customer_cb (gpointer *cust_p, gpointer user_data) +invoice_customer_cb (GtkWindow *dialog, gpointer *cust_p, gpointer user_data) { struct _customer_select_window *sw = user_data; GncOwner owner; @@ -793,12 +795,12 @@ invoice_customer_cb (gpointer *cust_p, gpointer user_data) return; gncOwnerInitCustomer (&owner, cust); - gnc_invoice_search (NULL, &owner, sw->book); + gnc_invoice_search (dialog, NULL, &owner, sw->book); return; } static void -order_customer_cb (gpointer *cust_p, gpointer user_data) +order_customer_cb (GtkWindow *dialog, gpointer *cust_p, gpointer user_data) { struct _customer_select_window *sw = user_data; GncOwner owner; @@ -812,12 +814,12 @@ order_customer_cb (gpointer *cust_p, gpointer user_data) return; gncOwnerInitCustomer (&owner, cust); - gnc_order_search (NULL, &owner, sw->book); + gnc_order_search (dialog, NULL, &owner, sw->book); return; } static void -jobs_customer_cb (gpointer *cust_p, gpointer user_data) +jobs_customer_cb (GtkWindow *dialog, gpointer *cust_p, gpointer user_data) { struct _customer_select_window *sw = user_data; GncOwner owner; @@ -831,12 +833,12 @@ jobs_customer_cb (gpointer *cust_p, gpointer user_data) return; gncOwnerInitCustomer (&owner, cust); - gnc_job_search (NULL, &owner, sw->book); + gnc_job_search (dialog, NULL, &owner, sw->book); return; } static void -payment_customer_cb (gpointer *cust_p, gpointer user_data) +payment_customer_cb (GtkWindow *dialog, gpointer *cust_p, gpointer user_data) { struct _customer_select_window *sw = user_data; GncOwner owner; @@ -850,12 +852,12 @@ payment_customer_cb (gpointer *cust_p, gpointer user_data) return; gncOwnerInitCustomer (&owner, cust); - gnc_ui_payment_new (&owner, sw->book); + gnc_ui_payment_new (dialog, &owner, sw->book); return; } static void -edit_customer_cb (gpointer *cust_p, gpointer user_data) +edit_customer_cb (GtkWindow *dialog, gpointer *cust_p, gpointer user_data) { GncCustomer *cust; @@ -865,20 +867,20 @@ edit_customer_cb (gpointer *cust_p, gpointer user_data) if (!cust) return; - gnc_ui_customer_edit (cust); + gnc_ui_customer_edit (dialog, cust); return; } static gpointer -new_customer_cb (gpointer user_data) +new_customer_cb (GtkWindow *dialog, gpointer user_data) { struct _customer_select_window *sw = user_data; CustomerWindow *cw; g_return_val_if_fail (sw, NULL); - cw = gnc_ui_customer_new (sw->book); + cw = gnc_ui_customer_new (dialog, sw->book); return cw_get_customer (cw); } @@ -894,7 +896,7 @@ free_userdata_cb (gpointer user_data) } GNCSearchWindow * -gnc_customer_search (GncCustomer *start, QofBook *book) +gnc_customer_search (GtkWindow *parent, GncCustomer *start, QofBook *book) { QofQuery *q, *q2 = NULL; QofIdType type = GNC_CUSTOMER_MODULE_NAME; @@ -957,7 +959,7 @@ gnc_customer_search (GncCustomer *start, QofBook *book) sw->book = book; sw->q = q; - return gnc_search_dialog_create (type, _("Find Customer"), + return gnc_search_dialog_create (parent, type, _("Find Customer"), params, columns, q, q2, buttons, NULL, new_customer_cb, sw, free_userdata_cb, GNC_PREFS_GROUP_SEARCH, NULL, @@ -965,18 +967,18 @@ gnc_customer_search (GncCustomer *start, QofBook *book) } GNCSearchWindow * -gnc_customer_search_select (gpointer start, gpointer book) +gnc_customer_search_select (GtkWindow *parent, gpointer start, gpointer book) { if (!book) return NULL; - return gnc_customer_search (start, book); + return gnc_customer_search (parent, start, book); } GNCSearchWindow * -gnc_customer_search_edit (gpointer start, gpointer book) +gnc_customer_search_edit (GtkWindow *parent, gpointer start, gpointer book) { if (start) - gnc_ui_customer_edit (start); + gnc_ui_customer_edit (parent, start); return NULL; } diff --git a/gnucash/gnome/dialog-customer.h b/gnucash/gnome/dialog-customer.h index 26d04faf77..eaca3fa9c7 100644 --- a/gnucash/gnome/dialog-customer.h +++ b/gnucash/gnome/dialog-customer.h @@ -31,11 +31,11 @@ typedef struct _customer_window CustomerWindow; #include "dialog-search.h" /* Functions to create and edit a customer */ -CustomerWindow * gnc_ui_customer_edit (GncCustomer *cust); -CustomerWindow * gnc_ui_customer_new (QofBook *book); +CustomerWindow * gnc_ui_customer_edit (GtkWindow *parent, GncCustomer *cust); +CustomerWindow * gnc_ui_customer_new (GtkWindow *parent, QofBook *book); /* Search for customers */ -GNCSearchWindow *gnc_customer_search (GncCustomer *start, QofBook *book); +GNCSearchWindow *gnc_customer_search (GtkWindow *parent, GncCustomer *start, QofBook *book); /* * These callbacks are for use with the gnc_general_search widget @@ -43,7 +43,7 @@ GNCSearchWindow *gnc_customer_search (GncCustomer *start, QofBook *book); * select() provides a Select Dialog and returns it. * edit() opens the existing customer for editing and returns NULL. */ -GNCSearchWindow * gnc_customer_search_select (gpointer start, gpointer book); -GNCSearchWindow * gnc_customer_search_edit (gpointer start, gpointer book); +GNCSearchWindow * gnc_customer_search_select (GtkWindow *parent, gpointer start, gpointer book); +GNCSearchWindow * gnc_customer_search_edit (GtkWindow *parent, gpointer start, gpointer book); #endif /* GNC_DIALOG_CUSTOMER_H_ */ diff --git a/gnucash/gnome/dialog-date-close.c b/gnucash/gnome/dialog-date-close.c index 60fee7ffef..0701b9a88d 100644 --- a/gnucash/gnome/dialog-date-close.c +++ b/gnucash/gnome/dialog-date-close.c @@ -71,14 +71,14 @@ gnc_dialog_date_close_ok_cb (GtkWidget *widget, gpointer user_data) if (!acc) { - gnc_error_dialog (ddc->dialog, "%s", + gnc_error_dialog (GTK_WINDOW (ddc->dialog), "%s", _("No Account selected. Please try again.")); return; } if (xaccAccountGetPlaceholder (acc)) { - gnc_error_dialog (ddc->dialog, "%s", + gnc_error_dialog (GTK_WINDOW (ddc->dialog), "%s", _("Placeholder account selected. Please try again.")); return; } diff --git a/gnucash/gnome/dialog-employee.c b/gnucash/gnome/dialog-employee.c index c4e3781711..c587bd0b9d 100644 --- a/gnucash/gnome/dialog-employee.c +++ b/gnucash/gnome/dialog-employee.c @@ -46,6 +46,7 @@ #include "dialog-employee.h" #include "dialog-invoice.h" #include "dialog-payment.h" +#include "business-gnome-utils.h" #define DIALOG_NEW_EMPLOYEE_CM_CLASS "dialog-new-employee" #define DIALOG_EDIT_EMPLOYEE_CM_CLASS "dialog-edit-employee" @@ -67,8 +68,8 @@ typedef enum struct _employee_select_window { - QofBook * book; - QofQuery * q; + QofBook *book; + QofQuery *q; }; struct _employee_window @@ -174,41 +175,14 @@ static void gnc_ui_to_employee (EmployeeWindow *ew, GncEmployee *employee) gnc_resume_gui_refresh (); } -#if 0 -static gboolean check_edit_amount (GtkWidget *dialog, GtkWidget *amount, - gnc_numeric *min, gnc_numeric *max, - const char * error_message) -{ - if (!gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT (amount))) - { - if (error_message) - gnc_error_dialog (dialog, error_message); - return TRUE; - } - /* We've got a valid-looking number; check mix/max */ - if (min || max) - { - gnc_numeric val = gnc_amount_edit_get_amount (GNC_AMOUNT_EDIT (amount)); - if ((min && gnc_numeric_compare (*min, val) > 0) || - (max && gnc_numeric_compare (val, *max) > 0)) - { - if (error_message) - gnc_error_dialog (dialog, error_message); - return TRUE; - } - } - return FALSE; -} -#endif - -static gboolean check_entry_nonempty (GtkWidget *dialog, GtkWidget *entry, +static gboolean check_entry_nonempty (GtkWidget *entry, const char * error_message) { const char *res = gtk_entry_get_text (GTK_ENTRY (entry)); if (g_strcmp0 (res, "") == 0) { if (error_message) - gnc_error_dialog (dialog, "%s", error_message); + gnc_error_dialog (gnc_ui_get_gtk_window(entry), "%s", error_message); return TRUE; } return FALSE; @@ -221,23 +195,23 @@ gnc_employee_window_ok_cb (GtkWidget *widget, gpointer data) gchar *string; /* Check for valid username */ - if (check_entry_nonempty (ew->dialog, ew->username_entry, + if (check_entry_nonempty (ew->username_entry, _("You must enter a username."))) return; /* Check for valid username */ - if (check_entry_nonempty (ew->dialog, ew->name_entry, + if (check_entry_nonempty (ew->name_entry, _("You must enter the employee's name."))) return; /* Make sure we have an address */ - if (check_entry_nonempty (ew->dialog, ew->addr1_entry, NULL) && - check_entry_nonempty (ew->dialog, ew->addr2_entry, NULL) && - check_entry_nonempty (ew->dialog, ew->addr3_entry, NULL) && - check_entry_nonempty (ew->dialog, ew->addr4_entry, NULL)) + if (check_entry_nonempty (ew->addr1_entry, NULL) && + check_entry_nonempty (ew->addr2_entry, NULL) && + check_entry_nonempty (ew->addr3_entry, NULL) && + check_entry_nonempty (ew->addr4_entry, NULL)) { const char *msg = _("You must enter an address."); - gnc_error_dialog (ew->dialog, "%s", msg); + gnc_error_dialog (gnc_ui_get_gtk_window (widget), "%s", msg); return; } @@ -391,7 +365,8 @@ find_handler (gpointer find_data, gpointer user_data) } static EmployeeWindow * -gnc_employee_new_window (QofBook *bookp, +gnc_employee_new_window (GtkWindow *parent, + QofBook *bookp, GncEmployee *employee) { EmployeeWindow *ew; @@ -415,6 +390,7 @@ gnc_employee_new_window (QofBook *bookp, find_handler, &employee_guid); if (ew) { + gtk_window_set_transient_for (GTK_WINDOW(ew->dialog), parent); gtk_window_present (GTK_WINDOW(ew->dialog)); return(ew); } @@ -437,6 +413,7 @@ gnc_employee_new_window (QofBook *bookp, builder = gtk_builder_new(); gnc_builder_add_from_file (builder, "dialog-employee.glade", "employee_dialog"); ew->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "employee_dialog")); + gtk_window_set_transient_for (GTK_WINDOW(ew->dialog), parent); // Set the style context for this dialog so it can be easily manipulated with css gnc_widget_set_style_context (GTK_WIDGET(ew->dialog), "GncEmployeeDialog"); @@ -597,26 +574,26 @@ gnc_employee_new_window (QofBook *bookp, } EmployeeWindow * -gnc_ui_employee_new (QofBook *bookp) +gnc_ui_employee_new (GtkWindow *parent, QofBook *bookp) { EmployeeWindow *ew; /* Make sure required options exist */ if (!bookp) return NULL; - ew = gnc_employee_new_window (bookp, NULL); + ew = gnc_employee_new_window (parent, bookp, NULL); return ew; } EmployeeWindow * -gnc_ui_employee_edit (GncEmployee *employee) +gnc_ui_employee_edit (GtkWindow *parent, GncEmployee *employee) { EmployeeWindow *ew; if (!employee) return NULL; - ew = gnc_employee_new_window (gncEmployeeGetBook(employee), employee); + ew = gnc_employee_new_window (parent, gncEmployeeGetBook(employee), employee); return ew; } @@ -624,7 +601,7 @@ gnc_ui_employee_edit (GncEmployee *employee) /* Functions for employee selection widgets */ static void -invoice_employee_cb (gpointer *employee_p, gpointer user_data) +invoice_employee_cb (GtkWindow *dialog, gpointer *employee_p, gpointer user_data) { struct _employee_select_window *sw = user_data; GncOwner owner; @@ -638,12 +615,12 @@ invoice_employee_cb (gpointer *employee_p, gpointer user_data) return; gncOwnerInitEmployee (&owner, employee); - gnc_invoice_search (NULL, &owner, sw->book); + gnc_invoice_search (dialog, NULL, &owner, sw->book); return; } static void -payment_employee_cb (gpointer *employee_p, gpointer user_data) +payment_employee_cb (GtkWindow *dialog, gpointer *employee_p, gpointer user_data) { struct _employee_select_window *sw = user_data; GncOwner owner; @@ -657,12 +634,12 @@ payment_employee_cb (gpointer *employee_p, gpointer user_data) return; gncOwnerInitEmployee (&owner, employee); - gnc_ui_payment_new (&owner, sw->book); + gnc_ui_payment_new (dialog, &owner, sw->book); return; } static void -edit_employee_cb (gpointer *employee_p, gpointer user_data) +edit_employee_cb (GtkWindow *dialog, gpointer *employee_p, gpointer user_data) { GncEmployee *employee; @@ -673,19 +650,19 @@ edit_employee_cb (gpointer *employee_p, gpointer user_data) if (!employee) return; - gnc_ui_employee_edit (employee); + gnc_ui_employee_edit (dialog, employee); return; } static gpointer -new_employee_cb (gpointer user_data) +new_employee_cb (GtkWindow *dialog, gpointer user_data) { struct _employee_select_window *sw = user_data; EmployeeWindow *ew; g_return_val_if_fail (user_data, NULL); - ew = gnc_ui_employee_new (sw->book); + ew = gnc_ui_employee_new (dialog, sw->book); return ew_get_employee (ew); } @@ -701,7 +678,7 @@ free_employee_cb (gpointer user_data) } GNCSearchWindow * -gnc_employee_search (GncEmployee *start, QofBook *book) +gnc_employee_search (GtkWindow *parent, GncEmployee *start, QofBook *book) { QofIdType type = GNC_EMPLOYEE_MODULE_NAME; struct _employee_select_window *sw; @@ -758,7 +735,7 @@ gnc_employee_search (GncEmployee *start, QofBook *book) sw->book = book; sw->q = q; - return gnc_search_dialog_create (type, _("Find Employee"), + return gnc_search_dialog_create (parent, type, _("Find Employee"), params, columns, q, q2, buttons, NULL, new_employee_cb, sw, free_employee_cb, @@ -767,18 +744,18 @@ gnc_employee_search (GncEmployee *start, QofBook *book) } GNCSearchWindow * -gnc_employee_search_select (gpointer start, gpointer book) +gnc_employee_search_select (GtkWindow *parent, gpointer start, gpointer book) { if (!book) return NULL; - return gnc_employee_search (start, book); + return gnc_employee_search (parent, start, book); } GNCSearchWindow * -gnc_employee_search_edit (gpointer start, gpointer book) +gnc_employee_search_edit (GtkWindow *parent, gpointer start, gpointer book) { if (start) - gnc_ui_employee_edit (start); + gnc_ui_employee_edit (parent, start); return NULL; } diff --git a/gnucash/gnome/dialog-employee.h b/gnucash/gnome/dialog-employee.h index d61647e7f1..05f22e8b3c 100644 --- a/gnucash/gnome/dialog-employee.h +++ b/gnucash/gnome/dialog-employee.h @@ -31,11 +31,11 @@ typedef struct _employee_window EmployeeWindow; #include "dialog-search.h" /* Functions to edit and create employees */ -EmployeeWindow * gnc_ui_employee_edit (GncEmployee *employee); -EmployeeWindow * gnc_ui_employee_new (QofBook *book); +EmployeeWindow * gnc_ui_employee_edit (GtkWindow *parent, GncEmployee *employee); +EmployeeWindow * gnc_ui_employee_new (GtkWindow *parent, QofBook *book); /* Search for an employee */ -GNCSearchWindow * gnc_employee_search (GncEmployee *start, QofBook *book); +GNCSearchWindow * gnc_employee_search (GtkWindow *parent, GncEmployee *start, QofBook *book); /* * These callbacks are for use with the gnc_general_search widget @@ -43,7 +43,7 @@ GNCSearchWindow * gnc_employee_search (GncEmployee *start, QofBook *book); * select() provides a Select Dialog and returns it. * edit() opens the existing vendor for editing and returns NULL. */ -GNCSearchWindow * gnc_employee_search_select (gpointer start, gpointer book); -GNCSearchWindow * gnc_employee_search_edit (gpointer start, gpointer book); +GNCSearchWindow * gnc_employee_search_select (GtkWindow *parent, gpointer start, gpointer book); +GNCSearchWindow * gnc_employee_search_edit (GtkWindow *parent, gpointer start, gpointer book); #endif /* GNC_DIALOG_EMPLOYEE_H_ */ diff --git a/gnucash/gnome/dialog-fincalc.c b/gnucash/gnome/dialog-fincalc.c index 24b914b631..25152cfdac 100644 --- a/gnucash/gnome/dialog-fincalc.c +++ b/gnucash/gnome/dialog-fincalc.c @@ -398,7 +398,7 @@ calc_value(FinCalcDialog *fcd, FinCalcValue value) { GtkWidget *entry; - gnc_error_dialog(fcd->dialog, "%s", string); + gnc_error_dialog (GTK_WINDOW (fcd->dialog), "%s", string); if (error_item == 0) entry = fcd->amounts[0]; else diff --git a/gnucash/gnome/dialog-find-transactions.c b/gnucash/gnome/dialog-find-transactions.c index 4274890d83..48ffa2e066 100644 --- a/gnucash/gnome/dialog-find-transactions.c +++ b/gnucash/gnome/dialog-find-transactions.c @@ -41,9 +41,10 @@ struct _ftd_data { - QofQuery * q; - QofQuery * ledger_q; - GNCSearchWindow * sw; + QofQuery *q; + QofQuery *ledger_q; + GNCSearchWindow *sw; + GtkWindow *parent; }; static void @@ -69,7 +70,7 @@ do_find_cb (QofQuery *query, gpointer user_data, gpointer *result) if (new_ledger) { page = gnc_plugin_page_register_new_ledger (ledger); - gnc_main_window_open_page (NULL, page); + gnc_main_window_open_page (GNC_MAIN_WINDOW(ftd->parent), page); } qof_query_destroy (ftd->q); @@ -97,6 +98,7 @@ gnc_ui_find_transactions_dialog_create(GNCLedgerDisplay * orig_ledg) QofQuery *start_q, *show_q = NULL; gboolean num_action = qof_book_use_split_action_for_num_field(gnc_get_current_book()); + GtkWindow *parent = GTK_WINDOW(gnc_ledger_display_get_parent(orig_ledg)); /* Build parameter list in reverse order */ if (params == NULL) @@ -221,7 +223,9 @@ gnc_ui_find_transactions_dialog_create(GNCLedgerDisplay * orig_ledg) ftd->q = start_q; /* save this to destroy it later */ } - ftd->sw = gnc_search_dialog_create (type, _("Find Transaction"), + ftd->parent = parent; + + ftd->sw = gnc_search_dialog_create (parent, type, _("Find Transaction"), params, NULL, start_q, show_q, NULL, do_find_cb, NULL, ftd, free_ftd_cb, GNC_PREFS_GROUP_SEARCH, NULL, diff --git a/gnucash/gnome/dialog-find-transactions2.c b/gnucash/gnome/dialog-find-transactions2.c index 2eb9bd1725..93514bd637 100644 --- a/gnucash/gnome/dialog-find-transactions2.c +++ b/gnucash/gnome/dialog-find-transactions2.c @@ -41,9 +41,10 @@ struct _ftd_data { - QofQuery * q; - QofQuery * ledger_q; - GNCSearchWindow * sw; + QofQuery *q; + QofQuery *ledger_q; + GNCSearchWindow *sw; + GtkWindow *parent; }; static void @@ -70,7 +71,7 @@ do_find_cb (QofQuery *query, gpointer user_data, gpointer *result) if (new_ledger) { page = gnc_plugin_page_register2_new_ledger (ledger); - gnc_main_window_open_page (NULL, page); + gnc_main_window_open_page (GNC_MAIN_WINDOW(ftd->parent), page); } qof_query_destroy (ftd->q); @@ -98,6 +99,7 @@ gnc_ui_find_transactions_dialog_create2 (GNCLedgerDisplay2 * orig_ledg) QofQuery *start_q, *show_q = NULL; gboolean num_action = qof_book_use_split_action_for_num_field(gnc_get_current_book()); + GtkWindow *parent = GTK_WINDOW(gnc_ledger_display2_get_parent (orig_ledg)); /* Build parameter list in reverse order */ if (params == NULL) @@ -222,7 +224,9 @@ gnc_ui_find_transactions_dialog_create2 (GNCLedgerDisplay2 * orig_ledg) ftd->q = start_q; /* save this to destroy it later */ } - ftd->sw = gnc_search_dialog_create (type, _("Find Transaction"), + ftd->parent = parent; + + ftd->sw = gnc_search_dialog_create (parent, type, _("Find Transaction"), params, NULL, start_q, show_q, NULL, do_find_cb, NULL, ftd, free_ftd_cb, GNC_PREFS_GROUP_SEARCH, NULL, diff --git a/gnucash/gnome/dialog-invoice.c b/gnucash/gnome/dialog-invoice.c index 78db3efeb9..b766c6f496 100644 --- a/gnucash/gnome/dialog-invoice.c +++ b/gnucash/gnome/dialog-invoice.c @@ -120,10 +120,10 @@ typedef enum struct _invoice_select_window { - QofBook * book; - GncOwner * owner; - QofQuery * q; - GncOwner owner_def; + QofBook *book; + GncOwner *owner; + QofQuery *q; + GncOwner owner_def; }; #define UNUSED_VAR __attribute__ ((unused)) @@ -207,17 +207,16 @@ struct _invoice_window }; /* Forward definitions for CB functions */ -void gnc_invoice_window_closeCB (GtkWidget *widget, gpointer data); void gnc_invoice_window_active_toggled_cb (GtkWidget *widget, gpointer data); gboolean gnc_invoice_window_leave_notes_cb (GtkWidget *widget, GdkEventFocus *event, gpointer data); -DialogQueryView *gnc_invoice_show_bills_due (QofBook *book, double days_in_advance, GncWhichDueType duetype); +DialogQueryView *gnc_invoice_show_docs_due (GtkWindow *parent, QofBook *book, double days_in_advance, GncWhichDueType duetype); #define INV_WIDTH_PREFIX "invoice_reg" #define BILL_WIDTH_PREFIX "bill_reg" #define VOUCHER_WIDTH_PREFIX "voucher_reg" static void gnc_invoice_update_window (InvoiceWindow *iw, GtkWidget *widget); -static InvoiceWindow * gnc_ui_invoice_modify (GncInvoice *invoice); +static InvoiceWindow * gnc_ui_invoice_modify (GtkWindow *parent, GncInvoice *invoice); /*******************************************************************************/ /* FUNCTIONS FOR ACCESSING DATA STRUCTURE FIELDS */ @@ -389,7 +388,7 @@ gnc_invoice_window_verify_ok (InvoiceWindow *iw) res = gncOwnerGetName (&(iw->owner)); if (res == NULL || g_strcmp0 (res, "") == 0) { - gnc_error_dialog (iw_get_window(iw), "%s", + gnc_error_dialog (GTK_WINDOW (iw_get_window(iw)), "%s", /* Translators: In this context, * 'Billing information' maps to the * label in the frame and means @@ -450,7 +449,7 @@ gnc_invoice_window_ok_cb (GtkWidget *widget, gpointer data) */ if ((iw->dialog_type == NEW_INVOICE || iw->dialog_type == DUP_INVOICE) && iw->created_invoice) - gnc_ui_invoice_edit (iw->created_invoice); + gnc_ui_invoice_edit (gnc_ui_get_main_window (iw->dialog), iw->created_invoice); gnc_close_gui_component (iw->component_id); } @@ -495,29 +494,23 @@ gnc_invoice_window_destroy_cb (GtkWidget *widget, gpointer data) } void -gnc_invoice_window_closeCB (GtkWidget *widget, gpointer data) -{ - gnc_invoice_window_ok_cb (widget, data); -} - -void -gnc_invoice_window_editCB (GtkWidget *widget, gpointer data) +gnc_invoice_window_editCB (GtkWindow *parent, gpointer data) { InvoiceWindow *iw = data; GncInvoice *invoice = iw_get_invoice (iw); if (invoice) - gnc_ui_invoice_modify (invoice); + gnc_ui_invoice_modify (parent, invoice); } void -gnc_invoice_window_duplicateInvoiceCB (GtkWidget *widget, gpointer data) +gnc_invoice_window_duplicateInvoiceCB (GtkWindow *parent, gpointer data) { InvoiceWindow *iw = data; GncInvoice *invoice = iw_get_invoice (iw); if (invoice) - gnc_ui_invoice_duplicate (invoice, TRUE, NULL); + gnc_ui_invoice_duplicate (parent, invoice, TRUE, NULL); } void gnc_invoice_window_entryUpCB (GtkWidget *widget, gpointer data) @@ -600,7 +593,7 @@ gnc_invoice_window_deleteCB (GtkWidget *widget, gpointer data) else msg = g_strdup (message); - result = gnc_verify_dialog (iw_get_window(iw), FALSE, "%s", msg); + result = gnc_verify_dialog (GTK_WINDOW (iw_get_window(iw)), FALSE, "%s", msg); g_free (msg); if (!result) @@ -648,7 +641,7 @@ gnc_invoice_window_blankCB (GtkWidget *widget, gpointer data) } static void -gnc_invoice_window_print_invoice(GncInvoice *invoice) +gnc_invoice_window_print_invoice(GtkWindow *parent, GncInvoice *invoice) { SCM func, arg, arg2; SCM args = SCM_EOL; @@ -674,13 +667,13 @@ gnc_invoice_window_print_invoice(GncInvoice *invoice) /* scm_gc_unprotect_object(func); */ if (report_id >= 0) - reportWindow (report_id); + reportWindow (report_id, parent); } void -gnc_invoice_window_printCB (GtkWidget *unused_widget, gpointer data) +gnc_invoice_window_printCB (GtkWindow* parent, gpointer data) { InvoiceWindow *iw = data; - gnc_invoice_window_print_invoice(iw_get_invoice (iw)); + gnc_invoice_window_print_invoice (parent, iw_get_invoice (iw)); } static gboolean @@ -764,6 +757,7 @@ struct post_invoice_params char *memo; /* Memo for posting transaction */ Account *acc; /* Account to post to */ gboolean accumulate; /* Whether to accumulate splits */ + GtkWindow *parent; }; static void @@ -794,7 +788,7 @@ gnc_invoice_post(InvoiceWindow *iw, struct post_invoice_params *post_params) /* Check that there is at least one Entry */ if (gncInvoiceGetEntries (invoice) == NULL) { - gnc_error_dialog (iw_get_window(iw), "%s", + gnc_error_dialog (GTK_WINDOW (iw_get_window(iw)), "%s", _("The Invoice must have at least one Entry.")); return; } @@ -853,7 +847,7 @@ gnc_invoice_post(InvoiceWindow *iw, struct post_invoice_params *post_params) */ if (show_dialog) { - gnc_info_dialog(iw_get_window(iw), "%s", text); + gnc_info_dialog(GTK_WINDOW (iw_get_window(iw)), "%s", text); show_dialog = FALSE; } @@ -967,7 +961,7 @@ cleanup: else { text = _("The post action was canceled because not all exchange rates were given."); - gnc_info_dialog(iw_get_window(iw), "%s", text); + gnc_info_dialog(GTK_WINDOW (iw_get_window(iw)), "%s", text); } /* ... and redisplay here. */ @@ -1028,20 +1022,20 @@ void gnc_invoice_window_paste_cb (GtkWidget *widget, gpointer data) gnucash_register_paste_clipboard (iw->reg); } -void gnc_invoice_window_new_invoice_cb (GtkWidget *widget, gpointer data) +void gnc_invoice_window_new_invoice_cb (GtkWindow *parent, gpointer data) { InvoiceWindow *iw = data; if (gncOwnerGetJob (&iw->job)) { - gnc_ui_invoice_new (&iw->job, iw->book); + gnc_ui_invoice_new (parent, &iw->job, iw->book); } else { - gnc_ui_invoice_new (&iw->owner, iw->book); + gnc_ui_invoice_new (parent, &iw->owner, iw->book); } } -void gnc_business_call_owner_report (GncOwner *owner, Account *acc) +void gnc_business_call_owner_report (GtkWindow *parent, GncOwner *owner, Account *acc) { int id; SCM args; @@ -1079,24 +1073,24 @@ void gnc_business_call_owner_report (GncOwner *owner, Account *acc) id = scm_to_int (arg); if (id >= 0) - reportWindow (id); + reportWindow (id, parent); } -void gnc_invoice_window_report_owner_cb (GtkWidget *widget, gpointer data) +void gnc_invoice_window_report_owner_cb (GtkWindow *parent, gpointer data) { InvoiceWindow *iw = data; - gnc_business_call_owner_report (&iw->owner, NULL); + gnc_business_call_owner_report (parent, &iw->owner, NULL); } -void gnc_invoice_window_payment_cb (GtkWidget *widget, gpointer data) +void gnc_invoice_window_payment_cb (GtkWindow *parent, gpointer data) { InvoiceWindow *iw = data; GncInvoice *invoice = iw_get_invoice(iw); if (gncOwnerGetJob (&iw->job)) - gnc_ui_payment_new_with_invoice (&iw->job, iw->book, invoice); + gnc_ui_payment_new_with_invoice (parent, &iw->job, iw->book, invoice); else - gnc_ui_payment_new_with_invoice (&iw->owner, iw->book, invoice); + gnc_ui_payment_new_with_invoice (parent, &iw->owner, iw->book, invoice); } /* Sorting callbacks */ @@ -1285,7 +1279,7 @@ gnc_invoice_job_changed_cb (GtkWidget *widget, gpointer data) } static GNCSearchWindow * -gnc_invoice_select_job_cb (gpointer jobp, gpointer user_data) +gnc_invoice_select_job_cb (GtkWindow *parent, gpointer jobp, gpointer user_data) { GncJob *j = jobp; InvoiceWindow *iw = user_data; @@ -1301,7 +1295,7 @@ gnc_invoice_select_job_cb (gpointer jobp, gpointer user_data) else gncOwnerCopy (&(iw->owner), &owner); - return gnc_job_search (j, &owner, iw->book); + return gnc_job_search (parent, j, &owner, iw->book); } static void @@ -1347,7 +1341,7 @@ gnc_invoice_update_job_choice (InvoiceWindow *iw) } static GNCSearchWindow * -gnc_invoice_select_proj_job_cb (gpointer jobp, gpointer user_data) +gnc_invoice_select_proj_job_cb (GtkWindow *parent, gpointer jobp, gpointer user_data) { GncJob *j = jobp; InvoiceWindow *iw = user_data; @@ -1363,7 +1357,7 @@ gnc_invoice_select_proj_job_cb (gpointer jobp, gpointer user_data) else gncOwnerCopy (&(iw->proj_cust), &owner); - return gnc_job_search (j, &owner, iw->book); + return gnc_job_search (parent, j, &owner, iw->book); } static int @@ -2456,7 +2450,7 @@ gnc_invoice_create_page (InvoiceWindow *iw, gpointer page) } static InvoiceWindow * -gnc_invoice_window_new_invoice (InvoiceDialogType dialog_type, QofBook *bookp, +gnc_invoice_window_new_invoice (GtkWindow *parent, InvoiceDialogType dialog_type, QofBook *bookp, const GncOwner *owner, GncInvoice *invoice) { InvoiceWindow *iw; @@ -2483,6 +2477,7 @@ gnc_invoice_window_new_invoice (InvoiceDialogType dialog_type, QofBook *bookp, find_handler, &invoice_guid); if (iw) { + gtk_window_set_transient_for (GTK_WINDOW(iw->dialog), parent); gtk_window_present (GTK_WINDOW(iw->dialog)); return(iw); } @@ -2542,6 +2537,7 @@ gnc_invoice_window_new_invoice (InvoiceDialogType dialog_type, QofBook *bookp, gnc_builder_add_from_file (builder, "dialog-invoice.glade", "terms_store"); gnc_builder_add_from_file (builder, "dialog-invoice.glade", "new_invoice_dialog"); iw->dialog = GTK_WIDGET (gtk_builder_get_object (builder, "new_invoice_dialog")); + gtk_window_set_transient_for (GTK_WINDOW(iw->dialog), parent); // Set the style context for this dialog so it can be easily manipulated with css gnc_widget_set_style_context (GTK_WIDGET(iw->dialog), "GncInvoiceDialog"); @@ -2672,7 +2668,7 @@ gnc_invoice_window_new_invoice (InvoiceDialogType dialog_type, QofBook *bookp, } InvoiceWindow * -gnc_ui_invoice_edit (GncInvoice *invoice) +gnc_ui_invoice_edit (GtkWindow *parent, GncInvoice *invoice) { InvoiceWindow *iw; InvoiceDialogType type; @@ -2686,18 +2682,19 @@ gnc_ui_invoice_edit (GncInvoice *invoice) type = EDIT_INVOICE; iw = gnc_invoice_new_page (gncInvoiceGetBook(invoice), type, - invoice, gncInvoiceGetOwner (invoice), NULL); + invoice, gncInvoiceGetOwner (invoice), + GNC_MAIN_WINDOW(gnc_ui_get_main_window (GTK_WIDGET (parent)))); return iw; } static InvoiceWindow * -gnc_ui_invoice_modify (GncInvoice *invoice) +gnc_ui_invoice_modify (GtkWindow *parent, GncInvoice *invoice) { InvoiceWindow *iw; if (!invoice) return NULL; - iw = gnc_invoice_window_new_invoice (MOD_INVOICE, NULL, NULL, invoice); + iw = gnc_invoice_window_new_invoice (parent, MOD_INVOICE, NULL, NULL, invoice); return iw; } @@ -2715,7 +2712,7 @@ set_gncEntry_date(gpointer data, gpointer user_data) } -InvoiceWindow * gnc_ui_invoice_duplicate (GncInvoice *old_invoice, gboolean open_properties, const GDate *new_date) +InvoiceWindow * gnc_ui_invoice_duplicate (GtkWindow *parent, GncInvoice *old_invoice, gboolean open_properties, const GDate *new_date) { InvoiceWindow *iw = NULL; GncInvoice *new_invoice = NULL; @@ -2764,12 +2761,12 @@ InvoiceWindow * gnc_ui_invoice_duplicate (GncInvoice *old_invoice, gboolean open if (open_properties) { // Open the "properties" pop-up for the invoice... - iw = gnc_invoice_window_new_invoice (DUP_INVOICE, NULL, NULL, new_invoice); + iw = gnc_invoice_window_new_invoice (parent, DUP_INVOICE, NULL, NULL, new_invoice); } else { // Open the newly created invoice in the "edit" window - iw = gnc_ui_invoice_edit (new_invoice); + iw = gnc_ui_invoice_edit (parent, new_invoice); // Check the ID; set one if necessary if (g_strcmp0 (gtk_entry_get_text (GTK_ENTRY (iw->id_entry)), "") == 0) { @@ -2780,22 +2777,22 @@ InvoiceWindow * gnc_ui_invoice_duplicate (GncInvoice *old_invoice, gboolean open } InvoiceWindow * -gnc_ui_invoice_new (GncOwner *ownerp, QofBook *bookp) +gnc_ui_invoice_new (GtkWindow *parent, GncOwner *owner, QofBook *book) { InvoiceWindow *iw; - GncOwner owner; + GncOwner inv_owner; - if (ownerp) + if (owner) { - gncOwnerCopy (ownerp, &owner); + gncOwnerCopy (owner, &inv_owner); } else - gncOwnerInitCustomer (&owner, NULL); /* XXX: pass in the owner type? */ + gncOwnerInitCustomer (&inv_owner, NULL); /* XXX: pass in the owner type? */ /* Make sure required options exist */ - if (!bookp) return NULL; + if (!book) return NULL; - iw = gnc_invoice_window_new_invoice (NEW_INVOICE, bookp, &owner, NULL); + iw = gnc_invoice_window_new_invoice (parent, NEW_INVOICE, book, &inv_owner, NULL); return iw; } @@ -2803,47 +2800,67 @@ gnc_ui_invoice_new (GncOwner *ownerp, QofBook *bookp) /* Functions for invoice selection widgets */ static void -edit_invoice_direct (gpointer invoice, gpointer user_data) +edit_invoice_direct (GtkWindow *dialog, gpointer invoice, gpointer user_data) { g_return_if_fail (invoice); - gnc_ui_invoice_edit (invoice); + gnc_ui_invoice_edit (gnc_ui_get_main_window (GTK_WIDGET (dialog)), invoice); } static void -edit_invoice_cb (gpointer inv, gpointer user_data) +edit_invoice_cb (GtkWindow *dialog, gpointer inv, gpointer user_data) { GncInvoice *invoice = inv; g_return_if_fail (invoice && user_data); - edit_invoice_direct (invoice, user_data); + edit_invoice_direct (dialog, invoice, user_data); } -static void -multi_edit_invoice_cb (GList *invoice_list, gpointer user_data) + +struct multi_edit_invoice_data { - g_list_foreach(invoice_list, edit_invoice_cb, user_data); + gpointer user_data; + GtkWindow *parent; +}; + +static void +multi_edit_invoice_one (gpointer inv, gpointer user_data) +{ + struct multi_edit_invoice_data *meid = user_data; + edit_invoice_cb (meid->parent, inv, meid->user_data); } static void -pay_invoice_direct (gpointer inv, gpointer user_data) +multi_edit_invoice_cb (GtkWindow *dialog, GList *invoice_list, gpointer user_data) +{ + struct multi_edit_invoice_data meid; + + meid.user_data = user_data; + meid.parent = dialog; + g_list_foreach (invoice_list, multi_edit_invoice_one, &meid); +} + +static void +pay_invoice_direct (GtkWindow *dialog, gpointer inv, gpointer user_data) { GncInvoice *invoice = inv; g_return_if_fail (invoice); - gnc_ui_payment_new_with_invoice (gncInvoiceGetOwner (invoice), + gnc_ui_payment_new_with_invoice (dialog, gncInvoiceGetOwner (invoice), gncInvoiceGetBook (invoice), invoice); } static void -pay_invoice_cb (gpointer *invoice_p, gpointer user_data) +pay_invoice_cb (GtkWindow *dialog, gpointer *invoice_p, gpointer user_data) { g_return_if_fail (invoice_p && user_data); if (! *invoice_p) return; - pay_invoice_direct (*invoice_p, user_data); + pay_invoice_direct (dialog, *invoice_p, user_data); } + struct multi_duplicate_invoice_data { GDate date; + GtkWindow *parent; }; static void multi_duplicate_invoice_one(gpointer data, gpointer user_data) @@ -2858,7 +2875,7 @@ static void multi_duplicate_invoice_one(gpointer data, gpointer user_data) // In this simplest form, we just use the existing duplication // algorithm, only without opening the "edit invoice" window for editing // the number etc. for each of the invoices. - InvoiceWindow *iw = gnc_ui_invoice_duplicate(old_invoice, FALSE, &dup_user_data->date); + InvoiceWindow *iw = gnc_ui_invoice_duplicate(dup_user_data->parent, old_invoice, FALSE, &dup_user_data->date); // FIXME: Now we could use this invoice and manipulate further data. g_assert(iw); new_invoice = iw_get_invoice(iw); @@ -2867,7 +2884,7 @@ static void multi_duplicate_invoice_one(gpointer data, gpointer user_data) } static void -multi_duplicate_invoice_cb (GList *invoice_list, gpointer user_data) +multi_duplicate_invoice_cb (GtkWindow *dialog, GList *invoice_list, gpointer user_data) { g_return_if_fail (invoice_list); switch (g_list_length(invoice_list)) @@ -2878,7 +2895,7 @@ multi_duplicate_invoice_cb (GList *invoice_list, gpointer user_data) { // Duplicate exactly one invoice GncInvoice *old_invoice = invoice_list->data; - gnc_ui_invoice_duplicate(old_invoice, TRUE, NULL); + gnc_ui_invoice_duplicate(dialog, old_invoice, TRUE, NULL); return; } default: @@ -2889,7 +2906,8 @@ multi_duplicate_invoice_cb (GList *invoice_list, gpointer user_data) // Default date: Today gnc_gdate_set_time64(&dup_user_data.date, gnc_time (NULL)); - dialog_ok = gnc_dup_date_dialog (NULL, _("Date of duplicated entries"), &dup_user_data.date); + dup_user_data.parent = dialog; + dialog_ok = gnc_dup_date_dialog (GTK_WIDGET(dialog), _("Date of duplicated entries"), &dup_user_data.date); if (!dialog_ok) { // User pressed cancel, so don't duplicate anything here. @@ -2909,7 +2927,7 @@ static void post_one_invoice_cb(gpointer data, gpointer user_data) { GncInvoice *invoice = data; struct post_invoice_params *post_params = user_data; - InvoiceWindow *iw = gnc_ui_invoice_edit(invoice); + InvoiceWindow *iw = gnc_ui_invoice_edit(post_params->parent, invoice); gnc_invoice_post(iw, post_params); } @@ -2917,7 +2935,7 @@ static void gnc_invoice_is_posted(gpointer inv, gpointer test_value) { GncInvoice *invoice = inv; gboolean *test = (gboolean*)test_value; - + if (gncInvoiceIsPosted (invoice)) { *test = TRUE; @@ -2926,7 +2944,7 @@ static void gnc_invoice_is_posted(gpointer inv, gpointer test_value) static void -multi_post_invoice_cb (GList *invoice_list, gpointer user_data) +multi_post_invoice_cb (GtkWindow *dialog, GList *invoice_list, gpointer user_data) { struct post_invoice_params post_params; gboolean test; @@ -2935,7 +2953,7 @@ multi_post_invoice_cb (GList *invoice_list, gpointer user_data) if (g_list_length(invoice_list) == 0) return; // Get the posting parameters for these invoices - iw = gnc_ui_invoice_edit(invoice_list->data); + iw = gnc_ui_invoice_edit(dialog, invoice_list->data); test = FALSE; gnc_suspend_gui_refresh (); // Turn off GUI refresh for the duration. // Check if any of the selected invoices have already been posted. @@ -2943,16 +2961,17 @@ multi_post_invoice_cb (GList *invoice_list, gpointer user_data) gnc_resume_gui_refresh (); if (test) { - gnc_error_dialog (iw_get_window(iw), "%s", + gnc_error_dialog (GTK_WINDOW (iw_get_window(iw)), "%s", _("One or more selected invoices have already been posted.\nRe-check your selection.")); return; } - + if (!gnc_dialog_post_invoice(iw, _("Do you really want to post these invoices?"), &post_params.ddue, &post_params.postdate, &post_params.memo, &post_params.acc, &post_params.accumulate)) return; + post_params.parent = dialog; // Turn off GUI refresh for the duration. This is more than just an // optimization. If the search that got us here is based on the "posted" @@ -2963,30 +2982,41 @@ multi_post_invoice_cb (GList *invoice_list, gpointer user_data) gnc_resume_gui_refresh (); } -static void print_one_invoice_cb(gpointer data, gpointer user_data) +static void print_one_invoice_cb(GtkWindow *dialog, gpointer data, gpointer user_data) { GncInvoice *invoice = data; - gnc_invoice_window_print_invoice(invoice); // that's all! + gnc_invoice_window_print_invoice (dialog, invoice); } static void -multi_print_invoice_cb (GList *invoice_list, gpointer user_data) +multi_print_invoice_one (gpointer data, gpointer user_data) { + struct multi_edit_invoice_data *meid = user_data; + print_one_invoice_cb (meid->parent, data, meid->user_data); +} + +static void +multi_print_invoice_cb (GtkWindow *dialog, GList *invoice_list, gpointer user_data) +{ + struct multi_edit_invoice_data meid; + if (g_list_length(invoice_list) == 0) return; - g_list_foreach(invoice_list, print_one_invoice_cb, user_data); + meid.user_data = user_data; + meid.parent = dialog; + g_list_foreach (invoice_list, multi_print_invoice_one, &meid); } static gpointer -new_invoice_cb (gpointer user_data) +new_invoice_cb (GtkWindow *dialog, gpointer user_data) { struct _invoice_select_window *sw = user_data; InvoiceWindow *iw; g_return_val_if_fail (user_data, NULL); - iw = gnc_ui_invoice_new (sw->owner, sw->book); + iw = gnc_ui_invoice_new (dialog, sw->owner, sw->book); return iw_get_invoice (iw); } @@ -3002,7 +3032,7 @@ free_invoice_cb (gpointer user_data) } GNCSearchWindow * -gnc_invoice_search (GncInvoice *start, GncOwner *owner, QofBook *book) +gnc_invoice_search (GtkWindow *parent, GncInvoice *start, GncOwner *owner, QofBook *book) { QofIdType type = GNC_INVOICE_MODULE_NAME; struct _invoice_select_window *sw; @@ -3269,14 +3299,14 @@ gnc_invoice_search (GncInvoice *start, GncOwner *owner, QofBook *book) buttons = inv_buttons; break; } - return gnc_search_dialog_create (type, title, params, columns, q, q2, + return gnc_search_dialog_create (parent, type, title, params, columns, q, q2, buttons, NULL, new_invoice_cb, sw, free_invoice_cb, GNC_PREFS_GROUP_SEARCH, label, style_class); } DialogQueryView * -gnc_invoice_show_bills_due (QofBook *book, double days_in_advance, GncWhichDueType duetype) +gnc_invoice_show_docs_due (GtkWindow *parent, QofBook *book, double days_in_advance, GncWhichDueType duetype) { QofIdType type = GNC_INVOICE_MODULE_NAME; Query *q; @@ -3411,7 +3441,8 @@ gnc_invoice_show_bills_due (QofBook *book, double days_in_advance, GncWhichDueTy len); title = _("Due Invoices Reminder"); } - dialog = gnc_dialog_query_view_create(param_list, q, + + dialog = gnc_dialog_query_view_create(parent, param_list, q, title, message, TRUE, FALSE, @@ -3426,7 +3457,7 @@ gnc_invoice_show_bills_due (QofBook *book, double days_in_advance, GncWhichDueTy } void -gnc_invoice_remind_bills_due (void) +gnc_invoice_remind_bills_due (GtkWindow *parent) { QofBook *book; gint days; @@ -3435,11 +3466,11 @@ gnc_invoice_remind_bills_due (void) book = qof_session_get_book(gnc_get_current_session()); days = gnc_prefs_get_float(GNC_PREFS_GROUP_BILL, GNC_PREF_DAYS_IN_ADVANCE); - gnc_invoice_show_bills_due(book, days, DUE_FOR_VENDOR); + gnc_invoice_show_docs_due (parent, book, days, DUE_FOR_VENDOR); } void -gnc_invoice_remind_invoices_due (void) +gnc_invoice_remind_invoices_due (GtkWindow *parent) { QofBook *book; gint days; @@ -3448,7 +3479,7 @@ gnc_invoice_remind_invoices_due (void) book = qof_session_get_book(gnc_get_current_session()); days = gnc_prefs_get_float(GNC_PREFS_GROUP_INVOICE, GNC_PREF_DAYS_IN_ADVANCE); - gnc_invoice_show_bills_due(book, days, DUE_FOR_CUSTOMER); + gnc_invoice_show_docs_due (parent, book, days, DUE_FOR_CUSTOMER); } void @@ -3457,7 +3488,7 @@ gnc_invoice_remind_bills_due_cb (void) if (!gnc_prefs_get_bool(GNC_PREFS_GROUP_BILL, GNC_PREF_NOTIFY_WHEN_DUE)) return; - gnc_invoice_remind_bills_due(); + gnc_invoice_remind_bills_due (GTK_WINDOW(gnc_ui_get_main_window (NULL))); } void @@ -3466,5 +3497,5 @@ gnc_invoice_remind_invoices_due_cb (void) if (!gnc_prefs_get_bool(GNC_PREFS_GROUP_INVOICE, GNC_PREF_NOTIFY_WHEN_DUE)) return; - gnc_invoice_remind_invoices_due(); + gnc_invoice_remind_invoices_due (GTK_WINDOW(gnc_ui_get_main_window (NULL))); } diff --git a/gnucash/gnome/dialog-invoice.h b/gnucash/gnome/dialog-invoice.h index 9823904a6f..93a92fa215 100644 --- a/gnucash/gnome/dialog-invoice.h +++ b/gnucash/gnome/dialog-invoice.h @@ -47,12 +47,12 @@ typedef enum /* Create and edit an invoice */ -InvoiceWindow * gnc_ui_invoice_edit (GncInvoice *invoice); -InvoiceWindow * gnc_ui_invoice_new (GncOwner *owner, QofBook *book); +InvoiceWindow * gnc_ui_invoice_edit (GtkWindow *parent, GncInvoice *invoice); +InvoiceWindow * gnc_ui_invoice_new (GtkWindow *parent, GncOwner *owner, QofBook *book); /** Create a new invoice as a duplicate of the given existing invoice. * - * \param invoice The invoice which is being duplicated + * \param old_invoice The invoice which is being duplicated * \param open_properties If TRUE, open the "invoice properties" dialog window after creating the new invoice * \param new_date If non-NULL, use this date as the date for the "opening date" and also as date for all invoice entries. * @@ -60,12 +60,12 @@ InvoiceWindow * gnc_ui_invoice_new (GncOwner *owner, QofBook *book); * among others the "created_invoice" as a GncInvoice* pointer on the newly * created invoice. */ -InvoiceWindow * gnc_ui_invoice_duplicate (GncInvoice *invoice, gboolean open_properties, const GDate *new_date); +InvoiceWindow* gnc_ui_invoice_duplicate (GtkWindow* parent, GncInvoice* old_invoice, gboolean open_properties, const GDate* new_date); /* Search for invoices */ -GNCSearchWindow * gnc_invoice_search (GncInvoice *start, GncOwner *owner, QofBook *book); +GNCSearchWindow * gnc_invoice_search (GtkWindow *parent, GncInvoice *start, GncOwner *owner, QofBook *book); -void gnc_business_call_owner_report (GncOwner *owner, Account *acc); +void gnc_business_call_owner_report (GtkWindow* parent, GncOwner *owner, Account *acc); void gnc_invoice_window_sort (InvoiceWindow *iw, invoice_sort_type_t sort_code); @@ -90,13 +90,13 @@ GtkWidget *gnc_invoice_get_register(InvoiceWindow *iw); /* definitions for CB functions */ void gnc_invoice_window_destroy_cb (GtkWidget *widget, gpointer data); -void gnc_invoice_window_new_invoice_cb (GtkWidget *widget, gpointer data); -void gnc_invoice_window_printCB (GtkWidget *widget, gpointer data); +void gnc_invoice_window_new_invoice_cb (GtkWindow* parent, gpointer data); +void gnc_invoice_window_printCB (GtkWindow* parent, gpointer data); void gnc_invoice_window_cut_cb (GtkWidget *widget, gpointer data); void gnc_invoice_window_copy_cb (GtkWidget *widget, gpointer data); void gnc_invoice_window_paste_cb (GtkWidget *widget, gpointer data); -void gnc_invoice_window_editCB (GtkWidget *widget, gpointer data); -void gnc_invoice_window_duplicateInvoiceCB (GtkWidget *widget, gpointer data); +void gnc_invoice_window_editCB (GtkWindow* parent, gpointer data); +void gnc_invoice_window_duplicateInvoiceCB (GtkWindow* parent, gpointer data); void gnc_invoice_window_postCB (GtkWidget *widget, gpointer data); void gnc_invoice_window_unpostCB (GtkWidget *widget, gpointer data); void gnc_invoice_window_recordCB (GtkWidget *widget, gpointer data); @@ -104,8 +104,8 @@ void gnc_invoice_window_cancelCB (GtkWidget *widget, gpointer data); void gnc_invoice_window_deleteCB (GtkWidget *widget, gpointer data); void gnc_invoice_window_blankCB (GtkWidget *widget, gpointer data); void gnc_invoice_window_duplicateCB (GtkWidget *widget, gpointer data); -void gnc_invoice_window_payment_cb (GtkWidget *widget, gpointer data); -void gnc_invoice_window_report_owner_cb (GtkWidget *widget, gpointer data); +void gnc_invoice_window_payment_cb (GtkWindow *parent, gpointer data); +void gnc_invoice_window_report_owner_cb (GtkWindow *parent, gpointer data); void gnc_invoice_window_entryUpCB (GtkWidget *widget, gpointer data); void gnc_invoice_window_entryDownCB (GtkWidget *widget, gpointer data); diff --git a/gnucash/gnome/dialog-job.c b/gnucash/gnome/dialog-job.c index e7ee6436a6..c18f5703b3 100644 --- a/gnucash/gnome/dialog-job.c +++ b/gnucash/gnome/dialog-job.c @@ -63,10 +63,10 @@ typedef enum struct _job_select_window { - QofBook * book; - GncOwner * owner; - QofQuery * q; - GncOwner owner_def; + QofBook *book; + GncOwner *owner; + QofQuery *q; + GncOwner owner_def; }; struct _job_window @@ -137,7 +137,7 @@ gnc_job_verify_ok (JobWindow *jw) if (g_strcmp0 (res, "") == 0) { const char *message = _("The Job must be given a name."); - gnc_error_dialog(jw->dialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (jw->dialog), "%s", message); return FALSE; } @@ -147,7 +147,7 @@ gnc_job_verify_ok (JobWindow *jw) if (res == NULL || g_strcmp0 (res, "") == 0) { const char *message = _("You must choose an owner for this job."); - gnc_error_dialog(jw->dialog, "%s", message); + gnc_error_dialog (GTK_WINDOW (jw->dialog), "%s", message); return FALSE; } @@ -302,7 +302,7 @@ find_handler (gpointer find_data, gpointer user_data) } static JobWindow * -gnc_job_new_window (QofBook *bookp, GncOwner *owner, GncJob *job) +gnc_job_new_window (GtkWindow *parent, QofBook *bookp, GncOwner *owner, GncJob *job) { JobWindow *jw; GtkBuilder *builder; @@ -321,6 +321,7 @@ gnc_job_new_window (QofBook *bookp, GncOwner *owner, GncJob *job) find_handler, &job_guid); if (jw) { + gtk_window_set_transient_for (GTK_WINDOW(jw->dialog), parent); gtk_window_present (GTK_WINDOW(jw->dialog)); return(jw); } @@ -339,6 +340,7 @@ gnc_job_new_window (QofBook *bookp, GncOwner *owner, GncJob *job) /* Find the dialog */ jw->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "job_dialog")); + gtk_window_set_transient_for (GTK_WINDOW(jw->dialog), parent); // Set the style context for this dialog so it can be easily manipulated with css gnc_widget_set_style_context (GTK_WIDGET(jw->dialog), "GncJobDialog"); @@ -433,17 +435,8 @@ gnc_job_new_window (QofBook *bookp, GncOwner *owner, GncJob *job) return jw; } -GncJob * -gnc_ui_job_new_return_handle (GncOwner *owner, QofBook *book) -{ - JobWindow *jw; - if (!book) return NULL; - jw = gnc_ui_job_new (owner, book); - return jw_get_job (jw); -} - JobWindow * -gnc_ui_job_new (GncOwner *ownerp, QofBook *bookp) +gnc_ui_job_new (GtkWindow *parent, GncOwner *ownerp, QofBook *bookp) { JobWindow *jw; GncOwner owner; @@ -461,25 +454,25 @@ gnc_ui_job_new (GncOwner *ownerp, QofBook *bookp) else gncOwnerInitCustomer (&owner, NULL); /* XXX */ - jw = gnc_job_new_window (bookp, &owner, NULL); + jw = gnc_job_new_window (parent, bookp, &owner, NULL); return jw; } JobWindow * -gnc_ui_job_edit (GncJob *job) +gnc_ui_job_edit (GtkWindow *parent, GncJob *job) { JobWindow *jw; if (!job) return NULL; - jw = gnc_job_new_window (gncJobGetBook(job), gncJobGetOwner(job), job); + jw = gnc_job_new_window (parent, gncJobGetBook(job), gncJobGetOwner(job), job); return jw; } /* Search functionality */ static void -edit_job_cb (gpointer *job_p, gpointer user_data) +edit_job_cb (GtkWindow *dialog, gpointer *job_p, gpointer user_data) { GncJob *job; @@ -490,11 +483,11 @@ edit_job_cb (gpointer *job_p, gpointer user_data) if (!job) return; - gnc_ui_job_edit (job); + gnc_ui_job_edit (dialog, job); } static void -invoice_job_cb (gpointer *job_p, gpointer user_data) +invoice_job_cb (GtkWindow *dialog, gpointer *job_p, gpointer user_data) { struct _job_select_window * sw = user_data; GncJob *job; @@ -507,11 +500,11 @@ invoice_job_cb (gpointer *job_p, gpointer user_data) return; gncOwnerInitJob (&owner, job); - gnc_invoice_search (NULL, &owner, sw->book); + gnc_invoice_search (dialog, NULL, &owner, sw->book); } static void -payment_job_cb (gpointer *job_p, gpointer user_data) +payment_job_cb (GtkWindow *dialog, gpointer *job_p, gpointer user_data) { struct _job_select_window *sw = user_data; GncOwner owner; @@ -525,19 +518,19 @@ payment_job_cb (gpointer *job_p, gpointer user_data) return; gncOwnerInitJob (&owner, job); - gnc_ui_payment_new (&owner, sw->book); + gnc_ui_payment_new (dialog, &owner, sw->book); return; } static gpointer -new_job_cb (gpointer user_data) +new_job_cb (GtkWindow *dialog, gpointer user_data) { struct _job_select_window *sw = user_data; JobWindow *jw; g_return_val_if_fail (user_data, NULL); - jw = gnc_ui_job_new (sw->owner, sw->book); + jw = gnc_ui_job_new (dialog, sw->owner, sw->book); return jw_get_job (jw); } @@ -553,7 +546,7 @@ free_userdata_cb (gpointer user_data) } GNCSearchWindow * -gnc_job_search (GncJob *start, GncOwner *owner, QofBook *book) +gnc_job_search (GtkWindow *parent, GncJob *start, GncOwner *owner, QofBook *book) { QofQuery *q, *q2 = NULL; QofIdType type = GNC_JOB_MODULE_NAME; @@ -647,7 +640,7 @@ gnc_job_search (GncJob *start, GncOwner *owner, QofBook *book) sw->book = book; sw->q = q; - return gnc_search_dialog_create (type, _("Find Job"), + return gnc_search_dialog_create (parent, type, _("Find Job"), params, columns, q, q2, buttons, NULL, new_job_cb, sw, free_userdata_cb, GNC_PREFS_GROUP_SEARCH, NULL, @@ -657,7 +650,7 @@ gnc_job_search (GncJob *start, GncOwner *owner, QofBook *book) /* Functions for widgets for job selection */ GNCSearchWindow * -gnc_job_search_select (gpointer start, gpointer book) +gnc_job_search_select (GtkWindow *parent, gpointer start, gpointer book) { GncJob *j = start; GncOwner owner, *ownerp; @@ -672,14 +665,14 @@ gnc_job_search_select (gpointer start, gpointer book) else gncOwnerInitCustomer (&owner, NULL); /* XXX */ - return gnc_job_search (start, &owner, book); + return gnc_job_search (parent, start, &owner, book); } GNCSearchWindow * -gnc_job_search_edit (gpointer start, gpointer book) +gnc_job_search_edit (GtkWindow *parent, gpointer start, gpointer book) { if (start) - gnc_ui_job_edit (start); + gnc_ui_job_edit (parent, start); return NULL; } diff --git a/gnucash/gnome/dialog-job.h b/gnucash/gnome/dialog-job.h index 40da5d8e23..4df562c3cc 100644 --- a/gnucash/gnome/dialog-job.h +++ b/gnucash/gnome/dialog-job.h @@ -32,13 +32,12 @@ typedef struct _job_window JobWindow; #include "dialog-search.h" /* Create or Edit a job */ -GncJob * gnc_ui_job_new_return_handle (GncOwner *owner, QofBook *book); -JobWindow * gnc_ui_job_edit (GncJob *job); -JobWindow * gnc_ui_job_new (GncOwner *owner, QofBook *book); +JobWindow * gnc_ui_job_edit (GtkWindow *parent, GncJob *job); +JobWindow * gnc_ui_job_new (GtkWindow *parent, GncOwner *owner, QofBook *book); /* Search for Jobs */ -GNCSearchWindow * gnc_job_search (GncJob *start, GncOwner *owner, - QofBook *book); +GNCSearchWindow * gnc_job_search (GtkWindow *parent, GncJob *start, + GncOwner *owner, QofBook *book); /* * These callbacks are for use with the gnc_general_search widget @@ -46,7 +45,7 @@ GNCSearchWindow * gnc_job_search (GncJob *start, GncOwner *owner, * select() provides a Select Dialog and returns it. * edit() opens the existing customer for editing and returns NULL. */ -GNCSearchWindow * gnc_job_search_select (gpointer start, gpointer book); -GNCSearchWindow * gnc_job_search_edit (gpointer start, gpointer book); +GNCSearchWindow * gnc_job_search_select (GtkWindow *parent, gpointer start, gpointer book); +GNCSearchWindow * gnc_job_search_edit (GtkWindow *parent, gpointer start, gpointer book); #endif /* GNC_DIALOG_JOB_H_ */ diff --git a/gnucash/gnome/dialog-new-user.c b/gnucash/gnome/dialog-new-user.c index bf5eaf2a0c..3cf6a9a462 100644 --- a/gnucash/gnome/dialog-new-user.c +++ b/gnucash/gnome/dialog-new-user.c @@ -67,7 +67,7 @@ after_hierarchy_assistant(void) gnc_set_first_startup (FALSE); qof_book_mark_session_dirty(gnc_get_current_book()); - gnc_ui_file_access_for_save_as(); + gnc_ui_file_access_for_save_as (gnc_ui_get_main_window (NULL)); } void diff --git a/gnucash/gnome/dialog-order.c b/gnucash/gnome/dialog-order.c index ab0d48017a..f2fd40099d 100644 --- a/gnucash/gnome/dialog-order.c +++ b/gnucash/gnome/dialog-order.c @@ -71,10 +71,10 @@ typedef enum struct _order_select_window { - QofBook * book; - GncOwner * owner; - QofQuery * q; - GncOwner owner_def; + QofBook *book; + GncOwner *owner; + QofQuery *q; + GncOwner owner_def; }; struct _order_window @@ -168,7 +168,7 @@ gnc_order_window_verify_ok (OrderWindow *ow) res = gtk_entry_get_text (GTK_ENTRY (ow->id_entry)); if (g_strcmp0 (res, "") == 0) { - gnc_error_dialog (ow->dialog, "%s", + gnc_error_dialog (GTK_WINDOW (ow->dialog), "%s", _("The Order must be given an ID.")); return FALSE; } @@ -178,7 +178,7 @@ gnc_order_window_verify_ok (OrderWindow *ow) res = gncOwnerGetName (&(ow->owner)); if (res == NULL || g_strcmp0 (res, "") == 0) { - gnc_error_dialog (ow->dialog, "%s", + gnc_error_dialog (GTK_WINDOW (ow->dialog), "%s", _("You need to supply Billing Information.")); return FALSE; } @@ -246,7 +246,7 @@ gnc_order_window_invoice_cb (GtkWidget *widget, gpointer data) return; /* Ok, go make an invoice */ - gnc_invoice_search (NULL, &(ow->owner), ow->book); + gnc_invoice_search (gtk_window_get_transient_for(GTK_WINDOW(ow->dialog)), NULL, &(ow->owner), ow->book); /* refresh the window */ gnc_order_update_window (ow); @@ -274,7 +274,7 @@ gnc_order_window_close_order_cb (GtkWidget *widget, gpointer data) /* Check that there is at least one Entry */ if (gncOrderGetEntries (order) == NULL) { - gnc_error_dialog (ow->dialog, "%s", + gnc_error_dialog (GTK_WINDOW (ow->dialog), "%s", _("The Order must have at least one Entry.")); return; } @@ -301,7 +301,7 @@ gnc_order_window_close_order_cb (GtkWidget *widget, gpointer data) "Are you sure you want to close it out before " "you invoice all the entries?"); - if (gnc_verify_dialog (ow->dialog, FALSE, "%s", message) == FALSE) + if (gnc_verify_dialog (GTK_WINDOW (ow->dialog), FALSE, "%s", message) == FALSE) return; } @@ -539,7 +539,7 @@ find_handler (gpointer find_data, gpointer user_data) } static OrderWindow * -gnc_order_new_window (QofBook *bookp, OrderDialogType type, +gnc_order_new_window (GtkWindow *parent, QofBook *bookp, OrderDialogType type, GncOrder *order, GncOwner *owner) { OrderWindow *ow; @@ -573,6 +573,7 @@ gnc_order_new_window (QofBook *bookp, OrderDialogType type, if (ow) { gtk_window_present (GTK_WINDOW(ow->dialog)); + gtk_window_set_transient_for (GTK_WINDOW(ow->dialog), parent); return(ow); } } @@ -591,6 +592,7 @@ gnc_order_new_window (QofBook *bookp, OrderDialogType type, builder = gtk_builder_new(); gnc_builder_add_from_file (builder, "dialog-order.glade", "order_entry_dialog"); ow->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "order_entry_dialog")); + gtk_window_set_transient_for (GTK_WINDOW(ow->dialog), parent); // Set the style context for this dialog so it can be easily manipulated with css gnc_widget_set_style_context (GTK_WIDGET(ow->dialog), "GncOrderDialog"); @@ -683,7 +685,7 @@ gnc_order_new_window (QofBook *bookp, OrderDialogType type, } static OrderWindow * -gnc_order_window_new_order (QofBook *bookp, GncOwner *owner) +gnc_order_window_new_order (GtkWindow *parent, QofBook *bookp, GncOwner *owner) { OrderWindow *ow; GtkBuilder *builder; @@ -706,6 +708,7 @@ gnc_order_window_new_order (QofBook *bookp, GncOwner *owner) gnc_builder_add_from_file (builder, "dialog-order.glade", "new_order_dialog"); ow->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "new_order_dialog")); + gtk_window_set_transient_for (GTK_WINDOW(ow->dialog), parent); // Set the style context for this dialog so it can be easily manipulated with css gnc_widget_set_style_context (GTK_WIDGET(ow->dialog), "GncOrderDialog"); @@ -759,7 +762,7 @@ gnc_order_window_new_order (QofBook *bookp, GncOwner *owner) } OrderWindow * -gnc_ui_order_edit (GncOrder *order) +gnc_ui_order_edit (GtkWindow *parent, GncOrder *order) { OrderWindow *ow; OrderDialogType type; @@ -773,14 +776,14 @@ gnc_ui_order_edit (GncOrder *order) type = VIEW_ORDER; } - ow = gnc_order_new_window (gncOrderGetBook(order), type, order, + ow = gnc_order_new_window (parent, gncOrderGetBook(order), type, order, gncOrderGetOwner (order)); return ow; } OrderWindow * -gnc_ui_order_new (GncOwner *ownerp, QofBook *bookp) +gnc_ui_order_new (GtkWindow *parent, GncOwner *ownerp, QofBook *bookp) { OrderWindow *ow; GncOwner owner; @@ -806,7 +809,7 @@ gnc_ui_order_new (GncOwner *ownerp, QofBook *bookp) /* Make sure required options exist */ if (!bookp) return NULL; - ow = gnc_order_window_new_order (bookp, &owner); + ow = gnc_order_window_new_order (parent, bookp, &owner); return ow; } @@ -814,7 +817,7 @@ gnc_ui_order_new (GncOwner *ownerp, QofBook *bookp) /* Functions for order selection widgets */ static void -edit_order_cb (gpointer *order_p, gpointer user_data) +edit_order_cb (GtkWindow *dialog, gpointer *order_p, gpointer user_data) { GncOrder *order; @@ -823,20 +826,20 @@ edit_order_cb (gpointer *order_p, gpointer user_data) order = *order_p; if (order) - gnc_ui_order_edit (order); + gnc_ui_order_edit (dialog, order); return; } static gpointer -new_order_cb (gpointer user_data) +new_order_cb (GtkWindow *dialog, gpointer user_data) { struct _order_select_window *sw = user_data; OrderWindow *ow; g_return_val_if_fail (user_data, NULL); - ow = gnc_ui_order_new (sw->owner, sw->book); + ow = gnc_ui_order_new (dialog, sw->owner, sw->book); return ow_get_order (ow); } @@ -852,7 +855,7 @@ free_order_cb (gpointer user_data) } GNCSearchWindow * -gnc_order_search (GncOrder *start, GncOwner *owner, QofBook *book) +gnc_order_search (GtkWindow *parent, GncOrder *start, GncOwner *owner, QofBook *book) { QofIdType type = GNC_ORDER_MODULE_NAME; struct _order_select_window *sw; @@ -950,7 +953,7 @@ gnc_order_search (GncOrder *start, GncOwner *owner, QofBook *book) sw->book = book; sw->q = q; - return gnc_search_dialog_create (type, _("Find Order"), + return gnc_search_dialog_create (parent, type, _("Find Order"), params, columns, q, q2, buttons, NULL, new_order_cb, sw, free_order_cb, GNC_PREFS_GROUP_SEARCH, @@ -958,7 +961,7 @@ gnc_order_search (GncOrder *start, GncOwner *owner, QofBook *book) } GNCSearchWindow * -gnc_order_search_select (gpointer start, gpointer book) +gnc_order_search_select (GtkWindow *parent, gpointer start, gpointer book) { GncOrder *o = start; GncOwner owner, *ownerp; @@ -973,14 +976,14 @@ gnc_order_search_select (gpointer start, gpointer book) else gncOwnerInitCustomer (&owner, NULL); /* XXX */ - return gnc_order_search (start, NULL, book); + return gnc_order_search (parent, start, NULL, book); } GNCSearchWindow * -gnc_order_search_edit (gpointer start, gpointer book) +gnc_order_search_edit (GtkWindow *parent, gpointer start, gpointer book) { if (start) - gnc_ui_order_edit (start); + gnc_ui_order_edit (parent, start); return NULL; } diff --git a/gnucash/gnome/dialog-order.h b/gnucash/gnome/dialog-order.h index 2398235e1c..3c9eace267 100644 --- a/gnucash/gnome/dialog-order.h +++ b/gnucash/gnome/dialog-order.h @@ -32,11 +32,11 @@ typedef struct _order_window OrderWindow; #include "dialog-search.h" /* Create and edit an order */ -OrderWindow * gnc_ui_order_edit (GncOrder *order); -OrderWindow * gnc_ui_order_new (GncOwner *owner, QofBook *book); +OrderWindow * gnc_ui_order_edit (GtkWindow *parent, GncOrder *order); +OrderWindow * gnc_ui_order_new (GtkWindow *parent, GncOwner *owner, QofBook *book); /* Search for orders */ -GNCSearchWindow * gnc_order_search (GncOrder *start, GncOwner *owner, +GNCSearchWindow * gnc_order_search (GtkWindow *parent, GncOrder *start, GncOwner *owner, QofBook *book); /* @@ -45,7 +45,7 @@ GNCSearchWindow * gnc_order_search (GncOrder *start, GncOwner *owner, * select() provides a Select Dialog and returns it. * edit() opens the existing order for editing and returns NULL. */ -GNCSearchWindow * gnc_order_search_select (gpointer start, gpointer book); -GNCSearchWindow * gnc_order_search_edit (gpointer start, gpointer book); +GNCSearchWindow * gnc_order_search_select (GtkWindow *parent, gpointer start, gpointer book); +GNCSearchWindow * gnc_order_search_edit (GtkWindow *parent, gpointer start, gpointer book); #endif /* GNC_DIALOG_ORDER_H_ */ diff --git a/gnucash/gnome/dialog-payment.c b/gnucash/gnome/dialog-payment.c index b78d2c8455..e11d07ad97 100644 --- a/gnucash/gnome/dialog-payment.c +++ b/gnucash/gnome/dialog-payment.c @@ -954,7 +954,7 @@ gnc_payment_ok_cb (G_GNUC_UNUSED GtkWidget *widget, gpointer data) text = _("The transfer and post accounts are associated with different currencies. Please specify the conversion rate."); xfer = gnc_xfer_dialog(pw->dialog, pw->post_acct); - gnc_info_dialog(pw->dialog, "%s", text); + gnc_info_dialog (GTK_WINDOW (pw->dialog), "%s", text); gnc_xfer_dialog_select_to_account(xfer, pw->xfer_acct); gnc_xfer_dialog_set_amount(xfer, pw->amount_tot); @@ -1117,7 +1117,7 @@ static void print_date (G_GNUC_UNUSED GtkTreeViewColumn *tree_column, } static PaymentWindow * -new_payment_window (GtkWidget *parent, QofBook *book, InitialPaymentInfo *tx_info) +new_payment_window (GtkWindow *parent, QofBook *book, InitialPaymentInfo *tx_info) { PaymentWindow *pw; GtkBuilder *builder; @@ -1154,6 +1154,7 @@ new_payment_window (GtkWidget *parent, QofBook *book, InitialPaymentInfo *tx_inf gncOwnerCopy (&pw->tx_info->owner, &(pw->owner)); gnc_payment_set_owner_type (pw, gncOwnerGetType(&pw->tx_info->owner)); + gtk_window_set_transient_for (GTK_WINDOW(pw->dialog), parent); gtk_window_present (GTK_WINDOW(pw->dialog)); return(pw); } @@ -1173,6 +1174,7 @@ new_payment_window (GtkWidget *parent, QofBook *book, InitialPaymentInfo *tx_inf gnc_builder_add_from_file (builder, "dialog-payment.glade", "owner_type_combo_model"); gnc_builder_add_from_file (builder, "dialog-payment.glade", "payment_dialog"); pw->dialog = GTK_WIDGET (gtk_builder_get_object (builder, "payment_dialog")); + gtk_window_set_transient_for (GTK_WINDOW(pw->dialog), parent); // Set the style context for this dialog so it can be easily manipulated with css gnc_widget_set_style_context (GTK_WIDGET(pw->dialog), "GncPaymentDialog"); @@ -1341,7 +1343,7 @@ new_payment_window (GtkWidget *parent, QofBook *book, InitialPaymentInfo *tx_inf * Let's assert this to protect from potential future changes. */ g_assert (g_list_length (pw->acct_types) == 1); acct_type = xaccAccountGetTypeStr(GPOINTER_TO_INT(pw->acct_types->data)); - gnc_warning_dialog(pw->dialog, + gnc_warning_dialog(GTK_WINDOW (pw->dialog), _("You have no valid \"Post To\" accounts. " "Please create an account of type \"%s\" " "before you continue to process this payment. " @@ -1364,8 +1366,8 @@ gnc_ui_payment_window_destroy (PaymentWindow *pw) } PaymentWindow * -gnc_ui_payment_new_with_invoice (const GncOwner *owner, QofBook *book, - GncInvoice *invoice) +gnc_ui_payment_new_with_invoice (GtkWindow *parent, const GncOwner *owner, + QofBook *book, GncInvoice *invoice) { GNCLot *postlot; InitialPaymentInfo *tx_info; @@ -1395,13 +1397,13 @@ gnc_ui_payment_new_with_invoice (const GncOwner *owner, QofBook *book, lot_info->amount = gnc_numeric_zero (); tx_info->lots = g_list_prepend (tx_info->lots, lot_info); } - return new_payment_window (NULL, book, tx_info); + return new_payment_window (parent, book, tx_info); } PaymentWindow * -gnc_ui_payment_new (GncOwner *owner, QofBook *book) +gnc_ui_payment_new (GtkWindow *parent, GncOwner *owner, QofBook *book) { - return gnc_ui_payment_new_with_invoice (owner, book, NULL); + return gnc_ui_payment_new_with_invoice (parent, owner, book, NULL); } // /////////////// @@ -1477,7 +1479,7 @@ static char *gen_split_desc (Transaction *txn, Split *split) return split_str; } -static Split *select_payment_split (GtkWidget *parent, Transaction *txn) +static Split *select_payment_split (GtkWindow *parent, Transaction *txn) { /* We require the txn to have one split in an Asset account. * The only exception would be a lot link transaction @@ -1490,7 +1492,7 @@ static Split *select_payment_split (GtkWidget *parent, Transaction *txn) if (xaccTransGetTxnType(txn) == TXN_TYPE_LINK) return NULL; - dialog = gtk_message_dialog_new (GTK_WINDOW(parent), + dialog = gtk_message_dialog_new (parent, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, @@ -1513,7 +1515,7 @@ static Split *select_payment_split (GtkWidget *parent, Transaction *txn) "Please select one, the others will be ignored.\n\n"); GtkDialog *dialog = GTK_DIALOG( gtk_dialog_new_with_buttons (_("Warning"), - GTK_WINDOW(parent), + parent, GTK_DIALOG_DESTROY_WITH_PARENT, _("Continue"), GTK_BUTTONS_OK, _("Cancel"), GTK_BUTTONS_CANCEL, @@ -1569,7 +1571,7 @@ static Split *select_payment_split (GtkWidget *parent, Transaction *txn) return payment_splits->data; } -static GList *select_txn_lots (GtkWidget *parent, Transaction *txn, Account **post_acct, gboolean *abort) +static GList *select_txn_lots (GtkWindow *parent, Transaction *txn, Account **post_acct, gboolean *abort) { gboolean has_no_lot_apar_splits = FALSE; SplitList *post_splits = NULL, *no_lot_post_splits = NULL; @@ -1624,7 +1626,7 @@ static GList *select_txn_lots (GtkWidget *parent, Transaction *txn, Account **po split_str = tmp_str2; } - dialog = gtk_message_dialog_new (GTK_WINDOW(parent), + dialog = gtk_message_dialog_new (parent, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_CANCEL, @@ -1648,7 +1650,7 @@ static GList *select_txn_lots (GtkWidget *parent, Transaction *txn, Account **po return txn_lots; } -PaymentWindow * gnc_ui_payment_new_with_txn (GtkWidget* parent, GncOwner *owner, Transaction *txn) +PaymentWindow * gnc_ui_payment_new_with_txn (GtkWindow* parent, GncOwner *owner, Transaction *txn) { Split *payment_split = NULL; Account *post_acct = NULL; @@ -1682,7 +1684,7 @@ PaymentWindow * gnc_ui_payment_new_with_txn (GtkWidget* parent, GncOwner *owner, tx_info->lots = txn_lots; gncOwnerCopy (owner, &tx_info->owner); - pw = new_payment_window (NULL, + pw = new_payment_window (parent, qof_instance_get_book(QOF_INSTANCE(txn)), tx_info); diff --git a/gnucash/gnome/dialog-payment.h b/gnucash/gnome/dialog-payment.h index 49113daed7..9927f6325b 100644 --- a/gnucash/gnome/dialog-payment.h +++ b/gnucash/gnome/dialog-payment.h @@ -30,11 +30,12 @@ typedef struct _payment_window PaymentWindow; #include "gncInvoice.h" /* Create a payment window */ -PaymentWindow * gnc_ui_payment_new (GncOwner *owner, QofBook *book); -PaymentWindow * gnc_ui_payment_new_with_invoice (const GncOwner *owner, - QofBook *book, - GncInvoice *invoice); -PaymentWindow * gnc_ui_payment_new_with_txn (GtkWidget *parent, GncOwner *owner, Transaction *txn); +PaymentWindow * gnc_ui_payment_new (GtkWindow *parent, GncOwner *owner, QofBook *book); +PaymentWindow * gnc_ui_payment_new_with_invoice (GtkWindow *parent, + const GncOwner *owner, + QofBook *book, + GncInvoice *invoice); +PaymentWindow * gnc_ui_payment_new_with_txn (GtkWindow *parent, GncOwner *owner, Transaction *txn); /** Returns TRUE if the given transaction (to be used with gnc_ui_payment_new_with_txn() ) * is for a customer, or FALSE if it's from a vendor or employee voucher. */ diff --git a/gnucash/gnome/dialog-price-edit-db.c b/gnucash/gnome/dialog-price-edit-db.c index a3c1630a8d..f6d5efb695 100644 --- a/gnucash/gnome/dialog-price-edit-db.c +++ b/gnucash/gnome/dialog-price-edit-db.c @@ -452,7 +452,7 @@ gnc_prices_dialog_remove_old_clicked (GtkWidget *widget, gpointer data) GList *comm_list = gnc_prices_dialog_get_commodities (pdb_dialog->remove_view); // Are you sure you want to delete the entries and we have commodities - if ((g_list_length (comm_list) != 0) && (gnc_verify_dialog (pdb_dialog->remove_dialog, FALSE, fmt, NULL))) + if ((g_list_length (comm_list) != 0) && (gnc_verify_dialog (GTK_WINDOW (pdb_dialog->remove_dialog), FALSE, fmt, NULL))) { Timespec last_ts; GDate fiscal_end_date = get_fiscal_end_date (); @@ -550,7 +550,7 @@ gnc_prices_dialog_get_quotes_clicked (GtkWidget *widget, gpointer data) } scm_window = SWIG_NewPointerObj(pdb_dialog->dialog, - SWIG_TypeQuery("_p_GtkWidget"), 0); + SWIG_TypeQuery("_p_GtkWindow"), 0); gnc_set_busy_cursor (NULL, TRUE); scm_call_2 (quotes_func, scm_window, book_scm); diff --git a/gnucash/gnome/dialog-price-editor.c b/gnucash/gnome/dialog-price-editor.c index 9a55f03de8..a787284f1b 100644 --- a/gnucash/gnome/dialog-price-editor.c +++ b/gnucash/gnome/dialog-price-editor.c @@ -279,7 +279,7 @@ pedit_dialog_response_cb (GtkDialog *dialog, gint response, gpointer data) error_str = gui_to_price (pedit_dialog); if (error_str) { - gnc_warning_dialog (pedit_dialog->dialog, "%s", error_str); + gnc_warning_dialog (GTK_WINDOW (pedit_dialog->dialog), "%s", error_str); return; } diff --git a/gnucash/gnome/dialog-sx-editor.c b/gnucash/gnome/dialog-sx-editor.c index 33b1bae53e..61e246a0ce 100644 --- a/gnucash/gnome/dialog-sx-editor.c +++ b/gnucash/gnome/dialog-sx-editor.c @@ -200,7 +200,7 @@ sxed_confirmed_cancel(GncSxEditorDialog *sxed) const char *sx_changed_msg = _( "This Scheduled Transaction has changed; are you " "sure you want to cancel?" ); - if (!gnc_verify_dialog(sxed->dialog, FALSE, "%s", sx_changed_msg)) + if (!gnc_verify_dialog (GTK_WINDOW (sxed->dialog), FALSE, "%s", sx_changed_msg)) { return FALSE; } @@ -490,7 +490,7 @@ gnc_sxed_check_names (GncSxEditorDialog *sxed) { const char *sx_has_no_name_msg = _( "Please name the Scheduled Transaction." ); - gnc_error_dialog( sxed->dialog, "%s", sx_has_no_name_msg ); + gnc_error_dialog (GTK_WINDOW (sxed->dialog), "%s", sx_has_no_name_msg ); g_free( name ); return FALSE; @@ -517,7 +517,7 @@ gnc_sxed_check_names (GncSxEditorDialog *sxed) const char *sx_has_existing_name_msg = _("A Scheduled Transaction with the name \"%s\" already exists. " "Are you sure you want to name this one the same?"); - if (!gnc_verify_dialog (sxed->dialog, FALSE, + if (!gnc_verify_dialog (GTK_WINDOW (sxed->dialog), FALSE, sx_has_existing_name_msg, name)) { g_free (name); @@ -540,7 +540,7 @@ gnc_sxed_check_endpoint (GncSxEditorDialog *sxed) { const char *sx_end_spec_msg = _("Please provide a valid end selection."); - gnc_error_dialog (sxed->dialog, "%s", sx_end_spec_msg); + gnc_error_dialog (GTK_WINDOW (sxed->dialog), "%s", sx_end_spec_msg); return FALSE; } @@ -555,7 +555,7 @@ gnc_sxed_check_endpoint (GncSxEditorDialog *sxed) { const char *sx_occur_count_zero_msg = _("There must be some number of occurrences."); - gnc_error_dialog (sxed->dialog, "%s", sx_occur_count_zero_msg); + gnc_error_dialog (GTK_WINDOW (sxed->dialog), "%s", sx_occur_count_zero_msg); return FALSE; } @@ -564,7 +564,7 @@ gnc_sxed_check_endpoint (GncSxEditorDialog *sxed) const char *sx_occur_counts_wrong_msg = _("The number of remaining occurrences (%d) is greater than " "the number of total occurrences (%d)."); - gnc_error_dialog (sxed->dialog, sx_occur_counts_wrong_msg, + gnc_error_dialog (GTK_WINDOW (sxed->dialog), sx_occur_counts_wrong_msg, rem, occur); return FALSE; } @@ -593,7 +593,7 @@ gnc_sxed_check_endpoint (GncSxEditorDialog *sxed) const char *invalid_sx_check_msg = _("You have attempted to create a Scheduled Transaction which " "will never run. Do you really want to do this?"); - if (!gnc_verify_dialog(sxed->dialog, FALSE, + if (!gnc_verify_dialog (GTK_WINDOW (sxed->dialog), FALSE, "%s", invalid_sx_check_msg)) return FALSE; } @@ -612,7 +612,7 @@ gnc_sxed_check_autocreate (GncSxEditorDialog *sxed, int ttVarCount, if (((ttVarCount > 0) || multi_commodity) && autocreateState) { - gnc_warning_dialog(sxed->dialog, "%s", + gnc_warning_dialog(GTK_WINDOW (sxed->dialog), "%s", _("Scheduled Transactions with variables " "or involving more than one commodity " "cannot be automatically created.")); @@ -623,7 +623,7 @@ gnc_sxed_check_autocreate (GncSxEditorDialog *sxed, int ttVarCount, * only valid if there's actually a transaction to create. */ if (autocreateState && splitCount == 0) { - gnc_warning_dialog(sxed->dialog, "%s", + gnc_warning_dialog(GTK_WINDOW (sxed->dialog), "%s", _("Scheduled Transactions without a template " "transaction cannot be automatically created.") ); return FALSE; @@ -672,7 +672,7 @@ gnc_sxed_split_calculate_formula (GncSxEditorDialog *sxed, Split *s, { gchar *err = g_strdup_printf (_("Couldn't parse %s for split \"%s\"."), key, xaccSplitGetMemo (s)); - gnc_error_dialog (GTK_WIDGET(sxed->dialog), "%s", err); + gnc_error_dialog (GTK_WINDOW (sxed->dialog), "%s", err); g_free (err); return FALSE; @@ -870,7 +870,7 @@ gnc_sxed_check_consistent( GncSxEditorDialog *sxed ) const char *msg = _("The Scheduled Transaction Editor cannot automatically " "balance this transaction. Should it still be entered?"); - if (!gnc_verify_dialog (sxed->dialog, FALSE, "%s", msg)) + if (!gnc_verify_dialog (GTK_WINDOW (sxed->dialog), FALSE, "%s", msg)) return FALSE; } @@ -1557,7 +1557,7 @@ gnc_sxed_reg_check_close(GncSxEditorDialog *sxed) return; } - if (gnc_verify_dialog(sxed->dialog, TRUE, "%s", message)) + if (gnc_verify_dialog (GTK_WINDOW (sxed->dialog), TRUE, "%s", message)) { if ( !gnc_split_register_save( reg, TRUE ) ) return; diff --git a/gnucash/gnome/dialog-sx-editor2.c b/gnucash/gnome/dialog-sx-editor2.c index f243e76a4e..333da7ff40 100644 --- a/gnucash/gnome/dialog-sx-editor2.c +++ b/gnucash/gnome/dialog-sx-editor2.c @@ -198,7 +198,7 @@ sxed_confirmed_cancel (GncSxEditorDialog2 *sxed) const char *sx_changed_msg = _( "This Scheduled Transaction has changed; are you " "sure you want to cancel?" ); - if (!gnc_verify_dialog (sxed->dialog, FALSE, "%s", sx_changed_msg)) + if (!gnc_verify_dialog (GTK_WINDOW (sxed->dialog), FALSE, "%s", sx_changed_msg)) { return FALSE; } @@ -636,7 +636,7 @@ gnc_sxed_check_consistent (GncSxEditorDialog2 *sxed) _( "Couldn't parse credit formula for " "split \"%s\"." ), xaccSplitGetMemo( s ) ); - gnc_error_dialog( GTK_WIDGET(sxed->dialog), "%s", + gnc_error_dialog (GTK_WINDOW (sxed->dialog), "%s", errStr->str ); g_string_free( errStr, TRUE ); @@ -658,7 +658,7 @@ gnc_sxed_check_consistent (GncSxEditorDialog2 *sxed) _( "Couldn't parse debit formula for " "split \"%s\"." ), xaccSplitGetMemo( s ) ); - gnc_error_dialog( GTK_WIDGET(sxed->dialog), "%s", + gnc_error_dialog (GTK_WINDOW (sxed->dialog), "%s", (gchar*)errStr->str ); g_string_free( errStr, TRUE ); @@ -686,7 +686,7 @@ gnc_sxed_check_consistent (GncSxEditorDialog2 *sxed) g_hash_table_destroy (txns); if (unbalanceable - && !gnc_verify_dialog (sxed->dialog, FALSE, + && !gnc_verify_dialog (GTK_WINDOW (sxed->dialog), FALSE, "%s", _("The Scheduled Transaction Editor " "cannot automatically balance " @@ -710,7 +710,7 @@ gnc_sxed_check_consistent (GncSxEditorDialog2 *sxed) { const char *sx_has_no_name_msg = _("Please name the Scheduled Transaction."); - gnc_error_dialog (sxed->dialog, "%s", sx_has_no_name_msg); + gnc_error_dialog (GTK_WINDOW (sxed->dialog), "%s", sx_has_no_name_msg); g_free (name); return FALSE; @@ -740,7 +740,7 @@ gnc_sxed_check_consistent (GncSxEditorDialog2 *sxed) "name \"%s\" already exists. " "Are you sure you want to name " "this one the same?"); - if (!gnc_verify_dialog (sxed->dialog, FALSE, + if (!gnc_verify_dialog (GTK_WINDOW (sxed->dialog), FALSE, sx_has_existing_name_msg, name)) { @@ -763,7 +763,7 @@ gnc_sxed_check_consistent (GncSxEditorDialog2 *sxed) if (((ttVarCount > 0) || multi_commodity) && autocreateState) { - gnc_warning_dialog (sxed->dialog, "%s", + gnc_warning_dialog (GTK_WINDOW (sxed->dialog), "%s", _("Scheduled Transactions with variables " "cannot be automatically created.")); return FALSE; @@ -773,7 +773,7 @@ gnc_sxed_check_consistent (GncSxEditorDialog2 *sxed) * only valid if there's actually a transaction to create. */ if (autocreateState && splitCount == 0) { - gnc_warning_dialog (sxed->dialog, "%s", + gnc_warning_dialog (GTK_WINDOW (sxed->dialog), "%s", _("Scheduled Transactions without a template " "transaction cannot be automatically created.")); return FALSE; @@ -790,7 +790,7 @@ gnc_sxed_check_consistent (GncSxEditorDialog2 *sxed) { const char *sx_end_spec_msg = _("Please provide a valid end selection."); - gnc_error_dialog (sxed->dialog, "%s", sx_end_spec_msg); + gnc_error_dialog (GTK_WINDOW (sxed->dialog), "%s", sx_end_spec_msg); return FALSE; } @@ -808,7 +808,7 @@ gnc_sxed_check_consistent (GncSxEditorDialog2 *sxed) { const char *sx_occur_count_zero_msg = _("There must be some number of occurrences."); - gnc_error_dialog (sxed->dialog, "%s", + gnc_error_dialog (GTK_WINDOW (sxed->dialog), "%s", sx_occur_count_zero_msg); return FALSE; } @@ -819,7 +819,7 @@ gnc_sxed_check_consistent (GncSxEditorDialog2 *sxed) _("The number of remaining occurrences " "(%d) is greater than the number of " "total occurrences (%d)."); - gnc_error_dialog (sxed->dialog, + gnc_error_dialog (GTK_WINDOW (sxed->dialog), sx_occur_counts_wrong_msg, rem, occur); return FALSE; @@ -851,7 +851,7 @@ gnc_sxed_check_consistent (GncSxEditorDialog2 *sxed) _("You have attempted to create a Scheduled " "Transaction which will never run. Do you " "really want to do this?"); - if (!gnc_verify_dialog (sxed->dialog, FALSE, + if (!gnc_verify_dialog (GTK_WINDOW (sxed->dialog), FALSE, "%s", invalid_sx_check_msg)) return FALSE; } @@ -1521,7 +1521,7 @@ gnc_sxed_reg_check_close (GncSxEditorDialog2 *sxed) if (dirty_trans == NULL) return; - if (gnc_verify_dialog (sxed->dialog, TRUE, "%s", message)) + if (gnc_verify_dialog (GTK_WINDOW (sxed->dialog), TRUE, "%s", message)) { /* Save the template transactions changes */ xaccTransCommitEdit (dirty_trans); diff --git a/gnucash/gnome/dialog-sx-from-trans.c b/gnucash/gnome/dialog-sx-from-trans.c index 4ca974df54..f300b1e7f1 100644 --- a/gnucash/gnome/dialog-sx-from-trans.c +++ b/gnucash/gnome/dialog-sx-from-trans.c @@ -256,7 +256,7 @@ sxftd_add_template_trans(SXFromTransInfo *sxfti) } if ( ! gnc_numeric_zero_p( runningBalance ) - && !gnc_verify_dialog( (GtkWidget *)sxfti->dialog, + && !gnc_verify_dialog (GTK_WINDOW (sxfti->dialog), FALSE, "%s", _("The Scheduled Transaction Editor " "cannot automatically balance " @@ -553,7 +553,7 @@ sxftd_ok_clicked(SXFromTransInfo *sxfti) { if ( sx_error == SXFTD_ERRNO_UNBALANCED_XACTION ) { - gnc_error_dialog( gnc_ui_get_toplevel(), "%s", + gnc_error_dialog (GTK_WINDOW (sxfti->dialog), "%s", _( "The Scheduled Transaction is unbalanced. " "You are strongly encouraged to correct this situation." ) ); } @@ -781,7 +781,7 @@ gnc_sx_create_from_trans( Transaction *trans ) { if ( errno == SXFTD_ERRNO_OPEN_XACTION ) { - gnc_error_dialog( gnc_ui_get_toplevel(), "%s", + gnc_error_dialog (NULL, "%s", _( "Cannot create a Scheduled Transaction " "from a Transaction currently " "being edited. Please Enter the " diff --git a/gnucash/gnome/dialog-sx-since-last-run.c b/gnucash/gnome/dialog-sx-since-last-run.c index a3889a21ef..7486daf647 100644 --- a/gnucash/gnome/dialog-sx-since-last-run.c +++ b/gnucash/gnome/dialog-sx-since-last-run.c @@ -41,6 +41,7 @@ #include "dialog-sx-since-last-run.h" #include "gnc-prefs.h" +#include "gnc-ui.h" #include "gnc-ui-util.h" #include "Query.h" #include "qof.h" @@ -847,7 +848,7 @@ gnc_sx_sxsincelast_book_opened(void) if (summary.need_dialog) { - gnc_ui_sx_since_last_run_dialog(inst_model, auto_created_txns); + gnc_ui_sx_since_last_run_dialog (gnc_ui_get_main_window (NULL), inst_model, auto_created_txns); auto_created_txns = NULL; } else @@ -858,7 +859,7 @@ gnc_sx_sxsincelast_book_opened(void) return; gnc_info_dialog - (NULL, + (gnc_ui_get_main_window (NULL), ngettext ("There are no Scheduled Transactions to be entered at this time. " "(One transaction automatically created)", @@ -959,7 +960,7 @@ variable_value_changed_cb(GtkCellRendererText *cell, } GncSxSinceLastRunDialog* -gnc_ui_sx_since_last_run_dialog(GncSxInstanceModel *sx_instances, GList *auto_created_txn_guids) +gnc_ui_sx_since_last_run_dialog (GtkWindow *parent, GncSxInstanceModel *sx_instances, GList *auto_created_txn_guids) { GncSxSinceLastRunDialog *dialog; GtkBuilder *builder; @@ -970,6 +971,7 @@ gnc_ui_sx_since_last_run_dialog(GncSxInstanceModel *sx_instances, GList *auto_cr gnc_builder_add_from_file (builder, "dialog-sx.glade", "since_last_run_dialog"); dialog->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "since_last_run_dialog")); + gtk_window_set_transient_for (GTK_WINDOW (dialog->dialog), parent); // Set the style context for this dialog so it can be easily manipulated with css gnc_widget_set_style_context (GTK_WIDGET(dialog->dialog), "GncSxSinceLastRunDialog"); diff --git a/gnucash/gnome/dialog-sx-since-last-run.h b/gnucash/gnome/dialog-sx-since-last-run.h index 2b7a5f7147..e94a355c0c 100644 --- a/gnucash/gnome/dialog-sx-since-last-run.h +++ b/gnucash/gnome/dialog-sx-since-last-run.h @@ -47,7 +47,7 @@ void gnc_sx_sxsincelast_book_opened(void); /** * Create the since-last-run dialog. **/ -GncSxSinceLastRunDialog* gnc_ui_sx_since_last_run_dialog(GncSxInstanceModel *sx_instances, +GncSxSinceLastRunDialog* gnc_ui_sx_since_last_run_dialog (GtkWindow *parent, GncSxInstanceModel *sx_instances, GList *auto_created_txn_guids); #endif diff --git a/gnucash/gnome/dialog-trans-assoc.c b/gnucash/gnome/dialog-trans-assoc.c index 372a274738..f5d865834e 100644 --- a/gnucash/gnome/dialog-trans-assoc.c +++ b/gnucash/gnome/dialog-trans-assoc.c @@ -272,7 +272,8 @@ row_selected_cb (GtkTreeView *view, GtkTreePath *path, g_free (uri_scheme); } else - gnc_error_dialog (NULL, "%s", _("This transaction is not associated with a valid URI.")); + gnc_error_dialog (gnc_ui_get_gtk_window(GTK_WIDGET (view)), + "%s", _("This transaction is not associated with a valid URI.")); } // Open transaction diff --git a/gnucash/gnome/dialog-vendor.c b/gnucash/gnome/dialog-vendor.c index d7e1d7d3af..9d48ea8759 100644 --- a/gnucash/gnome/dialog-vendor.c +++ b/gnucash/gnome/dialog-vendor.c @@ -70,8 +70,8 @@ typedef enum struct _vendor_select_window { - QofBook * book; - QofQuery * q; + QofBook *book; + QofQuery *q; }; struct _vendor_window @@ -190,14 +190,14 @@ static void gnc_ui_to_vendor (VendorWindow *vw, GncVendor *vendor) gnc_resume_gui_refresh (); } -static gboolean check_entry_nonempty (GtkWidget *dialog, GtkWidget *entry, +static gboolean check_entry_nonempty (GtkWidget *entry, const char * error_message) { const char *res = gtk_entry_get_text (GTK_ENTRY (entry)); if (g_strcmp0 (res, "") == 0) { if (error_message) - gnc_error_dialog (dialog, "%s", error_message); + gnc_error_dialog (gnc_ui_get_gtk_window (entry), "%s", error_message); return TRUE; } return FALSE; @@ -210,7 +210,7 @@ gnc_vendor_window_ok_cb (GtkWidget *widget, gpointer data) gchar *string; /* Check for valid company name */ - if (check_entry_nonempty (vw->dialog, vw->company_entry, + if (check_entry_nonempty (vw->company_entry, _("You must enter a company name. " "If this vendor is an individual (and not a company) " "you should enter the same value for:\nIdentification " @@ -218,13 +218,13 @@ gnc_vendor_window_ok_cb (GtkWidget *widget, gpointer data) return; /* Make sure we have an address */ - if (check_entry_nonempty (vw->dialog, vw->addr1_entry, NULL) && - check_entry_nonempty (vw->dialog, vw->addr2_entry, NULL) && - check_entry_nonempty (vw->dialog, vw->addr3_entry, NULL) && - check_entry_nonempty (vw->dialog, vw->addr4_entry, NULL)) + if (check_entry_nonempty (vw->addr1_entry, NULL) && + check_entry_nonempty (vw->addr2_entry, NULL) && + check_entry_nonempty (vw->addr3_entry, NULL) && + check_entry_nonempty (vw->addr4_entry, NULL)) { const char *msg = _("You must enter a payment address."); - gnc_error_dialog (vw->dialog, "%s", msg); + gnc_error_dialog (gnc_ui_get_gtk_window (widget), "%s", msg); return; } @@ -395,7 +395,7 @@ find_handler (gpointer find_data, gpointer user_data) } static VendorWindow * -gnc_vendor_new_window (QofBook *bookp, GncVendor *vendor) +gnc_vendor_new_window (GtkWindow *parent, QofBook *bookp, GncVendor *vendor) { VendorWindow *vw; GtkBuilder *builder; @@ -415,6 +415,7 @@ gnc_vendor_new_window (QofBook *bookp, GncVendor *vendor) find_handler, &vendor_guid); if (vw) { + gtk_window_set_transient_for (GTK_WINDOW(vw->dialog), parent); gtk_window_present (GTK_WINDOW(vw->dialog)); return(vw); } @@ -440,6 +441,7 @@ gnc_vendor_new_window (QofBook *bookp, GncVendor *vendor) gnc_builder_add_from_file (builder, "dialog-vendor.glade", "taxtable_store"); gnc_builder_add_from_file (builder, "dialog-vendor.glade", "vendor_dialog"); vw->dialog = GTK_WIDGET (gtk_builder_get_object (builder, "vendor_dialog")); + gtk_window_set_transient_for (GTK_WINDOW(vw->dialog), parent); // Set the style context for this dialog so it can be easily manipulated with css gnc_widget_set_style_context (GTK_WIDGET(vw->dialog), "GncVendorDialog"); @@ -559,25 +561,25 @@ gnc_vendor_new_window (QofBook *bookp, GncVendor *vendor) } VendorWindow * -gnc_ui_vendor_new (QofBook *bookp) +gnc_ui_vendor_new (GtkWindow *parent, QofBook *bookp) { VendorWindow *vw; /* Make sure required options exist */ if (!bookp) return NULL; - vw = gnc_vendor_new_window (bookp, NULL); + vw = gnc_vendor_new_window (parent, bookp, NULL); return vw; } VendorWindow * -gnc_ui_vendor_edit (GncVendor *vendor) +gnc_ui_vendor_edit (GtkWindow *parent, GncVendor *vendor) { VendorWindow *vw; if (!vendor) return NULL; - vw = gnc_vendor_new_window (gncVendorGetBook(vendor), vendor); + vw = gnc_vendor_new_window (parent, gncVendorGetBook(vendor), vendor); return vw; } @@ -585,7 +587,7 @@ gnc_ui_vendor_edit (GncVendor *vendor) /* Functions for vendor selection widgets */ static void -invoice_vendor_cb (gpointer *vendor_p, gpointer user_data) +invoice_vendor_cb (GtkWindow *dialog, gpointer *vendor_p, gpointer user_data) { struct _vendor_select_window *sw = user_data; GncOwner owner; @@ -599,12 +601,12 @@ invoice_vendor_cb (gpointer *vendor_p, gpointer user_data) return; gncOwnerInitVendor (&owner, vendor); - gnc_invoice_search (NULL, &owner, sw->book); + gnc_invoice_search (dialog, NULL, &owner, sw->book); return; } static void -order_vendor_cb (gpointer *vendor_p, gpointer user_data) +order_vendor_cb (GtkWindow *dialog, gpointer *vendor_p, gpointer user_data) { struct _vendor_select_window *sw = user_data; GncOwner owner; @@ -618,12 +620,12 @@ order_vendor_cb (gpointer *vendor_p, gpointer user_data) return; gncOwnerInitVendor (&owner, vendor); - gnc_order_search (NULL, &owner, sw->book); + gnc_order_search (dialog, NULL, &owner, sw->book); return; } static void -jobs_vendor_cb (gpointer *vendor_p, gpointer user_data) +jobs_vendor_cb (GtkWindow *dialog, gpointer *vendor_p, gpointer user_data) { struct _vendor_select_window *sw = user_data; GncOwner owner; @@ -637,12 +639,12 @@ jobs_vendor_cb (gpointer *vendor_p, gpointer user_data) return; gncOwnerInitVendor (&owner, vendor); - gnc_job_search (NULL, &owner, sw->book); + gnc_job_search (dialog, NULL, &owner, sw->book); return; } static void -payment_vendor_cb (gpointer *vendor_p, gpointer user_data) +payment_vendor_cb (GtkWindow *dialog, gpointer *vendor_p, gpointer user_data) { struct _vendor_select_window *sw = user_data; GncOwner owner; @@ -656,12 +658,12 @@ payment_vendor_cb (gpointer *vendor_p, gpointer user_data) return; gncOwnerInitVendor (&owner, vendor); - gnc_ui_payment_new (&owner, sw->book); + gnc_ui_payment_new (dialog, &owner, sw->book); return; } static void -edit_vendor_cb (gpointer *vendor_p, gpointer user_data) +edit_vendor_cb (GtkWindow *dialog, gpointer *vendor_p, gpointer user_data) { GncVendor *vendor; @@ -672,19 +674,19 @@ edit_vendor_cb (gpointer *vendor_p, gpointer user_data) if (!vendor) return; - gnc_ui_vendor_edit (vendor); + gnc_ui_vendor_edit (dialog, vendor); return; } static gpointer -new_vendor_cb (gpointer user_data) +new_vendor_cb (GtkWindow *dialog, gpointer user_data) { struct _vendor_select_window *sw = user_data; VendorWindow *vw; g_return_val_if_fail (user_data, NULL); - vw = gnc_ui_vendor_new (sw->book); + vw = gnc_ui_vendor_new (dialog, sw->book); return vw_get_vendor (vw); } @@ -699,7 +701,7 @@ free_vendor_cb (gpointer user_data) } GNCSearchWindow * -gnc_vendor_search (GncVendor *start, QofBook *book) +gnc_vendor_search (GtkWindow *parent, GncVendor *start, QofBook *book) { QofIdType type = GNC_VENDOR_MODULE_NAME; struct _vendor_select_window *sw; @@ -759,7 +761,7 @@ gnc_vendor_search (GncVendor *start, QofBook *book) sw->book = book; sw->q = q; - return gnc_search_dialog_create (type, _("Find Vendor"), + return gnc_search_dialog_create (parent, type, _("Find Vendor"), params, columns, q, q2, buttons, NULL, new_vendor_cb, sw, free_vendor_cb, GNC_PREFS_GROUP_SEARCH, NULL, @@ -767,18 +769,18 @@ gnc_vendor_search (GncVendor *start, QofBook *book) } GNCSearchWindow * -gnc_vendor_search_select (gpointer start, gpointer book) +gnc_vendor_search_select (GtkWindow *parent, gpointer start, gpointer book) { if (!book) return NULL; - return gnc_vendor_search (start, book); + return gnc_vendor_search (parent, start, book); } GNCSearchWindow * -gnc_vendor_search_edit (gpointer start, gpointer book) +gnc_vendor_search_edit (GtkWindow *parent, gpointer start, gpointer book) { if (start) - gnc_ui_vendor_edit (start); + gnc_ui_vendor_edit (parent, start); return NULL; } diff --git a/gnucash/gnome/dialog-vendor.h b/gnucash/gnome/dialog-vendor.h index fda57c4315..0835132a3f 100644 --- a/gnucash/gnome/dialog-vendor.h +++ b/gnucash/gnome/dialog-vendor.h @@ -31,11 +31,11 @@ typedef struct _vendor_window VendorWindow; #include "dialog-search.h" /* Create or Edit Vendors */ -VendorWindow * gnc_ui_vendor_edit (GncVendor *vendor); -VendorWindow * gnc_ui_vendor_new (QofBook *book); +VendorWindow * gnc_ui_vendor_edit (GtkWindow *parent, GncVendor *vendor); +VendorWindow * gnc_ui_vendor_new (GtkWindow *parent, QofBook *book); /* Search for vendors */ -GNCSearchWindow * gnc_vendor_search (GncVendor *start, QofBook *book); +GNCSearchWindow * gnc_vendor_search (GtkWindow *parent, GncVendor *start, QofBook *book); /* * These callbacks are for use with the gnc_general_search widget @@ -43,7 +43,7 @@ GNCSearchWindow * gnc_vendor_search (GncVendor *start, QofBook *book); * select() provides a Select Dialog and returns it. * edit() opens the existing vendor for editing and returns NULL. */ -GNCSearchWindow * gnc_vendor_search_select (gpointer start, gpointer book); -GNCSearchWindow * gnc_vendor_search_edit (gpointer start, gpointer book); +GNCSearchWindow * gnc_vendor_search_select (GtkWindow *parent, gpointer start, gpointer book); +GNCSearchWindow * gnc_vendor_search_edit (GtkWindow *parent, gpointer start, gpointer book); #endif /* GNC_DIALOG_VENDOR_H_ */ diff --git a/gnucash/gnome/gnc-plugin-basic-commands.c b/gnucash/gnome/gnc-plugin-basic-commands.c index d047fe3c96..248c494d01 100644 --- a/gnucash/gnome/gnc-plugin-basic-commands.c +++ b/gnucash/gnome/gnc-plugin-basic-commands.c @@ -422,7 +422,7 @@ gnc_plugin_basic_commands_class_init (GncPluginBasicCommandsClass *klass) /** Initialize a new instance of a basic commands plugin. This * function currently does nothing. * - * @param page The new object instance created by the object + * @param plugin The new object instance created by the object * system. */ static void gnc_plugin_basic_commands_init (GncPluginBasicCommands *plugin) @@ -456,7 +456,7 @@ gnc_main_window_cmd_file_new (GtkAction *action, GncMainWindowActionData *data) if (!gnc_main_window_all_finish_pending()) return; - gnc_file_new (); + gnc_file_new (GTK_WINDOW (data->window)); } static void @@ -469,9 +469,9 @@ gnc_main_window_cmd_file_open (GtkAction *action, GncMainWindowActionData *data) gnc_window_set_progressbar_window (GNC_WINDOW(data->window)); #ifdef HAVE_DBI_DBI_H - gnc_ui_file_access_for_open(); + gnc_ui_file_access_for_open (GTK_WINDOW (data->window)); #else - gnc_file_open (); + gnc_file_open (GTK_WINDOW (data->window)); #endif gnc_window_set_progressbar_window (NULL); } @@ -485,7 +485,7 @@ gnc_main_window_cmd_file_save (GtkAction *action, GncMainWindowActionData *data) return; gnc_window_set_progressbar_window (GNC_WINDOW(data->window)); - gnc_file_save (); + gnc_file_save (GTK_WINDOW (data->window)); gnc_window_set_progressbar_window (NULL); } @@ -499,9 +499,9 @@ gnc_main_window_cmd_file_save_as (GtkAction *action, GncMainWindowActionData *da gnc_window_set_progressbar_window (GNC_WINDOW(data->window)); #ifdef HAVE_DBI_DBI_H - gnc_ui_file_access_for_save_as(); + gnc_ui_file_access_for_save_as (GTK_WINDOW (data->window)); #else - gnc_file_save_as (); + gnc_file_save_as (GTK_WINDOW (data->window)); #endif gnc_window_set_progressbar_window (NULL); } @@ -515,7 +515,7 @@ gnc_main_window_cmd_file_revert (GtkAction *action, GncMainWindowActionData *dat return; gnc_window_set_progressbar_window (GNC_WINDOW(data->window)); - gnc_file_revert(); + gnc_file_revert(GTK_WINDOW (data->window)); gnc_window_set_progressbar_window (NULL); } @@ -526,7 +526,7 @@ gnc_main_window_cmd_file_export_accounts (GtkAction *action, GncMainWindowAction gnc_window_set_progressbar_window (GNC_WINDOW(data->window)); #ifdef HAVE_DBI_DBI_H - gnc_ui_file_access_for_export(); + gnc_ui_file_access_for_export (GTK_WINDOW (data->window)); #else gnc_file_export (); #endif @@ -551,7 +551,7 @@ gnc_main_window_cmd_actions_scheduled_transaction_editor (GtkAction *action, Gnc static void gnc_main_window_cmd_actions_since_last_run (GtkAction *action, GncMainWindowActionData *data) { - GncMainWindow *window; + GtkWindow *window; GncSxInstanceModel *sx_instances; GncSxSummary summary; GList *auto_created_txns = NULL; @@ -560,7 +560,7 @@ gnc_main_window_cmd_actions_since_last_run (GtkAction *action, GncMainWindowActi g_return_if_fail (data != NULL); - window = data->window; + window = GTK_WINDOW (data->window); if (qof_book_is_readonly(gnc_get_current_book())) { @@ -573,18 +573,18 @@ gnc_main_window_cmd_actions_since_last_run (GtkAction *action, GncMainWindowActi gnc_sx_instance_model_effect_change(sx_instances, TRUE, &auto_created_txns, NULL); if (summary.need_dialog) { - gnc_ui_sx_since_last_run_dialog(sx_instances, auto_created_txns); + gnc_ui_sx_since_last_run_dialog (window, sx_instances, auto_created_txns); auto_created_txns = NULL; } else { if (summary.num_auto_create_no_notify_instances == 0) { - gnc_info_dialog(GTK_WIDGET(&window->gtk_window), "%s", nothing_to_do_msg); + gnc_info_dialog (window, "%s", nothing_to_do_msg); } else { - gnc_info_dialog(GTK_WIDGET(&window->gtk_window), ngettext + gnc_info_dialog(window, ngettext /* Translators: %d is the number of transactions. This is a ngettext(3) message. */ ("There are no Scheduled Transactions to be entered at this time. " diff --git a/gnucash/gnome/gnc-plugin-business.c b/gnucash/gnome/gnc-plugin-business.c index 366574bd4e..01f061df14 100644 --- a/gnucash/gnome/gnc-plugin-business.c +++ b/gnucash/gnome/gnc-plugin-business.c @@ -471,7 +471,7 @@ gnc_plugin_business_cmd_customer_new_customer (GtkAction *action, g_return_if_fail (mw != NULL); g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data)); - gnc_ui_customer_new (gnc_get_current_book()); + gnc_ui_customer_new (GTK_WINDOW (mw->window), gnc_get_current_book ()); } static void @@ -488,7 +488,7 @@ gnc_plugin_business_cmd_customer_find_customer (GtkAction *action, plugin = GNC_PLUGIN_BUSINESS (mw->data); priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin); customer = gncOwnerGetCustomer (priv->last_customer); - gnc_customer_search (customer, gnc_get_current_book()); + gnc_customer_search (GTK_WINDOW (mw->window), customer, gnc_get_current_book ()); } static void @@ -504,7 +504,7 @@ gnc_plugin_business_cmd_customer_new_invoice (GtkAction *action, plugin = GNC_PLUGIN_BUSINESS (mw->data); priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin); last_window = mw->window; - gnc_ui_invoice_new (priv->last_customer, gnc_get_current_book()); + gnc_ui_invoice_new (GTK_WINDOW (mw->window), priv->last_customer, gnc_get_current_book ()); } static void @@ -520,7 +520,7 @@ gnc_plugin_business_cmd_customer_find_invoice (GtkAction *action, plugin = GNC_PLUGIN_BUSINESS (mw->data); priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin); last_window = mw->window; - gnc_invoice_search (NULL, priv->last_customer, gnc_get_current_book()); + gnc_invoice_search (GTK_WINDOW (mw->window), NULL, priv->last_customer, gnc_get_current_book ()); } static void @@ -535,7 +535,7 @@ gnc_plugin_business_cmd_customer_new_job (GtkAction *action, plugin = GNC_PLUGIN_BUSINESS (mw->data); priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin); - gnc_ui_job_new (priv->last_customer, gnc_get_current_book()); + gnc_ui_job_new (GTK_WINDOW (mw->window), priv->last_customer, gnc_get_current_book ()); } static void @@ -550,7 +550,7 @@ gnc_plugin_business_cmd_customer_find_job (GtkAction *action, plugin = GNC_PLUGIN_BUSINESS (mw->data); priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin); - gnc_job_search (NULL, priv->last_customer, gnc_get_current_book()); + gnc_job_search (GTK_WINDOW (mw->window), NULL, priv->last_customer, gnc_get_current_book ()); } static void @@ -565,7 +565,7 @@ gnc_plugin_business_cmd_customer_process_payment (GtkAction *action, plugin = GNC_PLUGIN_BUSINESS (mw->data); priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin); - gnc_ui_payment_new (priv->last_customer, gnc_get_current_book()); + gnc_ui_payment_new (GTK_WINDOW (mw->window), priv->last_customer, gnc_get_current_book ()); } static void @@ -588,7 +588,7 @@ gnc_plugin_business_cmd_vendor_new_vendor (GtkAction *action, g_return_if_fail (mw != NULL); g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data)); - gnc_ui_vendor_new (gnc_get_current_book()); + gnc_ui_vendor_new (GTK_WINDOW (mw->window), gnc_get_current_book ()); } static void @@ -605,7 +605,7 @@ gnc_plugin_business_cmd_vendor_find_vendor (GtkAction *action, plugin = GNC_PLUGIN_BUSINESS (mw->data); priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin); vendor = gncOwnerGetVendor (priv->last_vendor); - gnc_vendor_search (vendor, gnc_get_current_book()); + gnc_vendor_search (GTK_WINDOW (mw->window), vendor, gnc_get_current_book ()); } static void @@ -621,7 +621,7 @@ gnc_plugin_business_cmd_vendor_new_bill (GtkAction *action, plugin = GNC_PLUGIN_BUSINESS (mw->data); priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin); last_window = mw->window; - gnc_ui_invoice_new (priv->last_vendor, gnc_get_current_book()); + gnc_ui_invoice_new (GTK_WINDOW (mw->window), priv->last_vendor, gnc_get_current_book ()); } static void @@ -637,7 +637,7 @@ gnc_plugin_business_cmd_vendor_find_bill (GtkAction *action, plugin = GNC_PLUGIN_BUSINESS (mw->data); priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin); last_window = mw->window; - gnc_invoice_search (NULL, priv->last_vendor, gnc_get_current_book()); + gnc_invoice_search (GTK_WINDOW (mw->window), NULL, priv->last_vendor, gnc_get_current_book ()); } static void @@ -652,7 +652,7 @@ gnc_plugin_business_cmd_vendor_new_job (GtkAction *action, plugin = GNC_PLUGIN_BUSINESS (mw->data); priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin); - gnc_ui_job_new (priv->last_vendor, gnc_get_current_book()); + gnc_ui_job_new (GTK_WINDOW (mw->window), priv->last_vendor, gnc_get_current_book ()); } static void @@ -667,7 +667,7 @@ gnc_plugin_business_cmd_vendor_find_job (GtkAction *action, plugin = GNC_PLUGIN_BUSINESS (mw->data); priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin); - gnc_job_search (NULL, priv->last_vendor, gnc_get_current_book()); + gnc_job_search (GTK_WINDOW (mw->window), NULL, priv->last_vendor, gnc_get_current_book ()); } static void @@ -682,7 +682,7 @@ gnc_plugin_business_cmd_vendor_process_payment (GtkAction *action, plugin = GNC_PLUGIN_BUSINESS (mw->data); priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin); - gnc_ui_payment_new (priv->last_vendor, gnc_get_current_book()); + gnc_ui_payment_new (GTK_WINDOW (mw->window), priv->last_vendor, gnc_get_current_book ()); } static void @@ -705,7 +705,7 @@ gnc_plugin_business_cmd_employee_new_employee (GtkAction *action, g_return_if_fail (mw != NULL); g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data)); - gnc_ui_employee_new (gnc_get_current_book()); + gnc_ui_employee_new (GTK_WINDOW (mw->window), gnc_get_current_book ()); } static void @@ -722,7 +722,7 @@ gnc_plugin_business_cmd_employee_find_employee (GtkAction *action, plugin = GNC_PLUGIN_BUSINESS (mw->data); priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin); employee = gncOwnerGetEmployee (priv->last_employee); - gnc_employee_search (employee, gnc_get_current_book()); + gnc_employee_search (GTK_WINDOW (mw->window), employee, gnc_get_current_book ()); } static void @@ -738,7 +738,7 @@ gnc_plugin_business_cmd_employee_new_expense_voucher (GtkAction *action, plugin = GNC_PLUGIN_BUSINESS (mw->data); priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin); last_window = mw->window; - gnc_ui_invoice_new (priv->last_employee, gnc_get_current_book()); + gnc_ui_invoice_new (GTK_WINDOW (mw->window), priv->last_employee, gnc_get_current_book ()); } static void @@ -754,7 +754,7 @@ gnc_plugin_business_cmd_employee_find_expense_voucher (GtkAction *action, plugin = GNC_PLUGIN_BUSINESS (mw->data); priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin); last_window = mw->window; - gnc_invoice_search (NULL, priv->last_employee, gnc_get_current_book()); + gnc_invoice_search (GTK_WINDOW (mw->window), NULL, priv->last_employee, gnc_get_current_book ()); } static void @@ -769,7 +769,7 @@ gnc_plugin_business_cmd_employee_process_payment (GtkAction *action, plugin = GNC_PLUGIN_BUSINESS (mw->data); priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin); - gnc_ui_payment_new (priv->last_employee, gnc_get_current_book()); + gnc_ui_payment_new (GTK_WINDOW (mw->window), priv->last_employee, gnc_get_current_book ()); } static void @@ -800,7 +800,7 @@ gnc_plugin_business_cmd_bills_due_reminder (GtkAction *action, g_return_if_fail (mw != NULL); g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data)); - gnc_invoice_remind_bills_due(); + gnc_invoice_remind_bills_due (GTK_WINDOW (mw->window)); } @@ -811,7 +811,7 @@ gnc_plugin_business_cmd_invoices_due_reminder (GtkAction *action, g_return_if_fail (mw != NULL); g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data)); - gnc_invoice_remind_invoices_due(); + gnc_invoice_remind_invoices_due (GTK_WINDOW (mw->window)); } static void @@ -821,7 +821,7 @@ gnc_plugin_business_cmd_test_search (GtkAction *action, gnc_search_dialog_test(); } -static void gnc_business_assign_payment (GtkWidget *parent, +static void gnc_business_assign_payment (GtkWindow *parent, Transaction *trans, GncOwner *owner) { @@ -883,7 +883,7 @@ static void gnc_plugin_business_cmd_assign_payment (GtkAction *action, else owner_p = plugin_business_priv->last_vendor; - gnc_business_assign_payment (gnc_plugin_page_get_window(plugin_page), + gnc_business_assign_payment (GTK_WINDOW (mw->window), trans, owner_p); } @@ -1019,7 +1019,7 @@ gnc_plugin_business_cmd_test_init_data (GtkAction *action, gnc_account_append_child(root, tax_acct); // Launch the invoice editor - gnc_ui_invoice_edit(invoice); + gnc_ui_invoice_edit (GTK_WINDOW (data->window), invoice); } /* This is the list of actions which are switched inactive in a read-only book. */ diff --git a/gnucash/gnome/gnc-plugin-business.h b/gnucash/gnome/gnc-plugin-business.h index 9a0e72c4c6..9ded6cf984 100644 --- a/gnucash/gnome/gnc-plugin-business.h +++ b/gnucash/gnome/gnc-plugin-business.h @@ -60,8 +60,8 @@ GncPlugin *gnc_plugin_business_new (void); G_END_DECLS GncMainWindow *gnc_plugin_business_get_window (void); -void gnc_invoice_remind_bills_due (void); -void gnc_invoice_remind_invoices_due (void); +void gnc_invoice_remind_bills_due (GtkWindow *parent); +void gnc_invoice_remind_invoices_due (GtkWindow *parent); void gnc_invoice_remind_bills_due_cb (void); void gnc_invoice_remind_invoices_due_cb (void); const char *gnc_plugin_business_get_invoice_printreport(void); diff --git a/gnucash/gnome/gnc-plugin-page-invoice.c b/gnucash/gnome/gnc-plugin-page-invoice.c index c3622e6994..ced56d3166 100644 --- a/gnucash/gnome/gnc-plugin-page-invoice.c +++ b/gnucash/gnome/gnc-plugin-page-invoice.c @@ -648,12 +648,14 @@ gnc_plugin_page_invoice_cmd_new_invoice (GtkAction *action, GncPluginPageInvoice *plugin_page) { GncPluginPageInvoicePrivate *priv; + GtkWindow *parent; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); ENTER("(action %p, plugin_page %p)", action, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); - gnc_invoice_window_new_invoice_cb(NULL, priv->iw); + parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page))); + gnc_invoice_window_new_invoice_cb(parent, priv->iw); LEAVE(" "); } @@ -673,12 +675,14 @@ gnc_plugin_page_invoice_cmd_print (GtkAction *action, GncPluginPageInvoice *plugin_page) { GncPluginPageInvoicePrivate *priv; + GtkWindow *parent; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); ENTER("(action %p, plugin_page %p)", action, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); - gnc_invoice_window_printCB(NULL, priv->iw); + parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page))); + gnc_invoice_window_printCB (parent, priv->iw); LEAVE(" "); } @@ -729,12 +733,14 @@ gnc_plugin_page_invoice_cmd_edit (GtkAction *action, GncPluginPageInvoice *plugin_page) { GncPluginPageInvoicePrivate *priv; + GtkWindow *parent; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); ENTER("(action %p, plugin_page %p)", action, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); - gnc_invoice_window_editCB(NULL, priv->iw); + parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page))); + gnc_invoice_window_editCB (parent, priv->iw); LEAVE(" "); } @@ -743,12 +749,14 @@ gnc_plugin_page_invoice_cmd_duplicateInvoice (GtkAction *action, GncPluginPageInvoice *plugin_page) { GncPluginPageInvoicePrivate *priv; + GtkWindow *parent; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); ENTER("(action %p, plugin_page %p)", action, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); - gnc_invoice_window_duplicateInvoiceCB(NULL, priv->iw); + parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page))); + gnc_invoice_window_duplicateInvoiceCB(parent, priv->iw); LEAVE(" "); } @@ -906,12 +914,14 @@ gnc_plugin_page_invoice_cmd_pay_invoice (GtkAction *action, GncPluginPageInvoice *plugin_page) { GncPluginPageInvoicePrivate *priv; + GtkWindow *parent; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); ENTER("(action %p, plugin_page %p)", action, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); - gnc_invoice_window_payment_cb(NULL, priv->iw); + parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page))); + gnc_invoice_window_payment_cb (parent, priv->iw); LEAVE(" "); } @@ -920,12 +930,14 @@ gnc_plugin_page_invoice_cmd_company_report (GtkAction *action, GncPluginPageInvoice *plugin_page) { GncPluginPageInvoicePrivate *priv; + GtkWindow *parent; g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(plugin_page)); ENTER("(action %p, plugin_page %p)", action, plugin_page); priv = GNC_PLUGIN_PAGE_INVOICE_GET_PRIVATE(plugin_page); - gnc_invoice_window_report_owner_cb(NULL, priv->iw); + parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page))); + gnc_invoice_window_report_owner_cb (parent, priv->iw); LEAVE(" "); } diff --git a/gnucash/gnome/gnc-plugin-page-owner-tree.c b/gnucash/gnome/gnc-plugin-page-owner-tree.c index 80416a8457..e9097edde2 100644 --- a/gnucash/gnome/gnc-plugin-page-owner-tree.c +++ b/gnucash/gnome/gnc-plugin-page-owner-tree.c @@ -775,7 +775,7 @@ gnc_plugin_page_owner_tree_recreate_page (GtkWidget *window, } /* Wrapper function to open the proper edit dialog, depending on the owner type */ -static void gnc_ui_owner_edit (GncOwner *owner) +static void gnc_ui_owner_edit (GtkWindow *parent, GncOwner *owner) { if (NULL == owner) return; @@ -786,22 +786,22 @@ static void gnc_ui_owner_edit (GncOwner *owner) break; case GNC_OWNER_CUSTOMER : { - gnc_ui_customer_edit (owner->owner.customer); + gnc_ui_customer_edit (parent, owner->owner.customer); break; } case GNC_OWNER_JOB : { - gnc_ui_job_edit (owner->owner.job); + gnc_ui_job_edit (parent, owner->owner.job); break; } case GNC_OWNER_VENDOR : { - gnc_ui_vendor_edit (owner->owner.vendor); + gnc_ui_vendor_edit (parent, owner->owner.vendor); break; } case GNC_OWNER_EMPLOYEE : { - gnc_ui_employee_edit (owner->owner.employee); + gnc_ui_employee_edit (parent, owner->owner.employee); break; } } @@ -842,10 +842,12 @@ gnc_plugin_page_owner_tree_double_click_cb (GtkTreeView *treeview, GncPluginPageOwnerTree *page) { GncOwner *owner; + GtkWindow *parent; g_return_if_fail (GNC_IS_PLUGIN_PAGE_OWNER_TREE (page)); owner = gnc_tree_view_owner_get_owner_from_path (GNC_TREE_VIEW_OWNER(treeview), path); - gnc_ui_owner_edit (owner); + parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page))); + gnc_ui_owner_edit (parent, owner); } static void @@ -993,10 +995,12 @@ static void gnc_plugin_page_owner_tree_cmd_new_owner (GtkAction *action, GncPluginPageOwnerTree *page) { GncPluginPageOwnerTreePrivate *priv; + GtkWindow *parent; g_return_if_fail(GNC_IS_PLUGIN_PAGE_OWNER_TREE(page)); priv = GNC_PLUGIN_PAGE_OWNER_TREE_GET_PRIVATE (page); + parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page))); switch (priv->owner_type) { @@ -1005,7 +1009,7 @@ gnc_plugin_page_owner_tree_cmd_new_owner (GtkAction *action, GncPluginPageOwnerT break; case GNC_OWNER_CUSTOMER : { - gnc_ui_customer_new (gnc_get_current_book ()); + gnc_ui_customer_new (parent, gnc_get_current_book ()); break; } case GNC_OWNER_JOB : @@ -1016,12 +1020,12 @@ gnc_plugin_page_owner_tree_cmd_new_owner (GtkAction *action, GncPluginPageOwnerT } case GNC_OWNER_VENDOR : { - gnc_ui_vendor_new (gnc_get_current_book ()); + gnc_ui_vendor_new (parent, gnc_get_current_book ()); break; } case GNC_OWNER_EMPLOYEE : { - gnc_ui_employee_new (gnc_get_current_book ()); + gnc_ui_employee_new (parent, gnc_get_current_book ()); break; } } @@ -1030,12 +1034,14 @@ gnc_plugin_page_owner_tree_cmd_new_owner (GtkAction *action, GncPluginPageOwnerT static void gnc_plugin_page_owner_tree_cmd_edit_owner (GtkAction *action, GncPluginPageOwnerTree *page) { + GtkWindow *parent; GncOwner *owner = gnc_plugin_page_owner_tree_get_current_owner (page); if (NULL == owner) return; ENTER("action %p, page %p", action, page); - gnc_ui_owner_edit (owner); + parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page))); + gnc_ui_owner_edit (parent, owner); LEAVE(" "); } @@ -1132,6 +1138,7 @@ gnc_plugin_page_owner_tree_cmd_new_invoice (GtkAction *action, { GncPluginPageOwnerTreePrivate *priv; GncOwner current_owner; + GtkWindow *parent; ENTER("action %p, page %p", action, page); @@ -1168,8 +1175,9 @@ gnc_plugin_page_owner_tree_cmd_new_invoice (GtkAction *action, } } + parent = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page))); if (gncOwnerGetType(¤t_owner) != GNC_OWNER_UNDEFINED) - gnc_ui_invoice_new (¤t_owner, gnc_get_current_book()); + gnc_ui_invoice_new (parent, ¤t_owner, gnc_get_current_book ()); LEAVE(" "); } diff --git a/gnucash/gnome/gnc-plugin-page-register.c b/gnucash/gnome/gnc-plugin-page-register.c index d0cab8e69c..b42270d39d 100644 --- a/gnucash/gnome/gnc-plugin-page-register.c +++ b/gnucash/gnome/gnc-plugin-page-register.c @@ -694,7 +694,8 @@ gnc_plugin_page_register_new (Account *account, gboolean subaccounts) if (guid_equal (xaccAccountGetGUID (account), xaccAccountGetGUID (new_account))) { - gnc_error_dialog (NULL, "%s", + GtkWindow *window = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (new_register_page))); + gnc_error_dialog (window, "%s", _("You have tried to open an account in the old register while it is open in the new register.")); return NULL; } @@ -1570,7 +1571,7 @@ gnc_plugin_page_register_finish_pending (GncPluginPage *page) return TRUE; name = gnc_plugin_page_register_get_tab_name(page); - window = gnc_plugin_page_get_window(page); + window = gnc_plugin_page_get_window (page); dialog = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, @@ -2802,7 +2803,7 @@ gnc_plugin_page_register_cmd_print_check (GtkAction *action, priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(plugin_page); reg = gnc_ledger_display_get_split_register (priv->ledger); ledger_type = gnc_ledger_display_type(priv->ledger); - window = gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(plugin_page)); + window = gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page)); if (ledger_type == LD_SINGLE || ledger_type == LD_SUBACCOUNT) { account = gnc_plugin_page_register_get_account (plugin_page); @@ -2879,7 +2880,7 @@ gnc_plugin_page_register_cmd_print_check (GtkAction *action, } else { - gnc_error_dialog(window, "%s", + gnc_error_dialog(GTK_WINDOW (window), "%s", _("You can only print checks from a bank account register or search results.")); LEAVE("Unsupported ledger type"); return; @@ -2957,8 +2958,7 @@ gnc_plugin_page_register_cmd_find_account (GtkAction *action, g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER(page)); - window = gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(page)); - + window = gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page)); gnc_find_account_dialog (window, NULL); } @@ -3041,11 +3041,13 @@ gnc_plugin_page_register_cmd_void_transaction (GtkAction *action, GtkBuilder *builder; const char *reason; gint result; + GtkWindow *window; ENTER("(action %p, page %p)", action, page); g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER(page)); + window = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page))); priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(page); reg = gnc_ledger_display_get_split_register(priv->ledger); trans = gnc_split_register_get_current_trans(reg); @@ -3055,13 +3057,13 @@ gnc_plugin_page_register_cmd_void_transaction (GtkAction *action, return; if (xaccTransHasReconciledSplits(trans) || xaccTransHasSplitsInState(trans, CREC)) { - gnc_error_dialog(NULL, "%s", _("You cannot void a transaction with reconciled or cleared splits.")); + gnc_error_dialog (window, "%s", _("You cannot void a transaction with reconciled or cleared splits.")); return; } reason = xaccTransGetReadOnly (trans); if (reason) { - gnc_error_dialog(NULL, _("This transaction is marked read-only with the comment: '%s'"), reason); + gnc_error_dialog(window, _("This transaction is marked read-only with the comment: '%s'"), reason); return; } @@ -3131,7 +3133,7 @@ gnc_plugin_page_register_cmd_reverse_transaction (GtkAction *action, if (xaccTransGetReversedBy(trans)) { - gnc_error_dialog(gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(page)), "%s", + gnc_error_dialog(GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page))), "%s", _("A reversing entry has already been created for this transaction.")); return; } @@ -4155,7 +4157,7 @@ gnc_plugin_page_register_event_handler (QofInstance *entity, ENTER("entity %p of type %d, page %p, event data %p", entity, event_type, page, ed); - window = gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(page)); + window = gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page)); if (GNC_IS_ACCOUNT(entity)) { diff --git a/gnucash/gnome/gnc-plugin-page-register2.c b/gnucash/gnome/gnc-plugin-page-register2.c index ff69d3dd5a..bd10fa9ead 100644 --- a/gnucash/gnome/gnc-plugin-page-register2.c +++ b/gnucash/gnome/gnc-plugin-page-register2.c @@ -678,7 +678,8 @@ gnc_plugin_page_register2_new (Account *account, gboolean subaccounts) if (guid_equal (xaccAccountGetGUID (account), xaccAccountGetGUID (old_account))) { - gnc_error_dialog (NULL, "%s", + GtkWindow *window = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (old_register_page))); + gnc_error_dialog (window, "%s", _("You have tried to open an account in the new register while it is open in the old register.")); return NULL; } @@ -2624,7 +2625,7 @@ gnc_plugin_page_register2_cmd_print_check (GtkAction *action, gnc_ui_print_check_dialog_create (window, splits); g_list_free(splits); } - } + } } } else if (ledger_type == LD2_GL && model->type == SEARCH_LEDGER2) @@ -2675,7 +2676,7 @@ gnc_plugin_page_register2_cmd_print_check (GtkAction *action, } else { - gnc_error_dialog (window, "%s", + gnc_error_dialog (GTK_WINDOW (window), "%s", _("You can only print checks from a bank account register or search results.")); LEAVE("Unsupported ledger type"); return; @@ -2769,7 +2770,7 @@ gnc_plugin_page_register2_cmd_find_account (GtkAction *action, g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(page)); - window = gnc_plugin_page_get_window (GNC_PLUGIN_PAGE(page)); + window = gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page)); gnc_find_account_dialog (window, NULL); } @@ -2869,6 +2870,7 @@ gnc_plugin_page_register2_cmd_void_transaction (GtkAction *action, } if (xaccTransHasReconciledSplits (trans) || xaccTransHasSplitsInState (trans, CREC)) { + GtkWindow *window = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page))); gnc_error_dialog (NULL, "%s", _("You cannot void a transaction with reconciled or cleared splits.")); LEAVE("trans with reconciled splits"); return; @@ -4032,7 +4034,7 @@ gnc_plugin_page_register2_event_handler (QofInstance *entity, ENTER("entity %p of type %d, page %p, event data %p", entity, event_type, page, ed); - window = gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(page)); + window = gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page)); if (GNC_IS_ACCOUNT(entity)) { diff --git a/gnucash/gnome/gnc-plugin-page-sx-list.c b/gnucash/gnome/gnc-plugin-page-sx-list.c index 79da000ec2..e2334594ff 100644 --- a/gnucash/gnome/gnc-plugin-page-sx-list.c +++ b/gnucash/gnome/gnc-plugin-page-sx-list.c @@ -747,6 +747,7 @@ gnc_plugin_page_sx_list_cmd_delete(GtkAction *action, GncPluginPageSxList *page) GtkTreeSelection *selection; GList *selected_paths, *to_delete = NULL; GtkTreeModel *model; + GtkWindow *window; selection = gtk_tree_view_get_selection(priv->tree_view); selected_paths = gtk_tree_selection_get_selected_rows(selection, &model); @@ -767,11 +768,12 @@ gnc_plugin_page_sx_list_cmd_delete(GtkAction *action, GncPluginPageSxList *page) } } + window = GTK_WINDOW (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (page))); /* FIXME: Does this always refer to only one transaction? Or could multiple SXs be deleted as well? Ideally, the number of to-be-deleted SXs should be mentioned here; see dialog-sx-since-last-run.c:807 */ - if (gnc_verify_dialog(NULL, FALSE, "%s", _("Do you really want to delete this scheduled transaction?"))) + if (gnc_verify_dialog (window, FALSE, "%s", _("Do you really want to delete this scheduled transaction?"))) { g_list_foreach(to_delete, (GFunc)_destroy_sx, NULL); } diff --git a/gnucash/gnome/gnc-split-reg.c b/gnucash/gnome/gnc-split-reg.c index 678d1b51bf..e01223a711 100644 --- a/gnucash/gnome/gnc-split-reg.c +++ b/gnucash/gnome/gnc-split-reg.c @@ -762,8 +762,8 @@ gsr_default_reverse_txn_handler (GNCSplitReg *gsr, gpointer data) if (xaccTransGetReversedBy(trans)) { - gnc_error_dialog(gsr->window, "%s", - _("A reversing entry has already been created for this transaction.")); + gnc_error_dialog (GTK_WINDOW (gsr->window), "%s", + _("A reversing entry has already been created for this transaction.")); return; } @@ -1114,7 +1114,7 @@ gsr_default_execassociated_handler (GNCSplitReg *gsr, gpointer data) uri = xaccTransGetAssociation (trans); if (g_strcmp0 (uri, "") == 0 && g_strcmp0 (uri, NULL) == 0) - gnc_error_dialog (NULL, "%s", _("This transaction is not associated with a URI.")); + gnc_error_dialog (GTK_WINDOW (gsr->window), "%s", _("This transaction is not associated with a URI.")); else { if (g_str_has_prefix (uri,"file:/") && !g_str_has_prefix (uri,"file://")) // Check for relative path @@ -1140,7 +1140,7 @@ gsr_default_execassociated_handler (GNCSplitReg *gsr, gpointer data) g_free (uri_scheme); } else - gnc_error_dialog (NULL, "%s", _("This transaction is not associated with a valid URI.")); + gnc_error_dialog (GTK_WINDOW (gsr->window), "%s", _("This transaction is not associated with a valid URI.")); } return; } diff --git a/gnucash/gnome/gtkbuilder/dialog-customer.glade b/gnucash/gnome/gtkbuilder/dialog-customer.glade index 9e58fdf688..39be9776c3 100644 --- a/gnucash/gnome/gtkbuilder/dialog-customer.glade +++ b/gnucash/gnome/gtkbuilder/dialog-customer.glade @@ -27,7 +27,6 @@ - True False New Customer dialog diff --git a/gnucash/gnome/gtkbuilder/dialog-employee.glade b/gnucash/gnome/gtkbuilder/dialog-employee.glade index c75e9c32b0..80647a474d 100644 --- a/gnucash/gnome/gtkbuilder/dialog-employee.glade +++ b/gnucash/gnome/gtkbuilder/dialog-employee.glade @@ -3,7 +3,6 @@ - True False New Employee dialog diff --git a/gnucash/gnome/gtkbuilder/dialog-invoice.glade b/gnucash/gnome/gtkbuilder/dialog-invoice.glade index cb7315a17b..d06ffc1555 100644 --- a/gnucash/gnome/gtkbuilder/dialog-invoice.glade +++ b/gnucash/gnome/gtkbuilder/dialog-invoice.glade @@ -677,7 +677,6 @@ - True False New Invoice dialog @@ -1282,7 +1281,6 @@ - True False False True diff --git a/gnucash/gnome/gtkbuilder/dialog-job.glade b/gnucash/gnome/gtkbuilder/dialog-job.glade index fb2c7462b1..9326aa68d1 100644 --- a/gnucash/gnome/gtkbuilder/dialog-job.glade +++ b/gnucash/gnome/gtkbuilder/dialog-job.glade @@ -3,7 +3,6 @@ - True False Job Dialog False @@ -232,11 +231,11 @@ - + True False end - Rate + Billing ID right @@ -246,11 +245,11 @@ - + True False end - Billing ID + Rate right @@ -287,20 +286,6 @@ 0 - - - True - False - - - - - - False - True - 1 - - True @@ -315,6 +300,20 @@ 1 + + + True + False + + + + + + False + True + 1 + + True diff --git a/gnucash/gnome/gtkbuilder/dialog-order.glade b/gnucash/gnome/gtkbuilder/dialog-order.glade index 5f64135615..f1f584d2e7 100644 --- a/gnucash/gnome/gtkbuilder/dialog-order.glade +++ b/gnucash/gnome/gtkbuilder/dialog-order.glade @@ -4,7 +4,6 @@ - True False Order Entry 950 @@ -526,7 +525,6 @@ - True False New Order dialog diff --git a/gnucash/gnome/gtkbuilder/dialog-payment.glade b/gnucash/gnome/gtkbuilder/dialog-payment.glade index b946e152c0..daf839c973 100644 --- a/gnucash/gnome/gtkbuilder/dialog-payment.glade +++ b/gnucash/gnome/gtkbuilder/dialog-payment.glade @@ -57,7 +57,6 @@ - True False Process Payment 560 diff --git a/gnucash/gnome/gtkbuilder/dialog-sx.glade b/gnucash/gnome/gtkbuilder/dialog-sx.glade index e2c9ba3d46..f09c8f334e 100644 --- a/gnucash/gnome/gtkbuilder/dialog-sx.glade +++ b/gnucash/gnome/gtkbuilder/dialog-sx.glade @@ -1456,7 +1456,6 @@ - True False Since Last Run... center-on-parent diff --git a/gnucash/gnome/gtkbuilder/dialog-vendor.glade b/gnucash/gnome/gtkbuilder/dialog-vendor.glade index 40fcd1afc3..15643d346f 100644 --- a/gnucash/gnome/gtkbuilder/dialog-vendor.glade +++ b/gnucash/gnome/gtkbuilder/dialog-vendor.glade @@ -27,7 +27,6 @@ - True False New Vendor dialog diff --git a/gnucash/gnome/top-level.c b/gnucash/gnome/top-level.c index 4013ba562a..6d6ee938ee 100644 --- a/gnucash/gnome/top-level.c +++ b/gnucash/gnome/top-level.c @@ -183,7 +183,7 @@ gnc_html_register_url_cb (const char *location, const char *label, } page = gnc_plugin_page_register_new (account, FALSE); - gnc_main_window_open_page (NULL, page); + gnc_main_window_open_page (GNC_MAIN_WINDOW (result->parent), page); if (split) { gsr = gnc_plugin_page_register_get_gsr(page); @@ -213,7 +213,7 @@ gnc_html_price_url_cb (const char *location, const char *label, if (!validate_type("price-guid=", location, GNC_ID_PRICE, result, &guid, &entity)) return FALSE; - if (!gnc_price_edit_by_guid (NULL, &guid)) + if (!gnc_price_edit_by_guid (GTK_WIDGET (result->parent), &guid)) { result->error_message = g_strdup_printf (_("No such price: %s"), location); @@ -295,6 +295,8 @@ cleanup: g_error_free(error); if (file_guid) g_free(file_guid); + + gnc_totd_dialog_reparent (); } @@ -377,8 +379,6 @@ gnc_main_gui_init (void) gnc_html_register_url_handler (URL_TYPE_PRICE, gnc_html_price_url_cb); - gnc_ui_sx_initialize(); - /* Register the Owner search type */ gnc_search_core_register_type (GNC_OWNER_MODULE_NAME, (GNCSearchCoreNew) gnc_search_owner_new); @@ -421,6 +421,8 @@ gnc_main_gui_init (void) gnc_hook_add_dangler(HOOK_BOOK_OPENED, (GFunc)gnc_invoice_remind_invoices_due_cb, NULL); + gnc_ui_sx_initialize(); + /* Add to preferences under Business */ /* The parameters are; glade file, items to add from glade file - last being the dialog, preference tab name */ gnc_preferences_add_page("business-prefs.glade", "liststore_printinvoice,days_in_adj,cust_days_in_adj,business_prefs", diff --git a/gnucash/gnome/window-reconcile.c b/gnucash/gnome/window-reconcile.c index cb8104b330..90444f8cf3 100644 --- a/gnucash/gnome/window-reconcile.c +++ b/gnucash/gnome/window-reconcile.c @@ -1314,7 +1314,7 @@ gnc_ui_reconcile_window_delete_cb(GtkButton *button, gpointer data) "transaction?"); gboolean result; - result = gnc_verify_dialog(recnData->window, FALSE, "%s", message); + result = gnc_verify_dialog (GTK_WINDOW (recnData->window), FALSE, "%s", message); if (!result) return; @@ -1990,7 +1990,7 @@ recn_cancel(RecnWindow *recnData) { const char *message = _("You have made changes to this reconcile " "window. Are you sure you want to cancel?"); - if (!gnc_verify_dialog(recnData->window, FALSE, "%s", message)) + if (!gnc_verify_dialog (GTK_WINDOW (recnData->window), FALSE, "%s", message)) return; } @@ -2108,7 +2108,7 @@ recnFinishCB (GtkAction *action, RecnWindow *recnData) { const char *message = _("The account is not balanced. " "Are you sure you want to finish?"); - if (!gnc_verify_dialog (recnData->window, FALSE, "%s", message)) + if (!gnc_verify_dialog (GTK_WINDOW (recnData->window), FALSE, "%s", message)) return; } @@ -2165,7 +2165,7 @@ recnPostponeCB (GtkAction *action, gpointer data) { const char *message = _("Do you want to postpone this reconciliation " "and finish it later?"); - if (!gnc_verify_dialog (recnData->window, FALSE, "%s", message)) + if (!gnc_verify_dialog (GTK_WINDOW (recnData->window), FALSE, "%s", message)) return; } diff --git a/gnucash/gnome/window-reconcile2.c b/gnucash/gnome/window-reconcile2.c index a337b1847e..3b8082fd3a 100644 --- a/gnucash/gnome/window-reconcile2.c +++ b/gnucash/gnome/window-reconcile2.c @@ -1278,7 +1278,7 @@ gnc_ui_reconcile_window_delete_cb (GtkButton *button, gpointer data) "transaction?"); gboolean result; - result = gnc_verify_dialog (recnData->window, FALSE, "%s", message); + result = gnc_verify_dialog (GTK_WINDOW (recnData->window), FALSE, "%s", message); if (!result) return; @@ -1951,7 +1951,7 @@ recn_cancel (RecnWindow2 *recnData) { const char *message = _("You have made changes to this reconcile " "window. Are you sure you want to cancel?"); - if (!gnc_verify_dialog(recnData->window, FALSE, "%s", message)) + if (!gnc_verify_dialog (GTK_WINDOW (recnData->window), FALSE, "%s", message)) return; } @@ -2069,7 +2069,7 @@ recnFinishCB (GtkAction *action, RecnWindow2 *recnData) { const char *message = _("The account is not balanced. " "Are you sure you want to finish?"); - if (!gnc_verify_dialog (recnData->window, FALSE, "%s", message)) + if (!gnc_verify_dialog (GTK_WINDOW (recnData->window), FALSE, "%s", message)) return; } @@ -2126,7 +2126,7 @@ recnPostponeCB (GtkAction *action, gpointer data) { const char *message = _("Do you want to postpone this reconciliation " "and finish it later?"); - if (!gnc_verify_dialog (recnData->window, FALSE, "%s", message)) + if (!gnc_verify_dialog (GTK_WINDOW (recnData->window), FALSE, "%s", message)) return; } diff --git a/gnucash/gnucash-bin.c b/gnucash/gnucash-bin.c index 1569a416d1..0152a3a44e 100644 --- a/gnucash/gnucash-bin.c +++ b/gnucash/gnucash-bin.c @@ -646,7 +646,7 @@ inner_main (void *closure, int argc, char **argv) if (!nofile && (fn = get_file_to_load())) { gnc_update_splash_screen(_("Loading data..."), GNC_SPLASH_PERCENTAGE_UNKNOWN); - gnc_file_open_file(fn, /*open_readonly*/ FALSE); + gnc_file_open_file(gnc_get_splash_screen(), fn, /*open_readonly*/ FALSE); g_free(fn); } else if (gnc_prefs_get_bool(GNC_PREFS_GROUP_NEW_USER, GNC_PREF_FIRST_STARTUP)) diff --git a/gnucash/html/gnc-html-webkit1.c b/gnucash/html/gnc-html-webkit1.c index 0b0faddecd..4bba8691ec 100644 --- a/gnucash/html/gnc-html-webkit1.c +++ b/gnucash/html/gnc-html-webkit1.c @@ -543,7 +543,7 @@ load_to_stream( GncHtmlWebkit* self, URLType type, { if ( !https_allowed() ) { - gnc_error_dialog( priv->base.parent, "%s", + gnc_error_dialog (GTK_WINDOW (priv->base.parent), "%s", _("Secure HTTP access is disabled. " "You can enable it in the Network section of " "the Preferences dialog.")); @@ -553,7 +553,7 @@ load_to_stream( GncHtmlWebkit* self, URLType type, if ( !http_allowed() ) { - gnc_error_dialog( priv->base.parent, "%s", + gnc_error_dialog (GTK_WINDOW (priv->base.parent), "%s", _("Network HTTP access is disabled. " "You can enable it in the Network section of " "the Preferences dialog.")); @@ -881,18 +881,19 @@ impl_webkit_show_url( GncHtml* self, URLType type, result.base_type = URL_TYPE_FILE; result.base_location = NULL; result.error_message = NULL; + result.parent = GTK_WINDOW (priv->base.parent); ok = url_handler( location, label, new_window, &result ); if ( !ok ) { if ( result.error_message ) { - gnc_error_dialog( priv->base.parent, "%s", result.error_message ); + gnc_error_dialog (GTK_WINDOW (priv->base.parent), "%s", result.error_message ); } else { /* %s is a URL (some location somewhere). */ - gnc_error_dialog( priv->base.parent, _("There was an error accessing %s."), location ); + gnc_error_dialog (GTK_WINDOW (priv->base.parent), _("There was an error accessing %s."), location ); } if ( priv->base.load_cb ) @@ -958,7 +959,7 @@ impl_webkit_show_url( GncHtml* self, URLType type, { if ( !https_allowed() ) { - gnc_error_dialog( priv->base.parent, "%s", + gnc_error_dialog (GTK_WINDOW (priv->base.parent), "%s", _("Secure HTTP access is disabled. " "You can enable it in the Network section of " "the Preferences dialog.") ); @@ -970,7 +971,7 @@ impl_webkit_show_url( GncHtml* self, URLType type, { if ( !http_allowed() ) { - gnc_error_dialog( priv->base.parent, "%s", + gnc_error_dialog (GTK_WINDOW (priv->base.parent), "%s", _("Network HTTP access is disabled. " "You can enable it in the Network section of " "the Preferences dialog.") ); diff --git a/gnucash/html/gnc-html-webkit2.c b/gnucash/html/gnc-html-webkit2.c index 3a0f079928..5b884749b2 100644 --- a/gnucash/html/gnc-html-webkit2.c +++ b/gnucash/html/gnc-html-webkit2.c @@ -561,7 +561,7 @@ load_to_stream( GncHtmlWebkit* self, URLType type, { if ( !https_allowed() ) { - gnc_error_dialog( priv->base.parent, "%s", + gnc_error_dialog (GTK_WINDOW (priv->base.parent), "%s", _("Secure HTTP access is disabled. " "You can enable it in the Network section of " "the Preferences dialog.")); @@ -571,7 +571,7 @@ load_to_stream( GncHtmlWebkit* self, URLType type, if ( !http_allowed() ) { - gnc_error_dialog( priv->base.parent, "%s", + gnc_error_dialog (GTK_WINDOW (priv->base.parent), "%s", _("Network HTTP access is disabled. " "You can enable it in the Network section of " "the Preferences dialog.")); @@ -853,18 +853,19 @@ impl_webkit_show_url( GncHtml* self, URLType type, result.base_type = URL_TYPE_FILE; result.base_location = NULL; result.error_message = NULL; + result.parent = GTK_WINDOW (priv->base.parent); ok = url_handler( location, label, new_window, &result ); if ( !ok ) { if ( result.error_message ) { - gnc_error_dialog( priv->base.parent, "%s", result.error_message ); + gnc_error_dialog (GTK_WINDOW (priv->base.parent), "%s", result.error_message ); } else { /* %s is a URL (some location somewhere). */ - gnc_error_dialog( priv->base.parent, _("There was an error accessing %s."), location ); + gnc_error_dialog (GTK_WINDOW (priv->base.parent), _("There was an error accessing %s."), location ); } if ( priv->base.load_cb ) @@ -930,7 +931,7 @@ impl_webkit_show_url( GncHtml* self, URLType type, { if ( !https_allowed() ) { - gnc_error_dialog( priv->base.parent, "%s", + gnc_error_dialog (GTK_WINDOW (priv->base.parent), "%s", _("Secure HTTP access is disabled. " "You can enable it in the Network section of " "the Preferences dialog.") ); @@ -942,7 +943,7 @@ impl_webkit_show_url( GncHtml* self, URLType type, { if ( !http_allowed() ) { - gnc_error_dialog( priv->base.parent, "%s", + gnc_error_dialog (GTK_WINDOW (priv->base.parent), "%s", _("Network HTTP access is disabled. " "You can enable it in the Network section of " "the Preferences dialog.") ); diff --git a/gnucash/html/gnc-html.h b/gnucash/html/gnc-html.h index 8f32a3b0e4..ffb8aebe7a 100644 --- a/gnucash/html/gnc-html.h +++ b/gnucash/html/gnc-html.h @@ -67,6 +67,9 @@ typedef struct URLType base_type; gchar* base_location; + /* The window that triggered this URL request */ + GtkWindow *parent; + /* The following members are used if the handler fails (returns FALSE). */ gchar* error_message; } GNCURLResult; diff --git a/gnucash/import-export/aqb/assistant-ab-initial.c b/gnucash/import-export/aqb/assistant-ab-initial.c index 50c12bdcc0..920a58de42 100644 --- a/gnucash/import-export/aqb/assistant-ab-initial.c +++ b/gnucash/import-export/aqb/assistant-ab-initial.c @@ -373,7 +373,7 @@ aai_wizard_button_clicked_cb(GtkButton *button, gpointer user_data) { g_warning("on_aqhbci_button: Oops, no aqhbci setup wizard found."); gnc_error_dialog - (info->window, + (GTK_WINDOW (info->window), _("The external program \"AqBanking Setup Wizard\" has not " "been found. \n\n" "The %s package should include the " @@ -530,7 +530,7 @@ child_exit_cb(GPid pid, gint status, gpointer data) "value: %d. The called program was \"%s\".\n", exit_status, deferred_info->wizard_path); gnc_error_dialog - (info->window, "%s", + (GTK_WINDOW (info->window), "%s", _("The external program \"AqBanking Setup Wizard\" failed " "to run successfully because the " "additional software \"Qt\" was not found. " @@ -551,7 +551,7 @@ child_exit_cb(GPid pid, gint status, gpointer data) "value: %d. The called program was \"%s\".\n", exit_status, deferred_info->wizard_path); gnc_error_dialog - (info->window, "%s", + (GTK_WINDOW (info->window), "%s", _("The external program \"AqBanking Setup Wizard\" failed " "to run successfully. Online Banking can only be setup " "if this wizard has run successfully. " diff --git a/gnucash/import-export/aqb/dialog-ab-trans.c b/gnucash/import-export/aqb/dialog-ab-trans.c index dc4480a4a2..c3244f2b9d 100644 --- a/gnucash/import-export/aqb/dialog-ab-trans.c +++ b/gnucash/import-export/aqb/dialog-ab-trans.c @@ -606,7 +606,7 @@ gnc_ab_trans_dialog_verify_values(GncABTransDialog *td) const char* localBankCode = AB_Transaction_GetLocalBankCode(td->ab_trans); const char* localAccountCode = AB_Transaction_GetLocalAccountNumber(td->ab_trans); values_ok = FALSE; - gnc_error_dialog(td->dialog, + gnc_error_dialog(GTK_WINDOW (td->dialog), _("Your local bank account does not yet have the SEPA account information stored." " We are sorry, but in this development version one additional step is necessary " "which has not yet been implemented directly in gnucash. " @@ -1179,7 +1179,7 @@ gnc_ab_trans_dialog_add_templ_cb(GtkButton *button, gpointer user_data) find_templ_helper, &data); if (data.pointer) { - gnc_error_dialog(dialog, "%s", + gnc_error_dialog(GTK_WINDOW (dialog), "%s", _("A template with the given name already exists. " "Please enter another name.")); continue; @@ -1313,8 +1313,8 @@ gnc_ab_trans_dialog_del_templ_cb(GtkButton *button, gpointer user_data) } gtk_tree_model_get(model, &iter, TEMPLATE_NAME, &name, -1); - if (gnc_verify_dialog( - td->parent, FALSE, + if (gnc_verify_dialog ( + GTK_WINDOW (td->parent), FALSE, _("Do you really want to delete the template with the name \"%s\"?"), name)) { diff --git a/gnucash/import-export/aqb/gnc-ab-getbalance.c b/gnucash/import-export/aqb/gnc-ab-getbalance.c index 19569deac3..3a2c6cb5fa 100644 --- a/gnucash/import-export/aqb/gnc-ab-getbalance.c +++ b/gnucash/import-export/aqb/gnc-ab-getbalance.c @@ -80,7 +80,7 @@ gnc_ab_getbalance(GtkWidget *parent, Account *gnc_acc) if (!ab_acc) { g_warning("gnc_ab_getbalance: No AqBanking account found"); - gnc_error_dialog(parent, _("No valid online banking account assigned.")); + gnc_error_dialog (GTK_WINDOW (parent), _("No valid online banking account assigned.")); goto cleanup; } @@ -94,7 +94,7 @@ gnc_ab_getbalance(GtkWidget *parent, Account *gnc_acc) { g_warning("gnc_ab_getbalance: JobGetBalance not available for this " "account"); - gnc_error_dialog(parent, _("Online action \"Get Balance\" not available for this account.")); + gnc_error_dialog (GTK_WINDOW (parent), _("Online action \"Get Balance\" not available for this account.")); goto cleanup; } job_list = AB_Job_List2_new(); @@ -127,9 +127,9 @@ gnc_ab_getbalance(GtkWidget *parent, Account *gnc_acc) && job_status != AB_Job_StatusPending) { g_warning("gnc_ab_getbalance: Error on executing job"); - gnc_error_dialog(parent, _("Error on executing job.\n\nStatus: %s - %s") - , AB_Job_Status2Char(job_status) - , AB_Job_GetResultText(job)); + gnc_error_dialog (GTK_WINDOW (parent), _("Error on executing job.\n\nStatus: %s - %s"), + AB_Job_Status2Char(job_status), + AB_Job_GetResultText(job)); goto cleanup; } diff --git a/gnucash/import-export/aqb/gnc-ab-gettrans.c b/gnucash/import-export/aqb/gnc-ab-gettrans.c index f5a236e332..8a7641fe7b 100644 --- a/gnucash/import-export/aqb/gnc-ab-gettrans.c +++ b/gnucash/import-export/aqb/gnc-ab-gettrans.c @@ -134,7 +134,7 @@ gnc_ab_gettrans(GtkWidget *parent, Account *gnc_acc) if (!ab_acc) { g_warning("gnc_ab_gettrans: No AqBanking account found"); - gnc_error_dialog(parent, _("No valid online banking account assigned.")); + gnc_error_dialog (GTK_WINDOW (parent), _("No valid online banking account assigned.")); goto cleanup; } @@ -157,7 +157,7 @@ gnc_ab_gettrans(GtkWidget *parent, Account *gnc_acc) { g_warning("gnc_ab_gettrans: JobGetTransactions not available for this " "account"); - gnc_error_dialog(parent, _("Online action \"Get Transactions\" not available for this account.")); + gnc_error_dialog (GTK_WINDOW (parent), _("Online action \"Get Transactions\" not available for this account.")); goto cleanup; } AB_JobGetTransactions_SetFromTime(job, from_date); @@ -192,9 +192,9 @@ gnc_ab_gettrans(GtkWidget *parent, Account *gnc_acc) && job_status != AB_Job_StatusPending) { g_warning("gnc_ab_gettrans: Error on executing job"); - gnc_error_dialog(parent, _("Error on executing job.\n\nStatus: %s - %s") - , AB_Job_Status2Char(job_status) - , AB_Job_GetResultText(job)); + gnc_error_dialog (GTK_WINDOW (parent), _("Error on executing job.\n\nStatus: %s - %s"), + AB_Job_Status2Char(job_status), + AB_Job_GetResultText(job)); goto cleanup; } diff --git a/gnucash/import-export/aqb/gnc-ab-transfer.c b/gnucash/import-export/aqb/gnc-ab-transfer.c index abb68b32d4..128e94bcf0 100644 --- a/gnucash/import-export/aqb/gnc-ab-transfer.c +++ b/gnucash/import-export/aqb/gnc-ab-transfer.c @@ -56,8 +56,8 @@ save_templates(GtkWidget *parent, Account *gnc_acc, GList *templates, gboolean dont_ask) { g_return_if_fail(gnc_acc); - if (dont_ask || gnc_verify_dialog( - parent, FALSE, "%s", + if (dont_ask || gnc_verify_dialog ( + GTK_WINDOW (parent), FALSE, "%s", _("You have changed the list of online transfer templates, " "but you cancelled the transfer dialog. " "Do you nevertheless want to store the changes?"))) @@ -113,7 +113,7 @@ gnc_ab_maketrans(GtkWidget *parent, Account *gnc_acc, if (!ab_acc) { g_warning("gnc_ab_gettrans: No AqBanking account found"); - gnc_error_dialog(parent, _("No valid online banking account assigned.")); + gnc_error_dialog (GTK_WINDOW (parent), _("No valid online banking account assigned.")); goto cleanup; } @@ -180,8 +180,8 @@ gnc_ab_maketrans(GtkWidget *parent, Account *gnc_acc, #endif )) { - if (!gnc_verify_dialog( - parent, FALSE, "%s", + if (!gnc_verify_dialog ( + GTK_WINDOW (parent), FALSE, "%s", _("The backend found an error during the preparation " "of the job. It is not possible to execute this job. \n" "\n" @@ -289,8 +289,8 @@ gnc_ab_maketrans(GtkWidget *parent, Account *gnc_acc, && job_status != AB_Job_StatusPending) { successful = FALSE; - if (!gnc_verify_dialog( - parent, FALSE, "%s", + if (!gnc_verify_dialog ( + GTK_WINDOW (parent), FALSE, "%s", _("An error occurred while executing the job. Please check " "the log window for the exact error message.\n" "\n" diff --git a/gnucash/import-export/aqb/gnc-ab-utils.c b/gnucash/import-export/aqb/gnc-ab-utils.c index c06d92760e..161aca6e2f 100644 --- a/gnucash/import-export/aqb/gnc-ab-utils.c +++ b/gnucash/import-export/aqb/gnc-ab-utils.c @@ -715,7 +715,7 @@ txn_transaction_cb(const AB_TRANSACTION *element, gpointer user_data) { /* Oops, no job, probably not supported by bank */ if (gnc_verify_dialog( - NULL, FALSE, "%s", + GTK_WINDOW (data->parent), FALSE, "%s", _("The backend found an error during the preparation " "of the job. It is not possible to execute this job. \n" "\n" @@ -726,7 +726,8 @@ txn_transaction_cb(const AB_TRANSACTION *element, gpointer user_data) "\n" "Do you want to enter the job again?"))) { - gnc_error_dialog(NULL, "Sorry, not implemented yet. Please check the console or trace file logs to see which job was rejected."); + gnc_error_dialog (GTK_WINDOW (data->parent), + "Sorry, not implemented yet. Please check the console or trace file logs to see which job was rejected."); } } else @@ -807,7 +808,7 @@ txn_accountinfo_cb(AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data) if (!(data->awaiting & AWAIT_TRANSACTIONS)) { - if (gnc_verify_dialog(data->parent, TRUE, "%s", + if (gnc_verify_dialog (GTK_WINDOW (data->parent), TRUE, "%s", _("The bank has sent transaction information " "in its response." "\n" @@ -834,7 +835,7 @@ txn_accountinfo_cb(AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data) data->ab_acc = gnc_ab_get_ab_account(data->api, gnc_acc); if (!data->ab_acc) { - gnc_error_dialog(NULL, "%s", + gnc_error_dialog(GTK_WINDOW (data->parent), "%s", _("No Online Banking account found for this " "gnucash account. These transactions will " "not be executed by Online Banking.")); @@ -911,7 +912,7 @@ bal_accountinfo_cb(AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data) return NULL; /* Ask the user whether to import unawaited non-zero balance */ - if (gnc_verify_dialog(data->parent, TRUE, "%s", + if (gnc_verify_dialog (GTK_WINDOW (data->parent), TRUE, "%s", _("The bank has sent balance information " "in its response." "\n" @@ -1047,7 +1048,7 @@ bal_accountinfo_cb(AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data) { const char *message3 = _("Reconcile account now?"); - show_recn_window = gnc_verify_dialog(data->parent, TRUE, "%s\n%s\n%s", + show_recn_window = gnc_verify_dialog (GTK_WINDOW (data->parent), TRUE, "%s\n%s\n%s", message1, message2, message3); } g_free(booked_str); @@ -1110,7 +1111,7 @@ gnc_ab_import_context(AB_IMEXPORTER_CONTEXT *context, { const char* subject = AB_Message_GetSubject(bankmsg); const char* text = AB_Message_GetText(bankmsg); - gnc_info_dialog(data->parent, "%s\n%s %s\n%s", + gnc_info_dialog(GTK_WINDOW (data->parent), "%s\n%s %s\n%s", _("The bank has sent a message in its response."), _("Subject:"), subject, diff --git a/gnucash/import-export/aqb/gnc-file-aqb-import.c b/gnucash/import-export/aqb/gnc-file-aqb-import.c index 7194e02b5f..b7cbbddf87 100644 --- a/gnucash/import-export/aqb/gnc-file-aqb-import.c +++ b/gnucash/import-export/aqb/gnc-file-aqb-import.c @@ -68,7 +68,8 @@ typedef GWEN_SYNCIO GWEN_IO_LAYER; static QofLogModule log_module = GNC_MOD_IMPORT; void -gnc_file_aqbanking_import(const gchar *aqbanking_importername, +gnc_file_aqbanking_import(GtkWindow *parent, + const gchar *aqbanking_importername, const gchar *aqbanking_profilename, gboolean execute_transactions) { @@ -96,7 +97,7 @@ gnc_file_aqbanking_import(const gchar *aqbanking_importername, /* Select a file */ default_dir = gnc_get_default_directory(GNC_PREFS_GROUP_AQBANKING); - selected_filename = gnc_file_dialog(_("Select a file to import"), + selected_filename = gnc_file_dialog(parent, _("Select a file to import"), NULL, default_dir, GNC_FILE_DIALOG_IMPORT); g_free(default_dir); @@ -141,7 +142,7 @@ gnc_file_aqbanking_import(const gchar *aqbanking_importername, if (!importer) { g_warning("Import module %s not found", aqbanking_importername); - gnc_error_dialog(NULL, "%s", + gnc_error_dialog(parent, "%s", _("Import module for DTAUS import not found.")); goto cleanup; } @@ -229,7 +230,7 @@ gnc_file_aqbanking_import(const gchar *aqbanking_importername, /* Before importing the results, if this is a new book, let user specify * book options, since they affect how transactions are created */ if (gnc_is_new_book()) - gnc_new_book_option_display(gnc_ui_get_toplevel()); + gnc_new_book_option_display (GTK_WIDGET (parent)); /* Import the results */ ieci = gnc_ab_import_context(context, AWAIT_TRANSACTIONS, @@ -319,7 +320,7 @@ gnc_file_aqbanking_import(const gchar *aqbanking_importername, if (!successful) { g_warning("%s", errstr->str); - gnc_error_dialog(NULL, + gnc_error_dialog(parent, _("An error occurred while executing jobs: %d of %d failed. " "Please check the log window or gnucash.trace for the exact " "error message.\n\n%s") @@ -329,13 +330,13 @@ gnc_file_aqbanking_import(const gchar *aqbanking_importername, { if (num_jobs == 0) { - gnc_info_dialog(NULL, + gnc_info_dialog(parent, _("No jobs to be send.") ); } else { - gnc_info_dialog(NULL, ngettext + gnc_info_dialog(parent, ngettext ("The job was executed successfully, but as a precaution " "please check the log window for potential errors.", "All %d jobs were executed successfully, but as a precaution " diff --git a/gnucash/import-export/aqb/gnc-file-aqb-import.h b/gnucash/import-export/aqb/gnc-file-aqb-import.h index 85e8d96860..a09d069224 100644 --- a/gnucash/import-export/aqb/gnc-file-aqb-import.h +++ b/gnucash/import-export/aqb/gnc-file-aqb-import.h @@ -57,7 +57,8 @@ G_BEGIN_DECLS * transactions as online jobs over aqbanking/HBCI. If FALSE, just import the * transactions and that's it. */ -void gnc_file_aqbanking_import (const gchar *aqbanking_importername, +void gnc_file_aqbanking_import (GtkWindow *parent, + const gchar *aqbanking_importername, const gchar *aqbanking_formatname, gboolean exec_as_aqbanking_jobs); diff --git a/gnucash/import-export/aqb/gnc-gwen-gui.c b/gnucash/import-export/aqb/gnc-gwen-gui.c index eebc20a122..db8792f08d 100644 --- a/gnucash/import-export/aqb/gnc-gwen-gui.c +++ b/gnucash/import-export/aqb/gnc-gwen-gui.c @@ -1087,7 +1087,7 @@ get_input(GncGWENGui *gui, guint32 flags, const gchar *title, const gchar *text, gchar *msg = g_strdup_printf( _("The PIN needs to be at least %d characters \n" "long. Do you want to try again?"), min_len); - retval = gnc_verify_dialog(gui->parent, TRUE, "%s", msg); + retval = gnc_verify_dialog (GTK_WINDOW (gui->parent), TRUE, "%s", msg); g_free(msg); if (!retval) break; @@ -1589,7 +1589,7 @@ ggg_delete_event_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data) const char *still_running_msg = _("The Online Banking job is still running; are you " "sure you want to cancel?"); - if (!gnc_verify_dialog(gui->dialog, FALSE, "%s", still_running_msg)) + if (!gnc_verify_dialog (GTK_WINDOW (gui->dialog), FALSE, "%s", still_running_msg)) return FALSE; set_aborted(gui); diff --git a/gnucash/import-export/aqb/gnc-plugin-aqbanking.c b/gnucash/import-export/aqb/gnc-plugin-aqbanking.c index 7ac5dfed0a..fa0d886127 100644 --- a/gnucash/import-export/aqb/gnc-plugin-aqbanking.c +++ b/gnucash/import-export/aqb/gnc-plugin-aqbanking.c @@ -664,7 +664,8 @@ gnc_plugin_ab_cmd_mt940_import(GtkAction *action, GncMainWindowActionData *data) gchar *format = gnc_prefs_get_string(GNC_PREFS_GROUP_AQBANKING, GNC_PREF_FORMAT_SWIFT940); gnc_main_window = data->window; - gnc_file_aqbanking_import("swift", format ? format : "swift-mt940", FALSE); + gnc_file_aqbanking_import (GTK_WINDOW (gnc_main_window), + "swift", format ? format : "swift-mt940", FALSE); g_free(format); } @@ -674,7 +675,8 @@ gnc_plugin_ab_cmd_mt942_import(GtkAction *action, GncMainWindowActionData *data) gchar *format = gnc_prefs_get_string(GNC_PREFS_GROUP_AQBANKING, GNC_PREF_FORMAT_SWIFT942); gnc_main_window = data->window; - gnc_file_aqbanking_import("swift", format ? format : "swift-mt942", FALSE); + gnc_file_aqbanking_import (GTK_WINDOW (gnc_main_window), + "swift", format ? format : "swift-mt942", FALSE); g_free(format); } @@ -684,7 +686,8 @@ gnc_plugin_ab_cmd_dtaus_import(GtkAction *action, GncMainWindowActionData *data) gchar *format = gnc_prefs_get_string(GNC_PREFS_GROUP_AQBANKING, GNC_PREF_FORMAT_DTAUS); gnc_main_window = data->window; - gnc_file_aqbanking_import("dtaus", format ? format : "default", FALSE); + gnc_file_aqbanking_import (GTK_WINDOW (gnc_main_window), + "dtaus", format ? format : "default", FALSE); g_free(format); } @@ -695,7 +698,8 @@ gnc_plugin_ab_cmd_dtaus_importsend(GtkAction *action, gchar *format = gnc_prefs_get_string(GNC_PREFS_GROUP_AQBANKING, GNC_PREF_FORMAT_DTAUS); gnc_main_window = data->window; - gnc_file_aqbanking_import("dtaus", format ? format : "default", TRUE); + gnc_file_aqbanking_import (GTK_WINDOW (gnc_main_window), + "dtaus", format ? format : "default", TRUE); g_free(format); } 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 1ec3c530d0..c7f302e5c6 100644 --- a/gnucash/import-export/bi-import/dialog-bi-import-gui.c +++ b/gnucash/import-export/bi-import/dialog-bi-import-gui.c @@ -44,6 +44,7 @@ struct _bi_import_gui { + GtkWindow *parent; GtkWidget *dialog; GtkWidget *tree_view; GtkWidget *entryFilename; @@ -81,7 +82,7 @@ static void gnc_info2_dialog (GtkWidget *parent, const gchar *title, const gchar static QofLogModule UNUSED_VAR log_module = G_LOG_DOMAIN; //G_LOG_BUSINESS; BillImportGui * -gnc_plugin_bi_import_showGUI(void) +gnc_plugin_bi_import_showGUI (GtkWindow *parent) { BillImportGui *gui; GtkBuilder *builder; @@ -96,6 +97,9 @@ gnc_plugin_bi_import_showGUI(void) // window found gui = g_list_nth_data (glist, 0); g_list_free (glist); + + gtk_window_set_transient_for(GTK_WINDOW(gui->dialog), GTK_WINDOW(parent)); + gui->parent = parent; gtk_window_present (GTK_WINDOW(gui->dialog)); return gui; } @@ -108,6 +112,8 @@ gnc_plugin_bi_import_showGUI(void) builder = gtk_builder_new(); gnc_builder_add_from_file (builder, "dialog-bi-import-gui.glade", "bi_import_dialog"); gui->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "bi_import_dialog")); + gtk_window_set_transient_for(GTK_WINDOW(gui->dialog), GTK_WINDOW(parent)); + gui->parent = parent; gui->tree_view = GTK_WIDGET(gtk_builder_get_object (builder, "treeview1")); gui->entryFilename = GTK_WIDGET(gtk_builder_get_object (builder, "entryFilename")); @@ -170,7 +176,7 @@ gnc_plugin_bi_import_showGUI(void) } static gchar * -gnc_plugin_bi_import_getFilename(void) +gnc_plugin_bi_import_getFilename(GtkWindow *parent) { // prepare file import dialog gchar *filename = NULL; @@ -185,7 +191,7 @@ gnc_plugin_bi_import_getFilename(void) gtk_file_filter_set_name (filter, "text files (*.txt)"); gtk_file_filter_add_pattern (filter, "*.txt"); filters = g_list_append( filters, filter ); - filename = gnc_file_dialog(_("Import Bills or Invoices from csv"), filters, NULL, GNC_FILE_DIALOG_IMPORT); + filename = gnc_file_dialog(parent, _("Import Bills or Invoices from csv"), filters, NULL, GNC_FILE_DIALOG_IMPORT); return filename; } @@ -208,11 +214,12 @@ gnc_bi_import_gui_ok_cb (GtkWidget *widget, gpointer data) if (res == RESULT_OK) { gnc_bi_import_fix_bis (gui->store, &n_fixed, &n_deleted, info, gui->type); - gnc_bi_import_create_bis (gui->store, gui->book, &n_invoices_created, &n_invoices_updated, gui->type, gui->open_mode, info); + gnc_bi_import_create_bis (gui->store, gui->book, &n_invoices_created, &n_invoices_updated, + gui->type, gui->open_mode, info, gui->parent); if (info->len > 0) - gnc_info_dialog (gui->dialog, "%s", info->str); + gnc_info_dialog (GTK_WINDOW (gui->dialog), "%s", info->str); g_string_free( info, TRUE ); - gnc_info_dialog (gui->dialog, _("Import results:\n%i lines were ignored\n%i lines imported:\n %u fixes\n %u ignored (not fixable)\n\n %u created\n %u updated (based on id)"), stats.n_ignored, stats.n_imported, n_fixed, n_deleted, n_invoices_created, n_invoices_updated); + gnc_info_dialog (GTK_WINDOW (gui->dialog), _("Import results:\n%i lines were ignored\n%i lines imported:\n %u fixes\n %u ignored (not fixable)\n\n %u created\n %u updated (based on id)"), stats.n_ignored, stats.n_imported, n_fixed, n_deleted, n_invoices_created, n_invoices_updated); if (stats.n_ignored > 0) gnc_info2_dialog (gui->dialog, _("These lines were ignored during import"), stats.ignored_lines->str); @@ -221,11 +228,11 @@ gnc_bi_import_gui_ok_cb (GtkWidget *widget, gpointer data) } else if (res == RESULT_OPEN_FAILED) { - gnc_error_dialog (gui->dialog, _("The input file can not be opened.")); + gnc_error_dialog (GTK_WINDOW (gui->dialog), _("The input file can not be opened.")); } else if (res == RESULT_ERROR_IN_REGEXP) { - //gnc_error_dialog (gui->dialog, "The regular expression is faulty:\n\n%s", stats.err->str); + //gnc_error_dialog (GTK_WINDOW (gui->dialog), "The regular expression is faulty:\n\n%s", stats.err->str); } } @@ -272,7 +279,7 @@ void gnc_bi_import_gui_buttonOpen_cb (GtkWidget *widget, gpointer data) gchar *filename = NULL; BillImportGui *gui = data; - filename = gnc_plugin_bi_import_getFilename(); + filename = gnc_plugin_bi_import_getFilename (gnc_ui_get_gtk_window (widget)); if (filename) { //printf("Setting filename"); // debug diff --git a/gnucash/import-export/bi-import/dialog-bi-import-gui.h b/gnucash/import-export/bi-import/dialog-bi-import-gui.h index 084843715b..b698ad725f 100644 --- a/gnucash/import-export/bi-import/dialog-bi-import-gui.h +++ b/gnucash/import-export/bi-import/dialog-bi-import-gui.h @@ -39,7 +39,7 @@ typedef struct _bi_import_gui BillImportGui; /** * File chooser */ -BillImportGui *gnc_plugin_bi_import_showGUI(void); +BillImportGui *gnc_plugin_bi_import_showGUI(GtkWindow *parent); G_END_DECLS diff --git a/gnucash/import-export/bi-import/dialog-bi-import.c b/gnucash/import-export/bi-import/dialog-bi-import.c index ab146cb118..4fb5e74c77 100644 --- a/gnucash/import-export/bi-import/dialog-bi-import.c +++ b/gnucash/import-export/bi-import/dialog-bi-import.c @@ -98,7 +98,7 @@ gnc_bi_import_read_file (const gchar * filename, const gchar * parser_regexp, f = g_fopen (filename, "rt"); if (!f) { - //gnc_error_dialog( 0, _("File %s cannot be opened."), filename ); + //gnc_error_dialog (NULL, _("File %s cannot be opened."), filename ); return RESULT_OPEN_FAILED; } @@ -504,7 +504,8 @@ void gnc_bi_import_create_bis (GtkListStore * store, QofBook * book, guint * n_invoices_created, guint * n_invoices_updated, - gchar * type, gchar * open_mode, GString * info) + gchar * type, gchar * open_mode, GString * info, + GtkWindow *parent) { gboolean valid; GtkTreeIter iter; @@ -628,7 +629,6 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book, (*n_invoices_created)++; update = YES; - gncInvoiceCommitEdit (invoice); } // I want to warn the user that an existing billvoice exists, but not every @@ -645,7 +645,7 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book, } if (update != YES) // Pop up a dialog to ask if updates are the expected action { - dialog = gtk_message_dialog_new (NULL, + dialog = gtk_message_dialog_new (parent, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_YES_NO, @@ -840,7 +840,7 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book, || (g_ascii_strcasecmp(open_mode, "NOT_POSTED") == 0 && strlen(date_posted) == 0)) { - iw = gnc_ui_invoice_edit (invoice); + iw = gnc_ui_invoice_edit (parent, invoice); gnc_plugin_page_invoice_new (iw); } diff --git a/gnucash/import-export/bi-import/dialog-bi-import.h b/gnucash/import-export/bi-import/dialog-bi-import.h index f03af056d1..649b290677 100644 --- a/gnucash/import-export/bi-import/dialog-bi-import.h +++ b/gnucash/import-export/bi-import/dialog-bi-import.h @@ -68,7 +68,9 @@ void gnc_bi_import_fix_bis (GtkListStore *store, guint *fixed, guint *deleted, GString *info, gchar *type); void -gnc_bi_import_create_bis (GtkListStore *store, QofBook *book, guint *n_invoices_created, guint *n_invoices_updated, gchar *type, gchar *open_mode, GString * info); +gnc_bi_import_create_bis (GtkListStore *store, QofBook *book, guint *n_invoices_created, + guint *n_invoices_updated, gchar *type, gchar *open_mode, GString * info, + GtkWindow *parent); G_END_DECLS diff --git a/gnucash/import-export/bi-import/gnc-plugin-bi-import.c b/gnucash/import-export/bi-import/gnc-plugin-bi-import.c index e3ccb3c77d..9087661084 100644 --- a/gnucash/import-export/bi-import/gnc-plugin-bi-import.c +++ b/gnucash/import-export/bi-import/gnc-plugin-bi-import.c @@ -109,7 +109,7 @@ gnc_plugin_bi_import_cmd_test (GtkAction *action, GncMainWindowActionData *data) ENTER ("action %p, main window data %p", action, data); g_message ("bi_import"); - gnc_plugin_bi_import_showGUI(); + gnc_plugin_bi_import_showGUI(GTK_WINDOW(data->window)); LEAVE (" "); } diff --git a/gnucash/import-export/csv-exp/assistant-csv-export.c b/gnucash/import-export/csv-exp/assistant-csv-export.c index 7e05461bf4..a39090ce4f 100644 --- a/gnucash/import-export/csv-exp/assistant-csv-export.c +++ b/gnucash/import-export/csv-exp/assistant-csv-export.c @@ -146,7 +146,7 @@ csv_export_file_chooser_confirm_cb (GtkWidget *button, CsvExportInfo *info) "Are you sure you want to overwrite it?"); /* if user says cancel, we should break out */ - if (!gnc_verify_dialog (NULL, FALSE, format, file_name)) + if (!gnc_verify_dialog (GTK_WINDOW (assistant), FALSE, format, file_name)) return; } diff --git a/gnucash/import-export/csv-imp/assistant-csv-account-import.c b/gnucash/import-export/csv-imp/assistant-csv-account-import.c index 916ecdb068..aaceb5e9d1 100644 --- a/gnucash/import-export/csv-imp/assistant-csv-account-import.c +++ b/gnucash/import-export/csv-imp/assistant-csv-account-import.c @@ -168,7 +168,7 @@ csv_import_file_chooser_confirm_cb (GtkWidget *button, CsvImportInfo *info) gtk_list_store_clear (info->store); res = csv_import_read_file (info->file_name, info->regexp->str, info->store, 1 ); if (res == RESULT_OPEN_FAILED) - gnc_error_dialog (info->window, _("The input file can not be opened.")); + gnc_error_dialog (GTK_WINDOW (info->window), _("The input file can not be opened.")); else if (res == RESULT_OK) gtk_assistant_set_page_complete (assistant, page, TRUE); else if (res == MATCH_FOUND) diff --git a/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp b/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp index 3512aba4be..41779c63cd 100644 --- a/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp +++ b/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp @@ -643,13 +643,13 @@ CsvImpTransAssist::file_confirm_cb () catch (std::ifstream::failure& e) { /* File loading failed ... */ - gnc_error_dialog (GTK_WIDGET(csv_imp_asst), "%s", e.what()); + gnc_error_dialog (GTK_WINDOW (csv_imp_asst), "%s", e.what()); return; } catch (std::range_error &e) { /* Parsing failed ... */ - gnc_error_dialog (GTK_WIDGET(csv_imp_asst), "%s", e.what()); + gnc_error_dialog (GTK_WINDOW (csv_imp_asst), "%s", e.what()); return; } @@ -761,7 +761,7 @@ CsvImpTransAssist::preview_settings_load () tx_imp->settings (*preset); if (preset->m_load_error) - gnc_error_dialog (GTK_WIDGET(csv_imp_asst), + gnc_error_dialog (GTK_WINDOW (csv_imp_asst), "%s", _("There were problems reading some saved settings, continuing to load.\n" "Please review and save again.")); @@ -783,7 +783,7 @@ CsvImpTransAssist::preview_settings_delete () auto model = gtk_combo_box_get_model (settings_combo); gtk_tree_model_get (model, &iter, SET_GROUP, &preset, -1); - auto response = gnc_ok_cancel_dialog (GTK_WIDGET(csv_imp_asst), + auto response = gnc_ok_cancel_dialog (GTK_WINDOW (csv_imp_asst), GTK_RESPONSE_CANCEL, "%s", _("Delete the Import Settings.")); if (response == GTK_RESPONSE_OK) @@ -817,7 +817,7 @@ CsvImpTransAssist::preview_settings_save () if (preset && (preset->m_name == std::string(new_name))) { - auto response = gnc_ok_cancel_dialog (GTK_WIDGET(csv_imp_asst), + auto response = gnc_ok_cancel_dialog (GTK_WINDOW (csv_imp_asst), GTK_RESPONSE_OK, "%s", _("Setting name already exists, over write?")); if (response != GTK_RESPONSE_OK) @@ -832,7 +832,7 @@ CsvImpTransAssist::preview_settings_save () /* All checks passed, let's save this preset */ if (!tx_imp->save_settings()) { - gnc_info_dialog (GTK_WIDGET(csv_imp_asst), + gnc_info_dialog (GTK_WINDOW (csv_imp_asst), "%s", _("The settings have been saved.")); // Update the settings store @@ -857,7 +857,7 @@ CsvImpTransAssist::preview_settings_save () } } else - gnc_error_dialog (GTK_WIDGET(csv_imp_asst), + gnc_error_dialog (GTK_WINDOW (csv_imp_asst), "%s", _("There was a problem saving the settings, please try again.")); } @@ -938,7 +938,7 @@ void CsvImpTransAssist::preview_update_separators (GtkWidget* widget) /* Warn the user there was a problem and try to undo what caused * the error. (This will cause a reparsing and ideally a usable * configuration.) */ - gnc_error_dialog (GTK_WIDGET(csv_imp_asst), "Error in parsing"); + gnc_error_dialog (GTK_WINDOW (csv_imp_asst), "Error in parsing"); /* If we're here because the user changed the file format, we should just wait for the user * to update the configuration */ if (!widget) @@ -988,7 +988,7 @@ void CsvImpTransAssist::preview_update_file_format () catch (std::range_error &e) { /* Parsing failed ... */ - gnc_error_dialog (nullptr, "%s", e.what()); + gnc_error_dialog (GTK_WINDOW (csv_imp_asst), "%s", e.what()); return; } catch (...) @@ -1032,7 +1032,7 @@ CsvImpTransAssist::preview_update_encoding (const char* encoding) catch (...) { /* If it fails, change back to the old encoding. */ - gnc_error_dialog (nullptr, "%s", _("Invalid encoding selected")); + gnc_error_dialog (GTK_WINDOW (csv_imp_asst), "%s", _("Invalid encoding selected")); go_charmap_sel_set_encoding (encselector, previous_encoding.c_str()); } } @@ -1220,7 +1220,7 @@ fixed_context_menu_handler (GnumericPopupMenuElement const *element, } catch(std::range_error& e) { - gnc_error_dialog (nullptr, "%s", e.what()); + gnc_error_dialog (GTK_WINDOW (info->csv_imp_asst), "%s", e.what()); return false; } info->preview_refresh_table (); @@ -1265,7 +1265,7 @@ CsvImpTransAssist::preview_split_column (int col, int offset) } catch (std::range_error& e) { - gnc_error_dialog (nullptr, "%s", e.what()); + gnc_error_dialog (GTK_WINDOW (csv_imp_asst), "%s", e.what()); return; } preview_refresh_table(); @@ -1865,7 +1865,7 @@ CsvImpTransAssist::assist_doc_page_prepare () /* Oops! This shouldn't happen when using the import assistant ! * Inform the user and go back to the preview page. */ - gnc_error_dialog (GTK_WIDGET(csv_imp_asst), + gnc_error_dialog (GTK_WINDOW (csv_imp_asst), _("An unexpected error has occurred while mapping accounts. Please report this as a bug.\n\n" "Error message:\n%s"), err.what()); gtk_assistant_set_current_page (csv_imp_asst, 2); @@ -1899,7 +1899,7 @@ CsvImpTransAssist::assist_match_page_prepare () /* Oops! This shouldn't happen when using the import assistant ! * Inform the user and go back to the preview page. */ - gnc_error_dialog (GTK_WIDGET(csv_imp_asst), + gnc_error_dialog (GTK_WINDOW (csv_imp_asst), _("An unexpected error has occurred while creating transactions. Please report this as a bug.\n\n" "Error message:\n%s"), err.what()); gtk_assistant_set_current_page (csv_imp_asst, 2); diff --git a/gnucash/import-export/csv-imp/csv-account-import.c b/gnucash/import-export/csv-imp/csv-account-import.c index 58fe3315e5..5285b6885e 100644 --- a/gnucash/import-export/csv-imp/csv-account-import.c +++ b/gnucash/import-export/csv-imp/csv-account-import.c @@ -93,7 +93,7 @@ csv_import_read_file (const gchar *filename, const gchar *parser_regexp, if (!g_file_get_contents (filename, &locale_cont, NULL, NULL)) { - //gnc_error_dialog( 0, _("File %s cannot be opened."), filename ); + //gnc_error_dialog (NULL, _("File %s cannot be opened."), filename ); return RESULT_OPEN_FAILED; } 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 3884300bcc..a4160867c1 100644 --- a/gnucash/import-export/customer-import/dialog-customer-import-gui.c +++ b/gnucash/import-export/customer-import/dialog-customer-import-gui.c @@ -154,7 +154,7 @@ gnc_plugin_customer_import_showGUI(void) } static gchar * -gnc_plugin_customer_import_getFilename(void) +gnc_plugin_customer_import_getFilename (GtkWindow *parent) { // prepare file import dialog gchar *filename; @@ -169,7 +169,8 @@ gnc_plugin_customer_import_getFilename(void) gtk_file_filter_set_name (filter, "text files (*.txt)"); gtk_file_filter_add_pattern (filter, "*.txt"); filters = g_list_append( filters, filter ); - filename = gnc_file_dialog(_("Import Customers from csv"), filters, NULL, GNC_FILE_DIALOG_IMPORT); + filename = gnc_file_dialog(parent, + _("Import Customers from csv"), filters, NULL, GNC_FILE_DIALOG_IMPORT); return filename; } @@ -194,7 +195,7 @@ gnc_customer_import_gui_ok_cb (GtkWidget *widget, gpointer data) { gnc_customer_import_fix_customers (gui->store, &n_fixed, &n_deleted, gui->type); gnc_customer_import_create_customers (gui->store, gui->book, &n_customers_created, &n_customers_updated, gui->type); - gnc_info_dialog (gui->dialog, _("Import results:\n%i lines were ignored\n%i lines imported:\n %u %s fixed\n %u %s ignored (not fixable)\n\n %u %s created\n %u %s updated (based on id)"), \ + gnc_info_dialog (GTK_WINDOW (gui->dialog), _("Import results:\n%i lines were ignored\n%i lines imported:\n %u %s fixed\n %u %s ignored (not fixable)\n\n %u %s created\n %u %s updated (based on id)"), \ stats.n_ignored, stats.n_imported, n_fixed, cv_type_text, n_deleted, cv_type_text, n_customers_created, cv_type_text, n_customers_updated, cv_type_text); if (stats.n_ignored > 0) @@ -205,11 +206,11 @@ gnc_customer_import_gui_ok_cb (GtkWidget *widget, gpointer data) } else if (res == CI_RESULT_OPEN_FAILED) { - gnc_error_dialog (gui->dialog, _("The input file can not be opened.")); + gnc_error_dialog (GTK_WINDOW (gui->dialog), _("The input file can not be opened.")); } else if (res == CI_RESULT_ERROR_IN_REGEXP) { - //gnc_error_dialog (gui->dialog, "The regular expression is faulty:\n\n%s", stats.err->str); + //gnc_error_dialog (GTK_WINDOW (gui->dialog), "The regular expression is faulty:\n\n%s", stats.err->str); } } @@ -256,7 +257,7 @@ void gnc_customer_import_gui_buttonOpen_cb (GtkWidget *widget, gpointer data) gchar *filename; CustomerImportGui *gui = data; - filename = gnc_plugin_customer_import_getFilename(); + filename = gnc_plugin_customer_import_getFilename (gnc_ui_get_gtk_window (widget)); if (filename) { gtk_entry_set_text( GTK_ENTRY(gui->entryFilename), filename ); diff --git a/gnucash/import-export/customer-import/dialog-customer-import.c b/gnucash/import-export/customer-import/dialog-customer-import.c index 9f3accd74d..a095417189 100644 --- a/gnucash/import-export/customer-import/dialog-customer-import.c +++ b/gnucash/import-export/customer-import/dialog-customer-import.c @@ -83,7 +83,7 @@ gnc_customer_import_read_file (const gchar *filename, const gchar *parser_regexp f = g_fopen( filename, "rt" ); if (!f) { - //gnc_error_dialog( 0, _("File %s cannot be opened."), filename ); + //gnc_error_dialog (NULL, _("File %s cannot be opened."), filename ); return CI_RESULT_OPEN_FAILED; } @@ -187,8 +187,6 @@ gnc_customer_import_read_file (const gchar *filename, const gchar *parser_regexp regexpat = 0; fclose (f); - //gnc_info_dialog (0, _("Import results:\n%i customers imported\n%i lines ignored"), n_imported, n_ignored); - if (stats == &stats_fallback) // stats are not requested -> free the string g_string_free (stats->ignored_lines, TRUE); diff --git a/gnucash/import-export/import-account-matcher.c b/gnucash/import-export/import-account-matcher.c index a77ca310c8..33d1904977 100644 --- a/gnucash/import-export/import-account-matcher.c +++ b/gnucash/import-export/import-account-matcher.c @@ -189,7 +189,7 @@ account_tree_row_activated_cb(GtkTreeView *view, GtkTreePath *path, /* See if the selected account is a placeholder. */ if (picker->retAccount && xaccAccountGetPlaceholder (picker->retAccount)) { - gnc_error_dialog (picker->dialog, + gnc_error_dialog (GTK_WINDOW (picker->dialog), _("The account %s is a placeholder account and does not allow " "transactions. Please choose a different account."), retval_name); @@ -365,7 +365,7 @@ Account * gnc_import_select_account(GtkWidget *parent, if (retval && xaccAccountGetPlaceholder (retval)) { gnc_error_dialog - (picker->dialog, + (GTK_WINDOW (picker->dialog), _("The account %s is a placeholder account and does not allow " "transactions. Please choose a different account."), retval_name); diff --git a/gnucash/import-export/log-replay/gnc-log-replay.c b/gnucash/import-export/log-replay/gnc-log-replay.c index 0a61a7b89e..a559a160cd 100644 --- a/gnucash/import-export/log-replay/gnc-log-replay.c +++ b/gnucash/import-export/log-replay/gnc-log-replay.c @@ -544,7 +544,7 @@ static void process_trans_record( FILE *log_file) } } -void gnc_file_log_replay (void) +void gnc_file_log_replay (GtkWindow *parent) { char *selected_filename; char *default_dir; @@ -574,7 +574,8 @@ void gnc_file_log_replay (void) filter = gtk_file_filter_new(); gtk_file_filter_set_name(filter, "*.log"); gtk_file_filter_add_pattern(filter, "*.[Ll][Oo][Gg]"); - selected_filename = gnc_file_dialog(_("Select a .log file to replay"), + selected_filename = gnc_file_dialog(parent, + _("Select a .log file to replay"), g_list_prepend(NULL, filter), default_dir, GNC_FILE_DIALOG_OPEN); diff --git a/gnucash/import-export/log-replay/gnc-log-replay.h b/gnucash/import-export/log-replay/gnc-log-replay.h index 8487a08f7b..734a1c5a3d 100644 --- a/gnucash/import-export/log-replay/gnc-log-replay.h +++ b/gnucash/import-export/log-replay/gnc-log-replay.h @@ -25,9 +25,11 @@ #ifndef OFX_IMPORT_H #define OFX_IMPORT_H +#include + /** The gnc_file_log_replay() routine will pop up a standard file * selection dialogue asking the user to pick a log file to replay. If one * is selected the the .log file is opened and read. It's contents * are then silently merged in the current log file. */ -void gnc_file_log_replay (void); +void gnc_file_log_replay (GtkWindow *parent); #endif diff --git a/gnucash/import-export/log-replay/gnc-plugin-log-replay.c b/gnucash/import-export/log-replay/gnc-plugin-log-replay.c index 19247c2f6a..87b54ce1c0 100644 --- a/gnucash/import-export/log-replay/gnc-plugin-log-replay.c +++ b/gnucash/import-export/log-replay/gnc-plugin-log-replay.c @@ -144,7 +144,7 @@ gnc_plugin_log_replay_cmd_new_log_replay (GtkAction *action, GncMainWindowActionData *data) { gnc_suspend_gui_refresh(); - gnc_file_log_replay (); + gnc_file_log_replay (GTK_WINDOW (data->window)); gnc_resume_gui_refresh(); } diff --git a/gnucash/import-export/ofx/gnc-ofx-import.c b/gnucash/import-export/ofx/gnc-ofx-import.c index 38ae80a63e..cbfe10ad66 100644 --- a/gnucash/import-export/ofx/gnc-ofx-import.c +++ b/gnucash/import-export/ofx/gnc-ofx-import.c @@ -658,7 +658,7 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data, void * transaction_u // whether to continue or abort. choosing_account = gnc_verify_dialog( - gnc_gen_trans_list_widget(gnc_ofx_importer_gui), TRUE, + GTK_WINDOW (gnc_gen_trans_list_widget(gnc_ofx_importer_gui)), TRUE, "The chosen account \"%s\" does not have the correct " "currency/security \"%s\" (it has \"%s\" instead). " "This account cannot be used. " @@ -919,7 +919,7 @@ int ofx_proc_account_cb(struct OfxAccountData data, void * account_user_data) * calling 'gnc_import_select_account', allow the user to set book * options. */ if (new_book) - new_book = gnc_new_book_option_display(gnc_ui_get_toplevel()); + new_book = gnc_new_book_option_display (GTK_WIDGET (gnc_ui_get_main_window (NULL))); gnc_utf8_strip_invalid(data.account_name); gnc_utf8_strip_invalid(data.account_id); @@ -965,7 +965,7 @@ double ofx_get_investment_amount(const struct OfxTransactionData* data) } } -void gnc_file_ofx_import (void) +void gnc_file_ofx_import (GtkWindow *parent) { extern int ofx_PARSER_msg; extern int ofx_DEBUG_msg; @@ -987,7 +987,8 @@ void gnc_file_ofx_import (void) DEBUG("gnc_file_ofx_import(): Begin...\n"); default_dir = gnc_get_default_directory(GNC_PREFS_GROUP); - selected_filename = gnc_file_dialog(_("Select an OFX/QFX file to process"), + selected_filename = gnc_file_dialog(parent, + _("Select an OFX/QFX file to process"), NULL, default_dir, GNC_FILE_DIALOG_IMPORT); diff --git a/gnucash/import-export/ofx/gnc-ofx-import.h b/gnucash/import-export/ofx/gnc-ofx-import.h index 08421840bb..dfc8547dd0 100644 --- a/gnucash/import-export/ofx/gnc-ofx-import.h +++ b/gnucash/import-export/ofx/gnc-ofx-import.h @@ -25,10 +25,12 @@ #ifndef OFX_IMPORT_H #define OFX_IMPORT_H +#include + /** The gnc_file_ofx_import() routine will pop up a standard file * selection dialogue asking the user to pick a OFX/QFX file. If one * is selected the the OFX file is opened and read. It's contents * are merged into the existing session (if any). The current * session continues to remain open for editing. */ -void gnc_file_ofx_import (void); +void gnc_file_ofx_import (GtkWindow *parent); #endif diff --git a/gnucash/import-export/ofx/gnc-plugin-ofx.c b/gnucash/import-export/ofx/gnc-plugin-ofx.c index 67d23ca2af..c456261a60 100644 --- a/gnucash/import-export/ofx/gnc-plugin-ofx.c +++ b/gnucash/import-export/ofx/gnc-plugin-ofx.c @@ -141,7 +141,7 @@ static void gnc_plugin_ofx_cmd_import (GtkAction *action, GncMainWindowActionData *data) { - gnc_file_ofx_import (); + gnc_file_ofx_import (GTK_WINDOW (data->window)); } diff --git a/gnucash/import-export/qif-imp/assistant-qif-import.c b/gnucash/import-export/qif-imp/assistant-qif-import.c index 6939c331e5..18c9fae52d 100644 --- a/gnucash/import-export/qif-imp/assistant-qif-import.c +++ b/gnucash/import-export/qif-imp/assistant-qif-import.c @@ -1365,7 +1365,7 @@ gnc_ui_qif_import_close_cb(GtkAssistant *gtkassistant, gpointer user_data) if (!wind->acct_tree_found) { qof_book_mark_session_dirty(gnc_get_current_book()); - gnc_ui_file_access_for_save_as(); + gnc_ui_file_access_for_save_as (gnc_ui_get_main_window (GTK_WIDGET (gtkassistant))); } gnc_close_gui_component_by_data( ASSISTANT_QIF_IMPORT_CM_CLASS, wind ); @@ -1535,11 +1535,11 @@ gnc_ui_qif_import_load_file_complete (GtkAssistant *assistant, /* Validate the chosen filename. */ if (strlen(path_to_load) == 0) - gnc_error_dialog(wind->window, "%s", _("Please select a file to load.")); + gnc_error_dialog (GTK_WINDOW (assistant), "%s", _("Please select a file to load.")); else if (g_access(path_to_load, R_OK) < 0) - gnc_error_dialog(wind->window, "%s", - _("File not found or read permission denied. " - "Please select another file.")); + gnc_error_dialog (GTK_WINDOW (assistant), "%s", + _("File not found or read permission denied. " + "Please select another file.")); else { SCM qif_file_loaded = scm_c_eval_string("qif-dialog:qif-file-loaded?"); @@ -1548,9 +1548,9 @@ gnc_ui_qif_import_load_file_complete (GtkAssistant *assistant, if (scm_call_2(qif_file_loaded, scm_from_locale_string(path_to_load ? path_to_load : ""), wind->imported_files) == SCM_BOOL_T) - gnc_error_dialog(wind->window, "%s", - _("That QIF file is already loaded. " - "Please select another file.")); + gnc_error_dialog (GTK_WINDOW (assistant), "%s", + _("That QIF file is already loaded. " + "Please select another file.")); else { /* Passed all checks; proceed to the next page. */ @@ -1617,7 +1617,8 @@ gnc_ui_qif_import_select_file_cb(GtkButton * button, filter = gtk_file_filter_new(); gtk_file_filter_set_name(filter, "*.qif"); gtk_file_filter_add_pattern(filter, "*.[Qq][Ii][Ff]"); - new_file_name = gnc_file_dialog(_("Select QIF File"), + new_file_name = gnc_file_dialog(gnc_ui_get_gtk_window (GTK_WIDGET (button)), + _("Select QIF File"), g_list_prepend (NULL, filter), default_dir, GNC_FILE_DIALOG_IMPORT); @@ -1703,8 +1704,9 @@ gnc_ui_qif_import_load_progress_start_cb(GtkButton * button, gpointer user_data) { QIFImportWindow *wind = user_data; - gint num = gtk_assistant_get_current_page (GTK_ASSISTANT(wind->window)); - GtkWidget *page = gtk_assistant_get_nth_page (GTK_ASSISTANT(wind->window), num); + GtkAssistant *assistant = GTK_ASSISTANT(wind->window); + gint num = gtk_assistant_get_current_page (assistant); + GtkWidget *page = gtk_assistant_get_nth_page (assistant, num); const gchar * path_to_load; @@ -1784,8 +1786,8 @@ gnc_ui_qif_import_load_progress_start_cb(GtkButton * button, _( "An error occurred while loading the QIF file.")); gnc_progress_dialog_set_sub(wind->load_progress, _("Failed")); gnc_progress_dialog_reset_value(wind->load_progress); - gnc_error_dialog(wind->window, "%s", - _( "An error occurred while loading the QIF file.")); + gnc_error_dialog (GTK_WINDOW (assistant), "%s", + _( "An error occurred while loading the QIF file.")); /* FIXME: How should we request that the user report this problem? */ wind->busy = FALSE; @@ -1863,8 +1865,8 @@ gnc_ui_qif_import_load_progress_start_cb(GtkButton * button, _( "A bug was detected while parsing the QIF file.")); gnc_progress_dialog_set_sub(wind->load_progress, _("Failed")); gnc_progress_dialog_reset_value(wind->load_progress); - gnc_error_dialog(wind->window, "%s", - _( "A bug was detected while parsing the QIF file.")); + gnc_error_dialog (GTK_WINDOW (assistant), "%s", + _( "A bug was detected while parsing the QIF file.")); /* FIXME: How should we request that the user report this problem? */ wind->busy = FALSE; @@ -1927,7 +1929,7 @@ gnc_ui_qif_import_load_progress_start_cb(GtkButton * button, } /* Enable the assistant Forward button */ - gtk_assistant_set_page_complete (GTK_ASSISTANT(wind->window), page, TRUE); + gtk_assistant_set_page_complete (assistant, page, TRUE); /* Set Pause and Start buttons */ gtk_widget_set_sensitive(wind->load_pause, FALSE); @@ -1947,7 +1949,7 @@ gnc_ui_qif_import_load_progress_start_cb(GtkButton * button, wind->busy = FALSE; /* Auto step to next page */ - gtk_assistant_set_current_page (GTK_ASSISTANT(wind->window), num + 1); + gtk_assistant_set_current_page (assistant, num + 1); } } @@ -2689,14 +2691,14 @@ gnc_ui_qif_import_comm_valid (GtkAssistant *assistant, if (!name || (name[0] == 0)) { - gnc_warning_dialog(wind->window, "%s", + gnc_warning_dialog(GTK_WINDOW (assistant), "%s", _("Enter a name or short description, such as \"Red Hat Stock\".")); g_free(name_space); return FALSE; } else if (!mnemonic || (mnemonic[0] == 0)) { - gnc_warning_dialog(wind->window, "%s", + gnc_warning_dialog(GTK_WINDOW (assistant), "%s", _("Enter the ticker symbol or other well known abbreviation, such as" " \"RHT\". If there isn't one, or you don't know it, create your own.")); g_free(name_space); @@ -2704,7 +2706,7 @@ gnc_ui_qif_import_comm_valid (GtkAssistant *assistant, } else if (!name_space || (name_space[0] == 0)) { - gnc_warning_dialog(wind->window, "%s", + gnc_warning_dialog(GTK_WINDOW (assistant), "%s", _("Select the exchange on which the symbol is traded, or select the" " type of investment (such as FUND for mutual funds.) If you don't" " see your exchange or an appropriate investment type, you can" @@ -2724,7 +2726,7 @@ gnc_ui_qif_import_comm_valid (GtkAssistant *assistant, if (gnc_commodity_namespace_is_iso(name_space) && !gnc_commodity_table_lookup(table, name_space, mnemonic)) { - gnc_warning_dialog(wind->window, "%s", + gnc_warning_dialog(GTK_WINDOW (assistant), "%s", _("You must enter an existing national " "currency or enter a different type.")); @@ -2821,8 +2823,9 @@ gnc_ui_qif_import_convert_progress_start_cb(GtkButton * button, gpointer user_data) { QIFImportWindow *wind = user_data; - gint num = gtk_assistant_get_current_page (GTK_ASSISTANT(wind->window)); - GtkWidget *page = gtk_assistant_get_nth_page (GTK_ASSISTANT(wind->window), num); + GtkAssistant *assistant = GTK_ASSISTANT (wind->window); + gint num = gtk_assistant_get_current_page (assistant); + GtkWidget *page = gtk_assistant_get_nth_page (assistant, num); SCM qif_to_gnc = scm_c_eval_string("qif-import:qif-to-gnc"); SCM find_duplicates = scm_c_eval_string("gnc:account-tree-find-duplicates"); @@ -2904,8 +2907,8 @@ gnc_ui_qif_import_convert_progress_start_cb(GtkButton * button, _( "A bug was detected while converting the QIF data.")); gnc_progress_dialog_set_sub(wind->convert_progress, _("Failed")); gnc_progress_dialog_reset_value(wind->convert_progress); - gnc_error_dialog(wind->window, "%s", - _( "A bug was detected while converting the QIF data.")); + gnc_error_dialog (GTK_WINDOW (assistant), "%s", + _( "A bug was detected while converting the QIF data.")); /* FIXME: How should we request that the user report this problem? */ wind->busy = FALSE; @@ -2972,8 +2975,8 @@ gnc_ui_qif_import_convert_progress_start_cb(GtkButton * button, _( "A bug was detected while detecting duplicates.")); gnc_progress_dialog_set_sub(wind->convert_progress, _("Failed")); gnc_progress_dialog_reset_value(wind->convert_progress); - gnc_error_dialog(wind->window, "%s", - _( "A bug was detected while detecting duplicates.")); + gnc_error_dialog (GTK_WINDOW (assistant), "%s", + _( "A bug was detected while detecting duplicates.")); /* FIXME: How should we request that the user report this problem? */ gtk_widget_set_sensitive(wind->convert_pause, FALSE); @@ -2982,7 +2985,7 @@ gnc_ui_qif_import_convert_progress_start_cb(GtkButton * button, } /* Enable the Assistant Forward Button */ - gtk_assistant_set_page_complete (GTK_ASSISTANT(wind->window), page, TRUE); + gtk_assistant_set_page_complete (assistant, page, TRUE); /* Set Pause and Start buttons */ gtk_widget_set_sensitive(wind->convert_pause, FALSE); @@ -3000,7 +3003,7 @@ gnc_ui_qif_import_convert_progress_start_cb(GtkButton * button, /* If the log is empty, move on to the next page automatically. */ if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(wind->convert_log))) == 0) - gtk_assistant_set_current_page (GTK_ASSISTANT(wind->window), num + 1); + gtk_assistant_set_current_page (assistant, num + 1); } } @@ -3184,7 +3187,7 @@ gnc_ui_qif_import_end_page_prepare (GtkAssistant *assistant, * Invoked when the "Apply" button is clicked on the final page. ********************************************************************/ void -gnc_ui_qif_import_finish_cb (GtkAssistant *gtkassistant, +gnc_ui_qif_import_finish_cb (GtkAssistant *assistant, gpointer user_data) { QIFImportWindow * wind = user_data; @@ -3219,7 +3222,7 @@ gnc_ui_qif_import_finish_cb (GtkAssistant *gtkassistant, SCM_EOL); if (scm_result == SCM_BOOL_F) - gnc_warning_dialog(wind->window, "%s", + gnc_warning_dialog(GTK_WINDOW (assistant), "%s", _("GnuCash was unable to save your mapping preferences.")); /* Open an account tab in the main window if one doesn't exist already. */ @@ -3617,8 +3620,7 @@ gnc_ui_qif_import_assistant_make(QIFImportWindow *qif_win) get_assistant_widgets(qif_win, builder); /* Make this window stay on top */ - gtk_window_set_transient_for (GTK_WINDOW (qif_win->window), - GTK_WINDOW (gnc_ui_get_toplevel ())); + gtk_window_set_transient_for (GTK_WINDOW (qif_win->window), gnc_ui_get_main_window(NULL)); /* Build the details of all GtkTreeView widgets. */ build_views(qif_win); diff --git a/gnucash/register/ledger-core/gncEntryLedger.c b/gnucash/register/ledger-core/gncEntryLedger.c index 6a8c910f1e..8a75530ca2 100644 --- a/gnucash/register/ledger-core/gncEntryLedger.c +++ b/gnucash/register/ledger-core/gncEntryLedger.c @@ -96,7 +96,7 @@ gnc_entry_ledger_get_account_by_name (GncEntryLedger *ledger, BasicCell * bcell, if (!account) { /* Ask if they want to create a new one. */ - if (!gnc_verify_dialog (ledger->parent, TRUE, missing, name)) + if (!gnc_verify_dialog (GTK_WINDOW (ledger->parent), TRUE, missing, name)) return NULL; /* No changes, as yet. */ @@ -127,7 +127,7 @@ gnc_entry_ledger_get_account_by_name (GncEntryLedger *ledger, BasicCell * bcell, /* See if the account (either old or new) is a placeholder. */ if (xaccAccountGetPlaceholder (account)) { - gnc_error_dialog (ledger->parent, placeholder, name); + gnc_error_dialog (GTK_WINDOW (ledger->parent), placeholder, name); } /* Be seeing you. */ diff --git a/gnucash/register/ledger-core/gncEntryLedgerControl.c b/gnucash/register/ledger-core/gncEntryLedgerControl.c index 159b141f29..cc93fb17d2 100644 --- a/gnucash/register/ledger-core/gncEntryLedgerControl.c +++ b/gnucash/register/ledger-core/gncEntryLedgerControl.c @@ -158,7 +158,7 @@ gnc_entry_ledger_verify_acc_cell_ok (GncEntryLedger *ledger, const char *format = ("%s %s"); const char *gen_msg = _("Invalid Entry: You need to supply an account in the right currency for this position."); - gnc_error_dialog (ledger->parent, format, gen_msg, cell_msg); + gnc_error_dialog (GTK_WINDOW (ledger->parent), format, gen_msg, cell_msg); return FALSE; } return TRUE; @@ -762,7 +762,7 @@ static gboolean gnc_entry_ledger_traverse (VirtualLocation *p_new_virt_loc, { const char *format = _("The tax table %s does not exist. " "Would you like to create it?"); - if (!gnc_verify_dialog (ledger->parent, TRUE, format, name)) + if (!gnc_verify_dialog (GTK_WINDOW (ledger->parent), TRUE, format, name)) break; } @@ -995,7 +995,7 @@ gnc_entry_ledger_check_close_internal (GtkWidget *parent, if (!gnc_entry_ledger_verify_can_save (ledger)) return FALSE; - if (dontask || gnc_verify_dialog (parent, TRUE, "%s", message)) + if (dontask || gnc_verify_dialog (GTK_WINDOW (parent), TRUE, "%s", message)) gnc_entry_ledger_save (ledger, TRUE); else gnc_entry_ledger_cancel_cursor_changes (ledger); diff --git a/gnucash/register/ledger-core/split-register-control.c b/gnucash/register/ledger-core/split-register-control.c index a9dd3e985e..b66c073327 100644 --- a/gnucash/register/ledger-core/split-register-control.c +++ b/gnucash/register/ledger-core/split-register-control.c @@ -1322,7 +1322,7 @@ gnc_split_register_handle_exchange (SplitRegister *reg, gboolean force_dialog) if (force_dialog) { message = _("This register does not support editing exchange rates."); - gnc_error_dialog(gnc_split_register_get_parent(reg), "%s", message); + gnc_error_dialog (GTK_WINDOW (gnc_split_register_get_parent (reg)), "%s", message); } LEAVE("no rate cell"); return FALSE; @@ -1335,7 +1335,7 @@ gnc_split_register_handle_exchange (SplitRegister *reg, gboolean force_dialog) if (force_dialog) { message = _("This register does not support editing exchange rates."); - gnc_error_dialog(gnc_split_register_get_parent(reg), "%s", message); + gnc_error_dialog (GTK_WINDOW (gnc_split_register_get_parent (reg)), "%s", message); } LEAVE("null rate cell"); return FALSE; @@ -1362,7 +1362,7 @@ gnc_split_register_handle_exchange (SplitRegister *reg, gboolean force_dialog) { message = _("You need to select a split in order to modify its exchange " "rate."); - gnc_error_dialog(gnc_split_register_get_parent(reg), "%s", message); + gnc_error_dialog (GTK_WINDOW (gnc_split_register_get_parent (reg)), "%s", message); } LEAVE("expanded with transaction cursor; nothing to do"); return FALSE; @@ -1377,7 +1377,7 @@ gnc_split_register_handle_exchange (SplitRegister *reg, gboolean force_dialog) { message = _("You need to expand the transaction in order to modify its " "exchange rates."); - gnc_error_dialog (gnc_split_register_get_parent (reg), "%s", message); + gnc_error_dialog (GTK_WINDOW (gnc_split_register_get_parent (reg)), "%s", message); LEAVE("%s", message); return TRUE; } @@ -1388,7 +1388,7 @@ gnc_split_register_handle_exchange (SplitRegister *reg, gboolean force_dialog) if (force_dialog) { message = _("The entered account could not be found."); - gnc_error_dialog(gnc_split_register_get_parent(reg), "%s", message); + gnc_error_dialog (GTK_WINDOW (gnc_split_register_get_parent (reg)), "%s", message); } LEAVE("no xfer account"); return FALSE; @@ -1423,7 +1423,7 @@ gnc_split_register_handle_exchange (SplitRegister *reg, gboolean force_dialog) if (expanded || osplit == NULL) { message = _("The two currencies involved equal each other."); - gnc_error_dialog(gnc_split_register_get_parent(reg), "%s", message); + gnc_error_dialog (GTK_WINDOW (gnc_split_register_get_parent (reg)), "%s", message); LEAVE("register is expanded or osplit == NULL; not forcing dialog"); return FALSE; } @@ -1436,7 +1436,7 @@ gnc_split_register_handle_exchange (SplitRegister *reg, gboolean force_dialog) if (gnc_commodity_equal (txn_cur, xfer_com)) { message = _("The two currencies involved equal each other."); - gnc_error_dialog(gnc_split_register_get_parent(reg), "%s", message); + gnc_error_dialog (GTK_WINDOW (gnc_split_register_get_parent (reg)), "%s", message); LEAVE("reg commodity == txn commodity; not forcing"); return FALSE; } @@ -1454,7 +1454,7 @@ gnc_split_register_handle_exchange (SplitRegister *reg, gboolean force_dialog) "exchange rates."); if (force_dialog) { - gnc_error_dialog (gnc_split_register_get_parent (reg), "%s", message); + gnc_error_dialog (GTK_WINDOW (gnc_split_register_get_parent (reg)), "%s", message); } LEAVE("%s", message); return TRUE; @@ -1487,7 +1487,7 @@ gnc_split_register_handle_exchange (SplitRegister *reg, gboolean force_dialog) if (force_dialog) { message = _("The split's amount is zero, so no exchange rate is needed."); - gnc_error_dialog(gnc_split_register_get_parent(reg), "%s", message); + gnc_error_dialog (GTK_WINDOW (gnc_split_register_get_parent (reg)), "%s", message); } LEAVE("amount is zero; no exchange rate needed"); return FALSE; diff --git a/gnucash/register/ledger-core/split-register.c b/gnucash/register/ledger-core/split-register.c index 8349edafda..672760f41e 100644 --- a/gnucash/register/ledger-core/split-register.c +++ b/gnucash/register/ledger-core/split-register.c @@ -179,9 +179,9 @@ gnc_split_register_begin_edit_or_warn(SRInfo *info, Transaction *trans) } else { - GtkWidget *parent = NULL; + GtkWindow *parent = NULL; if (info->get_parent) - parent = info->get_parent(info->user_data); + parent = GTK_WINDOW (info->get_parent (info->user_data)); gnc_error_dialog(parent, "%s", _("This transaction is already being edited in another register. Please finish editing it there first.")); LEAVE("already editing"); return TRUE; @@ -455,7 +455,7 @@ gnc_split_register_duplicate_current (SplitRegister *reg) "record the changes before duplicating the transaction, or " "cancel the duplication?"); - window = gnc_split_register_get_parent(reg); + window = gnc_split_register_get_parent (reg); dialog = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, @@ -922,7 +922,7 @@ gnc_split_register_paste_current (SplitRegister *reg) /* Ask before overwriting an existing split. */ if (split != NULL && - !gnc_verify_dialog (gnc_split_register_get_parent (reg), + !gnc_verify_dialog (GTK_WINDOW (gnc_split_register_get_parent (reg)), FALSE, "%s", message)) { LEAVE("user cancelled"); @@ -960,7 +960,7 @@ gnc_split_register_paste_current (SplitRegister *reg) /* Ask before overwriting an existing transaction. */ if (split != blank_split && - !gnc_verify_dialog(gnc_split_register_get_parent(reg), + !gnc_verify_dialog (GTK_WINDOW (gnc_split_register_get_parent (reg)), FALSE, "%s", message)) { LEAVE("user cancelled"); @@ -1846,7 +1846,7 @@ gnc_split_register_get_account_by_name (SplitRegister *reg, BasicCell * bcell, if (!account && !creating_account) { /* Ask if they want to create a new one. */ - if (!gnc_verify_dialog (gnc_split_register_get_parent (reg), + if (!gnc_verify_dialog (GTK_WINDOW (gnc_split_register_get_parent (reg)), TRUE, missing, name)) return NULL; creating_account = TRUE; @@ -1870,7 +1870,7 @@ gnc_split_register_get_account_by_name (SplitRegister *reg, BasicCell * bcell, /* See if the account (either old or new) is a placeholder. */ if (xaccAccountGetPlaceholder (account)) { - gnc_error_dialog (gnc_split_register_get_parent (reg), + gnc_error_dialog (GTK_WINDOW (gnc_split_register_get_parent (reg)), placeholder, name); } diff --git a/gnucash/report/report-gnome/dialog-custom-report.c b/gnucash/report/report-gnome/dialog-custom-report.c index 3f3d727934..8f09a2a311 100644 --- a/gnucash/report/report-gnome/dialog-custom-report.c +++ b/gnucash/report/report-gnome/dialog-custom-report.c @@ -309,7 +309,7 @@ custom_report_delete (SCM guid, CustomReportDialog *crd) report_name = gnc_scm_to_utf8_string(scm_call_2(template_menu_name, guid, SCM_BOOL_F)); /* we must confirm the user wants to delete their precious custom report! */ - if (gnc_verify_dialog(crd->dialog, FALSE, _("Are you sure you want to delete %s?"), report_name)) + if (gnc_verify_dialog( GTK_WINDOW (crd->dialog), FALSE, _("Are you sure you want to delete %s?"), report_name)) { SCM del_report = scm_c_eval_string("gnc:delete-report"); scm_call_1(del_report, guid); @@ -352,7 +352,7 @@ get_custom_report_selection(CustomReportDialog *crd, else { /* no selection, notify user */ - gnc_error_dialog(GTK_WIDGET(crd->window), "%s", message); + gnc_error_dialog (GTK_WINDOW (crd->dialog), "%s", message); return SCM_EOL; } @@ -446,8 +446,8 @@ void custom_report_name_edited_cb(GtkCellRendererText *renderer, gchar *path, gc if (scm_is_true (scm_call_2 (unique_name_func, guid, new_name_scm))) custom_report_edit_report_name (guid, crd, new_text); else - gnc_error_dialog(crd->dialog, "%s", - _("A saved report configuration with this name already exists, please choose another name.") ); + gnc_error_dialog (GTK_WINDOW (crd->dialog), "%s", + _("A saved report configuration with this name already exists, please choose another name.") ); } diff --git a/gnucash/report/report-gnome/dialog-report-style-sheet.c b/gnucash/report/report-gnome/dialog-report-style-sheet.c index f2fbb97842..ebd8a1e42c 100644 --- a/gnucash/report/report-gnome/dialog-report-style-sheet.c +++ b/gnucash/report/report-gnome/dialog-report-style-sheet.c @@ -254,7 +254,7 @@ gnc_style_sheet_new (StyleSheetDialog * ssd) { /* If the name is empty, we display an error dialog but * refuse to create the new style sheet. */ - gnc_error_dialog (ssd->toplevel, "%s", _("You must provide a name for the new style sheet.")); + gnc_error_dialog (GTK_WINDOW (ssd->toplevel), "%s", _("You must provide a name for the new style sheet.")); name_str = NULL; } if (template_str && name_str) diff --git a/gnucash/report/report-gnome/gnc-plugin-page-report.c b/gnucash/report/report-gnome/gnc-plugin-page-report.c index a0fe927c8d..cd472619dd 100644 --- a/gnucash/report/report-gnome/gnc-plugin-page-report.c +++ b/gnucash/report/report-gnome/gnc-plugin-page-report.c @@ -413,7 +413,7 @@ gnc_plugin_page_report_create_widget( GncPluginPage *page ) report = GNC_PLUGIN_PAGE_REPORT(page); priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(report); - topLvl = GTK_WINDOW(gnc_ui_get_toplevel()); + topLvl = gnc_ui_get_main_window (NULL); // priv->html = gnc_html_new( topLvl ); priv->html = gnc_html_factory_create_html(); gnc_html_set_parent( priv->html, topLvl ); @@ -1486,7 +1486,8 @@ gnc_get_export_filename (SCM choice) title = g_strdup_printf (_("Save %s To File"), type); default_dir = gnc_get_default_directory(GNC_PREFS_GROUP_REPORT); - filepath = gnc_file_dialog (title, NULL, default_dir, GNC_FILE_DIALOG_EXPORT); + filepath = gnc_file_dialog (gnc_ui_get_main_window (NULL), + title, NULL, default_dir, GNC_FILE_DIALOG_EXPORT); /* Try to test for extension on file name, add if missing */ if (g_strrstr(filepath, ".") == NULL) diff --git a/gnucash/report/report-gnome/window-report.c b/gnucash/report/report-gnome/window-report.c index 82e2bc2154..d884df647c 100644 --- a/gnucash/report/report-gnome/window-report.c +++ b/gnucash/report/report-gnome/window-report.c @@ -56,10 +56,10 @@ ********************************************************************/ void -reportWindow(int report_id) +reportWindow(int report_id, GtkWindow *parent) { gnc_set_busy_cursor (NULL, TRUE); - gnc_main_window_open_report(report_id, NULL); + gnc_main_window_open_report(report_id, GNC_MAIN_WINDOW(parent)); gnc_unset_busy_cursor (NULL); } @@ -232,8 +232,8 @@ gnc_report_edit_options(SCM report, GtkWindow *parent) options = scm_call_1(get_options, report); if (options == SCM_BOOL_F) { - gnc_warning_dialog(GTK_WIDGET(gnc_ui_get_toplevel()), "%s", - _("There are no options for this report.")); + gnc_warning_dialog (parent, "%s", + _("There are no options for this report.")); return FALSE; } @@ -324,7 +324,7 @@ gnc_html_options_url_cb (const char *location, const char *label, return FALSE; } - gnc_report_edit_options (report, NULL); + gnc_report_edit_options (report, GTK_WINDOW(result->parent)); return TRUE; } @@ -350,7 +350,7 @@ gnc_html_report_url_cb (const char *location, const char *label, char *url; url = gnc_build_url (URL_TYPE_REPORT, location, label); - gnc_main_window_open_report_url (url, NULL); + gnc_main_window_open_report_url (url, GNC_MAIN_WINDOW(result->parent)); g_free (url); result->load_to_stream = FALSE; diff --git a/gnucash/report/report-gnome/window-report.h b/gnucash/report/report-gnome/window-report.h index 4e3e475ec4..7d4371ca1e 100644 --- a/gnucash/report/report-gnome/window-report.h +++ b/gnucash/report/report-gnome/window-report.h @@ -38,7 +38,7 @@ GtkWidget * gnc_report_window_default_params_editor(SCM options, SCM report, Gtk // 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); +void reportWindow(int id, GtkWindow *parent); gboolean gnc_report_edit_options(SCM report, GtkWindow *parent); // module[/plugin]-init void gnc_report_init (void); diff --git a/libgnucash/core-utils/CMakeLists.txt b/libgnucash/core-utils/CMakeLists.txt index 52e1251581..a6f1c7bb2e 100644 --- a/libgnucash/core-utils/CMakeLists.txt +++ b/libgnucash/core-utils/CMakeLists.txt @@ -43,10 +43,19 @@ ADD_CUSTOM_TARGET(swig-runtime-h DEPENDS ${SWIG_RUNTIME_H}) SET_SOURCE_FILES_PROPERTIES (gnc-guile-utils.c PROPERTIES OBJECT_DEPENDS ${SWIG_RUNTIME_H}) SET(prefix ${CMAKE_INSTALL_PREFIX}) -SET(datadir ${DATADIR}) -SET(bindir ${BINDIR}) -SET(libdir ${LIBDIR}) -SET(sysconfdir ${SYSCONFDIR}) +if(ENABLE_BINRELOC) + SET(datadir ${DATADIR}) + SET(bindir ${BINDIR}) + SET(libdir ${LIBDIR}) + SET(sysconfdir ${SYSCONFDIR}) + SET(localedir ${LOCALEDIR}) +else() + SET(datadir ${CMAKE_INSTALL_FULL_DATADIR}) + SET(bindir ${CMAKE_INSTALL_FULL_BINDIR}) + SET(libdir ${CMAKE_INSTALL_FULL_LIBDIR}) + SET(sysconfdir ${CMAKE_INSTALL_FULL_SYSCONFDIR}) + SET(localedir "${CMAKE_INSTALL_FULL_DATAROOTDIR}/locale") +endif() GNC_CONFIGURE(gncla-dir.h.in gncla-dir.h) ### Create gnc-version.h ### diff --git a/libgnucash/core-utils/binreloc.c b/libgnucash/core-utils/binreloc.c index 55b7905b87..1b7b1b6e22 100644 --- a/libgnucash/core-utils/binreloc.c +++ b/libgnucash/core-utils/binreloc.c @@ -33,7 +33,6 @@ #ifndef __BINRELOC_C__ #define __BINRELOC_C__ #include -#include "gncla-dir.h" #include #if PLATFORM(WINDOWS) @@ -53,7 +52,9 @@ #include #include #include "binreloc.h" +#include "gnc-filepath-utils.h" #include +#include "gncla-dir.h" G_BEGIN_DECLS @@ -84,7 +85,7 @@ _br_find_exe (Gnc_GbrInitError *error) the current process */ prefix = g_win32_get_package_installation_directory_of_module (NULL); result = g_build_filename (prefix, - "bin", "gnucash.exe", + BINDIR, "gnucash.exe", (char*)NULL); g_free (prefix); return result; @@ -385,13 +386,14 @@ gnc_gbr_find_exe_dir (const gchar *default_dir) * will be returned. If default_prefix is NULL, then NULL will be * returned. */ -gchar * -gnc_gbr_find_prefix (const gchar *default_prefix) + +static inline gchar * +get_mac_bundle_prefix() { #if defined ENABLE_BINRELOC && defined MAC_INTEGRATION gchar *id = gtkosx_application_get_bundle_id (); gchar *path = gtkosx_application_get_resource_path (); - if (id == NULL) + if (id == NULL) { gchar *dirname = g_path_get_dirname (path); g_free (path); @@ -400,9 +402,24 @@ gnc_gbr_find_prefix (const gchar *default_prefix) } g_free (id); return path; -#else - gchar *dir1, *dir2; +#endif + return NULL; +} +static inline gchar* +get_builddir_prefix() +{ + if (g_getenv ("GNC_UNINSTALLED")) + return g_strdup (g_getenv ("GNC_BUILDDIR")); + return NULL; +} + +gchar * +gnc_gbr_find_prefix (const gchar *default_prefix) +{ + gchar *dir1, *dir2; + if ((dir2 = get_builddir_prefix()) || (dir2 = get_mac_bundle_prefix())) + return dir2; if (exe == NULL) { /* BinReloc not initialized. */ @@ -415,7 +432,6 @@ gnc_gbr_find_prefix (const gchar *default_prefix) dir2 = g_path_get_dirname (dir1); g_free (dir1); return dir2; -#endif //ENABLE_BINRELOC && defined MAC_INTEGRATION } @@ -435,7 +451,7 @@ gnc_gbr_find_prefix (const gchar *default_prefix) gchar * gnc_gbr_find_bin_dir (const gchar *default_bin_dir) { - gchar *prefix, *dir; + gchar *prefix, *dir, *bindir; prefix = gnc_gbr_find_prefix (NULL); if (prefix == NULL) { @@ -445,47 +461,13 @@ gnc_gbr_find_bin_dir (const gchar *default_bin_dir) else return NULL; } - - dir = g_build_filename (prefix, "bin", NULL); + bindir = gnc_file_path_relative_part(PREFIX, BINDIR); + dir = g_build_filename (prefix, bindir, NULL); + g_free (bindir); g_free (prefix); return dir; } - -/** Locate the application's superuser binary folder. - * - * The path is generated by the following pseudo-code evaluation: - * \code - * prefix + "/sbin" - * \endcode - * - * @param default_sbin_dir A default path which will used as fallback. - * @return A string containing the sbin folder's path, which must be freed when - * no longer necessary. If BinReloc is not initialized, or if the - * initialization function failed, then a copy of default_sbin_dir will - * be returned. If default_bin_dir is NULL, then NULL will be returned. - */ -gchar * -gnc_gbr_find_sbin_dir (const gchar *default_sbin_dir) -{ - gchar *prefix, *dir; - - prefix = gnc_gbr_find_prefix (NULL); - if (prefix == NULL) - { - /* BinReloc not initialized. */ - if (default_sbin_dir != NULL) - return g_strdup (default_sbin_dir); - else - return NULL; - } - - dir = g_build_filename (prefix, "sbin", NULL); - g_free (prefix); - return dir; -} - - /** Locate the application's data folder. * * The path is generated by the following pseudo-code evaluation: @@ -503,7 +485,7 @@ gnc_gbr_find_sbin_dir (const gchar *default_sbin_dir) gchar * gnc_gbr_find_data_dir (const gchar *default_data_dir) { - gchar *prefix, *dir; + gchar *prefix, *dir, *datadir; prefix = gnc_gbr_find_prefix (NULL); if (prefix == NULL) @@ -515,12 +497,13 @@ gnc_gbr_find_data_dir (const gchar *default_data_dir) return NULL; } - dir = g_build_filename (prefix, "share", NULL); + datadir = gnc_file_path_relative_part(PREFIX, DATADIR); + dir = g_build_filename (prefix, datadir, NULL); + g_free (datadir); g_free (prefix); return dir; } - /** Locate the application's library folder. * * The path is generated by the following pseudo-code evaluation: @@ -537,7 +520,7 @@ gnc_gbr_find_data_dir (const gchar *default_data_dir) gchar * gnc_gbr_find_lib_dir (const gchar *default_lib_dir) { - gchar *prefix, *dir; + gchar *prefix, *dir, *libdir; prefix = gnc_gbr_find_prefix (NULL); if (prefix == NULL) @@ -549,46 +532,13 @@ gnc_gbr_find_lib_dir (const gchar *default_lib_dir) return NULL; } - dir = g_build_filename (prefix, LIBDIR, NULL); + libdir = gnc_file_path_relative_part(PREFIX, LIBDIR); + dir = g_build_filename (prefix, libdir, NULL); + g_free (libdir); g_free (prefix); return dir; } - -/** Locate the application's libexec folder. - * - * The path is generated by the following pseudo-code evaluation: - * \code - * prefix + "/libexec" - * \endcode - * - * @param default_libexec_dir A default path which will used as fallback. - * @return A string containing the libexec folder's path, which must be freed when - * no longer necessary. If BinReloc is not initialized, or if the initialization - * function failed, then a copy of default_libexec_dir will be returned. - * If default_libexec_dir is NULL, then NULL will be returned. - */ -gchar * -gnc_gbr_find_libexec_dir (const gchar *default_libexec_dir) -{ - gchar *prefix, *dir; - - prefix = gnc_gbr_find_prefix (NULL); - if (prefix == NULL) - { - /* BinReloc not initialized. */ - if (default_libexec_dir != NULL) - return g_strdup (default_libexec_dir); - else - return NULL; - } - - dir = g_build_filename (prefix, "libexec", NULL); - g_free (prefix); - return dir; -} - - /** Locate the application's configuration files folder. * * The path is generated by the following pseudo-code evaluation: @@ -605,7 +555,7 @@ gnc_gbr_find_libexec_dir (const gchar *default_libexec_dir) gchar * gnc_gbr_find_etc_dir (const gchar *default_etc_dir) { - gchar *prefix, *dir; + gchar *prefix, *dir, *sysconfdir; prefix = gnc_gbr_find_prefix (NULL); if (prefix == NULL) @@ -617,7 +567,9 @@ gnc_gbr_find_etc_dir (const gchar *default_etc_dir) return NULL; } - dir = g_build_filename (prefix, "etc", NULL); + sysconfdir = gnc_file_path_relative_part(PREFIX, SYSCONFDIR); + dir = g_build_filename (prefix, sysconfdir, NULL); + g_free (sysconfdir); g_free (prefix); return dir; } diff --git a/libgnucash/core-utils/gnc-filepath-utils.cpp b/libgnucash/core-utils/gnc-filepath-utils.cpp index ab2c21610d..881bfcfc20 100644 --- a/libgnucash/core-utils/gnc-filepath-utils.cpp +++ b/libgnucash/core-utils/gnc-filepath-utils.cpp @@ -193,6 +193,14 @@ gnc_resolve_file_path (const gchar * filefrag) } +gchar *gnc_file_path_relative_part (const gchar *prefix, const gchar *path) +{ + std::string p{path}; + if (p.find(prefix) == 0) + return g_strdup(p.substr(strlen(prefix)).c_str()); + return g_strdup(path); +} + /* Searches for a file fragment paths set via GNC_DOC_PATH environment * variable. If this variable is not set, fall back to search in * - a html directory in the local user's gnucash settings directory diff --git a/libgnucash/core-utils/gnc-filepath-utils.h b/libgnucash/core-utils/gnc-filepath-utils.h index 9c2a93ab76..d0e9ff4cba 100644 --- a/libgnucash/core-utils/gnc-filepath-utils.h +++ b/libgnucash/core-utils/gnc-filepath-utils.h @@ -41,6 +41,14 @@ */ gchar *gnc_resolve_file_path (const gchar *filefrag); +/** Given a prefix and a path return the relative portion of the path. + * @param prefix The prefix that might be the first part of the path + * @param path The path from which the prefix might be removed + * @return a char* that must be g_freed containing the path without + * the prefix if path begins with prefix, otherwise a copy of path. + */ +gchar *gnc_file_path_relative_part (const gchar *prefix, const gchar *path); + /** @brief Find an absolute path to a localized version of a given * relative path to a html or html related file. * If no localized version exists, an absolute path to the file diff --git a/libgnucash/core-utils/gnc-path.c b/libgnucash/core-utils/gnc-path.c index 4a0607d85e..c979c1fbc3 100644 --- a/libgnucash/core-utils/gnc-path.c +++ b/libgnucash/core-utils/gnc-path.c @@ -138,11 +138,16 @@ gchar *gnc_path_get_gtkbuilderdir() * @returns A newly allocated string. */ gchar *gnc_path_get_localedir() { - gchar *prefix = gnc_path_get_prefix(); - gchar *result = g_build_filename (prefix, LOCALE_DATADIRNAME, "locale", (char*)NULL); - g_free (prefix); - //printf("Returning localedir %s\n", result); - return result; + if (g_path_is_absolute (LOCALEDIR)) + return g_strdup(LOCALEDIR); + else + { + gchar *prefix = gnc_path_get_prefix(); + gchar *result = g_build_filename (prefix, LOCALEDIR, (char*)NULL); + g_free (prefix); + //printf("Returning localedir %s\n", result); + return result; + } } /** Returns the accounts file path, usually diff --git a/libgnucash/core-utils/gncla-dir.h.in b/libgnucash/core-utils/gncla-dir.h.in index c6921787e6..a55d90f3cd 100644 --- a/libgnucash/core-utils/gncla-dir.h.in +++ b/libgnucash/core-utils/gncla-dir.h.in @@ -30,4 +30,4 @@ #define BINDIR "@-bindir-@" #define LIBDIR "@-libdir-@" -#define LOCALE_DATADIRNAME "@-DATADIRNAME-@" +#define LOCALEDIR "@-localedir-@" diff --git a/libgnucash/core-utils/test/CMakeLists.txt b/libgnucash/core-utils/test/CMakeLists.txt index f1aa44404a..2d7f46b6ee 100644 --- a/libgnucash/core-utils/test/CMakeLists.txt +++ b/libgnucash/core-utils/test/CMakeLists.txt @@ -1,8 +1,8 @@ - +set(MODULEPATH ${CMAKE_SOURCE_DIR}/libgnucash/core-utils) SET(CORE_UTILS_TEST_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/common # for config.h - ${CMAKE_SOURCE_DIR}/libgnucash/core-utils + ${MODULEPATH} ${CMAKE_SOURCE_DIR}/common/test-core ${GLIB2_INCLUDE_DIRS} ${GTK_MAC_INCLUDE_DIRS} @@ -27,5 +27,31 @@ IF (MAC_INTEGRATION) TARGET_COMPILE_DEFINITIONS(test-userdata-dir PRIVATE ${GTK_MAC_CFLAGS_OTHER}) ENDIF(MAC_INTEGRATION) -SET_DIST_LIST(test_core_utils_DIST CMakeLists.txt Makefile.am test-gnc-glib-utils.c - test-resolve-file-path.c test-userdata-dir.c test-userdata-dir-invalid-home.c) +set(gtest_core_utils_INCLUDES + ${MODULEPATH} + ${CMAKE_BINARY_DIR}/common # for config.h + ${CMAKE_SOURCE_DIR}/common # for platform.h + ${CMAKE_BINARY_DIR}/libgnucash/core-utils # for gncla-dir.h + ${GLIB2_INCLUDE_DIRS} + ${GTEST_INCLUDE_DIR} + ) + +SET(gtest_core_utils_LIBS + ${GLIB2_LDFLAGS} + ${Boost_LIBRARIES} + ${GTHREAD_LDFLAGS} + ${GTEST_LIB}) + +set(test_gnc_path_util_SOURCES + ${MODULEPATH}/gnc-path.c + ${MODULEPATH}/binreloc.c + ${MODULEPATH}/gnc-filepath-utils.cpp + gtest-path-utilities.cpp + ${GTEST_SRC}) + +gnc_add_test(test-gnc-path-util "${test_gnc_path_util_SOURCES}" + gtest_core_utils_INCLUDES gtest_core_utils_LIBS "GNC_UNINSTALLED=yes") + +SET_DIST_LIST(test_core_utils_DIST CMakeLists.txt Makefile.am + test-gnc-glib-utils.c test-resolve-file-path.c test-userdata-dir.c + test-userdata-dir-invalid-home.c gtest-path-utilities.cpp) diff --git a/libgnucash/core-utils/test/gtest-path-utilities.cpp b/libgnucash/core-utils/test/gtest-path-utilities.cpp new file mode 100644 index 0000000000..94e83566ff --- /dev/null +++ b/libgnucash/core-utils/test/gtest-path-utilities.cpp @@ -0,0 +1,125 @@ +extern "C" +{ +#include +#include +#include +#include +#include +#include +} + +#include + +struct PathTest : public testing::Test +{ + PathTest() : m_prefix{nullptr} {} + void SetUp() + { +#ifdef ENABLE_BINRELOC + gnc_gbr_init(nullptr); +#endif + char *builddir = g_strdup(g_getenv("GNC_BUILDDIR")); + if (builddir) + m_prefix = builddir; + else + m_prefix = g_get_current_dir(); + } + void TearDown() + { + if (m_prefix) + g_free(m_prefix); + } + char *m_prefix; +}; + +TEST_F(PathTest, gnc_path_get_prefix) +{ +#ifdef ENABLE_BINRELOC + EXPECT_STREQ(gnc_path_get_prefix(), m_prefix); +#else + g_setenv("GNC_UNINSTALLED", "1", TRUE); + g_setenv("GNC_BUILDDIR", m_prefix, 1); + EXPECT_STREQ(gnc_path_get_prefix(), m_prefix); + g_unsetenv("GNC_UNINSTALLED"); + g_unsetenv("GNC_BUILDDIR"); + EXPECT_STREQ(gnc_path_get_prefix(), PREFIX); +#endif +} + +TEST_F(PathTest, gnc_path_get_bindir) +{ + gchar *dirname = gnc_file_path_relative_part(PREFIX, BINDIR); + gchar *binpath = g_build_filename(m_prefix, dirname, NULL); + g_free(dirname); +#ifdef ENABLE_BINRELOC + EXPECT_STREQ(gnc_path_get_bindir(), binpath); + g_free(binpath); +#else + g_setenv("GNC_UNINSTALLED", "1", TRUE); + g_setenv("GNC_BUILDDIR", m_prefix, 1); + EXPECT_STREQ(gnc_path_get_bindir(), binpath); + g_free(binpath); + g_unsetenv("GNC_UNINSTALLED"); + g_unsetenv("GNC_BUILDDIR"); + EXPECT_STREQ(gnc_path_get_bindir(), BINDIR); +#endif +} + +TEST_F(PathTest, gnc_path_get_libdir) +{ + gchar *dirname = gnc_file_path_relative_part(PREFIX, LIBDIR); + gchar *libpath = g_build_filename(m_prefix, dirname, NULL); + g_free(dirname); +#ifdef ENABLE_BINRELOC + EXPECT_STREQ(gnc_path_get_libdir(), libpath); + g_free(libpath); +#else + g_setenv("GNC_UNINSTALLED", "1", TRUE); + g_setenv("GNC_BUILDDIR", m_prefix, 1); + EXPECT_STREQ(gnc_path_get_libdir(), libpath); + g_free(libpath); + g_unsetenv("GNC_UNINSTALLED"); + g_unsetenv("GNC_BUILDDIR"); + EXPECT_STREQ(gnc_path_get_libdir(), LIBDIR); +#endif +} + +TEST_F(PathTest, gnc_path_get_datadir) +{ + gchar *dirname = gnc_file_path_relative_part(PREFIX, DATADIR); + gchar *datapath = g_build_filename(m_prefix, dirname, NULL); + g_free(dirname); +#ifdef ENABLE_BINRELOC + EXPECT_STREQ(gnc_path_get_datadir(), datapath); + g_free(datapath); +#else + g_setenv("GNC_UNINSTALLED", "1", TRUE); + g_setenv("GNC_BUILDDIR", m_prefix, 1); + EXPECT_STREQ(gnc_path_get_datadir(), datapath); + g_free(datapath); + g_unsetenv("GNC_UNINSTALLED"); + g_unsetenv("GNC_BUILDDIR"); + EXPECT_STREQ(gnc_path_get_datadir(), DATADIR); +#endif +} + +TEST_F(PathTest, gnc_path_get_sysconfdir) +{ + gchar *dirname = gnc_file_path_relative_part(PREFIX, SYSCONFDIR); + gchar *sysconfpath = g_build_filename(m_prefix, dirname, "gnucash", NULL); + g_free(dirname); +#ifdef ENABLE_BINRELOC + EXPECT_STREQ(gnc_path_get_pkgsysconfdir(), sysconfpath); + g_free(sysconfpath); +#else + g_setenv("GNC_UNINSTALLED", "1", TRUE); + g_setenv("GNC_BUILDDIR", m_prefix, 1); + EXPECT_STREQ(gnc_path_get_pkgsysconfdir(), sysconfpath); + g_free(sysconfpath); + g_unsetenv("GNC_UNINSTALLED"); + g_unsetenv("GNC_BUILDDIR"); + sysconfpath = g_build_filename(SYSCONFDIR, "gnucash", NULL); + EXPECT_STREQ(gnc_path_get_pkgsysconfdir(), sysconfpath); + g_free(sysconfpath); +#endif +} diff --git a/libgnucash/engine/gnc-timezone.cpp b/libgnucash/engine/gnc-timezone.cpp index d0ad216832..0a26b484be 100644 --- a/libgnucash/engine/gnc-timezone.cpp +++ b/libgnucash/engine/gnc-timezone.cpp @@ -603,6 +603,8 @@ void TimeZoneProvider::parse_file(const std::string& tzname) { IANAParser::IANAParser parser(tzname); + using boost::posix_time::hours; + const auto one_year = hours(366 * 24); //Might be a leap year. auto last_info = std::find_if(parser.tzinfo.begin(), parser.tzinfo.end(), [](IANAParser::TZInfo tz) {return !tz.info.isdst;}); @@ -620,34 +622,48 @@ TimeZoneProvider::parse_file(const std::string& tzname) auto this_time = ptime(date(1970, 1, 1), time_duration(txi->timestamp / 3600, 0, txi->timestamp % 3600)); + /* Note: The "get" function retrieves the last zone with a + * year *earlier* than the requested year: Zone periods run + * from the saved year to the beginning year of the next zone. + */ try { auto this_year = this_time.date().year(); //Initial case if (last_time.is_not_a_date_time()) - zone_vector.push_back(zone_no_dst(this_year - 1, last_info)); - //gap in transitions > 1 year, non-dst zone - //change. In the last case the exact date of the change will be - //wrong because boost::local_date::timezone isn't able to - //represent it. For GnuCash's purposes this isn't likely to be - //important as the last time this sort of transition happened - //was 1946, but we have to handle the case in order to parse - //the tz file. - else if (this_year - last_time.date().year() > 1 || - last_info->info.isdst == this_info->info.isdst) { - zone_vector.push_back(zone_no_dst(this_year, last_info)); + zone_vector.push_back(zone_no_dst(this_year - 1, last_info)); + zone_vector.push_back(zone_no_dst(this_year, this_info)); } - - else + // No change in is_dst means a permanent zone change. + else if (last_info->info.isdst == this_info->info.isdst) + { + zone_vector.push_back(zone_no_dst(this_year, this_info)); + } + /* If there have been no transitions in at least a year + * then we need to create a no-DST rule with last_info to + * reflect the frozen timezone. + */ + else if (this_time - last_time > one_year) + { + auto year = last_time.date().year(); + if (zone_vector.back().first == year) + year = year + 1; // no operator ++ or +=, sigh. + zone_vector.push_back(zone_no_dst(year, last_info)); + } + /* It's been less than a year, so it's probably a DST + * cycle. This consumes two transitions so we want only + * the return-to-standard-time one to make a DST rule. + */ + else if (!this_info->info.isdst) { DSTRule::DSTRule new_rule(last_info, this_info, last_time, this_time); if (new_rule != last_rule) { last_rule = new_rule; - zone_vector.push_back(zone_from_rule (this_time.date().year(), - new_rule)); + auto year = last_time.date().year(); + zone_vector.push_back(zone_from_rule(year, new_rule)); } } } @@ -658,12 +674,12 @@ TimeZoneProvider::parse_file(const std::string& tzname) last_time = this_time; last_info = this_info; } - +/* if the transitions end before the end of the zoneinfo coverage + * period then the zone rescinded DST and we need a final no-dstzone. + */ if (last_time.is_not_a_date_time() || last_time.date().year() < parser.last_year) - zone_vector.push_back(zone_no_dst(max_year, last_info)); - else //Last DST rule forever after. - zone_vector.push_back(zone_from_rule(max_year, last_rule)); + zone_vector.push_back(zone_no_dst(last_time.date().year(), last_info)); } bool @@ -714,13 +730,11 @@ TimeZoneProvider::TimeZoneProvider(const std::string& tzname) : zone_vector {} TZ_Ptr TimeZoneProvider::get(int year) const noexcept { + if (zone_vector.empty()) + return TZ_Ptr(new PTZ("UTC0")); auto iter = find_if(zone_vector.rbegin(), zone_vector.rend(), [=](TZ_Entry e) { return e.first <= year; }); if (iter == zone_vector.rend()) - { - if (!zone_vector.empty()) return zone_vector.front().second; - return TZ_Ptr(new PTZ("UTC0")); - } return iter->second; } diff --git a/libgnucash/engine/qof-backend.cpp b/libgnucash/engine/qof-backend.cpp index 06ee78c397..b954ec8d00 100644 --- a/libgnucash/engine/qof-backend.cpp +++ b/libgnucash/engine/qof-backend.cpp @@ -105,12 +105,7 @@ static char* get_default_module_dir(const char* rel_path) if (uninstalled) { #ifdef CMAKE_BUILD - #ifdef WIN32 - #define MODULE_LIBDIR "bin" - #else - #define MODULE_LIBDIR LIBDIR "/gnucash" - #endif - pkglibdir = g_build_path (G_DIR_SEPARATOR_S, builddir, MODULE_LIBDIR, NULL); + pkglibdir = gnc_path_get_pkglibdir (); #else if (rel_path) pkglibdir = g_build_path (G_DIR_SEPARATOR_S, builddir, diff --git a/libgnucash/engine/test/gtest-gnc-timezone.cpp b/libgnucash/engine/test/gtest-gnc-timezone.cpp index b73b085a05..0703333012 100644 --- a/libgnucash/engine/test/gtest-gnc-timezone.cpp +++ b/libgnucash/engine/test/gtest-gnc-timezone.cpp @@ -65,10 +65,213 @@ TEST(gnc_timezone_constructors, test_posix_timezone) std::string timezone("FST08FDT07,M4.1.0,M10.31.0"); TimeZoneProvider tzp(timezone); TZ_Ptr tz = tzp.get(2006); - EXPECT_TRUE(tz->std_zone_abbrev() == "FST"); - EXPECT_TRUE(tz->dst_zone_abbrev() == "FDT"); - EXPECT_TRUE(tz->base_utc_offset().hours() == 8L); - EXPECT_TRUE(tz->dst_offset().hours() == 7L); + EXPECT_EQ(tz->std_zone_abbrev(), "FST"); + EXPECT_EQ(tz->dst_zone_abbrev(), "FDT"); + EXPECT_EQ(tz->base_utc_offset().hours(), 8L); + EXPECT_EQ(tz->dst_offset().hours(), 7L); +} + +TEST(gnc_timezone_constructors, test_IANA_Belize_tz) +{ + TimeZoneProvider tzp("America/Belize"); + for (int year = 1908; year < 1990; ++year) + { + auto tz = tzp.get(year); + if (year < 1912) + { + EXPECT_EQ(tz->std_zone_abbrev(), "LMT"); + EXPECT_FALSE(tz->has_dst()); + EXPECT_EQ(tz->base_utc_offset().total_seconds(), -21168); + } + else if (year < 1918) + { + EXPECT_EQ(tz->std_zone_abbrev(), "CST"); + EXPECT_FALSE(tz->has_dst()); + EXPECT_EQ(tz->base_utc_offset().total_seconds(), -21600); + } + else if (year < 1943) + { + EXPECT_EQ(tz->std_zone_abbrev(), "CST"); + EXPECT_TRUE(tz->has_dst()); + EXPECT_EQ(tz->base_utc_offset().total_seconds(), -21600); + EXPECT_EQ(tz->dst_zone_abbrev(), "-0530"); + EXPECT_EQ(tz->dst_offset().total_seconds(), 1800); + } + else if (year == 1973 || year == 1982) + { + EXPECT_EQ(tz->std_zone_abbrev(), "CST"); + EXPECT_TRUE(tz->has_dst()); + EXPECT_EQ(tz->base_utc_offset().total_seconds(), -21600); + EXPECT_EQ(tz->dst_zone_abbrev(), "CDT"); + EXPECT_EQ(tz->dst_offset().total_seconds(), 3600); + } + else + { + EXPECT_EQ(tz->std_zone_abbrev(), "CST"); + EXPECT_FALSE(tz->has_dst()); + EXPECT_EQ(tz->base_utc_offset().total_seconds(), -21600); + } + } +} + +TEST(gnc_timezone_constructors, test_IANA_Perth_tz) +{ + TimeZoneProvider tzp("Australia/Perth"); + for (int year = 1893; year < 2048; ++year) + { + auto tz = tzp.get(year); + if (year < 1895) + { + EXPECT_EQ(tz->std_zone_abbrev(), "LMT"); + EXPECT_FALSE(tz->has_dst()); + EXPECT_EQ(tz->base_utc_offset().total_seconds(), 27804); + } + else if (year < 1916) + { + EXPECT_EQ(tz->std_zone_abbrev(), "AWST"); + EXPECT_FALSE(tz->has_dst()); + EXPECT_EQ(tz->base_utc_offset().total_seconds(), 28800); + } + else if (year < 1917) + { + EXPECT_EQ(tz->std_zone_abbrev(), "AWST"); + EXPECT_TRUE(tz->has_dst()); + EXPECT_EQ(tz->base_utc_offset().total_seconds(), 28800); + EXPECT_EQ(tz->dst_zone_abbrev(), "AWDT"); + EXPECT_EQ(tz->dst_offset().total_seconds(), 3600); + } + else if (year < 1941) + { + EXPECT_EQ(tz->std_zone_abbrev(), "AWST"); + EXPECT_FALSE(tz->has_dst()); + EXPECT_EQ(tz->base_utc_offset().total_seconds(), 28800); + } + else if (year < 1943) + { + EXPECT_EQ(tz->std_zone_abbrev(), "AWST"); + EXPECT_TRUE(tz->has_dst()); + EXPECT_EQ(tz->base_utc_offset().total_seconds(), 28800); + EXPECT_EQ(tz->dst_zone_abbrev(), "AWDT"); + EXPECT_EQ(tz->dst_offset().total_seconds(), 3600); + } + else if (year == 1974 || year == 1983 || year == 1991 || + (year > 2005 && year < 2009)) + { + EXPECT_EQ(tz->std_zone_abbrev(), "AWST"); + EXPECT_TRUE(tz->has_dst()); + EXPECT_EQ(tz->base_utc_offset().total_seconds(), 28800); + EXPECT_EQ(tz->dst_zone_abbrev(), "AWDT"); + EXPECT_EQ(tz->dst_offset().total_seconds(), 3600); + } + else + { + EXPECT_EQ(tz->std_zone_abbrev(), "AWST"); + EXPECT_FALSE(tz->has_dst()); + EXPECT_EQ(tz->base_utc_offset().total_seconds(), 28800); + } + } +} + +TEST(gnc_timezone_constructors, test_IANA_Minsk_tz) +{ + TimeZoneProvider tzp("Europe/Minsk"); + for (int year = 1870; year < 2020; ++year) + { + auto tz = tzp.get(year); + if (year < 1879) + { + EXPECT_EQ(tz->std_zone_abbrev(), "LMT"); + EXPECT_FALSE(tz->has_dst()); + EXPECT_EQ(tz->base_utc_offset().total_seconds(), 6616); + } + else if (year < 1924) + { + EXPECT_EQ(tz->std_zone_abbrev(), "MMT"); + EXPECT_FALSE(tz->has_dst()); + EXPECT_EQ(tz->base_utc_offset().total_seconds(), 6600); + } + else if (year < 1930) + { + EXPECT_EQ(tz->std_zone_abbrev(), "EET"); + EXPECT_FALSE(tz->has_dst()); + EXPECT_EQ(tz->base_utc_offset().total_seconds(), 7200); + } + else if (year < 1941) + { + EXPECT_EQ(tz->std_zone_abbrev(), "MSK"); + EXPECT_FALSE(tz->has_dst()); + EXPECT_EQ(tz->base_utc_offset().total_seconds(), 10800); + } + /* The TZInfo says Minsk had DST from June 1941 - Nov + * 1942. Boost::date_time doesn't know how to model that so we + * just pretend that it was a weird standard time. Note that + * Minsk was under German occupation and got shifted to Berlin + * time, sort of. + */ + else if (year < 1943) + { + EXPECT_EQ(tz->std_zone_abbrev(), "CEST"); + EXPECT_FALSE(tz->has_dst()); + EXPECT_EQ(tz->base_utc_offset().total_seconds(), 7200); + EXPECT_EQ(tz->dst_zone_abbrev(), ""); + EXPECT_EQ(tz->dst_offset().total_seconds(), 0); + } + else if (year == 1943) + { + EXPECT_EQ(tz->std_zone_abbrev(), "CET"); + EXPECT_TRUE(tz->has_dst()); + EXPECT_EQ(tz->base_utc_offset().total_seconds(), 3600); + EXPECT_EQ(tz->dst_zone_abbrev(), "CEST"); + EXPECT_EQ(tz->dst_offset().total_seconds(), 3600); + } + /* Minsk was "liberated" by the Soviets 2 Jul 1944 and went + * back to a more reasonable local time with no DST. Another + * case that's too hard for boost::timezone to model correctly + * so we fudge. + */ + else if (year == 1944) + { + EXPECT_EQ(tz->std_zone_abbrev(), "MSK"); + EXPECT_TRUE(tz->has_dst()); + EXPECT_EQ(tz->base_utc_offset().total_seconds(), 10800); + EXPECT_EQ(tz->dst_zone_abbrev(), "CEST"); + EXPECT_EQ(tz->dst_offset().total_seconds(), -3600); + } + else if (year < 1981) + { + EXPECT_EQ(tz->std_zone_abbrev(), "MSK"); + EXPECT_FALSE(tz->has_dst()); + EXPECT_EQ(tz->base_utc_offset().total_seconds(), 10800); + } + else if (year < 1989) + { + EXPECT_EQ(tz->std_zone_abbrev(), "MSK"); + EXPECT_TRUE(tz->has_dst()); + EXPECT_EQ(tz->base_utc_offset().total_seconds(), 10800); + EXPECT_EQ(tz->dst_zone_abbrev(), "MSD"); + EXPECT_EQ(tz->dst_offset().total_seconds(), 3600); + } + else if (year < 1991) + { + EXPECT_EQ(tz->std_zone_abbrev(), "MSK"); + EXPECT_FALSE(tz->has_dst()); + EXPECT_EQ(tz->base_utc_offset().total_seconds(), 10800); + } + else if (year < 2011) + { + EXPECT_EQ(tz->std_zone_abbrev(), "EET"); + EXPECT_TRUE(tz->has_dst()); + EXPECT_EQ(tz->base_utc_offset().total_seconds(), 7200); + EXPECT_EQ(tz->dst_zone_abbrev(), "EEST"); + EXPECT_EQ(tz->dst_offset().total_seconds(), 3600); + } + else + { + EXPECT_EQ(tz->std_zone_abbrev(), "+03"); + EXPECT_FALSE(tz->has_dst()); + EXPECT_EQ(tz->base_utc_offset().total_seconds(), 10800); + } + } } #endif