From 7bfa951302f5d02c54c0ce1f73b45568766f0544 Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Mon, 2 Feb 1998 18:12:07 +0000 Subject: [PATCH] misc bug fixes git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@491 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/Ledger.c | 28 +++++++++++++++++++--------- src/register/combocell.c | 29 +++++++++++++++++++++++++++++ src/register/combocell.h | 1 + src/register/table.c | 25 ++++++++++++++++++++++++- 4 files changed, 73 insertions(+), 10 deletions(-) diff --git a/src/Ledger.c b/src/Ledger.c index 5947fb4666..8c7674362d 100644 --- a/src/Ledger.c +++ b/src/Ledger.c @@ -97,6 +97,7 @@ xaccSaveRegEntry (BasicRegister *reg) if (!split) return; trans = (Transaction *) (split->parent); +printf ("saving %s \n", trans->description); /* copy the contents from the cursor to the split */ xaccTransSetDate (trans, reg->dateCell->date.tm_mday, reg->dateCell->date.tm_mon+1, @@ -108,13 +109,15 @@ xaccSaveRegEntry (BasicRegister *reg) xaccSplitSetAction (split, reg->actionCell->cell.value); xaccSplitSetReconcile (split, reg->recnCell->value[0]); - /* hack alert -- do transfers */ - + /* if the user changed thw value of the xfrm cell, + * then move the far end oof the split to the new location. + */ xfr = GetPeerAccName (split); if (strcmp (xfr, reg->xfrmCell->cell.value) && strcmp (SPLIT_STR, reg->xfrmCell->cell.value)) { Split *peer_split; +printf ("xfr from %s to %x \n", xfr, reg->xfrmCell->cell.value); peer_split = GetPeerSplit (split); if (peer_split) { acc = (Account *) (peer_split->acc); @@ -153,7 +156,7 @@ xaccLoadRegEntry (BasicRegister *reg, Split *split) trans->date.year); xaccSetBasicCellValue (reg->numCell, trans->num); - xaccSetBasicCellValue (&(reg->actionCell->cell), split->action); + xaccSetComboCellValue (reg->actionCell, split->action); xaccSetQuickFillCellValue (reg->descCell, trans->description); xaccSetBasicCellValue (reg->memoCell, split->memo); @@ -162,9 +165,8 @@ xaccLoadRegEntry (BasicRegister *reg, Split *split) xaccSetBasicCellValue (reg->recnCell, buff); /* the transfer account */ - /* hack alert -- this is incorrect for splits in general */ accname = GetPeerAccName (split); - xaccSetBasicCellValue (&(reg->xfrmCell->cell), accname); + xaccSetComboCellValue (reg->xfrmCell, accname); xaccSetDebCredCellValue (reg->debitCell, reg->creditCell, split->damount); @@ -217,14 +219,14 @@ xaccLoadRegister (BasicRegister *reg, Split **slist) } /* ======================================================== */ +/* walk account tree recursively, pulling out all the names */ -void xaccLoadXferCell (ComboCell *cell, AccountGroup *grp) +static void +LoadXferCell (ComboCell *cell, AccountGroup *grp) { Account * acc; int n; - xaccAddComboCellMenuItem (cell, SPLIT_STR); - if (!grp) return; /* build the xfer menu out of account names */ @@ -233,10 +235,18 @@ void xaccLoadXferCell (ComboCell *cell, AccountGroup *grp) acc = getAccount (grp, n); while (acc) { xaccAddComboCellMenuItem (cell, acc->accountName); - xaccLoadXferCell (cell, acc->children); + LoadXferCell (cell, acc->children); n++; acc = getAccount (grp, n); } } +/* ======================================================== */ + +void xaccLoadXferCell (ComboCell *cell, AccountGroup *grp) +{ + xaccAddComboCellMenuItem (cell, SPLIT_STR); + LoadXferCell (cell, grp); +} + /* ======================= end of file =================== */ diff --git a/src/register/combocell.c b/src/register/combocell.c index 1808dd43f3..1235172301 100644 --- a/src/register/combocell.c +++ b/src/register/combocell.c @@ -87,6 +87,34 @@ xaccAddComboCellMenuItem (ComboCell *cell, char * menustr) } } +/* =============================================== */ +/* not only do we set the cell contents, but we + * make the gui reflect the right value too. + */ + +void +xaccSetComboCellValue (ComboCell *cell, const char * str) +{ + PopBox * box; + + xaccSetBasicCellValue (&(cell->cell), str); + box = (PopBox *) (cell->cell.gui_private); + + if (str) { + if (0x0 != str[0]) { + XmString choosen; + /* convert String to XmString ... arghhh */ + choosen = XmCvtCTToXmString ((char *) str); + XmComboBoxSelectItem (box->combobox, choosen, False); + XmStringFree (choosen); + } else { + XmComboBoxClearItemSelection (box->combobox); + } + } else { + XmComboBoxClearItemSelection (box->combobox); + } +} + /* =============================================== */ static @@ -323,6 +351,7 @@ static void selectCB (Widget w, XtPointer cd, XtPointer cb ) XbaeMatrixSetCell (box->parent, box->currow, box->curcol, choice); xaccSetBasicCellValue (&(cell->cell), choice); +printf ("celectcb choice %s \n", choice); XtFree (choice); /* a diffeent way of getting the user's selection ... */ diff --git a/src/register/combocell.h b/src/register/combocell.h index 7bc6d58921..2505ff80e6 100644 --- a/src/register/combocell.h +++ b/src/register/combocell.h @@ -22,6 +22,7 @@ typedef struct _ComboCell { ComboCell * xaccMallocComboCell (void); void xaccInitComboCell (ComboCell *); +void xaccSetComboCellValue (ComboCell *, const char *); void xaccAddComboCellMenuItem (ComboCell *, char * menustr); diff --git a/src/register/table.c b/src/register/table.c index b70aaf5c08..8ce28e4437 100644 --- a/src/register/table.c +++ b/src/register/table.c @@ -330,6 +330,11 @@ void xaccMoveCursor (Table *table, int virt_row, int virt_col) int iphys,jphys; BasicCell *cell; +printf ("move cursor from %d %d to %d %d \n", +table->current_cursor_row, +table->current_cursor_col, +virt_row, virt_col); + /* call the callback, allowing the app to commit any changes */ if (table->move_cursor) { (table->move_cursor) (table, table->client_data); @@ -462,6 +467,11 @@ verifyCursorPosition (Table *table, int phys_row, int phys_col) if ((virt_row != table->current_cursor_row) || (virt_col != table->current_cursor_col)) { +printf ("verify cursor bad cur %d %d new %d %d \n", +table->current_cursor_row, +table->current_cursor_col, +virt_row, virt_col); + /* before leaving, the current virtual position, * commit any aedits that have been accumulated * in the cursor */ @@ -664,6 +674,11 @@ enterCB (Widget mw, XtPointer cd, XtPointer cb) cbs->doit = False; } } + + /* record this position as the cell that will be + * traversed out of if a traverse even happens */ + table->prev_phys_traverse_row = row; + table->prev_phys_traverse_col = col; } /* ==================================================== */ @@ -828,7 +843,7 @@ traverseCB (Widget mw, XtPointer cd, XtPointer cb) row = cbs->row; col = cbs->column; - verifyCursorPosition (table, row, col); +printf ("traverse from %d %d %s %d\n", row, col, cbs->param, cbs->qparam); /* If the quark is zero, then it is likely that we are * here because we traversed out of a cell that had a @@ -851,10 +866,13 @@ traverseCB (Widget mw, XtPointer cd, XtPointer cb) cbs->qparam = QRight; row = table->prev_phys_traverse_row; col = table->prev_phys_traverse_col; +printf ("null quark emulate rows %d %d \n", row, col); } } } + verifyCursorPosition (table, row, col); + /* compute the cell location */ rel_row = row - table->num_header_rows; rel_col = col; @@ -886,6 +904,11 @@ traverseCB (Widget mw, XtPointer cd, XtPointer cb) table->prev_phys_traverse_row = cbs->next_row; table->prev_phys_traverse_col = cbs->next_column; + +printf ("traverse all said & done %d %d \n", +table->prev_phys_traverse_row, +table->prev_phys_traverse_col); + }