Hi,

I've attached two patches, one that could be applied to 2.2.7 and the other for application to trunk. In the post screen for vendor bills, in 2.2.7, the account combo box shows an account but doesn't consider it selected.. this patch allows it to behave as it appears that it should behave (aka, using the account visible in the combo box)

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).

-Jamie
Index: src/business/business-gnome/dialog-date-close.c
===================================================================
--- src/business/business-gnome/dialog-date-close.c	(revision 57)
+++ src/business/business-gnome/dialog-date-close.c	(working copy)
@@ -101,7 +101,7 @@
 }
 
 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);
 
@@ -111,7 +111,7 @@
   gnc_account_sel_set_new_account_modal( gas, TRUE );
 
   /* XXX: Some way to remember the last selection? */
-  gnc_account_sel_set_account( gas, NULL );
+  gnc_account_sel_set_account( gas, NULL, set_default_acct );
 }
 
 static void
@@ -229,6 +229,7 @@
 				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... */
@@ -312,7 +313,7 @@
     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,
@@ -391,7 +392,7 @@
   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,
Index: src/business/business-gnome/dialog-date-close.h
===================================================================
--- src/business/business-gnome/dialog-date-close.h	(revision 57)
+++ src/business/business-gnome/dialog-date-close.h	(working copy)
@@ -50,6 +50,7 @@
 				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... */
Index: src/business/business-gnome/dialog-employee.c
===================================================================
--- src/business/business-gnome/dialog-employee.c	(revision 57)
+++ src/business/business-gnome/dialog-employee.c	(working copy)
@@ -549,7 +549,7 @@
     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 */
Index: src/business/business-gnome/dialog-invoice.c
===================================================================
--- src/business/business-gnome/dialog-invoice.c	(revision 57)
+++ src/business/business-gnome/dialog-invoice.c	(working copy)
@@ -650,7 +650,7 @@
   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;
Index: src/gnome-utils/gnc-account-sel.c
===================================================================
--- src/gnome-utils/gnc-account-sel.c	(revision 57)
+++ src/gnome-utils/gnc-account-sel.c	(working copy)
@@ -282,11 +282,19 @@
   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;
 
Index: src/gnome-utils/gnc-account-sel.h
===================================================================
--- src/gnome-utils/gnc-account-sel.h	(revision 57)
+++ src/gnome-utils/gnc-account-sel.h	(working copy)
@@ -70,9 +70,10 @@
 /**
  * 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.
Index: src/gnome-utils/dialog-options.c
===================================================================
--- src/gnome-utils/dialog-options.c	(revision 57)
+++ src/gnome-utils/dialog-options.c	(working copy)
@@ -2384,7 +2384,7 @@
     acc = SWIG_MustGetPtr(value, SWIG_TypeQuery("_p_Account"), 4, 0);
   }
 	
-  gnc_account_sel_set_account (GNC_ACCOUNT_SEL(widget), acc);
+  gnc_account_sel_set_account (GNC_ACCOUNT_SEL(widget), acc, FALSE);
 
   return FALSE;
 }
Index: src/gnome/druid-loan.c
===================================================================
--- src/gnome/druid-loan.c	(revision 57)
+++ src/gnome/druid-loan.c	(working copy)
@@ -1277,7 +1277,7 @@
         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; i<ldd->ld.repayOptCount; i++ ) {
                 rouid = ldd->repayOptsUI[i];
@@ -1414,11 +1414,11 @@
                 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 @@
                                                    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 @@
         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 @@
         {
                 gnc_account_sel_set_account( ldd->payAcctFromGAS,
                                              ldd->ld.repayOpts[ldd->currentIdx]
-                                             ->from );
+                                             ->from, FALSE );
         }
 }
 
Index: src/business/business-gnome/dialog-date-close.c
===================================================================
--- src/business/business-gnome/dialog-date-close.c	(revision 57)
+++ src/business/business-gnome/dialog-date-close.c	(working copy)
@@ -101,7 +101,7 @@
 }
 
 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 @@
   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 @@
 				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_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 @@
   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_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,
Index: src/business/business-gnome/dialog-date-close.h
===================================================================
--- src/business/business-gnome/dialog-date-close.h	(revision 57)
+++ src/business/business-gnome/dialog-date-close.h	(working copy)
@@ -52,6 +52,7 @@
 				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... */
Index: src/business/business-gnome/dialog-employee.c
===================================================================
--- src/business/business-gnome/dialog-employee.c	(revision 57)
+++ src/business/business-gnome/dialog-employee.c	(working copy)
@@ -549,7 +549,7 @@
     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 */
Index: src/business/business-gnome/dialog-invoice.c
===================================================================
--- src/business/business-gnome/dialog-invoice.c	(revision 57)
+++ src/business/business-gnome/dialog-invoice.c	(working copy)
@@ -664,7 +664,7 @@
   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;
Index: src/gnome-utils/gnc-account-sel.c
===================================================================
--- src/gnome-utils/gnc-account-sel.c	(revision 57)
+++ src/gnome-utils/gnc-account-sel.c	(working copy)
@@ -285,11 +285,18 @@
   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;
 
Index: src/gnome-utils/gnc-account-sel.h
===================================================================
--- src/gnome-utils/gnc-account-sel.h	(revision 57)
+++ src/gnome-utils/gnc-account-sel.h	(working copy)
@@ -70,9 +70,9 @@
 /**
  * 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.
Index: src/gnome-utils/dialog-options.c
===================================================================
--- src/gnome-utils/dialog-options.c	(revision 57)
+++ src/gnome-utils/dialog-options.c	(working copy)
@@ -2384,7 +2384,8 @@
     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;
 }
Index: src/gnome/druid-loan.c
===================================================================
--- src/gnome/druid-loan.c	(revision 57)
+++ src/gnome/druid-loan.c	(working copy)
@@ -1277,7 +1277,7 @@
         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; i<ldd->ld.repayOptCount; i++ ) {
                 rouid = ldd->repayOptsUI[i];
@@ -1414,11 +1414,11 @@
                 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 @@
                                                    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 @@
         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 @@
         {
                 gnc_account_sel_set_account( ldd->payAcctFromGAS,
                                              ldd->ld.repayOpts[ldd->currentIdx]
-                                             ->from );
+                                             ->from, FALSE );
         }
 }
 
_______________________________________________
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel

Reply via email to