mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
* src/register/gnome/gnucash-sheet.c: if input is cancelled by
user during delete, ignore the insert callback. * src/MultiLedger.c: update for new view api * src/register/recncell.{ch}: allow setting a parent to be used for the dialog. * src/gnome/query-user.c (gnc_verify_dialog_parented): handle null parent by using gnc_get_ui_data. * src/gnome/window-register.c: eliminate calls to xaccSRCheckReconciled. confirmation is done in SplitLedger.c now. * src/SplitLedger.c: use new data entry confirmation callback to confirm changes to a reconciled split. * src/register/splitreg.{ch}: mod for table-allgui changes * src/register/table-allgui.{ch}: encapsulate 'view' callbacks into a struct. add a callback for confiming data entry. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3726 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
fa161cd3b5
commit
275142e3c2
74
ChangeLog
74
ChangeLog
@ -1,3 +1,27 @@
|
||||
2001-03-01 Dave Peticolas <dave@krondo.com>
|
||||
|
||||
* src/register/gnome/gnucash-sheet.c: if input is cancelled by
|
||||
user during delete, ignore the insert callback.
|
||||
|
||||
* src/MultiLedger.c: update for new view api
|
||||
|
||||
* src/register/recncell.{ch}: allow setting a parent to be used
|
||||
for the dialog.
|
||||
|
||||
* src/gnome/query-user.c (gnc_verify_dialog_parented): handle null
|
||||
parent by using gnc_get_ui_data.
|
||||
|
||||
* src/gnome/window-register.c: eliminate calls to
|
||||
xaccSRCheckReconciled. confirmation is done in SplitLedger.c now.
|
||||
|
||||
* src/SplitLedger.c: use new data entry confirmation callback
|
||||
to confirm changes to a reconciled split.
|
||||
|
||||
* src/register/splitreg.{ch}: mod for table-allgui changes
|
||||
|
||||
* src/register/table-allgui.{ch}: encapsulate 'view' callbacks
|
||||
into a struct. add a callback for confiming data entry.
|
||||
|
||||
2001-03-01 Robert Graham Merkel <rgmerk@mira.net>
|
||||
|
||||
* src/scm/report/transaction-report.scm (add-split-row): Now
|
||||
@ -26,7 +50,6 @@
|
||||
forthcoming. Didn't change back because for-each is R5RS, but
|
||||
for-each-in-order isn't. Probably should make the substitution
|
||||
globally.
|
||||
|
||||
|
||||
2001-02-28 Dave Peticolas <dave@krondo.com>
|
||||
|
||||
@ -437,8 +460,8 @@
|
||||
* src/gnome/druid-commodity.c: remove consts from
|
||||
gnc_commoditities (after consultation with Bill).
|
||||
|
||||
* src/gnome/dialog-account.c: remove consts from gnc_commoditities (after
|
||||
consultation with Bill).
|
||||
* src/gnome/dialog-account.c: remove consts from gnc_commoditities
|
||||
(after consultation with Bill).
|
||||
|
||||
* src/gnome/dialog-options.c: remove consts from gnc_commoditities
|
||||
(after consultation with Bill).
|
||||
@ -455,11 +478,11 @@
|
||||
* src/gnc-ui-util.c: remove consts from gnc_commoditities (after
|
||||
consultation with Bill).
|
||||
|
||||
* src/engine/Transaction.h: remove consts from gnc_commoditities (after
|
||||
consultation with Bill).
|
||||
* src/engine/Transaction.h: remove consts from gnc_commoditities
|
||||
(after consultation with Bill).
|
||||
|
||||
* src/engine/Transaction.c: remove consts from gnc_commoditities (after
|
||||
consultation with Bill).
|
||||
* src/engine/Transaction.c: remove consts from gnc_commoditities
|
||||
(after consultation with Bill).
|
||||
|
||||
* src/engine/Scrub.c: remove consts from gnc_commoditities (after
|
||||
consultation with Bill).
|
||||
@ -1538,9 +1561,9 @@
|
||||
(xaccTransSetDocref): deleted.
|
||||
(xaccTransGetDocref): deleted.
|
||||
|
||||
* src/engine/Transaction.h: accomodate changes to Transaction.c.
|
||||
* src/engine/Transaction.h: accomodate changes to Transaction.c.
|
||||
|
||||
* src/engine/TransactionP.h: accomodate changes to Transaction.c.
|
||||
* src/engine/TransactionP.h: accomodate changes to Transaction.c.
|
||||
|
||||
* src/engine/Session.c:
|
||||
(xaccSessionGetFileError): new function - migrate away from using
|
||||
@ -1757,30 +1780,34 @@
|
||||
|
||||
2000-09-05 Robert Graham Merkel <rgmerk@mira.net>
|
||||
|
||||
* src/scm/date-utilities.scm ((gnc:reldate-initialize)): New function - initialise
|
||||
explicitly at startup rather than in ad-hoc manner
|
||||
* src/scm/date-utilities.scm ((gnc:reldate-initialize)): New
|
||||
function - initialise explicitly at startup rather than in ad-hoc
|
||||
manner
|
||||
|
||||
2000-08-31 Robert Graham Merkel <rgmerk@mira.net>
|
||||
|
||||
* src/scm/report/balance-and-pnl.scm: Bug fixes for new date options.
|
||||
* src/scm/report/balance-and-pnl.scm: Bug fixes for new date
|
||||
options.
|
||||
|
||||
* src/scm/report/transaction-report.scm: Bug fixes for new date options.
|
||||
* src/scm/report/transaction-report.scm: Bug fixes for new date
|
||||
options.
|
||||
|
||||
* src/scm/report/budget-report.scm: Bug fixes for new date options.
|
||||
|
||||
2000-08-30 Robert Graham Merkel <rgmerk@mira.net>
|
||||
|
||||
* src/scm/report/hello-world.scm: A couple of new functions to test the relative
|
||||
and combination date style options.
|
||||
* src/scm/report/hello-world.scm: A couple of new functions to
|
||||
test the relative and combination date style options.
|
||||
|
||||
* src/scm/report/*.scm: Modified date options to take the new function. Most
|
||||
are still using absolute options at this stage, will get modified to use relative
|
||||
dates later.
|
||||
* src/scm/report/*.scm: Modified date options to take the new
|
||||
function. Most are still using absolute options at this stage,
|
||||
will get modified to use relative dates later.
|
||||
|
||||
* src/scm/options.scm (gnc:make-option): new argument (option-data-fns)
|
||||
for manipulating multi-choice style options. Changes
|
||||
to option-makers to either support this.
|
||||
(gnc:make-date-option): modified to support relative and combination dates.
|
||||
* src/scm/options.scm (gnc:make-option): new argument
|
||||
(option-data-fns) for manipulating multi-choice style options.
|
||||
Changes to option-makers to either support this.
|
||||
(gnc:make-date-option): modified to support relative and
|
||||
combination dates.
|
||||
|
||||
* src/scm/date-utilities.scm: Extensive additions for manipulating
|
||||
relative dates.
|
||||
@ -1889,7 +1916,8 @@
|
||||
startup.
|
||||
(gnc:main): support --evalutate properly.
|
||||
|
||||
* src/scm/engine-utilities.scm (gnc:transaction-map-splits): moved here.
|
||||
* src/scm/engine-utilities.scm (gnc:transaction-map-splits): moved
|
||||
here.
|
||||
(gnc:group-map-accounts): moved here.
|
||||
|
||||
* src/scm/command-line.scm (gnc:*arg-defs*): add --evaluate
|
||||
|
@ -640,6 +640,7 @@ xaccLedgerDisplayInternal (Account *lead_account, Query *q,
|
||||
xaccLedgerDisplay *ld;
|
||||
gboolean show_all;
|
||||
const char *class;
|
||||
TableView view;
|
||||
GList *splits;
|
||||
|
||||
switch (ld_type)
|
||||
@ -738,13 +739,16 @@ xaccLedgerDisplayInternal (Account *lead_account, Query *q,
|
||||
|
||||
/* xaccMallocSplitRegister will malloc & initialize the register,
|
||||
* but will not do the gui init */
|
||||
ld->reg = xaccMallocSplitRegister (reg_type, style, FALSE,
|
||||
xaccSRGetEntryHandler,
|
||||
xaccSRGetLabelHandler,
|
||||
xaccSRGetIOFlagsHandler,
|
||||
xaccSRGetFGColorHandler,
|
||||
xaccSRGetBGColorHandler,
|
||||
xaccSRGetCellBorderHandler,
|
||||
view.entry_handler = xaccSRGetEntryHandler;
|
||||
view.label_handler = xaccSRGetLabelHandler;
|
||||
view.io_flag_handler = xaccSRGetIOFlagsHandler;
|
||||
view.fg_color_handler = xaccSRGetFGColorHandler;
|
||||
view.bg_color_handler = xaccSRGetBGColorHandler;
|
||||
view.cell_border_handler = xaccSRGetCellBorderHandler;
|
||||
view.confirm_handler = xaccSRConfirmHandler;
|
||||
view.handler_user_data = NULL;
|
||||
|
||||
ld->reg = xaccMallocSplitRegister (reg_type, style, FALSE, &view,
|
||||
xaccMLGUIDMalloc,
|
||||
xaccMLGUIDFree,
|
||||
xaccMLGUIDCopy);
|
||||
|
@ -23,7 +23,7 @@
|
||||
* SplitLedger.c
|
||||
*
|
||||
* FUNCTION:
|
||||
* copy transaction data from engine into split-register object.
|
||||
* Provide view for SplitRegister object.
|
||||
*
|
||||
*
|
||||
* DESIGN NOTES:
|
||||
@ -183,6 +183,10 @@ struct _SRInfo
|
||||
/* true if we are loading the register for the first time */
|
||||
gboolean first_pass;
|
||||
|
||||
/* true if the user has already confirmed changes of a reconciled
|
||||
* split */
|
||||
gboolean change_confirmed;
|
||||
|
||||
/* User data for users of SplitRegisters */
|
||||
gpointer user_data;
|
||||
|
||||
@ -1013,6 +1017,9 @@ LedgerMoveCursor (Table *table, VirtualLocation *p_new_virt_loc)
|
||||
info->cursor_hint_cursor_class = new_class;
|
||||
}
|
||||
|
||||
if (old_split != new_split)
|
||||
info->change_confirmed = FALSE;
|
||||
|
||||
gnc_resume_gui_refresh ();
|
||||
|
||||
/* redrawing the register can muck everything up */
|
||||
@ -1563,6 +1570,8 @@ LedgerTraverse (Table *table,
|
||||
switch (result)
|
||||
{
|
||||
case GNC_VERIFY_YES:
|
||||
break;
|
||||
|
||||
case GNC_VERIFY_NO:
|
||||
{
|
||||
VirtualCellLocation vcell_loc;
|
||||
@ -1570,9 +1579,6 @@ LedgerTraverse (Table *table,
|
||||
Split *trans_split;
|
||||
CursorClass new_class;
|
||||
|
||||
if ((result == GNC_VERIFY_YES) && xaccSRCheckReconciled (reg))
|
||||
break;
|
||||
|
||||
new_split = sr_get_split(reg, virt_loc.vcell_loc);
|
||||
trans_split = xaccSRGetTransSplit(reg, virt_loc.vcell_loc, NULL);
|
||||
new_class = xaccSplitRegisterGetCursorClass (reg, virt_loc.vcell_loc);
|
||||
@ -4369,6 +4375,55 @@ xaccSRGetBGColorHandler (VirtualLocation virt_loc,
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
xaccSRConfirmHandler (VirtualLocation virt_loc,
|
||||
gpointer user_data)
|
||||
{
|
||||
SplitRegister *reg = user_data;
|
||||
SRInfo *info = xaccSRGetInfo (reg);
|
||||
guint32 changed;
|
||||
Split *split;
|
||||
char recn;
|
||||
|
||||
/* This assumes we reset the flag whenver we change splits.
|
||||
* This happens in LedgerMoveCursor. */
|
||||
if (info->change_confirmed)
|
||||
return TRUE;
|
||||
|
||||
split = sr_get_split (reg, virt_loc.vcell_loc);
|
||||
if (!split)
|
||||
return TRUE;
|
||||
|
||||
changed = xaccSplitRegisterGetChangeFlag (reg);
|
||||
|
||||
if (MOD_RECN & changed)
|
||||
recn = xaccRecnCellGetFlag (reg->recnCell);
|
||||
else
|
||||
recn = xaccSplitGetReconcile (split);
|
||||
|
||||
if (recn == YREC)
|
||||
{
|
||||
gboolean confirm;
|
||||
char *message = _("You are about to change a reconciled split.\n"
|
||||
"Are you sure you want to do that?");
|
||||
|
||||
confirm = gnc_lookup_boolean_option ("Register",
|
||||
"Confirm before changing reconciled",
|
||||
TRUE);
|
||||
if (!confirm)
|
||||
return TRUE;
|
||||
|
||||
confirm = gnc_verify_dialog_parented (xaccSRGetParent (reg),
|
||||
message, FALSE);
|
||||
|
||||
info->change_confirmed = confirm;
|
||||
|
||||
return confirm;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* ======================================================== */
|
||||
|
||||
G_INLINE_FUNC void
|
||||
@ -4814,6 +4869,9 @@ xaccSRLoadRegister (SplitRegister *reg, GList * slist,
|
||||
xaccComboCellSetCompleteChar (reg->mxfrmCell, account_separator);
|
||||
xaccComboCellSetCompleteChar (reg->xfrmCell, account_separator);
|
||||
|
||||
/* set the dialog parent for the reconcile cell */
|
||||
xaccRecnCellSetParent (reg->recnCell, xaccSRGetParent (reg));
|
||||
|
||||
/* enable callback for cursor user-driven moves */
|
||||
table->move_cursor = LedgerMoveCursor;
|
||||
table->traverse = LedgerTraverse;
|
||||
@ -4962,38 +5020,6 @@ trans_has_reconciled_splits (Transaction *trans)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
xaccSRCheckReconciled (SplitRegister *reg)
|
||||
{
|
||||
Transaction *trans;
|
||||
guint32 changed;
|
||||
gboolean confirm;
|
||||
char *message = _("You are about to change a transaction with reconciled\n"
|
||||
"splits. Are you sure you want to do that?");
|
||||
|
||||
if (reg == NULL)
|
||||
return TRUE;
|
||||
|
||||
changed = xaccSplitRegisterGetChangeFlag (reg);
|
||||
if (!changed)
|
||||
return TRUE;
|
||||
|
||||
trans = xaccSRGetCurrentTrans (reg);
|
||||
if (trans == NULL)
|
||||
return TRUE;
|
||||
|
||||
if (!trans_has_reconciled_splits (trans))
|
||||
return TRUE;
|
||||
|
||||
confirm = gnc_lookup_boolean_option ("Register",
|
||||
"Confirm before changing reconciled",
|
||||
TRUE);
|
||||
if (!confirm)
|
||||
return TRUE;
|
||||
|
||||
return gnc_verify_dialog_parented (xaccSRGetParent (reg), message, FALSE);
|
||||
}
|
||||
|
||||
/* ======================================================== */
|
||||
|
||||
void
|
||||
|
@ -180,14 +180,6 @@ void xaccSRRedrawReg (SplitRegister *reg);
|
||||
* has changed cells that have not been committed. */
|
||||
gboolean xaccSRHasPendingChanges (SplitRegister *reg);
|
||||
|
||||
/* The xaccSRCheckReconciled() method returns TRUE if the current
|
||||
* cursor has not been changed. It also returns TRUE if it has been
|
||||
* changed, but the relevant split is not reconciled or frozen. It
|
||||
* also returns TRUE if it has been changed and it is reconciled and
|
||||
* the user verifies in a dialog that the split should be changed.
|
||||
* Otherwise, it returns FALSE. */
|
||||
gboolean xaccSRCheckReconciled (SplitRegister *reg);
|
||||
|
||||
/* If TRUE, visually indicate the demarcation between splits with post
|
||||
* dates prior to the present, and after. This will only make sense if
|
||||
* the splits are ordered primarily by post date. */
|
||||
@ -224,5 +216,7 @@ guint32 xaccSRGetBGColorHandler (VirtualLocation virt_loc,
|
||||
void xaccSRGetCellBorderHandler (VirtualLocation virt_loc,
|
||||
PhysicalCellBorders *borders,
|
||||
gpointer user_data);
|
||||
gboolean xaccSRConfirmHandler (VirtualLocation virt_loc,
|
||||
gpointer user_data);
|
||||
|
||||
#endif /* __XACC_SPLIT_LEDGER_H__ */
|
||||
|
@ -194,6 +194,8 @@ gnc_verify_dialog_parented(gncUIWidget parent, const char *message,
|
||||
|
||||
if (parent != NULL)
|
||||
gnome_dialog_set_parent(GNOME_DIALOG(verify_box), GTK_WINDOW(parent));
|
||||
else
|
||||
gnome_dialog_set_parent(GNOME_DIALOG(verify_box), gnc_get_ui_data());
|
||||
|
||||
gnome_dialog_set_default(GNOME_DIALOG(verify_box), yes_is_default ? 0 : 1);
|
||||
|
||||
|
@ -1074,20 +1074,15 @@ expand_trans_cb (GtkWidget *widget, gpointer data)
|
||||
}
|
||||
|
||||
static void
|
||||
new_trans_cb(GtkWidget *widget, gpointer data)
|
||||
new_trans_cb (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
RegWindow *regData = data;
|
||||
SplitRegister *reg;
|
||||
|
||||
reg = xaccLedgerDisplayGetSR (regData->ledger);
|
||||
|
||||
if (xaccSRCheckReconciled (reg))
|
||||
{
|
||||
if (xaccSRSaveRegEntry (reg, TRUE))
|
||||
xaccSRRedrawReg (reg);
|
||||
}
|
||||
else
|
||||
xaccSRCancelCursorTransChanges (reg);
|
||||
if (xaccSRSaveRegEntry (reg, TRUE))
|
||||
xaccSRRedrawReg (reg);
|
||||
|
||||
gnc_register_jump_to_blank (regData);
|
||||
}
|
||||
@ -2556,16 +2551,8 @@ recordCB (GtkWidget *w, gpointer data)
|
||||
|
||||
trans = xaccSRGetCurrentTrans (reg);
|
||||
|
||||
if (xaccSRCheckReconciled (reg))
|
||||
{
|
||||
if (!xaccSRSaveRegEntry (reg, TRUE))
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
xaccSRCancelCursorTransChanges (reg);
|
||||
if (!xaccSRSaveRegEntry (reg, TRUE))
|
||||
return;
|
||||
}
|
||||
|
||||
if (trans != NULL)
|
||||
gnc_register_include_date (regData, xaccTransGetDate(trans));
|
||||
|
@ -420,7 +420,6 @@ gnucash_sheet_show_row (GnucashSheet *sheet, gint virt_row)
|
||||
void
|
||||
gnucash_sheet_make_cell_visible (GnucashSheet *sheet, VirtualLocation virt_loc)
|
||||
{
|
||||
|
||||
g_return_if_fail (sheet != NULL);
|
||||
g_return_if_fail (GNUCASH_IS_SHEET (sheet));
|
||||
|
||||
@ -656,7 +655,8 @@ gnucash_sheet_modify_current_cell(GnucashSheet *sheet, const gchar *new_text)
|
||||
new_text_wc, new_text_len,
|
||||
new_text_wc, new_text_len,
|
||||
&cursor_position,
|
||||
&start_sel, &end_sel);
|
||||
&start_sel, &end_sel,
|
||||
NULL);
|
||||
|
||||
g_free (new_text_wc);
|
||||
|
||||
@ -710,6 +710,13 @@ gnucash_sheet_insert_cb (GtkWidget *widget,
|
||||
int old_position;
|
||||
int i;
|
||||
|
||||
if (sheet->input_cancelled)
|
||||
{
|
||||
gtk_signal_emit_stop_by_name (GTK_OBJECT (sheet->entry),
|
||||
"insert_text");
|
||||
return;
|
||||
}
|
||||
|
||||
if (insert_text_len <= 0)
|
||||
return;
|
||||
|
||||
@ -782,7 +789,8 @@ gnucash_sheet_insert_cb (GtkWidget *widget,
|
||||
retval = gnc_table_modify_update (table, virt_loc,
|
||||
change_text_w, change_text_len,
|
||||
new_text_w, new_text_len,
|
||||
position, &start_sel, &end_sel);
|
||||
position, &start_sel, &end_sel,
|
||||
&sheet->input_cancelled);
|
||||
|
||||
if (retval &&
|
||||
((safe_strcmp (retval, new_text) != 0) ||
|
||||
@ -890,7 +898,8 @@ gnucash_sheet_delete_cb (GtkWidget *widget,
|
||||
NULL, 0,
|
||||
new_text_w, new_text_len,
|
||||
&cursor_position,
|
||||
&start_sel, &end_sel);
|
||||
&start_sel, &end_sel,
|
||||
&sheet->input_cancelled);
|
||||
|
||||
if (retval && (safe_strcmp (retval, new_text) != 0))
|
||||
{
|
||||
@ -1583,7 +1592,11 @@ gnucash_sheet_key_press_event (GtkWidget *widget, GdkEventKey *event)
|
||||
end_sel = 0;
|
||||
}
|
||||
|
||||
result = gtk_widget_event(sheet->entry, (GdkEvent *) event);
|
||||
sheet->input_cancelled = FALSE;
|
||||
|
||||
result = gtk_widget_event (sheet->entry, (GdkEvent *) event);
|
||||
|
||||
sheet->input_cancelled = FALSE;
|
||||
|
||||
new_pos = editable->current_pos;
|
||||
|
||||
@ -2052,6 +2065,8 @@ gnucash_sheet_init (GnucashSheet *sheet)
|
||||
sheet->num_visible_blocks = 1;
|
||||
sheet->num_visible_phys_rows = 1;
|
||||
|
||||
sheet->input_cancelled = FALSE;
|
||||
|
||||
sheet->num_virt_rows = 0;
|
||||
sheet->num_virt_cols = 0;
|
||||
sheet->item_editor = NULL;
|
||||
|
@ -84,6 +84,8 @@ typedef struct
|
||||
GnomeCanvasItem *item_editor;
|
||||
GtkWidget *entry;
|
||||
|
||||
gboolean input_cancelled;
|
||||
|
||||
gint top_block; /* maybe not fully visible */
|
||||
gint bottom_block;
|
||||
gint left_block;
|
||||
|
@ -33,6 +33,8 @@
|
||||
* Copyright (c) 2000 Dave Peticolas
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
@ -95,7 +97,8 @@ RecnEnter (BasicCell *_cell,
|
||||
const char *message = _("Do you really want to mark this transaction "
|
||||
"not reconciled?\nDoing so might make future "
|
||||
"reconciliation difficult!");
|
||||
if (!gnc_verify_dialog(message, TRUE))
|
||||
|
||||
if (!gnc_verify_dialog_parented (cell->parent, message, TRUE))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -173,6 +176,9 @@ RecnSetValue (BasicCell *_cell, const char *value)
|
||||
void
|
||||
xaccDestroyRecnCell (RecnCell *cell)
|
||||
{
|
||||
if (!cell)
|
||||
return;
|
||||
|
||||
xaccDestroyBasicCell (&cell->cell);
|
||||
}
|
||||
|
||||
@ -183,6 +189,8 @@ xaccRecnCellSetFlag (RecnCell *cell, char reconciled_flag)
|
||||
{
|
||||
const char *string;
|
||||
|
||||
g_return_if_fail (cell != NULL);
|
||||
|
||||
cell->reconciled_flag = reconciled_flag;
|
||||
|
||||
string = RecnCellGetString (reconciled_flag);
|
||||
@ -195,6 +203,8 @@ xaccRecnCellSetFlag (RecnCell *cell, char reconciled_flag)
|
||||
char
|
||||
xaccRecnCellGetFlag (RecnCell *cell)
|
||||
{
|
||||
g_return_val_if_fail (cell != NULL, NREC);
|
||||
|
||||
return cell->reconciled_flag;
|
||||
}
|
||||
|
||||
@ -206,4 +216,14 @@ xaccRecnCellSetStringGetter (RecnCellStringGetter getter)
|
||||
string_getter = getter;
|
||||
}
|
||||
|
||||
/* ================================================ */
|
||||
|
||||
void
|
||||
xaccRecnCellSetParent (RecnCell *cell, gncUIWidget parent)
|
||||
{
|
||||
g_return_if_fail (cell != NULL);
|
||||
|
||||
cell->parent = parent;
|
||||
}
|
||||
|
||||
/* --------------- end of file ---------------------- */
|
||||
|
@ -41,6 +41,7 @@
|
||||
#define __RECN_CELL_C__
|
||||
|
||||
#include "basiccell.h"
|
||||
#include "gnc-ui.h"
|
||||
|
||||
typedef const char * (*RecnCellStringGetter)(char);
|
||||
|
||||
@ -49,6 +50,7 @@ typedef struct _RecnCell
|
||||
BasicCell cell;
|
||||
|
||||
char reconciled_flag; /* The actual flag value */
|
||||
gncUIWidget parent;
|
||||
} RecnCell;
|
||||
|
||||
RecnCell * xaccMallocRecnCell (void);
|
||||
@ -56,6 +58,8 @@ void xaccDestroyRecnCell (RecnCell *cell);
|
||||
|
||||
void xaccRecnCellSetFlag (RecnCell *cell, char reconciled_flag);
|
||||
char xaccRecnCellGetFlag (RecnCell *cell);
|
||||
|
||||
void xaccRecnCellSetParent (RecnCell *cell, gncUIWidget parent);
|
||||
|
||||
void xaccRecnCellSetStringGetter (RecnCellStringGetter getter);
|
||||
|
||||
|
@ -141,12 +141,7 @@ xaccInitSplitRegister (SplitRegister *reg,
|
||||
SplitRegisterType type,
|
||||
SplitRegisterStyle style,
|
||||
gboolean use_double_line,
|
||||
TableGetEntryHandler entry_handler,
|
||||
TableGetLabelHandler label_handler,
|
||||
TableGetCellIOFlags io_flag_handler,
|
||||
TableGetFGColorHandler fg_color_handler,
|
||||
TableGetBGColorHandler bg_color_handler,
|
||||
TableGetCellBorderHandler cell_border_handler,
|
||||
TableView *view,
|
||||
VirtCellDataAllocator allocator,
|
||||
VirtCellDataDeallocator deallocator,
|
||||
VirtCellDataCopy copy);
|
||||
@ -555,20 +550,19 @@ SplitRegister *
|
||||
xaccMallocSplitRegister (SplitRegisterType type,
|
||||
SplitRegisterStyle style,
|
||||
gboolean use_double_line,
|
||||
TableGetEntryHandler entry_handler,
|
||||
TableGetLabelHandler label_handler,
|
||||
TableGetCellIOFlags io_flag_handler,
|
||||
TableGetFGColorHandler fg_color_handler,
|
||||
TableGetBGColorHandler bg_color_handler,
|
||||
TableGetCellBorderHandler cell_border_handler,
|
||||
TableView *view,
|
||||
VirtCellDataAllocator allocator,
|
||||
VirtCellDataDeallocator deallocator,
|
||||
VirtCellDataCopy copy)
|
||||
{
|
||||
SplitRegister * reg;
|
||||
|
||||
g_return_val_if_fail (view != NULL, NULL);
|
||||
|
||||
reg = g_new0 (SplitRegister, 1);
|
||||
|
||||
view->handler_user_data = reg;
|
||||
|
||||
if (type >= NUM_SINGLE_REGISTER_TYPES)
|
||||
style = REG_STYLE_JOURNAL;
|
||||
|
||||
@ -576,12 +570,7 @@ xaccMallocSplitRegister (SplitRegisterType type,
|
||||
type,
|
||||
style,
|
||||
use_double_line,
|
||||
entry_handler,
|
||||
label_handler,
|
||||
io_flag_handler,
|
||||
fg_color_handler,
|
||||
bg_color_handler,
|
||||
cell_border_handler,
|
||||
view,
|
||||
allocator,
|
||||
deallocator,
|
||||
copy);
|
||||
@ -659,12 +648,7 @@ xaccInitSplitRegister (SplitRegister *reg,
|
||||
SplitRegisterType type,
|
||||
SplitRegisterStyle style,
|
||||
gboolean use_double_line,
|
||||
TableGetEntryHandler entry_handler,
|
||||
TableGetLabelHandler label_handler,
|
||||
TableGetCellIOFlags io_flag_handler,
|
||||
TableGetFGColorHandler fg_color_handler,
|
||||
TableGetBGColorHandler bg_color_handler,
|
||||
TableGetCellBorderHandler cell_border_handler,
|
||||
TableView *view,
|
||||
VirtCellDataAllocator allocator,
|
||||
VirtCellDataDeallocator deallocator,
|
||||
VirtCellDataCopy copy)
|
||||
@ -817,16 +801,7 @@ xaccInitSplitRegister (SplitRegister *reg,
|
||||
/* add menu items for the action cell */
|
||||
configAction (reg);
|
||||
|
||||
table = gnc_table_new (entry_handler,
|
||||
label_handler,
|
||||
io_flag_handler,
|
||||
fg_color_handler,
|
||||
bg_color_handler,
|
||||
cell_border_handler,
|
||||
reg,
|
||||
allocator,
|
||||
deallocator,
|
||||
copy);
|
||||
table = gnc_table_new (view, allocator, deallocator, copy);
|
||||
|
||||
reg->table = table;
|
||||
|
||||
|
@ -233,12 +233,7 @@ SplitRegister *
|
||||
xaccMallocSplitRegister (SplitRegisterType type,
|
||||
SplitRegisterStyle style,
|
||||
gboolean use_double_line,
|
||||
TableGetEntryHandler entry_handler,
|
||||
TableGetLabelHandler label_handler,
|
||||
TableGetCellIOFlags io_flag_handler,
|
||||
TableGetFGColorHandler fg_color_handler,
|
||||
TableGetBGColorHandler bg_color_handler,
|
||||
TableGetCellBorderHandler cell_border_handler,
|
||||
TableView *view,
|
||||
VirtCellDataAllocator allocator,
|
||||
VirtCellDataDeallocator deallocator,
|
||||
VirtCellDataCopy copy);
|
||||
|
@ -61,30 +61,20 @@ static void gnc_table_resize (Table * table, int virt_rows, int virt_cols);
|
||||
/** Implementation *****************************************************/
|
||||
|
||||
Table *
|
||||
gnc_table_new (TableGetEntryHandler entry_handler,
|
||||
TableGetLabelHandler label_handler,
|
||||
TableGetCellIOFlags io_flag_handler,
|
||||
TableGetFGColorHandler fg_color_handler,
|
||||
TableGetBGColorHandler bg_color_handler,
|
||||
TableGetCellBorderHandler cell_border_handler,
|
||||
gpointer handler_user_data,
|
||||
gnc_table_new (TableView *view,
|
||||
VirtCellDataAllocator allocator,
|
||||
VirtCellDataDeallocator deallocator,
|
||||
VirtCellDataCopy copy)
|
||||
{
|
||||
Table *table;
|
||||
|
||||
g_assert (entry_handler != NULL);
|
||||
g_return_val_if_fail (view != NULL, NULL);
|
||||
g_return_val_if_fail (view->entry_handler, NULL);
|
||||
|
||||
table = g_new0 (Table, 1);
|
||||
|
||||
table->entry_handler = entry_handler;
|
||||
table->label_handler = label_handler;
|
||||
table->io_flag_handler = io_flag_handler;
|
||||
table->fg_color_handler = fg_color_handler;
|
||||
table->bg_color_handler = bg_color_handler;
|
||||
table->cell_border_handler = cell_border_handler;
|
||||
table->handler_user_data = handler_user_data;
|
||||
table->view = *view;
|
||||
|
||||
table->vcell_data_allocator = allocator;
|
||||
table->vcell_data_deallocator = deallocator;
|
||||
table->vcell_data_copy = copy;
|
||||
@ -180,9 +170,9 @@ gnc_table_get_entry_internal (Table *table, VirtualLocation virt_loc,
|
||||
{
|
||||
const char *entry;
|
||||
|
||||
entry = table->entry_handler (virt_loc,
|
||||
conditionally_changed,
|
||||
table->handler_user_data);
|
||||
entry = table->view.entry_handler (virt_loc,
|
||||
conditionally_changed,
|
||||
table->view.handler_user_data);
|
||||
if (!entry)
|
||||
entry = "";
|
||||
|
||||
@ -219,7 +209,8 @@ gnc_table_get_entry (Table *table, VirtualLocation virt_loc)
|
||||
return cb_cell->cell->value;
|
||||
}
|
||||
|
||||
entry = table->entry_handler (virt_loc, NULL, table->handler_user_data);
|
||||
entry = table->view.entry_handler (virt_loc, NULL,
|
||||
table->view.handler_user_data);
|
||||
if (!entry)
|
||||
entry = "";
|
||||
|
||||
@ -231,10 +222,10 @@ gnc_table_get_entry (Table *table, VirtualLocation virt_loc)
|
||||
CellIOFlags
|
||||
gnc_table_get_io_flags (Table *table, VirtualLocation virt_loc)
|
||||
{
|
||||
if (!table->io_flag_handler)
|
||||
if (!table->view.io_flag_handler)
|
||||
return XACC_CELL_ALLOW_NONE;
|
||||
|
||||
return table->io_flag_handler (virt_loc, table->handler_user_data);
|
||||
return table->view.io_flag_handler (virt_loc, table->view.handler_user_data);
|
||||
}
|
||||
|
||||
/* ==================================================== */
|
||||
@ -242,10 +233,10 @@ gnc_table_get_io_flags (Table *table, VirtualLocation virt_loc)
|
||||
const char *
|
||||
gnc_table_get_label (Table *table, VirtualLocation virt_loc)
|
||||
{
|
||||
if (!table->label_handler)
|
||||
if (!table->view.label_handler)
|
||||
return "";
|
||||
|
||||
return table->label_handler (virt_loc, table->handler_user_data);
|
||||
return table->view.label_handler (virt_loc, table->view.handler_user_data);
|
||||
}
|
||||
|
||||
/* ==================================================== */
|
||||
@ -253,10 +244,11 @@ gnc_table_get_label (Table *table, VirtualLocation virt_loc)
|
||||
guint32
|
||||
gnc_table_get_fg_color (Table *table, VirtualLocation virt_loc)
|
||||
{
|
||||
if (!table->fg_color_handler)
|
||||
if (!table->view.fg_color_handler)
|
||||
return 0x0; /* black */
|
||||
|
||||
return table->fg_color_handler (virt_loc, table->handler_user_data);
|
||||
return table->view.fg_color_handler (virt_loc,
|
||||
table->view.handler_user_data);
|
||||
}
|
||||
|
||||
/* ==================================================== */
|
||||
@ -265,11 +257,11 @@ guint32
|
||||
gnc_table_get_bg_color (Table *table, VirtualLocation virt_loc,
|
||||
gboolean *hatching)
|
||||
{
|
||||
if (!table->bg_color_handler)
|
||||
if (!table->view.bg_color_handler)
|
||||
return 0xffffff; /* white */
|
||||
|
||||
return table->bg_color_handler (virt_loc, hatching,
|
||||
table->handler_user_data);
|
||||
return table->view.bg_color_handler (virt_loc, hatching,
|
||||
table->view.handler_user_data);
|
||||
}
|
||||
|
||||
/* ==================================================== */
|
||||
@ -278,10 +270,11 @@ void
|
||||
gnc_table_get_borders (Table *table, VirtualLocation virt_loc,
|
||||
PhysicalCellBorders *borders)
|
||||
{
|
||||
if (!table->cell_border_handler)
|
||||
if (!table->view.cell_border_handler)
|
||||
return;
|
||||
|
||||
table->cell_border_handler (virt_loc, borders, table->handler_user_data);
|
||||
table->view.cell_border_handler (virt_loc, borders,
|
||||
table->view.handler_user_data);
|
||||
}
|
||||
|
||||
/* ==================================================== */
|
||||
@ -713,7 +706,7 @@ gnc_table_verify_cursor_position (Table *table, VirtualLocation virt_loc)
|
||||
|
||||
/* ==================================================== */
|
||||
|
||||
void *
|
||||
gpointer
|
||||
gnc_table_get_vcell_data (Table *table, VirtualCellLocation vcell_loc)
|
||||
{
|
||||
VirtualCell *vcell;
|
||||
@ -969,7 +962,8 @@ gnc_table_modify_update(Table *table,
|
||||
int newval_len,
|
||||
int *cursor_position,
|
||||
int *start_selection,
|
||||
int *end_selection)
|
||||
int *end_selection,
|
||||
gboolean *cancelled)
|
||||
{
|
||||
gboolean changed = FALSE;
|
||||
CellModifyVerifyFunc mv;
|
||||
@ -990,6 +984,19 @@ gnc_table_modify_update(Table *table,
|
||||
|
||||
ENTER ("\n");
|
||||
|
||||
if (table->view.confirm_handler &&
|
||||
! (table->view.confirm_handler (virt_loc,
|
||||
table->view.handler_user_data)))
|
||||
{
|
||||
if (cancelled)
|
||||
*cancelled = TRUE;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (cancelled)
|
||||
*cancelled = FALSE;
|
||||
|
||||
/* OK, if there is a callback for this cell, call it */
|
||||
cb_cell = gnc_cellblock_get_cell (cb, cell_row, cell_col);
|
||||
cell = cb_cell->cell;
|
||||
@ -1039,13 +1046,13 @@ gnc_table_modify_update(Table *table,
|
||||
/* ==================================================== */
|
||||
|
||||
gboolean
|
||||
gnc_table_direct_update(Table *table,
|
||||
VirtualLocation virt_loc,
|
||||
char **newval_ptr,
|
||||
int *cursor_position,
|
||||
int *start_selection,
|
||||
int *end_selection,
|
||||
void *gui_data)
|
||||
gnc_table_direct_update (Table *table,
|
||||
VirtualLocation virt_loc,
|
||||
char **newval_ptr,
|
||||
int *cursor_position,
|
||||
int *start_selection,
|
||||
int *end_selection,
|
||||
gpointer gui_data)
|
||||
{
|
||||
CellBlockCell *cb_cell;
|
||||
gboolean result;
|
||||
@ -1071,15 +1078,26 @@ gnc_table_direct_update(Table *table,
|
||||
if (cell->direct_update == NULL)
|
||||
return FALSE;
|
||||
|
||||
old_value = g_strdup(cell->value);
|
||||
old_value = g_strdup (cell->value);
|
||||
|
||||
result = cell->direct_update(cell, cursor_position, start_selection,
|
||||
end_selection, gui_data);
|
||||
result = cell->direct_update (cell, cursor_position, start_selection,
|
||||
end_selection, gui_data);
|
||||
|
||||
if (safe_strcmp(old_value, cell->value) != 0)
|
||||
if (safe_strcmp (old_value, cell->value) != 0)
|
||||
{
|
||||
cell->changed = GNC_CELL_CHANGED;
|
||||
*newval_ptr = cell->value;
|
||||
if (table->view.confirm_handler &&
|
||||
! (table->view.confirm_handler (virt_loc,
|
||||
table->view.handler_user_data)))
|
||||
{
|
||||
xaccSetBasicCellValue (cell, old_value);
|
||||
*newval_ptr = NULL;
|
||||
result = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
cell->changed = GNC_CELL_CHANGED;
|
||||
*newval_ptr = cell->value;
|
||||
}
|
||||
}
|
||||
else
|
||||
*newval_ptr = NULL;
|
||||
@ -1090,11 +1108,11 @@ gnc_table_direct_update(Table *table,
|
||||
{
|
||||
char *help_str;
|
||||
|
||||
help_str = xaccBasicCellGetHelp(cell);
|
||||
help_str = xaccBasicCellGetHelp (cell);
|
||||
|
||||
table->set_help(table, help_str);
|
||||
table->set_help (table, help_str);
|
||||
|
||||
g_free(help_str);
|
||||
g_free (help_str);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -184,6 +184,22 @@ typedef void (*TableGetCellBorderHandler) (VirtualLocation virt_loc,
|
||||
PhysicalCellBorders *borders,
|
||||
gpointer user_data);
|
||||
|
||||
typedef gboolean (*TableConfirmHandler) (VirtualLocation virt_loc,
|
||||
gpointer user_data);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
TableGetEntryHandler entry_handler;
|
||||
TableGetLabelHandler label_handler;
|
||||
TableGetCellIOFlags io_flag_handler;
|
||||
TableGetFGColorHandler fg_color_handler;
|
||||
TableGetBGColorHandler bg_color_handler;
|
||||
TableGetCellBorderHandler cell_border_handler;
|
||||
TableConfirmHandler confirm_handler;
|
||||
|
||||
gpointer handler_user_data;
|
||||
} TableView;
|
||||
|
||||
typedef gpointer (*VirtCellDataAllocator) (void);
|
||||
typedef void (*VirtCellDataDeallocator) (gpointer user_data);
|
||||
typedef void (*VirtCellDataCopy) (gpointer to, gconstpointer from);
|
||||
@ -210,7 +226,7 @@ struct _Table
|
||||
|
||||
/* This value is initialized to NULL and never touched afterwards.
|
||||
* It can be used by higher-level code. */
|
||||
void * user_data;
|
||||
gpointer user_data;
|
||||
|
||||
/* Determines whether the passive background
|
||||
* colors alternate between odd and even virt
|
||||
@ -229,16 +245,9 @@ struct _Table
|
||||
/* The virtual cell table */
|
||||
GTable *virt_cells;
|
||||
|
||||
void * ui_data;
|
||||
gpointer ui_data;
|
||||
|
||||
TableGetEntryHandler entry_handler;
|
||||
TableGetLabelHandler label_handler;
|
||||
TableGetCellIOFlags io_flag_handler;
|
||||
TableGetFGColorHandler fg_color_handler;
|
||||
TableGetBGColorHandler bg_color_handler;
|
||||
TableGetCellBorderHandler cell_border_handler;
|
||||
|
||||
gpointer handler_user_data;
|
||||
TableView view;
|
||||
|
||||
TableDestroyFunc destroy;
|
||||
|
||||
@ -249,13 +258,7 @@ struct _Table
|
||||
|
||||
|
||||
/* Functions to create and destroy Tables. */
|
||||
Table * gnc_table_new (TableGetEntryHandler entry_handler,
|
||||
TableGetLabelHandler label_handler,
|
||||
TableGetCellIOFlags io_flag_handler,
|
||||
TableGetFGColorHandler fg_color_handler,
|
||||
TableGetBGColorHandler bg_color_handler,
|
||||
TableGetCellBorderHandler cell_border_handler,
|
||||
gpointer handler_user_data,
|
||||
Table * gnc_table_new (TableView *view,
|
||||
VirtCellDataAllocator allocator,
|
||||
VirtCellDataDeallocator deallocator,
|
||||
VirtCellDataCopy copy);
|
||||
@ -377,7 +380,7 @@ gboolean gnc_table_find_close_valid_cell (Table *table,
|
||||
/* UI-specific functions */
|
||||
|
||||
/* Initialize the GUI from a table */
|
||||
void gnc_table_init_gui (gncUIWidget widget, void *data);
|
||||
void gnc_table_init_gui (gncUIWidget widget, gpointer data);
|
||||
|
||||
/* Refresh the current cursor gui */
|
||||
void gnc_table_refresh_current_cursor_gui (Table * table,
|
||||
@ -424,7 +427,8 @@ const char * gnc_table_modify_update(Table *table,
|
||||
int newval_len,
|
||||
int *cursor_position,
|
||||
int *start_selection,
|
||||
int *end_selection);
|
||||
int *end_selection,
|
||||
gboolean *cancelled);
|
||||
|
||||
gboolean gnc_table_direct_update(Table *table,
|
||||
VirtualLocation virt_loc,
|
||||
@ -432,7 +436,7 @@ gboolean gnc_table_direct_update(Table *table,
|
||||
int *cursor_position,
|
||||
int *start_selection,
|
||||
int *end_selection,
|
||||
void *gui_data);
|
||||
gpointer gui_data);
|
||||
|
||||
gboolean gnc_table_traverse_update(Table *table,
|
||||
VirtualLocation virt_loc,
|
||||
|
Loading…
Reference in New Issue
Block a user