fix a bug i'd introduced last night

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@1848 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 1999-07-31 17:11:42 +00:00
parent 7d0bceee4e
commit 872dbd0f8c
3 changed files with 25 additions and 12 deletions

View File

@ -901,6 +901,8 @@ gnc_table_enter_update(Table *table,
if (table->entries[row][col]) free (table->entries[row][col]);
table->entries[row][col] = retval;
(arr->cells[rel_row][rel_col])->changed = 0xffffffff;
} else {
retval = NULL;
}
}
PINFO(")\n");
@ -940,6 +942,8 @@ gnc_table_leave_update(Table *table, int row, int col,
*/
if (retval && (retval != callback_text)) {
newval = (char *) retval;
} else {
retval = NULL;
}
}

View File

@ -268,17 +268,6 @@ void * xaccGetUserData (Table *table, int phys_row, int phys_col);
/* ==================================================== */
/* these are used internally by table-{motif,gtk}.c
perhaps these should go in a table-allguiP.h
They were also ripped more or less straight out of table-motif.c
and just made UI independent. In the long run, they should
probably be rewritten to have even clearer interfaces/semantics.
For now, though, this will do.
Function bodies may also be a little contorted, but that's because
I had to be careful to only make changes that preserved all the
previous invariants. Sometimes the most careful change may not
have been the clearest.
*/
int
@ -296,6 +285,18 @@ doRefreshCursorGUI (Table * table, CellBlock *curs, int from_row, int from_col);
void
xaccRefreshCursorGUI (Table * table);
/*
* gnc_table_enter_update() is a utility function used to determine
* how the gui will respond. If it returns NULL, then the GUI will
* map an editing widget onto this cell, and allow user input. If
* it returns non-null, then the returned value will be used as the
* new cell value, and an editor for the cell will not be mapped
* (viz, the user will be prevented from updating the cell)
*
* Note: since this is an internal-use-only routine, if you do not
* like this semantic, cut&paste this code and change it to suit you.
* However, don't just change it, because it will break functional code.
*/
const char *
gnc_table_enter_update(Table *table, int row, int col);

View File

@ -165,9 +165,11 @@ enterCB (Widget mw, XtPointer cd, XtPointer cb) {
const int col = cbs->column;
const char *new_text;
ENTER ("enterCB()\n");
new_text = gnc_table_enter_update(table, row, col);
if(new_text) {
DEBUG ("enterCB new text = %s\n", new_text);
XbaeMatrixSetCell (mw, row, col, (char *)new_text);
XbaeMatrixRefreshCell (mw, row, col);
@ -178,6 +180,7 @@ enterCB (Widget mw, XtPointer cd, XtPointer cb) {
cbs->doit = True;
cbs->map = True;
}
LEAVE ("enterCB()\n");
}
/* ==================================================== */
@ -197,6 +200,7 @@ modifyCB (Widget mw, XtPointer cd, XtPointer cb)
int len = 1;
const char *retval;
char *newval;
ENTER("modifyCB()\n");
/* accept edits by default, unless the cell handler rejects them */
cbs->verify->doit = True;
@ -215,6 +219,7 @@ modifyCB (Widget mw, XtPointer cd, XtPointer cb)
retval = gnc_table_modify_update(table, row, col, oldval, change, newval);
if (retval && (retval != newval)) {
DEBUG ("modifyCB() new text: %s\n", retval);
XbaeMatrixSetCell (mw, row, col, (char *) retval);
XbaeMatrixRefreshCell (mw, row, col);
XbaeMatrixSetCursorPosition (mw, (cbs->verify->endPos) + 1);
@ -228,7 +233,7 @@ modifyCB (Widget mw, XtPointer cd, XtPointer cb)
cbs->verify->doit = False;
free(newval);
}
PINFO("modifyCB(): exit\n");
LEAVE("modifyCB()\n");
}
/* ==================================================== */
@ -242,15 +247,18 @@ leaveCB (Widget mw, XtPointer cd, XtPointer cb)
const int row = cbs->row;
const int col = cbs->column;
const char * new_text;
ENTER("leaveCB()\n");
new_text = gnc_table_leave_update(table, row, col, cbs->value);
if(new_text) {
DEBUG("leaveCB() new text=%s\n", new_text);
cbs->value = strdup (new_text);
}
/* by default, accept whatever the final proposed edit is */
cbs->doit = True;
LEAVE("leaveCB()\n");
}