mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Clean up register code. Separate register type and register style.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2496 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
d19485f074
commit
8d966b080d
@ -1,5 +1,9 @@
|
|||||||
2000-06-21 Dave Peticolas <dave@krondo.com>
|
2000-06-21 Dave Peticolas <dave@krondo.com>
|
||||||
|
|
||||||
|
* src/register/splitreg.h: break out the register type and the
|
||||||
|
register style into two separate struct members, instead of using
|
||||||
|
bitmasks. This is much, much simpler.
|
||||||
|
|
||||||
* src/optional/swig/Makefile.am (gnucash-engine-perl5_wrap.c):
|
* src/optional/swig/Makefile.am (gnucash-engine-perl5_wrap.c):
|
||||||
remove the -stat argument, it's no longer support in later swig
|
remove the -stat argument, it's no longer support in later swig
|
||||||
versions.
|
versions.
|
||||||
|
@ -153,9 +153,8 @@ ledgerIsMember (xaccLedgerDisplay *reg, Account * acc)
|
|||||||
xaccLedgerDisplay *
|
xaccLedgerDisplay *
|
||||||
xaccLedgerDisplaySimple (Account *acc)
|
xaccLedgerDisplaySimple (Account *acc)
|
||||||
{
|
{
|
||||||
xaccLedgerDisplay *retval;
|
SplitRegisterType reg_type;
|
||||||
int acc_type;
|
GNCAccountType acc_type;
|
||||||
int reg_type = -1;
|
|
||||||
|
|
||||||
acc_type = xaccAccountGetType (acc);
|
acc_type = xaccAccountGetType (acc);
|
||||||
|
|
||||||
@ -197,11 +196,7 @@ xaccLedgerDisplaySimple (Account *acc)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* default to single-line display */
|
return xaccLedgerDisplayGeneral (acc, NULL, reg_type, REG_SINGLE_LINE);
|
||||||
reg_type |= REG_SINGLE_LINE;
|
|
||||||
|
|
||||||
retval = xaccLedgerDisplayGeneral (acc, NULL, reg_type);
|
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************\
|
/********************************************************************\
|
||||||
@ -216,12 +211,13 @@ xaccLedgerDisplaySimple (Account *acc)
|
|||||||
xaccLedgerDisplay *
|
xaccLedgerDisplay *
|
||||||
xaccLedgerDisplayAccGroup (Account *acc)
|
xaccLedgerDisplayAccGroup (Account *acc)
|
||||||
{
|
{
|
||||||
|
SplitRegisterType ledger_type;
|
||||||
xaccLedgerDisplay *retval;
|
xaccLedgerDisplay *retval;
|
||||||
|
GNCAccountType acc_type;
|
||||||
|
GNCAccountType le_type;
|
||||||
Account **list;
|
Account **list;
|
||||||
int ledger_type;
|
|
||||||
Account *le;
|
Account *le;
|
||||||
int n;
|
int n;
|
||||||
int acc_type, le_type;
|
|
||||||
|
|
||||||
/* build a flat list from the tree */
|
/* build a flat list from the tree */
|
||||||
list = xaccGroupToList (acc);
|
list = xaccGroupToList (acc);
|
||||||
@ -270,12 +266,10 @@ xaccLedgerDisplayAccGroup (Account *acc)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* default to single-line display */
|
retval = xaccLedgerDisplayGeneral (acc, list, ledger_type, REG_SINGLE_LINE);
|
||||||
ledger_type |= REG_SINGLE_LINE;
|
|
||||||
|
|
||||||
retval = xaccLedgerDisplayGeneral (acc, list, ledger_type);
|
|
||||||
|
|
||||||
if (list) _free (list);
|
if (list) _free (list);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,7 +314,7 @@ xaccLedgerDisplaySetHelp(void *user_data, const char *help_str)
|
|||||||
|
|
||||||
xaccLedgerDisplay *
|
xaccLedgerDisplay *
|
||||||
xaccLedgerDisplayGeneral (Account *lead_acc, Account **acclist,
|
xaccLedgerDisplayGeneral (Account *lead_acc, Account **acclist,
|
||||||
int ledger_type)
|
SplitRegisterType type, SplitRegisterStyle style)
|
||||||
{
|
{
|
||||||
xaccLedgerDisplay *regData = NULL;
|
xaccLedgerDisplay *regData = NULL;
|
||||||
gboolean show_all;
|
gboolean show_all;
|
||||||
@ -373,7 +367,7 @@ xaccLedgerDisplayGeneral (Account *lead_acc, Account **acclist,
|
|||||||
* and then, store them. */
|
* and then, store them. */
|
||||||
regData->numAcc = accListCount (acclist);
|
regData->numAcc = accListCount (acclist);
|
||||||
regData->displayed_accounts = accListCopy (acclist);
|
regData->displayed_accounts = accListCopy (acclist);
|
||||||
regData->type = ledger_type;
|
regData->type = type;
|
||||||
|
|
||||||
show_all = gnc_lookup_boolean_option("Register",
|
show_all = gnc_lookup_boolean_option("Register",
|
||||||
"Show All Transactions",
|
"Show All Transactions",
|
||||||
@ -386,7 +380,7 @@ xaccLedgerDisplayGeneral (Account *lead_acc, Account **acclist,
|
|||||||
* configurable, or maybe we should go back a time range instead
|
* configurable, or maybe we should go back a time range instead
|
||||||
* of picking a number, or maybe we should be able to exclude
|
* of picking a number, or maybe we should be able to exclude
|
||||||
* based on reconciled status. Anyway, this works for now. */
|
* based on reconciled status. Anyway, this works for now. */
|
||||||
if (!show_all && ((ledger_type & REG_TYPE_MASK) != SEARCH_LEDGER))
|
if (!show_all && (type != SEARCH_LEDGER))
|
||||||
xaccQuerySetMaxSplits(regData->query, 30);
|
xaccQuerySetMaxSplits(regData->query, 30);
|
||||||
|
|
||||||
xaccQuerySetGroup(regData->query, gncGetCurrentGroup());
|
xaccQuerySetGroup(regData->query, gncGetCurrentGroup());
|
||||||
@ -410,7 +404,7 @@ xaccLedgerDisplayGeneral (Account *lead_acc, Account **acclist,
|
|||||||
|
|
||||||
/* xaccMallocSplitRegister will malloc & initialize the register,
|
/* xaccMallocSplitRegister will malloc & initialize the register,
|
||||||
* but will not do the gui init */
|
* but will not do the gui init */
|
||||||
regData->ledger = xaccMallocSplitRegister (ledger_type);
|
regData->ledger = xaccMallocSplitRegister (type, style);
|
||||||
|
|
||||||
xaccSRSetData(regData->ledger, regData,
|
xaccSRSetData(regData->ledger, regData,
|
||||||
xaccLedgerDisplayParent,
|
xaccLedgerDisplayParent,
|
||||||
|
@ -46,8 +46,9 @@ struct _xaccLedgerDisplay {
|
|||||||
short numAcc; /* number of accounts in list */
|
short numAcc; /* number of accounts in list */
|
||||||
Query *query; /* query engine & filter for displaying */
|
Query *query; /* query engine & filter for displaying */
|
||||||
|
|
||||||
short type; /* register display type, usually equal to *
|
SplitRegisterType type; /* register display type, usually equal to *
|
||||||
* account type, but not always. */
|
* account type, but not always. */
|
||||||
|
|
||||||
double balance; /* balance */
|
double balance; /* balance */
|
||||||
double clearedBalance;
|
double clearedBalance;
|
||||||
double reconciledBalance;
|
double reconciledBalance;
|
||||||
@ -81,7 +82,8 @@ xaccLedgerDisplay * xaccLedgerDisplayAccGroup (Account *acc);
|
|||||||
*/
|
*/
|
||||||
xaccLedgerDisplay * xaccLedgerDisplayGeneral (Account *lead_acc,
|
xaccLedgerDisplay * xaccLedgerDisplayGeneral (Account *lead_acc,
|
||||||
Account **acclist,
|
Account **acclist,
|
||||||
int ledger_type);
|
SplitRegisterType type,
|
||||||
|
SplitRegisterStyle style);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* redisplay/redraw all windows that contain any transactions
|
* redisplay/redraw all windows that contain any transactions
|
||||||
|
@ -642,7 +642,6 @@ LedgerMoveCursor (Table *table,
|
|||||||
int new_cell_col;
|
int new_cell_col;
|
||||||
int phys_row_offset;
|
int phys_row_offset;
|
||||||
int phys_col_offset;
|
int phys_col_offset;
|
||||||
int style;
|
|
||||||
|
|
||||||
PINFO ("start callback %d %d \n", new_phys_row, new_phys_col);
|
PINFO ("start callback %d %d \n", new_phys_row, new_phys_col);
|
||||||
|
|
||||||
@ -759,9 +758,8 @@ LedgerMoveCursor (Table *table,
|
|||||||
* to expand out the splits at the new location. We use the
|
* to expand out the splits at the new location. We use the
|
||||||
* cursor_hint data members to tell the refresh routine where
|
* cursor_hint data members to tell the refresh routine where
|
||||||
* to go. */
|
* to go. */
|
||||||
style = ((reg->type) & REG_STYLE_MASK);
|
if ((REG_SINGLE_DYNAMIC == reg->style) ||
|
||||||
if ((REG_SINGLE_DYNAMIC == style) ||
|
(REG_DOUBLE_DYNAMIC == reg->style))
|
||||||
(REG_DOUBLE_DYNAMIC == style))
|
|
||||||
{
|
{
|
||||||
new_trans = xaccSRGetTrans(reg, new_phys_row, new_phys_col);
|
new_trans = xaccSRGetTrans(reg, new_phys_row, new_phys_col);
|
||||||
info->cursor_hint_trans = new_trans;
|
info->cursor_hint_trans = new_trans;
|
||||||
@ -808,6 +806,7 @@ LedgerAutoCompletion(SplitRegister *reg, gncTableTraversalDir dir,
|
|||||||
SRInfo *info = xaccSRGetInfo(reg);
|
SRInfo *info = xaccSRGetInfo(reg);
|
||||||
Split *blank_split = xaccSplitLookup(&info->blank_split_guid);
|
Split *blank_split = xaccSplitLookup(&info->blank_split_guid);
|
||||||
Transaction *pending_trans = xaccTransLookup(&info->pending_trans_guid);
|
Transaction *pending_trans = xaccTransLookup(&info->pending_trans_guid);
|
||||||
|
SplitRegisterType reg_type;
|
||||||
CursorType cursor_type;
|
CursorType cursor_type;
|
||||||
unsigned int changed;
|
unsigned int changed;
|
||||||
CellType cell_type;
|
CellType cell_type;
|
||||||
@ -826,6 +825,7 @@ LedgerAutoCompletion(SplitRegister *reg, gncTableTraversalDir dir,
|
|||||||
if (trans == NULL)
|
if (trans == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
reg_type = reg->type;
|
||||||
cursor_type = xaccSplitRegisterGetCursorType(reg);
|
cursor_type = xaccSplitRegisterGetCursorType(reg);
|
||||||
cell_type = xaccSplitRegisterGetCellType(reg);
|
cell_type = xaccSplitRegisterGetCellType(reg);
|
||||||
changed = xaccSplitRegisterGetChangeFlag(reg);
|
changed = xaccSplitRegisterGetChangeFlag(reg);
|
||||||
@ -940,7 +940,6 @@ LedgerAutoCompletion(SplitRegister *reg, gncTableTraversalDir dir,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CURSOR_SPLIT: {
|
case CURSOR_SPLIT: {
|
||||||
SplitRegisterType typo = reg->type & REG_TYPE_MASK;
|
|
||||||
char *memo, *fullname;
|
char *memo, *fullname;
|
||||||
gboolean unit_price;
|
gboolean unit_price;
|
||||||
Split *auto_split;
|
Split *auto_split;
|
||||||
@ -999,9 +998,9 @@ LedgerAutoCompletion(SplitRegister *reg, gncTableTraversalDir dir,
|
|||||||
xaccBasicCellSetChanged(&(reg->xfrmCell->cell), GNC_T);
|
xaccBasicCellSetChanged(&(reg->xfrmCell->cell), GNC_T);
|
||||||
|
|
||||||
/* auto-complete the amounts */
|
/* auto-complete the amounts */
|
||||||
if ((STOCK_REGISTER == typo) ||
|
if ((STOCK_REGISTER == reg_type) ||
|
||||||
(CURRENCY_REGISTER == typo) ||
|
(CURRENCY_REGISTER == reg_type) ||
|
||||||
(PORTFOLIO_LEDGER == typo))
|
(PORTFOLIO_LEDGER == reg_type))
|
||||||
amount = xaccSplitGetShareAmount (auto_split);
|
amount = xaccSplitGetShareAmount (auto_split);
|
||||||
else
|
else
|
||||||
amount = xaccSplitGetValue (auto_split);
|
amount = xaccSplitGetValue (auto_split);
|
||||||
@ -2181,7 +2180,6 @@ xaccSRSaveRegEntryToSCM (SplitRegister *reg, SCM trans_scm, SCM split_scm)
|
|||||||
{
|
{
|
||||||
Transaction *trans;
|
Transaction *trans;
|
||||||
unsigned int changed;
|
unsigned int changed;
|
||||||
int style;
|
|
||||||
|
|
||||||
/* use the changed flag to avoid heavy-weight updates
|
/* use the changed flag to avoid heavy-weight updates
|
||||||
* of the split & transaction fields. This will help
|
* of the split & transaction fields. This will help
|
||||||
@ -2190,8 +2188,6 @@ xaccSRSaveRegEntryToSCM (SplitRegister *reg, SCM trans_scm, SCM split_scm)
|
|||||||
if (!changed)
|
if (!changed)
|
||||||
return GNC_F;
|
return GNC_F;
|
||||||
|
|
||||||
style = (reg->type) & REG_STYLE_MASK;
|
|
||||||
|
|
||||||
/* get the handle to the current split and transaction */
|
/* get the handle to the current split and transaction */
|
||||||
trans = xaccSRGetCurrentTrans (reg);
|
trans = xaccSRGetCurrentTrans (reg);
|
||||||
if (trans == NULL)
|
if (trans == NULL)
|
||||||
@ -2301,9 +2297,9 @@ xaccSRSaveRegEntryToSCM (SplitRegister *reg, SCM trans_scm, SCM split_scm)
|
|||||||
|
|
||||||
price = gnc_split_scm_get_share_price(split_scm);
|
price = gnc_split_scm_get_share_price(split_scm);
|
||||||
|
|
||||||
if ((STOCK_REGISTER == (reg->type & REG_TYPE_MASK)) ||
|
if ((STOCK_REGISTER == (reg->type)) ||
|
||||||
(CURRENCY_REGISTER == (reg->type & REG_TYPE_MASK)) ||
|
(CURRENCY_REGISTER == (reg->type)) ||
|
||||||
(PORTFOLIO_LEDGER == (reg->type & REG_TYPE_MASK)))
|
(PORTFOLIO_LEDGER == (reg->type)))
|
||||||
;
|
;
|
||||||
else
|
else
|
||||||
new_amount = new_amount / price;
|
new_amount = new_amount / price;
|
||||||
@ -2486,10 +2482,8 @@ xaccSRSaveChangedCells (SplitRegister *reg, Transaction *trans, Split *split)
|
|||||||
{
|
{
|
||||||
GList *refresh_accounts = NULL;
|
GList *refresh_accounts = NULL;
|
||||||
unsigned int changed;
|
unsigned int changed;
|
||||||
int style;
|
|
||||||
|
|
||||||
changed = xaccSplitRegisterGetChangeFlag (reg);
|
changed = xaccSplitRegisterGetChangeFlag (reg);
|
||||||
style = (reg->type) & REG_STYLE_MASK;
|
|
||||||
|
|
||||||
/* copy the contents from the cursor to the split */
|
/* copy the contents from the cursor to the split */
|
||||||
if (MOD_DATE & changed) {
|
if (MOD_DATE & changed) {
|
||||||
@ -2676,9 +2670,9 @@ xaccSRSaveChangedCells (SplitRegister *reg, Transaction *trans, Split *split)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (((MOD_AMNT | MOD_PRIC | MOD_VALU) & changed) &&
|
if (((MOD_AMNT | MOD_PRIC | MOD_VALU) & changed) &&
|
||||||
((STOCK_REGISTER == (reg->type & REG_TYPE_MASK)) ||
|
((STOCK_REGISTER == (reg->type)) ||
|
||||||
(CURRENCY_REGISTER == (reg->type & REG_TYPE_MASK)) ||
|
(CURRENCY_REGISTER == (reg->type)) ||
|
||||||
(PORTFOLIO_LEDGER == (reg->type & REG_TYPE_MASK)))) {
|
(PORTFOLIO_LEDGER == (reg->type)))) {
|
||||||
|
|
||||||
double value;
|
double value;
|
||||||
double price;
|
double price;
|
||||||
@ -2803,9 +2797,9 @@ xaccSRSaveChangedCells (SplitRegister *reg, Transaction *trans, Split *split)
|
|||||||
|
|
||||||
DEBUG ("MOD_AMNT: %f\n", new_amount);
|
DEBUG ("MOD_AMNT: %f\n", new_amount);
|
||||||
|
|
||||||
if ((STOCK_REGISTER == (reg->type & REG_TYPE_MASK)) ||
|
if ((STOCK_REGISTER == (reg->type)) ||
|
||||||
(CURRENCY_REGISTER == (reg->type & REG_TYPE_MASK)) ||
|
(CURRENCY_REGISTER == (reg->type)) ||
|
||||||
(PORTFOLIO_LEDGER == (reg->type & REG_TYPE_MASK)))
|
(PORTFOLIO_LEDGER == (reg->type)))
|
||||||
xaccSplitSetShareAmount (split, new_amount);
|
xaccSplitSetShareAmount (split, new_amount);
|
||||||
else
|
else
|
||||||
xaccSplitSetValue (split, new_amount);
|
xaccSplitSetValue (split, new_amount);
|
||||||
@ -2839,7 +2833,7 @@ xaccSRLoadRegEntry (SplitRegister *reg, Split *split)
|
|||||||
{
|
{
|
||||||
SRInfo *info = xaccSRGetInfo(reg);
|
SRInfo *info = xaccSRGetInfo(reg);
|
||||||
Split *blank_split = xaccSplitLookup(&info->blank_split_guid);
|
Split *blank_split = xaccSplitLookup(&info->blank_split_guid);
|
||||||
int typo = reg->type & REG_TYPE_MASK;
|
SplitRegisterType reg_type = reg->type;
|
||||||
char buff[2];
|
char buff[2];
|
||||||
double baln;
|
double baln;
|
||||||
|
|
||||||
@ -2899,8 +2893,8 @@ xaccSRLoadRegEntry (SplitRegister *reg, Split *split)
|
|||||||
if (reverse_balance(account))
|
if (reverse_balance(account))
|
||||||
baln = -baln;
|
baln = -baln;
|
||||||
}
|
}
|
||||||
else if ((INCOME_REGISTER == typo) ||
|
else if ((INCOME_REGISTER == reg_type) ||
|
||||||
(EXPENSE_REGISTER == typo)) {
|
(EXPENSE_REGISTER == reg_type)) {
|
||||||
baln = -baln;
|
baln = -baln;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2969,9 +2963,9 @@ xaccSRLoadRegEntry (SplitRegister *reg, Split *split)
|
|||||||
buff[1] = 0x0;
|
buff[1] = 0x0;
|
||||||
xaccSetBasicCellValue (reg->recnCell, buff);
|
xaccSetBasicCellValue (reg->recnCell, buff);
|
||||||
|
|
||||||
if ((STOCK_REGISTER == typo) ||
|
if ((STOCK_REGISTER == reg_type) ||
|
||||||
(CURRENCY_REGISTER == typo) ||
|
(CURRENCY_REGISTER == reg_type) ||
|
||||||
(PORTFOLIO_LEDGER == typo))
|
(PORTFOLIO_LEDGER == reg_type))
|
||||||
{
|
{
|
||||||
amt = xaccSplitGetShareAmount (split);
|
amt = xaccSplitGetShareAmount (split);
|
||||||
} else {
|
} else {
|
||||||
@ -2984,7 +2978,7 @@ xaccSRLoadRegEntry (SplitRegister *reg, Split *split)
|
|||||||
xaccSetPriceCellValue (reg->valueCell, xaccSplitGetValue (split));
|
xaccSetPriceCellValue (reg->valueCell, xaccSplitGetValue (split));
|
||||||
}
|
}
|
||||||
|
|
||||||
reg->table->current_cursor->user_data = (void *) split;
|
reg->table->current_cursor->user_data = split;
|
||||||
|
|
||||||
/* copy cursor contents into the table */
|
/* copy cursor contents into the table */
|
||||||
xaccCommitCursor (reg->table);
|
xaccCommitCursor (reg->table);
|
||||||
@ -3022,16 +3016,16 @@ xaccSRCountRows (SplitRegister *reg,
|
|||||||
gncBoolean multi_line;
|
gncBoolean multi_line;
|
||||||
gncBoolean dynamic;
|
gncBoolean dynamic;
|
||||||
|
|
||||||
|
SplitRegisterStyle style;
|
||||||
int save_cursor_phys_row;
|
int save_cursor_phys_row;
|
||||||
int save_cursor_virt_row;
|
int save_cursor_virt_row;
|
||||||
int save_cell_row;
|
int save_cell_row;
|
||||||
int num_phys_rows;
|
int num_phys_rows;
|
||||||
int num_virt_rows;
|
int num_virt_rows;
|
||||||
int style;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
table = reg->table;
|
table = reg->table;
|
||||||
style = (reg->type) & REG_STYLE_MASK;
|
style = reg->style;
|
||||||
multi_line = (REG_MULTI_LINE == style);
|
multi_line = (REG_MULTI_LINE == style);
|
||||||
dynamic = ((REG_SINGLE_DYNAMIC == style) || (REG_DOUBLE_DYNAMIC == style));
|
dynamic = ((REG_SINGLE_DYNAMIC == style) || (REG_DOUBLE_DYNAMIC == style));
|
||||||
if ((REG_SINGLE_LINE == style) ||
|
if ((REG_SINGLE_LINE == style) ||
|
||||||
@ -3329,9 +3323,10 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
|
|||||||
gncBoolean multi_line;
|
gncBoolean multi_line;
|
||||||
gncBoolean dynamic;
|
gncBoolean dynamic;
|
||||||
|
|
||||||
|
SplitRegisterType type;
|
||||||
|
SplitRegisterStyle style;
|
||||||
unsigned int changed;
|
unsigned int changed;
|
||||||
int save_phys_col;
|
int save_phys_col;
|
||||||
int type, style;
|
|
||||||
int phys_row;
|
int phys_row;
|
||||||
int vrow;
|
int vrow;
|
||||||
int i;
|
int i;
|
||||||
@ -3357,8 +3352,8 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
|
|||||||
info->default_source_account = default_source_acc;
|
info->default_source_account = default_source_acc;
|
||||||
|
|
||||||
table = reg->table;
|
table = reg->table;
|
||||||
type = (reg->type) & REG_TYPE_MASK;
|
type = reg->type;
|
||||||
style = (reg->type) & REG_STYLE_MASK;
|
style = reg->style;
|
||||||
multi_line = (REG_MULTI_LINE == style);
|
multi_line = (REG_MULTI_LINE == style);
|
||||||
dynamic = ((REG_SINGLE_DYNAMIC == style) || (REG_DOUBLE_DYNAMIC == style));
|
dynamic = ((REG_SINGLE_DYNAMIC == style) || (REG_DOUBLE_DYNAMIC == style));
|
||||||
if ((REG_SINGLE_LINE == style) ||
|
if ((REG_SINGLE_LINE == style) ||
|
||||||
|
@ -585,10 +585,12 @@ gnc_ui_find_transactions_dialog_ok_cb(GtkButton * button,
|
|||||||
|
|
||||||
if(!ftd->ledger) {
|
if(!ftd->ledger) {
|
||||||
new_ledger = TRUE;
|
new_ledger = TRUE;
|
||||||
ftd->ledger = xaccLedgerDisplayGeneral(NULL, NULL, SEARCH_LEDGER);
|
ftd->ledger = xaccLedgerDisplayGeneral(NULL, NULL,
|
||||||
xaccFreeQuery(ftd->ledger->query);
|
SEARCH_LEDGER,
|
||||||
|
REG_SINGLE_LINE);
|
||||||
|
xaccFreeQuery(ftd->ledger->query);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(search_type) {
|
switch(search_type) {
|
||||||
case 0:
|
case 0:
|
||||||
ftd->ledger->query = q;
|
ftd->ledger->query = q;
|
||||||
|
@ -231,14 +231,11 @@ gnc_register_jump_to_split(RegWindow *regData, Split *split)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static SplitRegisterStyle
|
||||||
gnc_register_get_default_type(SplitRegister *reg)
|
gnc_get_default_register_style()
|
||||||
{
|
{
|
||||||
|
SplitRegisterStyle new_style = REG_SINGLE_LINE;
|
||||||
char *style_string;
|
char *style_string;
|
||||||
int new_style = REG_SINGLE_LINE;
|
|
||||||
int type = reg->type;
|
|
||||||
|
|
||||||
type &= ~REG_STYLE_MASK;
|
|
||||||
|
|
||||||
style_string = gnc_lookup_multichoice_option("Register",
|
style_string = gnc_lookup_multichoice_option("Register",
|
||||||
"Default Register Mode",
|
"Default Register Mode",
|
||||||
@ -255,25 +252,19 @@ gnc_register_get_default_type(SplitRegister *reg)
|
|||||||
else if (safe_strcmp(style_string, "auto_double") == 0)
|
else if (safe_strcmp(style_string, "auto_double") == 0)
|
||||||
new_style = REG_DOUBLE_DYNAMIC;
|
new_style = REG_DOUBLE_DYNAMIC;
|
||||||
|
|
||||||
type |= new_style;
|
|
||||||
|
|
||||||
if (style_string != NULL)
|
if (style_string != NULL)
|
||||||
free(style_string);
|
free(style_string);
|
||||||
|
|
||||||
return type;
|
return new_style;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gnc_register_change_style(RegWindow *regData, int style_code)
|
gnc_register_change_style(RegWindow *regData, SplitRegisterStyle style)
|
||||||
{
|
{
|
||||||
SplitRegister *reg = regData->ledger->ledger;
|
SplitRegister *reg = regData->ledger->ledger;
|
||||||
int type = reg->type;
|
|
||||||
|
|
||||||
type &= ~REG_STYLE_MASK;
|
xaccConfigSplitRegister(reg, reg->type, style);
|
||||||
type |= style_code;
|
|
||||||
|
|
||||||
xaccConfigSplitRegister(reg, type);
|
|
||||||
|
|
||||||
regData->ledger->dirty = 1;
|
regData->ledger->dirty = 1;
|
||||||
xaccLedgerDisplayRefresh(regData->ledger);
|
xaccLedgerDisplayRefresh(regData->ledger);
|
||||||
@ -892,7 +883,7 @@ gnc_register_create_status_bar(RegWindow *regData)
|
|||||||
|
|
||||||
regData->statusbar = statusbar;
|
regData->statusbar = statusbar;
|
||||||
|
|
||||||
switch (regData->ledger->ledger->type & REG_TYPE_MASK)
|
switch (regData->ledger->type)
|
||||||
{
|
{
|
||||||
case GENERAL_LEDGER:
|
case GENERAL_LEDGER:
|
||||||
case INCOME_LEDGER:
|
case INCOME_LEDGER:
|
||||||
@ -1318,12 +1309,8 @@ gnc_register_create_menu_bar(RegWindow *regData, GtkWidget *statusbar)
|
|||||||
{
|
{
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
int index;
|
int index;
|
||||||
int style;
|
|
||||||
|
|
||||||
style = gnc_register_get_default_type(regData->ledger->ledger);
|
switch (gnc_get_default_register_style())
|
||||||
style &= REG_STYLE_MASK;
|
|
||||||
|
|
||||||
switch (style)
|
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case REG_SINGLE_LINE:
|
case REG_SINGLE_LINE:
|
||||||
@ -1430,11 +1417,9 @@ gnc_register_record_cb(GnucashRegister *reg, gpointer data)
|
|||||||
* when you are entering transactions. */
|
* when you are entering transactions. */
|
||||||
{
|
{
|
||||||
SplitRegister *sr = regData->ledger->ledger;
|
SplitRegister *sr = regData->ledger->ledger;
|
||||||
int type = sr->type;
|
SplitRegisterStyle style = sr->style;
|
||||||
|
|
||||||
type &= REG_STYLE_MASK;
|
if ((style == REG_SINGLE_LINE) || (style == REG_DOUBLE_LINE))
|
||||||
|
|
||||||
if ((type == REG_SINGLE_LINE) || (type == REG_DOUBLE_LINE))
|
|
||||||
{
|
{
|
||||||
Split *blank_split;
|
Split *blank_split;
|
||||||
|
|
||||||
@ -1496,7 +1481,7 @@ gnc_reg_set_window_name(RegWindow *regData)
|
|||||||
if (regData == NULL)
|
if (regData == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (regData->ledger->type & REG_TYPE_MASK)
|
switch (regData->ledger->type)
|
||||||
{
|
{
|
||||||
case GENERAL_LEDGER:
|
case GENERAL_LEDGER:
|
||||||
case INCOME_LEDGER:
|
case INCOME_LEDGER:
|
||||||
@ -1667,19 +1652,17 @@ regWindowLedger(xaccLedgerDisplay *ledger)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* be sure to initialize the gui elements associated with the cursor */
|
/* be sure to initialize the gui elements associated with the cursor */
|
||||||
xaccConfigSplitRegister(ledger->ledger,
|
xaccConfigSplitRegister(ledger->ledger, ledger->type,
|
||||||
gnc_register_get_default_type(ledger->ledger));
|
gnc_get_default_register_style());
|
||||||
|
|
||||||
/* Allow grow, allow shrink, auto-shrink */
|
/* Allow grow, allow shrink, auto-shrink */
|
||||||
gtk_window_set_policy(GTK_WINDOW(register_window), TRUE, TRUE, TRUE);
|
gtk_window_set_policy(GTK_WINDOW(register_window), TRUE, TRUE, TRUE);
|
||||||
|
|
||||||
{
|
{
|
||||||
int type;
|
|
||||||
int *width;
|
int *width;
|
||||||
char *prefix;
|
char *prefix;
|
||||||
|
|
||||||
type = ledger->ledger->type & REG_TYPE_MASK;
|
switch (ledger->type)
|
||||||
switch (type)
|
|
||||||
{
|
{
|
||||||
case STOCK_REGISTER:
|
case STOCK_REGISTER:
|
||||||
case PORTFOLIO_LEDGER:
|
case PORTFOLIO_LEDGER:
|
||||||
@ -1798,7 +1781,7 @@ gnc_reg_save_size(RegWindow *regData)
|
|||||||
int *width;
|
int *width;
|
||||||
char *prefix;
|
char *prefix;
|
||||||
|
|
||||||
switch (regData->ledger->ledger->type & REG_TYPE_MASK)
|
switch (regData->ledger->type)
|
||||||
{
|
{
|
||||||
case STOCK_REGISTER:
|
case STOCK_REGISTER:
|
||||||
case PORTFOLIO_LEDGER:
|
case PORTFOLIO_LEDGER:
|
||||||
@ -2261,13 +2244,13 @@ gnc_transaction_delete_query(GtkWindow *parent)
|
|||||||
static void
|
static void
|
||||||
deleteCB(GtkWidget *widget, gpointer data)
|
deleteCB(GtkWidget *widget, gpointer data)
|
||||||
{
|
{
|
||||||
RegWindow *regData = (RegWindow *) data;
|
RegWindow *regData = data;
|
||||||
|
SplitRegisterStyle style;
|
||||||
CursorType cursor_type;
|
CursorType cursor_type;
|
||||||
Transaction *trans;
|
Transaction *trans;
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
Split *split;
|
Split *split;
|
||||||
gint result;
|
gint result;
|
||||||
int style;
|
|
||||||
|
|
||||||
/* get the current split based on cursor position */
|
/* get the current split based on cursor position */
|
||||||
split = xaccSRGetCurrentSplit(regData->ledger->ledger);
|
split = xaccSRGetCurrentSplit(regData->ledger->ledger);
|
||||||
@ -2278,7 +2261,7 @@ deleteCB(GtkWidget *widget, gpointer data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
trans = xaccSplitGetParent(split);
|
trans = xaccSplitGetParent(split);
|
||||||
style = regData->ledger->ledger->type & REG_STYLE_MASK;
|
style = regData->ledger->ledger->style;
|
||||||
cursor_type = xaccSplitRegisterGetCursorType(regData->ledger->ledger);
|
cursor_type = xaccSplitRegisterGetCursorType(regData->ledger->ledger);
|
||||||
|
|
||||||
/* Deleting the blank split just cancels */
|
/* Deleting the blank split just cancels */
|
||||||
|
@ -1384,7 +1384,7 @@ gnucash_sheet_style_compile (GnucashSheet *sheet, CellBlock *cellblock,
|
|||||||
|
|
||||||
style = g_new0(SheetBlockStyle, 1);
|
style = g_new0(SheetBlockStyle, 1);
|
||||||
|
|
||||||
style->reg_type = sr->type & REG_TYPE_MASK;
|
style->reg_type = sr->type;
|
||||||
style->cursor_type = cursor_type;
|
style->cursor_type = cursor_type;
|
||||||
|
|
||||||
style->nrows = cellblock->numRows;
|
style->nrows = cellblock->numRows;
|
||||||
|
@ -168,10 +168,12 @@ xaccSplitRegisterSetCreditStringGetter(SRStringGetter getter)
|
|||||||
static void
|
static void
|
||||||
configLabels (SplitRegister *reg)
|
configLabels (SplitRegister *reg)
|
||||||
{
|
{
|
||||||
|
SplitRegisterType type;
|
||||||
BasicCell *hc;
|
BasicCell *hc;
|
||||||
int type = (reg->type) & REG_TYPE_MASK;
|
|
||||||
char *string;
|
char *string;
|
||||||
|
|
||||||
|
type = reg->type;
|
||||||
|
|
||||||
LABEL (DATE, DATE_STR);
|
LABEL (DATE, DATE_STR);
|
||||||
LABEL (NUM, NUM_STR);
|
LABEL (NUM, NUM_STR);
|
||||||
LABEL (DESC, DESC_STR);
|
LABEL (DESC, DESC_STR);
|
||||||
@ -222,10 +224,8 @@ configLabels (SplitRegister *reg)
|
|||||||
static void
|
static void
|
||||||
configAction (SplitRegister *reg)
|
configAction (SplitRegister *reg)
|
||||||
{
|
{
|
||||||
int type = (reg->type) & REG_TYPE_MASK;
|
|
||||||
|
|
||||||
/* setup strings in the action pull-down */
|
/* setup strings in the action pull-down */
|
||||||
switch (type) {
|
switch (reg->type) {
|
||||||
case BANK_REGISTER:
|
case BANK_REGISTER:
|
||||||
case SEARCH_LEDGER: /* broken ! FIXME bg */
|
case SEARCH_LEDGER: /* broken ! FIXME bg */
|
||||||
xaccAddComboCellMenuItem ( reg->actionCell, DEPOSIT_STR);
|
xaccAddComboCellMenuItem ( reg->actionCell, DEPOSIT_STR);
|
||||||
@ -346,7 +346,6 @@ static void
|
|||||||
configLayout (SplitRegister *reg)
|
configLayout (SplitRegister *reg)
|
||||||
{
|
{
|
||||||
CellBlock *curs, *header;
|
CellBlock *curs, *header;
|
||||||
int type = (reg->type) & REG_TYPE_MASK;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* define header for macros */
|
/* define header for macros */
|
||||||
@ -362,7 +361,7 @@ configLayout (SplitRegister *reg)
|
|||||||
reg->double_cursor->cells[1][i] = reg->nullCell;
|
reg->double_cursor->cells[1][i] = reg->nullCell;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (reg->type) {
|
||||||
case BANK_REGISTER:
|
case BANK_REGISTER:
|
||||||
case CASH_REGISTER:
|
case CASH_REGISTER:
|
||||||
case ASSET_REGISTER:
|
case ASSET_REGISTER:
|
||||||
@ -576,7 +575,7 @@ configLayout (SplitRegister *reg)
|
|||||||
|
|
||||||
/* --------------------------------------------------------- */
|
/* --------------------------------------------------------- */
|
||||||
default:
|
default:
|
||||||
PERR ("unknown register type %d \n", type);
|
PERR ("unknown register type %d \n", reg->type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -816,11 +815,13 @@ configTraverse (SplitRegister *reg)
|
|||||||
/* ============================================== */
|
/* ============================================== */
|
||||||
|
|
||||||
SplitRegister *
|
SplitRegister *
|
||||||
xaccMallocSplitRegister (int type)
|
xaccMallocSplitRegister (SplitRegisterType type, SplitRegisterStyle style)
|
||||||
{
|
{
|
||||||
SplitRegister * reg;
|
SplitRegister * reg;
|
||||||
reg = (SplitRegister *) malloc (sizeof (SplitRegister));
|
|
||||||
xaccInitSplitRegister (reg, type);
|
reg = malloc (sizeof (SplitRegister));
|
||||||
|
xaccInitSplitRegister (reg, type, style);
|
||||||
|
|
||||||
return reg;
|
return reg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -837,12 +838,10 @@ xaccSetSplitRegisterColors (SplitRegisterColors reg_colors_new)
|
|||||||
static void
|
static void
|
||||||
configTable(SplitRegister *reg)
|
configTable(SplitRegister *reg)
|
||||||
{
|
{
|
||||||
int style = reg->type & REG_STYLE_MASK;
|
|
||||||
|
|
||||||
if ((reg == NULL) || (reg->table == NULL))
|
if ((reg == NULL) || (reg->table == NULL))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (style) {
|
switch (reg->style) {
|
||||||
case REG_SINGLE_LINE:
|
case REG_SINGLE_LINE:
|
||||||
case REG_SINGLE_DYNAMIC:
|
case REG_SINGLE_DYNAMIC:
|
||||||
reg->table->alternate_bg_colors = GNC_T;
|
reg->table->alternate_bg_colors = GNC_T;
|
||||||
@ -910,9 +909,7 @@ configCursors (SplitRegister *reg)
|
|||||||
static void
|
static void
|
||||||
mallocCursors (SplitRegister *reg)
|
mallocCursors (SplitRegister *reg)
|
||||||
{
|
{
|
||||||
int type = (reg->type) & REG_TYPE_MASK;
|
switch (reg->type) {
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case BANK_REGISTER:
|
case BANK_REGISTER:
|
||||||
case CASH_REGISTER:
|
case CASH_REGISTER:
|
||||||
case ASSET_REGISTER:
|
case ASSET_REGISTER:
|
||||||
@ -968,7 +965,9 @@ mallocCursors (SplitRegister *reg)
|
|||||||
reg->CN##Cell = xaccMalloc##TYPE##Cell(); \
|
reg->CN##Cell = xaccMalloc##TYPE##Cell(); \
|
||||||
|
|
||||||
void
|
void
|
||||||
xaccInitSplitRegister (SplitRegister *reg, int type)
|
xaccInitSplitRegister (SplitRegister *reg,
|
||||||
|
SplitRegisterType type,
|
||||||
|
SplitRegisterStyle style)
|
||||||
{
|
{
|
||||||
Table * table;
|
Table * table;
|
||||||
CellBlock *header;
|
CellBlock *header;
|
||||||
@ -978,6 +977,7 @@ xaccInitSplitRegister (SplitRegister *reg, int type)
|
|||||||
reg->user_data = NULL;
|
reg->user_data = NULL;
|
||||||
reg->destroy = NULL;
|
reg->destroy = NULL;
|
||||||
reg->type = type;
|
reg->type = type;
|
||||||
|
reg->style = style;
|
||||||
|
|
||||||
/* --------------------------- */
|
/* --------------------------- */
|
||||||
/* define the number of columns in the display, malloc the cursors */
|
/* define the number of columns in the display, malloc the cursors */
|
||||||
@ -1107,7 +1107,7 @@ xaccInitSplitRegister (SplitRegister *reg, int type)
|
|||||||
xaccSetBasicCellBlankHelp (®->actionCell->cell, ACTION_CELL_HELP);
|
xaccSetBasicCellBlankHelp (®->actionCell->cell, ACTION_CELL_HELP);
|
||||||
|
|
||||||
/* number format for share quantities in stock ledgers */
|
/* number format for share quantities in stock ledgers */
|
||||||
switch (type & REG_TYPE_MASK) {
|
switch (type) {
|
||||||
case CURRENCY_REGISTER:
|
case CURRENCY_REGISTER:
|
||||||
xaccSetPriceCellIsCurrency (reg->priceCell, GNC_T);
|
xaccSetPriceCellIsCurrency (reg->priceCell, GNC_T);
|
||||||
|
|
||||||
@ -1173,11 +1173,14 @@ xaccInitSplitRegister (SplitRegister *reg, int type)
|
|||||||
/* ============================================== */
|
/* ============================================== */
|
||||||
|
|
||||||
void
|
void
|
||||||
xaccConfigSplitRegister (SplitRegister *reg, int newtype)
|
xaccConfigSplitRegister (SplitRegister *reg,
|
||||||
|
SplitRegisterType newtype,
|
||||||
|
SplitRegisterStyle newstyle)
|
||||||
{
|
{
|
||||||
if (!reg) return;
|
if (!reg) return;
|
||||||
|
|
||||||
reg->type = newtype;
|
reg->type = newtype;
|
||||||
|
reg->style = newstyle;
|
||||||
|
|
||||||
/* Make sure that any GUI elements associated with this reconfig
|
/* Make sure that any GUI elements associated with this reconfig
|
||||||
* are properly initialized. */
|
* are properly initialized. */
|
||||||
|
@ -80,8 +80,6 @@ typedef enum
|
|||||||
SEARCH_LEDGER = 14
|
SEARCH_LEDGER = 14
|
||||||
} SplitRegisterType;
|
} SplitRegisterType;
|
||||||
|
|
||||||
#define REG_TYPE_MASK 0xff
|
|
||||||
|
|
||||||
/* These values are used to identify the cells in the register. */
|
/* These values are used to identify the cells in the register. */
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
@ -119,12 +117,14 @@ typedef enum
|
|||||||
* REG_DOUBLE_DYNAMIC -- dynamically expand edited transaction,
|
* REG_DOUBLE_DYNAMIC -- dynamically expand edited transaction,
|
||||||
* all other transactions on two lines
|
* all other transactions on two lines
|
||||||
*/
|
*/
|
||||||
#define REG_SINGLE_LINE (1 << 8)
|
typedef enum
|
||||||
#define REG_DOUBLE_LINE (2 << 8)
|
{
|
||||||
#define REG_MULTI_LINE (3 << 8)
|
REG_SINGLE_LINE = 1,
|
||||||
#define REG_SINGLE_DYNAMIC (4 << 8)
|
REG_DOUBLE_LINE = 2,
|
||||||
#define REG_DOUBLE_DYNAMIC (5 << 8)
|
REG_MULTI_LINE = 3,
|
||||||
#define REG_STYLE_MASK (0xff << 8)
|
REG_SINGLE_DYNAMIC = 4,
|
||||||
|
REG_DOUBLE_DYNAMIC = 5
|
||||||
|
} SplitRegisterStyle;
|
||||||
|
|
||||||
/* modified flags -- indicate which cell values have been modified by user */
|
/* modified flags -- indicate which cell values have been modified by user */
|
||||||
#define MOD_NONE 0x0000
|
#define MOD_NONE 0x0000
|
||||||
@ -193,9 +193,11 @@ struct _SplitRegister {
|
|||||||
PriceCell * ncreditCell;
|
PriceCell * ncreditCell;
|
||||||
PriceCell * ndebitCell;
|
PriceCell * ndebitCell;
|
||||||
|
|
||||||
/* the type of the register, must be one of the enumerated types
|
/* The type of the register, must be one of the enumerated types
|
||||||
* above *_REGISTER, *_LEDGER, above */
|
* named *_REGISTER, *_LEDGER, above */
|
||||||
int type;
|
SplitRegisterType type;
|
||||||
|
|
||||||
|
SplitRegisterStyle style;
|
||||||
|
|
||||||
/* some private data; outsiders should not access this */
|
/* some private data; outsiders should not access this */
|
||||||
int num_cols;
|
int num_cols;
|
||||||
@ -247,16 +249,21 @@ typedef char* (*SRStringGetter) (SplitRegisterType);
|
|||||||
void xaccSplitRegisterSetDebitStringGetter(SRStringGetter getter);
|
void xaccSplitRegisterSetDebitStringGetter(SRStringGetter getter);
|
||||||
void xaccSplitRegisterSetCreditStringGetter(SRStringGetter getter);
|
void xaccSplitRegisterSetCreditStringGetter(SRStringGetter getter);
|
||||||
|
|
||||||
SplitRegister * xaccMallocSplitRegister (int type);
|
SplitRegister * xaccMallocSplitRegister (SplitRegisterType type,
|
||||||
void xaccInitSplitRegister (SplitRegister *, int type);
|
SplitRegisterStyle style);
|
||||||
void xaccConfigSplitRegister (SplitRegister *, int type);
|
void xaccInitSplitRegister (SplitRegister *reg,
|
||||||
void xaccDestroySplitRegister (SplitRegister *);
|
SplitRegisterType type,
|
||||||
|
SplitRegisterStyle style);
|
||||||
|
void xaccConfigSplitRegister (SplitRegister *reg,
|
||||||
|
SplitRegisterType type,
|
||||||
|
SplitRegisterStyle style);
|
||||||
|
void xaccDestroySplitRegister (SplitRegister *reg);
|
||||||
|
|
||||||
void xaccSetSplitRegisterColors (SplitRegisterColors reg_colors);
|
void xaccSetSplitRegisterColors (SplitRegisterColors reg_colors);
|
||||||
void xaccSplitRegisterConfigColors (SplitRegister *reg);
|
void xaccSplitRegisterConfigColors (SplitRegister *reg);
|
||||||
|
|
||||||
/* returns non-zero value if updates have been made to data */
|
/* returns non-zero value if updates have been made to data */
|
||||||
unsigned int xaccSplitRegisterGetChangeFlag (SplitRegister *);
|
unsigned int xaccSplitRegisterGetChangeFlag (SplitRegister *reg);
|
||||||
|
|
||||||
/* Clears all change flags in the register. Does not alter values */
|
/* Clears all change flags in the register. Does not alter values */
|
||||||
void xaccSplitRegisterClearChangeFlag (SplitRegister *reg);
|
void xaccSplitRegisterClearChangeFlag (SplitRegister *reg);
|
||||||
|
Loading…
Reference in New Issue
Block a user