From 1401b066bd81f24bd33b986fb5eb6072ad52279c Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Sat, 25 Oct 2008 08:59:40 +0000 Subject: [PATCH] Add account defaulting for posting vendor bill In the post screen for vendor bills, in trunk, the account combo box initially has no entry and the user needs to pick one. This isn't a bug, but is an extra step for the user, so the trunk patch does defaulting. I tested the "memory" function to make sure the defaulting doesn't smash the account the user picked for this vendor the last time through, and it works (doesn't conflict). Patch by aradzak . git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@17644 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/business/business-gnome/dialog-date-close.c | 11 ++++++----- src/business/business-gnome/dialog-date-close.h | 1 + src/business/business-gnome/dialog-employee.c | 2 +- src/business/business-gnome/dialog-invoice.c | 2 +- src/gnome-utils/dialog-options.c | 3 ++- src/gnome-utils/gnc-account-sel.c | 11 +++++++++-- src/gnome-utils/gnc-account-sel.h | 4 ++-- src/gnome/druid-loan.c | 16 ++++++++-------- 8 files changed, 30 insertions(+), 20 deletions(-) diff --git a/src/business/business-gnome/dialog-date-close.c b/src/business/business-gnome/dialog-date-close.c index 2901b40ed6..3adc79a624 100644 --- a/src/business/business-gnome/dialog-date-close.c +++ b/src/business/business-gnome/dialog-date-close.c @@ -101,7 +101,7 @@ gnc_dialog_date_close_ok_cb (GtkWidget *widget, gpointer user_data) } static void -fill_in_acct_info (DialogDateClose *ddc) +fill_in_acct_info (DialogDateClose *ddc, gboolean set_default_acct) { GNCAccountSel *gas = GNC_ACCOUNT_SEL (ddc->acct_combo); @@ -109,7 +109,7 @@ fill_in_acct_info (DialogDateClose *ddc) gnc_account_sel_set_acct_filters( gas, ddc->acct_types ); gnc_account_sel_set_new_account_ability( gas, TRUE ); gnc_account_sel_set_new_account_modal( gas, TRUE ); - gnc_account_sel_set_account( gas, ddc->acct ); + gnc_account_sel_set_account( gas, ddc->acct, set_default_acct ); } static void @@ -227,6 +227,7 @@ gnc_dialog_dates_acct_question_parented (GtkWidget *parent, const char *message, const char *acct_label_message, const char *question_check_message, gboolean ok_is_default, + gboolean set_default_acct, GList * acct_types, GNCBook *book, GncBillTerm *terms, /* Returned Data... */ @@ -311,7 +312,7 @@ gnc_dialog_dates_acct_question_parented (GtkWidget *parent, const char *message, gnc_date_edit_set_time_ts (GNC_DATE_EDIT (ddc->date), *ddue); /* Setup the account widget */ - fill_in_acct_info (ddc); + fill_in_acct_info (ddc, set_default_acct); /* Setup signals */ glade_xml_signal_autoconnect_full( xml, @@ -371,7 +372,7 @@ gnc_dialog_date_acct_parented (GtkWidget *parent, const char *message, acct_box = glade_xml_get_widget (xml, "acct_hbox"); ddc->acct_combo = gnc_account_sel_new(); if (*acct) - gnc_account_sel_set_account (GNC_ACCOUNT_SEL(ddc->acct_combo), *acct); + gnc_account_sel_set_account (GNC_ACCOUNT_SEL(ddc->acct_combo), *acct, FALSE); gtk_box_pack_start (GTK_BOX(acct_box), ddc->acct_combo, TRUE, TRUE, 0); date_box = glade_xml_get_widget (xml, "date_box"); @@ -393,7 +394,7 @@ gnc_dialog_date_acct_parented (GtkWidget *parent, const char *message, gnc_date_edit_set_time_ts (GNC_DATE_EDIT (ddc->date), *date); /* Setup the account widget */ - fill_in_acct_info (ddc); + fill_in_acct_info (ddc, FALSE); /* Setup signals */ glade_xml_signal_autoconnect_full( xml, diff --git a/src/business/business-gnome/dialog-date-close.h b/src/business/business-gnome/dialog-date-close.h index 267c7304ab..1ebd46ec49 100644 --- a/src/business/business-gnome/dialog-date-close.h +++ b/src/business/business-gnome/dialog-date-close.h @@ -52,6 +52,7 @@ gnc_dialog_dates_acct_question_parented (GtkWidget *parent, const char *message, const char *acct_label_message, const char *question_check_message, gboolean ok_is_default, + gboolean set_default_acct, GList * acct_types, GNCBook *book, GncBillTerm *terms, /* Returned Data... */ diff --git a/src/business/business-gnome/dialog-employee.c b/src/business/business-gnome/dialog-employee.c index 7e9de61707..9803e0287e 100644 --- a/src/business/business-gnome/dialog-employee.c +++ b/src/business/business-gnome/dialog-employee.c @@ -549,7 +549,7 @@ gnc_employee_new_window (GNCBook *bookp, gtk_widget_set_sensitive (ew->ccard_acct_sel, FALSE); } else { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ew->ccard_acct_check), TRUE); - gnc_account_sel_set_account (GNC_ACCOUNT_SEL (ew->ccard_acct_sel), ccard_acct); + gnc_account_sel_set_account (GNC_ACCOUNT_SEL (ew->ccard_acct_sel), ccard_acct, FALSE); } /* XXX: Set the ACL */ diff --git a/src/business/business-gnome/dialog-invoice.c b/src/business/business-gnome/dialog-invoice.c index 07cbc2dc36..1d8830ef42 100644 --- a/src/business/business-gnome/dialog-invoice.c +++ b/src/business/business-gnome/dialog-invoice.c @@ -664,7 +664,7 @@ gnc_invoice_window_postCB (GtkWidget *widget, gpointer data) accumulate = gnc_gconf_get_bool(GCONF_SECTION_INVOICE, "accumulate_splits", NULL); if (!gnc_dialog_dates_acct_question_parented (iw_get_window(iw), message, ddue_label, - post_label, acct_label, question_label, TRUE, + post_label, acct_label, question_label, TRUE, TRUE, acct_types, iw->book, iw->terms, &ddue, &postdate, &memo, &acc, &accumulate)) return; diff --git a/src/gnome-utils/dialog-options.c b/src/gnome-utils/dialog-options.c index e4d4d3626a..afe48e3562 100644 --- a/src/gnome-utils/dialog-options.c +++ b/src/gnome-utils/dialog-options.c @@ -2384,7 +2384,8 @@ gnc_option_set_ui_value_account_sel (GNCOption *option, gboolean use_default, acc = SWIG_MustGetPtr(value, SWIG_TypeQuery("_p_Account"), 4, 0); } - gnc_account_sel_set_account (GNC_ACCOUNT_SEL(widget), acc); + //doesn't default because this function is called to set a specific account + gnc_account_sel_set_account (GNC_ACCOUNT_SEL(widget), acc, FALSE); return FALSE; } diff --git a/src/gnome-utils/gnc-account-sel.c b/src/gnome-utils/gnc-account-sel.c index 01adcc2e98..11286665d6 100644 --- a/src/gnome-utils/gnc-account-sel.c +++ b/src/gnome-utils/gnc-account-sel.c @@ -285,11 +285,18 @@ gnc_account_sel_find_account (GtkTreeModel *model, return TRUE; } void -gnc_account_sel_set_account( GNCAccountSel *gas, Account *acct ) +gnc_account_sel_set_account( GNCAccountSel *gas, Account *acct, gboolean set_default_acct ) { gas_find_data data; - gtk_combo_box_set_active( GTK_COMBO_BOX(gas->combo), -1 ); + if (set_default_acct) + { + gtk_combo_box_set_active(GTK_COMBO_BOX(gas->combo), 0); + } + else + { + gtk_combo_box_set_active( GTK_COMBO_BOX(gas->combo), -1 ); + } if ( acct == NULL ) return; diff --git a/src/gnome-utils/gnc-account-sel.h b/src/gnome-utils/gnc-account-sel.h index 1027b7a019..43c7952860 100644 --- a/src/gnome-utils/gnc-account-sel.h +++ b/src/gnome-utils/gnc-account-sel.h @@ -70,9 +70,9 @@ GtkWidget* gnc_account_sel_new (void); /** * Sets the GAS to the given account. If the account doesn't exist in the * list, then it doesn't change the state of the GAS. If the account is - * NULL, then the first list selection is made. + * NULL, then the first list selection is made if set_default_acct is TRUE. **/ -void gnc_account_sel_set_account( GNCAccountSel *gas, Account *acct ); +void gnc_account_sel_set_account( GNCAccountSel *gas, Account *acct, gboolean set_default_acct ); /** * Returns the currently-selected Account. If, for some reason the selection * is in a bad state, NULL will be returned. diff --git a/src/gnome/druid-loan.c b/src/gnome/druid-loan.c index b5d1e80df8..1654569cd0 100644 --- a/src/gnome/druid-loan.c +++ b/src/gnome/druid-loan.c @@ -1277,7 +1277,7 @@ ld_opts_prep( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ) if ( ldd->ld.escrowAcct ) { gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(ldd->optEscrowCb), TRUE ); - gnc_account_sel_set_account( ldd->optEscrowGAS, ldd->ld.escrowAcct ); + gnc_account_sel_set_account( ldd->optEscrowGAS, ldd->ld.escrowAcct, FALSE ); } for ( i=0; ild.repayOptCount; i++ ) { rouid = ldd->repayOptsUI[i]; @@ -1414,11 +1414,11 @@ ld_rep_prep( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ) gtk_entry_set_text( ldd->repAmtEntry, ldd->ld.repAmount ); gnc_account_sel_set_account( ldd->repAssetsFromGAS, - ldd->ld.repFromAcct ); + ldd->ld.repFromAcct, FALSE ); gnc_account_sel_set_account( ldd->repPrincToGAS, - ldd->ld.repPriAcct ); + ldd->ld.repPriAcct, FALSE ); gnc_account_sel_set_account( ldd->repIntToGAS, - ldd->ld.repIntAcct ); + ldd->ld.repIntAcct, FALSE ); gnc_frequency_setup_recurrence(ldd->repGncFreq, ldd->ld.repayment_schedule, ldd->ld.repStartDate); @@ -1483,7 +1483,7 @@ ld_pay_prep( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ) ldd ); } - gnc_account_sel_set_account( ldd->payAcctToGAS, rod->to ); + gnc_account_sel_set_account( ldd->payAcctToGAS, rod->to, FALSE ); uniq = (rod->schedule != NULL); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(ldd->payTxnFreqPartRb), @@ -1684,9 +1684,9 @@ ld_pay_use_esc_setup( LoanDruidData *ldd, gboolean newState ) if ( newState ) { gnc_account_sel_set_account( ldd->payAcctEscToGAS, - ldd->ld.escrowAcct ); + ldd->ld.escrowAcct, FALSE ); gnc_account_sel_set_account( ldd->payAcctEscFromGAS, - ldd->ld.escrowAcct ); + ldd->ld.escrowAcct, FALSE ); } } @@ -1711,7 +1711,7 @@ ld_pay_spec_src_setup( LoanDruidData *ldd, gboolean newState ) { gnc_account_sel_set_account( ldd->payAcctFromGAS, ldd->ld.repayOpts[ldd->currentIdx] - ->from ); + ->from, FALSE ); } }