Fixes to register behavior.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2373 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2000-05-24 10:25:43 +00:00
parent 151a0a35fa
commit d280b43597
5 changed files with 194 additions and 129 deletions

View File

@ -1,5 +1,15 @@
2000-05-24 Dave Peticolas <peticola@cs.ucdavis.edu>
* src/SplitLedger.c: some simplification, some additional
complexity :) Fixed a crash-bug with traversing out of the
pending transaction and rolling it back. Fixed traversal out
of the blank line of a multi-split transaction that has been
edited.
2000-05-23 Dave Peticolas <peticola@cs.ucdavis.edu> 2000-05-23 Dave Peticolas <peticola@cs.ucdavis.edu>
* src/engine: removed QIF routines from the engine.
* src/scm/options.scm: add a currency option type. * src/scm/options.scm: add a currency option type.
* src/gnome/dialog-options.c: add support for currency options. * src/gnome/dialog-options.c: add support for currency options.

View File

@ -138,6 +138,9 @@ struct _SRInfo
/* A column used to remember which column to put the cursor */ /* A column used to remember which column to put the cursor */
int cursor_hint_phys_col; int cursor_hint_phys_col;
/* If the hints were set by the traverse callback */
gncBoolean hint_set_by_traverse;
/* The default account where new splits are added */ /* The default account where new splits are added */
Account *default_source_account; Account *default_source_account;
@ -313,6 +316,28 @@ gnc_trans_prepend_account_list(Transaction *trans, GList *accounts)
} while(1); } while(1);
} }
static GList *
gnc_trans_prepend_split_list(Transaction *trans, GList *splits)
{
Split *split;
int i = 0;
if (trans == NULL)
return splits;
do
{
split = xaccTransGetSplit(trans, i);
if (split == NULL)
return splits;
splits = g_list_prepend(splits, split);
i++;
} while(1);
}
static int static int
gnc_trans_split_index(Transaction *trans, Split *split) gnc_trans_split_index(Transaction *trans, Split *split)
{ {
@ -418,14 +443,23 @@ LedgerMoveCursor (Table *table,
phys_row_offset = new_phys_row - table->current_cursor_phys_row; phys_row_offset = new_phys_row - table->current_cursor_phys_row;
phys_col_offset = new_phys_col - table->current_cursor_phys_col; phys_col_offset = new_phys_col - table->current_cursor_phys_col;
/* The transaction where we are moving to */ if (!info->hint_set_by_traverse)
new_trans = xaccSRGetTrans(reg, new_phys_row, new_phys_col); {
/* The transaction where we are moving to */
new_trans = xaccSRGetTrans(reg, new_phys_row, new_phys_col);
/* The split at the transaction line we are moving to */ /* The split we are moving to */
trans_split = xaccSRGetTransSplit(reg, new_phys_row, new_phys_col); new_split = xaccGetUserData(reg->table, new_phys_row, new_phys_col);
/* The split we are moving to */ /* The split at the transaction line we are moving to */
new_split = xaccGetUserData(reg->table, new_phys_row, new_phys_col); trans_split = xaccSRGetTransSplit(reg, new_phys_row, new_phys_col);
}
else
{
new_trans = info->cursor_hint_trans;
new_split = info->cursor_hint_split;
trans_split = info->cursor_hint_trans_split;
}
/* The cell offset we are moving to */ /* The cell offset we are moving to */
locator = table->locators[new_phys_row][new_phys_col]; locator = table->locators[new_phys_row][new_phys_col];
@ -550,19 +584,22 @@ LedgerMoveCursor (Table *table,
info->cursor_hint_trans_split = trans_split; info->cursor_hint_trans_split = trans_split;
info->cursor_hint_phys_col = -1; info->cursor_hint_phys_col = -1;
} }
info->hint_set_by_traverse = GNC_F;
} }
/* ======================================================== */ /* ======================================================== */
/* this callback gets called when the user clicks on the gui /* This callback gets called when the user clicks on the gui
* in such a way as to leave the current transaction, and to * in such a way as to leave the current transaction, and to
* go to a new one. It is called to verify what the coordinates * go to a new one. It is called to verify what the coordinates
* of the new cell will be. It currently does nothing. * of the new cell will be.
*/ */
static void static void
LedgerTraverse (Table *table, LedgerTraverse (Table *table,
int *p_new_phys_row, int *p_new_phys_row,
int *p_new_phys_col, int *p_new_phys_col,
gncTableTraversalDir dir,
void * client_data) void * client_data)
{ {
SplitRegister *reg = client_data; SplitRegister *reg = client_data;
@ -573,7 +610,9 @@ LedgerTraverse (Table *table,
int virt_row, virt_col; int virt_row, virt_col;
unsigned int changed; unsigned int changed;
GNCVerifyResult result; GNCVerifyResult result;
Split *split;
split = xaccSRGetCurrentSplit(reg);
trans = xaccSRGetCurrentTrans(reg); trans = xaccSRGetCurrentTrans(reg);
if (trans == NULL) if (trans == NULL)
return; return;
@ -600,6 +639,23 @@ LedgerTraverse (Table *table,
if (trans == new_trans) if (trans == new_trans)
return; return;
if (changed && (split == NULL) && (dir == GNC_TABLE_TRAVERSE_RIGHT))
{
/* If we are here, then: (a) the current cursor has been
* edited, and (b) we are on the blank split of a multi-line
* transaction, and (c) we are tabbing out of the last cell
* on the line. Thus, we want to go ahead and add the new
* split and end up on the new blank split of the current
* transaction. */
info->cursor_hint_trans = trans;
info->cursor_hint_split = split;
info->cursor_hint_trans_split = xaccSRGetCurrentTransSplit (reg);
info->cursor_hint_phys_col = -1;
info->hint_set_by_traverse = GNC_T;
return;
}
/* Ok, we are changing transactions and the current transaction has /* Ok, we are changing transactions and the current transaction has
* changed. See what the user wants to do. */ * changed. See what the user wants to do. */
@ -609,8 +665,34 @@ LedgerTraverse (Table *table,
switch (result) switch (result)
{ {
case GNC_VERIFY_NO: case GNC_VERIFY_NO: {
Split *new_split;
Split *trans_split;
new_split = xaccGetUserData(reg->table, phys_row, phys_col);
trans_split = xaccSRGetTransSplit(reg, phys_row, phys_col);
xaccSRCancelCursorTransChanges(reg); xaccSRCancelCursorTransChanges(reg);
if (xaccSRGetTransSplitRowCol (reg, new_trans, trans_split, new_split,
&virt_row, &virt_col))
{
RevLocator *rev_locator;
rev_locator = table->rev_locators[virt_row][virt_col];
phys_row = rev_locator->phys_row;
}
if (phys_row >= table->num_phys_rows)
phys_row = table->num_phys_rows - 1;
if (phys_col >= table->num_phys_cols)
phys_col = table->num_phys_cols - 1;
*p_new_phys_row = phys_row;
*p_new_phys_col = phys_col;
}
break; break;
case GNC_VERIFY_CANCEL: case GNC_VERIFY_CANCEL:
*p_new_phys_row = table->current_cursor_phys_row; *p_new_phys_row = table->current_cursor_phys_row;
@ -1305,10 +1387,10 @@ void
xaccSRDeleteCurrentSplit (SplitRegister *reg) xaccSRDeleteCurrentSplit (SplitRegister *reg)
{ {
SRInfo *info = xaccSRGetInfo(reg); SRInfo *info = xaccSRGetInfo(reg);
Split *split, *s;
Transaction *trans; Transaction *trans;
int i, num_splits; Account *account;
Account *account, **affected_accounts; GList *accounts;
Split *split;
/* get the current split based on cursor position */ /* get the current split based on cursor position */
split = xaccSRGetCurrentSplit(reg); split = xaccSRGetCurrentSplit(reg);
@ -1328,17 +1410,8 @@ xaccSRDeleteCurrentSplit (SplitRegister *reg)
* affected by this deletion, so that we can update * affected by this deletion, so that we can update
* their register windows after the deletion. */ * their register windows after the deletion. */
trans = xaccSplitGetParent(split); trans = xaccSplitGetParent(split);
num_splits = xaccTransCountSplits(trans);
affected_accounts = (Account **) malloc((num_splits + 1) *
sizeof(Account *));
assert(affected_accounts != NULL);
for (i = 0; i < num_splits; i++) accounts = gnc_trans_prepend_account_list(trans, NULL);
{
s = xaccTransGetSplit(trans, i);
affected_accounts[i] = xaccSplitGetAccount(s);
}
affected_accounts[num_splits] = NULL;
account = xaccSplitGetAccount(split); account = xaccSplitGetAccount(split);
@ -1352,9 +1425,9 @@ xaccSRDeleteCurrentSplit (SplitRegister *reg)
if (trans == info->pending_trans) if (trans == info->pending_trans)
info->pending_trans = NULL; info->pending_trans = NULL;
gnc_account_list_ui_refresh(affected_accounts); gnc_account_glist_ui_refresh(accounts);
free(affected_accounts); g_list_free(accounts);
gnc_refresh_main_window (); gnc_refresh_main_window ();
} }
@ -1365,10 +1438,10 @@ void
xaccSRDeleteCurrentTrans (SplitRegister *reg) xaccSRDeleteCurrentTrans (SplitRegister *reg)
{ {
SRInfo *info = xaccSRGetInfo(reg); SRInfo *info = xaccSRGetInfo(reg);
Split *split, *s;
Transaction *trans; Transaction *trans;
int i, num_splits; Account *account;
Account *account, **affected_accounts; GList *accounts;
Split *split;
/* get the current split based on cursor position */ /* get the current split based on cursor position */
split = xaccSRGetCurrentSplit(reg); split = xaccSRGetCurrentSplit(reg);
@ -1399,20 +1472,10 @@ xaccSRDeleteCurrentTrans (SplitRegister *reg)
/* make a copy of all of the accounts that will be /* make a copy of all of the accounts that will be
* affected by this deletion, so that we can update * affected by this deletion, so that we can update
* their register windows after the deletion. * their register windows after the deletion. */
*/
trans = xaccSplitGetParent(split); trans = xaccSplitGetParent(split);
num_splits = xaccTransCountSplits(trans);
affected_accounts = (Account **) malloc((num_splits + 1) *
sizeof(Account *));
assert(affected_accounts != NULL);
for (i = 0; i < num_splits; i++) accounts = gnc_trans_prepend_account_list(trans, NULL);
{
s = xaccTransGetSplit(trans, i);
affected_accounts[i] = xaccSplitGetAccount(s);
}
affected_accounts[num_splits] = NULL;
xaccTransBeginEdit(trans, 1); xaccTransBeginEdit(trans, 1);
xaccTransDestroy(trans); xaccTransDestroy(trans);
@ -1422,9 +1485,9 @@ xaccSRDeleteCurrentTrans (SplitRegister *reg)
if (trans == info->pending_trans) if (trans == info->pending_trans)
info->pending_trans = NULL; info->pending_trans = NULL;
gnc_account_list_ui_refresh(affected_accounts); gnc_account_glist_ui_refresh(accounts);
free(affected_accounts); g_list_free(accounts);
gnc_refresh_main_window (); gnc_refresh_main_window ();
} }
@ -1435,11 +1498,12 @@ void
xaccSREmptyCurrentTrans (SplitRegister *reg) xaccSREmptyCurrentTrans (SplitRegister *reg)
{ {
SRInfo *info = xaccSRGetInfo(reg); SRInfo *info = xaccSRGetInfo(reg);
Split *split, *s;
Split **splits;
Transaction *trans; Transaction *trans;
int i, num_splits; Account *account;
Account *account, **affected_accounts; GList *accounts;
GList *splits;
GList *node;
Split *split;
/* get the current split based on cursor position */ /* get the current split based on cursor position */
split = xaccSRGetCurrentSplit(reg); split = xaccSRGetCurrentSplit(reg);
@ -1470,39 +1534,26 @@ xaccSREmptyCurrentTrans (SplitRegister *reg)
/* make a copy of all of the accounts that will be /* make a copy of all of the accounts that will be
* affected by this deletion, so that we can update * affected by this deletion, so that we can update
* their register windows after the deletion. * their register windows after the deletion. */
*/
trans = xaccSplitGetParent(split); trans = xaccSplitGetParent(split);
num_splits = xaccTransCountSplits(trans);
affected_accounts = (Account **) malloc((num_splits + 1) *
sizeof(Account *));
splits = calloc(num_splits, sizeof(Split *));
assert(affected_accounts != NULL); accounts = gnc_trans_prepend_account_list(trans, NULL);
assert(splits != NULL); splits = gnc_trans_prepend_split_list(trans, NULL);
for (i = 0; i < num_splits; i++)
{
s = xaccTransGetSplit(trans, i);
splits[i] = s;
affected_accounts[i] = xaccSplitGetAccount(s);
}
affected_accounts[num_splits] = NULL;
xaccTransBeginEdit(trans, 1); xaccTransBeginEdit(trans, 1);
for (i = 0; i < num_splits; i++) for (node = splits; node; node = node->next)
if (splits[i] != split) if (node->data != split)
xaccSplitDestroy(splits[i]); xaccSplitDestroy(node->data);
xaccTransCommitEdit(trans); xaccTransCommitEdit(trans);
/* Check pending transaction */ /* Check pending transaction */
if (trans == info->pending_trans) if (trans == info->pending_trans)
info->pending_trans = NULL; info->pending_trans = NULL;
gnc_account_list_ui_refresh(affected_accounts); gnc_account_glist_ui_refresh(accounts);
free(affected_accounts); g_list_free(accounts);
free(splits); g_list_free(splits);
gnc_refresh_main_window (); gnc_refresh_main_window ();
} }
@ -1540,14 +1591,11 @@ xaccSRCancelCursorTransChanges (SplitRegister *reg)
{ {
SRInfo *info = xaccSRGetInfo(reg); SRInfo *info = xaccSRGetInfo(reg);
Transaction *trans; Transaction *trans;
Split *split; GList *accounts;
int i, num_splits = 0, more_splits = 0;
Account **affected_accounts = NULL;
/* Get the currently open transaction, rollback the edits on it, and /* Get the currently open transaction, rollback the edits on it, and
* then repaint everything. To repaint everything, make a note of * then repaint everything. To repaint everything, make a note of
* all of the accounts that will be affected by this rollback. Geez, * all of the accounts that will be affected by this rollback. */
* there must be some easier way of doing redraw notification. */
trans = info->pending_trans; trans = info->pending_trans;
if (!xaccTransIsOpen(trans)) if (!xaccTransIsOpen(trans))
@ -1556,34 +1604,15 @@ xaccSRCancelCursorTransChanges (SplitRegister *reg)
return; return;
} }
num_splits = xaccTransCountSplits (trans); accounts = gnc_trans_prepend_account_list(trans, NULL);
affected_accounts = (Account **) malloc ((num_splits+1) *
sizeof (Account *));
for (i = 0; i < num_splits; i++)
{
split = xaccTransGetSplit (trans, i);
affected_accounts[i] = xaccSplitGetAccount (split);
}
affected_accounts[num_splits] = NULL;
xaccTransRollbackEdit (trans); xaccTransRollbackEdit (trans);
/* and do some more redraw, for the new set of accounts .. */ accounts = gnc_trans_prepend_account_list(trans, accounts);
more_splits = xaccTransCountSplits (trans);
affected_accounts = (Account **) realloc (affected_accounts,
(more_splits+num_splits+1) *
sizeof (Account *));
for (i = 0; i < more_splits; i++) gnc_account_glist_ui_refresh(accounts);
{
split = xaccTransGetSplit (trans, i);
affected_accounts[i+num_splits] = xaccSplitGetAccount (split);
}
affected_accounts[num_splits+more_splits] = NULL;
xaccAccListDisplayRefresh (affected_accounts); g_list_free(accounts);
free (affected_accounts);
info->pending_trans = NULL; info->pending_trans = NULL;
@ -1823,6 +1852,7 @@ xaccSRSaveRegEntry (SplitRegister *reg, Transaction *new_trans)
* xaccSRGetCurrent will handle this case, too. We will create * xaccSRGetCurrent will handle this case, too. We will create
* a new split, copy the row contents to that split, and append * a new split, copy the row contents to that split, and append
* the split to the pre-existing transaction. */ * the split to the pre-existing transaction. */
Split *trans_split;
split = xaccMallocSplit (); split = xaccMallocSplit ();
xaccTransAppendSplit (trans, split); xaccTransAppendSplit (trans, split);
@ -1832,6 +1862,12 @@ xaccSRSaveRegEntry (SplitRegister *reg, Transaction *new_trans)
assert (reg->table->current_cursor); assert (reg->table->current_cursor);
reg->table->current_cursor->user_data = (void *) split; reg->table->current_cursor->user_data = (void *) split;
trans_split = xaccSRGetCurrentTransSplit (reg);
if ((info->cursor_hint_trans == trans) &&
(info->cursor_hint_trans_split == trans_split) &&
(info->cursor_hint_split == NULL))
info->cursor_hint_split = split;
} }
DEBUG ("updating trans addr=%p\n", trans); DEBUG ("updating trans addr=%p\n", trans);
@ -2376,7 +2412,8 @@ xaccSRCountRows (SplitRegister *reg,
Split *find_trans_split, Split *find_trans_split,
gncBoolean *ext_found_trans, gncBoolean *ext_found_trans,
gncBoolean *ext_found_split, gncBoolean *ext_found_split,
gncBoolean *ext_found_trans_split) gncBoolean *ext_found_trans_split,
gncBoolean *ext_on_blank_split)
{ {
SRInfo *info = xaccSRGetInfo(reg); SRInfo *info = xaccSRGetInfo(reg);
CellBlock *lead_cursor; CellBlock *lead_cursor;
@ -2388,6 +2425,8 @@ xaccSRCountRows (SplitRegister *reg,
gncBoolean found_split = GNC_F; gncBoolean found_split = GNC_F;
gncBoolean found_trans = GNC_F; gncBoolean found_trans = GNC_F;
gncBoolean found_trans_split = GNC_F; gncBoolean found_trans_split = GNC_F;
gncBoolean on_blank_split = GNC_F;
gncBoolean did_expand = GNC_F;
gncBoolean on_trans_split; gncBoolean on_trans_split;
gncBoolean multi_line; gncBoolean multi_line;
gncBoolean dynamic; gncBoolean dynamic;
@ -2466,8 +2505,6 @@ xaccSRCountRows (SplitRegister *reg,
split = NULL; split = NULL;
while (split) { while (split) {
gncBoolean did_expand = GNC_F;
/* do not count the blank split */ /* do not count the blank split */
if (split != info->blank_split) { if (split != info->blank_split) {
gncBoolean do_expand; gncBoolean do_expand;
@ -2589,25 +2626,34 @@ xaccSRCountRows (SplitRegister *reg,
if (on_trans_split || !found_trans_split) if (on_trans_split || !found_trans_split)
found_split = GNC_T; found_split = GNC_T;
found_trans = GNC_T; found_trans = GNC_T;
on_blank_split = GNC_T;
} }
else if (!found_split && (trans == find_trans)) { else if (!found_split && (trans == find_trans)) {
save_cursor_phys_row = num_phys_rows; save_cursor_phys_row = num_phys_rows;
save_cursor_virt_row = num_virt_rows; save_cursor_virt_row = num_virt_rows;
found_trans = GNC_T; found_trans = GNC_T;
on_blank_split = GNC_T;
} }
} }
if (multi_line) { if (multi_line || dynamic) {
if (!found_split && (find_split == NULL) && (trans == find_trans)) { if (!found_split && (find_split == NULL) && (trans == find_trans)) {
save_cursor_phys_row = num_phys_rows + 1; save_cursor_phys_row = num_phys_rows + 1;
save_cursor_virt_row = num_virt_rows + 1; save_cursor_virt_row = num_virt_rows + 1;
if (on_trans_split || !found_trans_split) if (on_trans_split || !found_trans_split)
found_split = GNC_T; found_split = GNC_T;
found_trans = GNC_T; found_trans = GNC_T;
on_blank_split = GNC_T;
}
if (multi_line || (dynamic && on_blank_split)) {
num_virt_rows += 2;
num_phys_rows += reg->trans_cursor->numRows;
num_phys_rows += reg->split_cursor->numRows;
}
else {
num_virt_rows += 1;
num_phys_rows += reg->trans_cursor->numRows;
} }
num_virt_rows += 2;
num_phys_rows += reg->trans_cursor->numRows;
num_phys_rows += reg->split_cursor->numRows;
} else { } else {
num_virt_rows += 1; num_virt_rows += 1;
num_phys_rows += lead_cursor->numRows; num_phys_rows += lead_cursor->numRows;
@ -2638,6 +2684,8 @@ xaccSRCountRows (SplitRegister *reg,
*ext_found_split = found_split; *ext_found_split = found_split;
if (ext_found_trans_split != NULL) if (ext_found_trans_split != NULL)
*ext_found_trans_split = found_trans_split; *ext_found_trans_split = found_trans_split;
if (ext_on_blank_split != NULL)
*ext_on_blank_split = on_blank_split;
} }
/* ======================================================== */ /* ======================================================== */
@ -2660,6 +2708,8 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
gncBoolean found_split = GNC_F; gncBoolean found_split = GNC_F;
gncBoolean found_trans = GNC_F; gncBoolean found_trans = GNC_F;
gncBoolean found_trans_split = GNC_F; gncBoolean found_trans_split = GNC_F;
gncBoolean did_expand = GNC_F;
gncBoolean on_blank_split;
gncBoolean multi_line; gncBoolean multi_line;
gncBoolean dynamic; gncBoolean dynamic;
@ -2705,7 +2755,8 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
/* count the number of rows, looking for the place we want to go. */ /* count the number of rows, looking for the place we want to go. */
xaccSRCountRows (reg, slist, xaccSRCountRows (reg, slist,
find_trans, find_split, find_trans_split, find_trans, find_split, find_trans_split,
&found_trans, &found_split, &found_trans_split); &found_trans, &found_split, &found_trans_split,
&on_blank_split);
/* If the current cursor has changed, and the 'current split' /* If the current cursor has changed, and the 'current split'
* is still among the living, we save the values for later * is still among the living, we save the values for later
@ -2745,7 +2796,6 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
split = NULL; split = NULL;
while (split) { while (split) {
gncBoolean did_expand = GNC_F;
if (info->pending_trans == xaccSplitGetParent (split)) if (info->pending_trans == xaccSplitGetParent (split))
found_pending = GNC_T; found_pending = GNC_T;
@ -2850,7 +2900,7 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
} }
/* do the split row of the blank split */ /* do the split row of the blank split */
if (multi_line) { if (multi_line || dynamic) {
Transaction *trans; Transaction *trans;
/* do the transaction row of the blank split */ /* do the transaction row of the blank split */
@ -2860,13 +2910,15 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
vrow ++; vrow ++;
phys_row += reg->trans_cursor->numRows; phys_row += reg->trans_cursor->numRows;
trans = xaccSplitGetParent (split); if (multi_line || (dynamic && on_blank_split)) {
split = xaccTransGetSplit (trans, 1); trans = xaccSplitGetParent (split);
xaccSetCursor (table, reg->split_cursor, phys_row, 0, vrow, 0); split = xaccTransGetSplit (trans, 1);
xaccMoveCursor (table, phys_row, 0); xaccSetCursor (table, reg->split_cursor, phys_row, 0, vrow, 0);
xaccSRLoadRegEntry (reg, split); xaccMoveCursor (table, phys_row, 0);
vrow ++; xaccSRLoadRegEntry (reg, split);
phys_row += reg->split_cursor->numRows; vrow ++;
phys_row += reg->split_cursor->numRows;
}
} else { } else {
xaccSetCursor (table, lead_cursor, phys_row, 0, vrow, 0); xaccSetCursor (table, lead_cursor, phys_row, 0, vrow, 0);
xaccMoveCursor (table, phys_row, 0); xaccMoveCursor (table, phys_row, 0);
@ -2910,6 +2962,7 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
info->cursor_hint_split = xaccSRGetCurrentSplit (reg); info->cursor_hint_split = xaccSRGetCurrentSplit (reg);
info->cursor_hint_trans_split = xaccSRGetCurrentTransSplit (reg); info->cursor_hint_trans_split = xaccSRGetCurrentTransSplit (reg);
info->cursor_hint_phys_col = -1; info->cursor_hint_phys_col = -1;
info->hint_set_by_traverse = GNC_F;
xaccRefreshTableGUI (table); xaccRefreshTableGUI (table);

View File

@ -2116,10 +2116,8 @@ recordCB(GtkWidget *w, gpointer data)
RegWindow *regData = (RegWindow *) data; RegWindow *regData = (RegWindow *) data;
gncBoolean really_saved; gncBoolean really_saved;
Transaction *trans; Transaction *trans;
Split *split;
split = xaccSRGetCurrentSplit(regData->ledger->ledger); trans = xaccSRGetCurrentTrans(regData->ledger->ledger);
trans = xaccSplitGetParent(split);
really_saved = xaccSRSaveRegEntry(regData->ledger->ledger, NULL); really_saved = xaccSRSaveRegEntry(regData->ledger->ledger, NULL);
if (!really_saved) if (!really_saved)

View File

@ -535,10 +535,13 @@ doMoveCursor (Table *table, int new_phys_row, int new_phys_col,
phys_col_origin = new_phys_col; phys_col_origin = new_phys_col;
phys_col_origin -= table->locators[new_phys_row][new_phys_col]->phys_col_offset; phys_col_origin -= table->locators[new_phys_row][new_phys_col]->phys_col_offset;
/* setting the previous traversal value to the last of a traversal chain will /* setting the previous traversal value to the last of a traversal chain
* guarantee that first entry into a register will occur at the first cell */ * will guarantee that the first entry into a register will occur at the
table->prev_phys_traverse_row = phys_row_origin + curs->last_reenter_traverse_row; * first cell */
table->prev_phys_traverse_col = phys_col_origin + curs->last_reenter_traverse_col; table->prev_phys_traverse_row = (phys_row_origin +
curs->last_reenter_traverse_row);
table->prev_phys_traverse_col = (phys_col_origin +
curs->last_reenter_traverse_col);
/* update the cell values to reflect the new position */ /* update the cell values to reflect the new position */
for (i=0; i<curs->numRows; i++) { for (i=0; i<curs->numRows; i++) {
@ -1241,7 +1244,7 @@ gnc_table_traverse_update(Table *table, int row, int col,
/* next, check the current row and column. If they are out of bounds /* next, check the current row and column. If they are out of bounds
* we can recover by treating the traversal as a mouse point. This can * we can recover by treating the traversal as a mouse point. This can
* occur whenever the Xbae widget is resized smaller. */ * occur whenever the register widget is resized smaller, maybe?. */
if ((row >= table->num_phys_rows) || (row < 0) || if ((row >= table->num_phys_rows) || (row < 0) ||
(col >= table->num_phys_cols) || (col < 0)) { (col >= table->num_phys_cols) || (col < 0)) {
@ -1335,7 +1338,7 @@ gnc_table_traverse_update(Table *table, int row, int col,
/* Call the table traverse callback for any modifications. */ /* Call the table traverse callback for any modifications. */
if (table->traverse) if (table->traverse)
(table->traverse) (table, dest_row, dest_col, table->client_data); (table->traverse) (table, dest_row, dest_col, dir, table->client_data);
table->prev_phys_traverse_row = *dest_row; table->prev_phys_traverse_row = *dest_row;
table->prev_phys_traverse_col = *dest_col; table->prev_phys_traverse_col = *dest_col;

View File

@ -124,7 +124,7 @@ typedef enum {
GNC_TABLE_TRAVERSE_DOWN GNC_TABLE_TRAVERSE_DOWN
} gncTableTraversalDir; } gncTableTraversalDir;
/* the Locator structure is used provide a mapping from /* The Locator structure is used provide a mapping from
* the physical array of cells to the logical array of * the physical array of cells to the logical array of
* virtual cell blocks. * virtual cell blocks.
* *
@ -208,6 +208,7 @@ struct _Table {
/* callback that is called to determine traversal */ /* callback that is called to determine traversal */
void (*traverse) (Table *, int *p_new_phys_row, void (*traverse) (Table *, int *p_new_phys_row,
int *p_new_phys_col, int *p_new_phys_col,
gncTableTraversalDir dir,
void *client_data); void *client_data);
TableSetHelpFunc set_help; TableSetHelpFunc set_help;