Changes to use shared quick-fill for teh account transfer combo box.

Untested but should work fine.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@10009 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas
2004-05-31 17:47:20 +00:00
parent aec37075f0
commit 2083da1480
@@ -29,13 +29,15 @@
#include <libguile.h> #include <libguile.h>
#include "Account.h" #include "Account.h"
#include "gnc-ui-util.h" #include "account-quickfill.h"
#include "recncell.h"
#include "combocell.h" #include "combocell.h"
#include "messages.h"
#include "global-options.h" #include "global-options.h"
#include "business-options.h"
#include "gnc-component-manager.h" #include "gnc-component-manager.h"
#include "gnc-ui-util.h"
#include "messages.h"
#include "recncell.h"
#include "business-options.h"
#include "gncEntry.h" #include "gncEntry.h"
#include "gncEntryLedger.h" #include "gncEntryLedger.h"
@@ -122,83 +124,114 @@ static void load_payment_type_cells (GncEntryLedger *ledger)
gnc_combo_cell_add_menu_item (cell, _("Charge")); gnc_combo_cell_add_menu_item (cell, _("Charge"));
} }
static void load_xfer_cell (ComboCell * cell, AccountGroup * grp, /* ==================================================================== */
GncEntryLedgerType ledger_type) /* Return TRUE if we don't want to add this account to the xfer menu */
static gboolean
skip_acct_cb (Account *account, gpointer user_data)
{ {
GList *list; GncEntryLedgerType ledger_type = (GncEntryLedgerType) user_data;
GList *node; GNCAccountType type;
if (!grp) return; /* Don't add A/R, A/P, Bank, Cash, or Equity accounts */
type = xaccAccountGetType (account);
if (type == PAYABLE || type == RECEIVABLE ||
type == CASH || type == BANK || type == EQUITY)
{
return TRUE;
}
/* Build the xfer menu out of account names. */ /* Don't add placeholder accounts */
if (xaccAccountGetPlaceholder (account))
{
return TRUE;
}
list = xaccGroupGetSubAccounts (grp); /* If this is an ORDER or INVOICE, then leave out the expenses.
* if it's a BILL, then leave out the incomes
for (node = list; node; node = node->next) { */
Account *account = node->data; switch (ledger_type)
char *name; {
GNCAccountType type;
/* Don't add placeholder accounts */
if (xaccAccountGetPlaceholder (account))
continue;
/* Don't add A/R, A/P, Bank, Cash, or Equity accounts */
type = xaccAccountGetType (account);
if (type == PAYABLE || type == RECEIVABLE ||
type == CASH || type == BANK || type == EQUITY)
continue;
/* If this is an ORDER or INVOICE, then leave out the expenses.
* if it's a BILL, then leave out the incomes
*/
switch (ledger_type) {
case GNCENTRY_ORDER_ENTRY: case GNCENTRY_ORDER_ENTRY:
case GNCENTRY_ORDER_VIEWER: case GNCENTRY_ORDER_VIEWER:
case GNCENTRY_INVOICE_ENTRY: case GNCENTRY_INVOICE_ENTRY:
case GNCENTRY_INVOICE_VIEWER: case GNCENTRY_INVOICE_VIEWER:
if (type == EXPENSE) continue; if (type == EXPENSE) return TRUE;
break; return FALSE;
case GNCENTRY_BILL_ENTRY: case GNCENTRY_BILL_ENTRY:
case GNCENTRY_BILL_VIEWER: case GNCENTRY_BILL_VIEWER:
case GNCENTRY_EXPVOUCHER_ENTRY: case GNCENTRY_EXPVOUCHER_ENTRY:
case GNCENTRY_EXPVOUCHER_VIEWER: case GNCENTRY_EXPVOUCHER_VIEWER:
case GNCENTRY_NUM_REGISTER_TYPES: case GNCENTRY_NUM_REGISTER_TYPES:
if (type == INCOME) continue; if (type == INCOME) return TRUE;
break; return FALSE;
}
name = xaccAccountGetFullName (account, gnc_get_account_separator ());
if (name != NULL)
gnc_combo_cell_add_menu_item (cell, name);
g_free(name);
} }
return FALSE;
g_list_free (list);
} }
static void load_xfer_type_cells (GncEntryLedger *ledger) /* ===================================================================== */
/* Splat the account name into the transfer cell combobox menu */
typedef struct {
ComboCell *cell;
GncEntryLedgerType ledger_type;
} BCE;
static gpointer
load_xfer_cell_cb (Account *account, gpointer data)
{ {
BCE *bce = data;
char *name;
if (skip_acct_cb (account, (gpointer) bce->ledger_type)) return NULL;
name = xaccAccountGetFullName (account, gnc_get_account_separator ());
if (NULL == name) return NULL;
gnc_combo_cell_add_menu_item (bce->cell, name);
g_free(name);
return NULL;
}
#define BKEY "Business entry quickfill"
static void
load_xfer_type_cells (GncEntryLedger *ledger)
{
BCE bce;
AccountGroup *group; AccountGroup *group;
ComboCell *cell; ComboCell *cell;
QuickFill *qf;
group = gnc_book_get_group (ledger->book); group = gnc_book_get_group (ledger->book);
if (group == NULL) if (group == NULL) return;
return;
/* Use a common, shared quickfill */
qf = gnc_get_shared_account_name_quickfill (group, BKEY,
skip_acct_cb, (gpointer) ledger->type);
cell = (ComboCell *) cell = (ComboCell *)
gnc_table_layout_get_cell (ledger->table->layout, ENTRY_IACCT_CELL); gnc_table_layout_get_cell (ledger->table->layout, ENTRY_IACCT_CELL);
gnc_combo_cell_clear_menu (cell); gnc_combo_cell_clear_menu (cell);
load_xfer_cell (cell, group, ledger->type); gnc_combo_cell_use_quickfill_cache (cell, qf);
bce.cell = cell;
bce.ledger_type = ledger->type;
xaccGroupForEachAccount (group, load_xfer_cell_cb, &bce, TRUE);
cell = (ComboCell *) cell = (ComboCell *)
gnc_table_layout_get_cell (ledger->table->layout, ENTRY_BACCT_CELL); gnc_table_layout_get_cell (ledger->table->layout, ENTRY_BACCT_CELL);
gnc_combo_cell_clear_menu (cell); gnc_combo_cell_clear_menu (cell);
load_xfer_cell (cell, group, ledger->type); gnc_combo_cell_use_quickfill_cache (cell, qf);
bce.cell = cell;
bce.ledger_type = ledger->type;
xaccGroupForEachAccount (group, load_xfer_cell_cb, &bce, TRUE);
} }
/* ===================================================================== */
static void load_taxtable_type_cells (GncEntryLedger *ledger) static void load_taxtable_type_cells (GncEntryLedger *ledger)
{ {
GList *list; GList *list;
@@ -240,6 +273,10 @@ void gnc_entry_ledger_load_xfer_cells (GncEntryLedger *ledger)
/* XXX (FIXME): This should be in a config file! */ /* XXX (FIXME): This should be in a config file! */
/* Copy GncEntry information from the list to the rows of the Ledger. */ /* Copy GncEntry information from the list to the rows of the Ledger. */
/* XXX This code is a cut-n-paste job from the SplitRegister code;
* the split-regsiter should be generalized to the point where a cut-n-paste
* like this isn't required, and this should be trashed.
*/
void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list) void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
{ {
static SCM id_book = SCM_UNDEFINED; static SCM id_book = SCM_UNDEFINED;
@@ -506,3 +543,5 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
/* enable callback for cursor user-driven moves */ /* enable callback for cursor user-driven moves */
gnc_table_control_allow_move (table->control, TRUE); gnc_table_control_allow_move (table->control, TRUE);
} }
/* =========================== END OF FILE ========================== */