mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
remove last remaining traces of gui stuff from account structures.
Note that this still leaves the file RegWindow quite broken. Will fix later. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@478 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
63395a85ac
commit
917cb045bf
@ -33,6 +33,14 @@
|
||||
|
||||
int next_free_unique_account_id = 0;
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
/********************************************************************\
|
||||
* Because I can't use C++ for this project, doesn't mean that I *
|
||||
* can't pretend too! These functions perform actions on the *
|
||||
@ -69,13 +77,6 @@ mallocAccount( void )
|
||||
acc->splits = (Split **) _malloc (sizeof (Split *));
|
||||
acc->splits[0] = NULL;
|
||||
|
||||
/* private data */
|
||||
acc->arrowb = NULL;
|
||||
acc->expand = 0;
|
||||
acc->regData = NULL;
|
||||
acc->regLedger = NULL;
|
||||
acc->ledgerList = NULL;
|
||||
|
||||
return acc;
|
||||
}
|
||||
|
||||
@ -149,15 +150,6 @@ freeAccount( Account *acc )
|
||||
acc->description = NULL;
|
||||
acc->notes = NULL;
|
||||
|
||||
/* hack alert -- shouldn't we destroy this widget ??? */
|
||||
acc->arrowb = NULL;
|
||||
acc->expand = 0;
|
||||
acc->regData = NULL;
|
||||
acc->regLedger = NULL;
|
||||
|
||||
if (acc->ledgerList) _free (acc->ledgerList);
|
||||
acc->ledgerList = NULL;
|
||||
|
||||
_free(acc);
|
||||
}
|
||||
|
||||
@ -178,7 +170,7 @@ void
|
||||
xaccInsertSplit ( Account *acc, Split *split )
|
||||
{
|
||||
int i,j;
|
||||
int inserted = False;
|
||||
int inserted = FALSE;
|
||||
Split **oldsplits;
|
||||
Transaction *trans;
|
||||
|
||||
@ -186,7 +178,7 @@ xaccInsertSplit ( Account *acc, Split *split )
|
||||
if (!split) return;
|
||||
|
||||
/* mark the data file as needing to be saved: */
|
||||
if( acc->parent != NULL ) acc->parent->saved = False;
|
||||
if( acc->parent != NULL ) acc->parent->saved = FALSE;
|
||||
|
||||
split->acc = (struct _account *) acc;
|
||||
|
||||
@ -214,7 +206,7 @@ xaccInsertSplit ( Account *acc, Split *split )
|
||||
if (xaccTransOrder (&ot,&trans) > 0) {
|
||||
acc->splits[i] = split;
|
||||
j--;
|
||||
inserted = True;
|
||||
inserted = TRUE;
|
||||
} else {
|
||||
acc->splits[i] = oldsplits[j];
|
||||
}
|
||||
@ -243,7 +235,7 @@ xaccRemoveSplit ( Account *acc, Split *split )
|
||||
if (!split) return;
|
||||
|
||||
/* mark the data file as needing to be saved: */
|
||||
if( acc->parent != NULL ) acc->parent->saved = False;
|
||||
if( acc->parent != NULL ) acc->parent->saved = FALSE;
|
||||
|
||||
for( i=0,j=0; j<acc->numSplits; i++,j++ ) {
|
||||
acc->splits[i] = acc->splits[j];
|
||||
@ -405,10 +397,10 @@ xaccCheckDateOrder (Account * acc, Split *split )
|
||||
|
||||
/* figure out if the transactions are out of order */
|
||||
if (NULL != prevSplit) {
|
||||
if( xaccTransOrder (&(prevSplit->parent), &(split->parent)) >0 ) outOfOrder = True;
|
||||
if( xaccTransOrder (&(prevSplit->parent), &(split->parent)) >0 ) outOfOrder = TRUE;
|
||||
}
|
||||
if (NULL != nextSplit) {
|
||||
if( xaccTransOrder (&(split->parent), &(nextSplit->parent)) >0 ) outOfOrder = True;
|
||||
if( xaccTransOrder (&(split->parent), &(nextSplit->parent)) >0 ) outOfOrder = TRUE;
|
||||
}
|
||||
|
||||
/* take care of re-ordering, if necessary */
|
||||
|
@ -321,7 +321,7 @@ adjBOkCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||
xaccSetAmount (&(trans->credit_split), dcurrAmount - themount);
|
||||
|
||||
/* Refresh the account register window */
|
||||
regRefresh(acc->regData);
|
||||
regRefresh(acc);
|
||||
|
||||
/* Refresh the account reconcile window */
|
||||
recnRefresh (acc);
|
||||
|
24
src/Data.c
24
src/Data.c
@ -29,6 +29,14 @@
|
||||
#include "Data.h"
|
||||
#include "util.h"
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
/********************************************************************\
|
||||
* Because I can't use C++ for this project, doesn't mean that I *
|
||||
* can't pretend too! These functions perform actions on the *
|
||||
@ -43,8 +51,8 @@ AccountGroup *topgroup = 0x0;
|
||||
void
|
||||
xaccInitializeAccountGroup (AccountGroup *grp)
|
||||
{
|
||||
grp->saved = True;
|
||||
grp->new = False;
|
||||
grp->saved = TRUE;
|
||||
grp->new = FALSE;
|
||||
|
||||
grp->parent = NULL;
|
||||
grp->numAcc = 0;
|
||||
@ -96,7 +104,7 @@ xaccAccountGroupMarkSaved (AccountGroup *grp)
|
||||
int i;
|
||||
|
||||
if (!grp) return;
|
||||
grp->saved = True;
|
||||
grp->saved = TRUE;
|
||||
|
||||
for (i=0; i<grp->numAcc; i++) {
|
||||
xaccAccountGroupMarkSaved (grp->account[i]->children);
|
||||
@ -112,7 +120,7 @@ xaccAccountGroupNotSaved (AccountGroup *grp)
|
||||
int i;
|
||||
|
||||
if (!grp) return 0;
|
||||
if (False == grp->saved) return 1;
|
||||
if (FALSE == grp->saved) return 1;
|
||||
|
||||
for (i=0; i<grp->numAcc; i++) {
|
||||
not_saved = xaccAccountGroupNotSaved (grp->account[i]->children);
|
||||
@ -296,7 +304,7 @@ removeAccount( AccountGroup *grp, int num )
|
||||
int i,j;
|
||||
Account **oldAcc = grp->account;
|
||||
|
||||
grp->saved = False;
|
||||
grp->saved = FALSE;
|
||||
|
||||
grp->numAcc--;
|
||||
grp->account = (Account **)_malloc((grp->numAcc)*sizeof(Account *));
|
||||
@ -340,7 +348,7 @@ xaccRemoveGroup (AccountGroup *grp)
|
||||
grp = acc -> parent;
|
||||
if (!grp) return;
|
||||
|
||||
grp->saved = False;
|
||||
grp->saved = FALSE;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
@ -363,7 +371,7 @@ xaccRemoveAccount (Account *acc)
|
||||
|
||||
oldAcc = grp->account;
|
||||
|
||||
grp->saved = False;
|
||||
grp->saved = FALSE;
|
||||
|
||||
grp->numAcc--;
|
||||
|
||||
@ -429,7 +437,7 @@ insertAccount( AccountGroup *grp, Account *acc )
|
||||
|
||||
oldAcc = grp->account;
|
||||
|
||||
grp->saved = False;
|
||||
grp->saved = FALSE;
|
||||
|
||||
grp->numAcc++;
|
||||
grp->account = (Account **)_malloc((grp->numAcc)*sizeof(Account *));
|
||||
|
@ -45,8 +45,7 @@ xaccAccountWindowDestroy (Account *acc)
|
||||
}
|
||||
}
|
||||
|
||||
xaccDestroyRegWindow (acc->regData);
|
||||
xaccDestroyRegWindow (acc->regLedger);
|
||||
xaccDestroyRegWindow (acc);
|
||||
xaccDestroyRecnWindow (acc);
|
||||
xaccDestroyAdjBWindow (acc);
|
||||
xaccDestroyEditAccWindow (acc);
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "Transaction.h"
|
||||
#include "util.h"
|
||||
|
||||
typedef struct _RegWindow xxxRegWindow;
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
|
||||
int accListCount (Account **list)
|
||||
@ -200,7 +202,7 @@ ledgerListAdd (Account * acc, struct _RegWindow *addreg)
|
||||
if (!acc) return;
|
||||
if (!addreg) return;
|
||||
|
||||
oldlist = acc->ledgerList;
|
||||
/* oldlist = acc->ledgerList; */
|
||||
n = ledgerListCount (oldlist);
|
||||
|
||||
newlist = (struct _RegWindow **)
|
||||
@ -219,7 +221,7 @@ ledgerListAdd (Account * acc, struct _RegWindow *addreg)
|
||||
newlist[n] = addreg;
|
||||
newlist[n+1] = NULL;
|
||||
|
||||
acc->ledgerList = newlist;
|
||||
/* acc->ledgerList = newlist; */
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
@ -235,7 +237,7 @@ ledgerListRemove (Account * acc, struct _RegWindow *delreg)
|
||||
if (!acc) return;
|
||||
if (!delreg) return;
|
||||
|
||||
oldlist = acc->ledgerList;
|
||||
/* oldlist = acc->ledgerList; */
|
||||
n = ledgerListCount (oldlist);
|
||||
|
||||
newlist = (struct _RegWindow **)
|
||||
@ -256,7 +258,7 @@ ledgerListRemove (Account * acc, struct _RegWindow *delreg)
|
||||
}
|
||||
newlist[i] = NULL;
|
||||
|
||||
acc->ledgerList = newlist;
|
||||
/* acc->ledgerList = newlist; */
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
@ -271,7 +273,7 @@ ledgerListIsMember (Account * acc, struct _RegWindow *memreg)
|
||||
if (!acc) return 0;
|
||||
if (!memreg) return 0;
|
||||
|
||||
list = acc->ledgerList;
|
||||
/* list = acc->ledgerList; */
|
||||
if (!list) return 0;
|
||||
|
||||
n = 0;
|
||||
|
150
src/MainWindow.c
150
src/MainWindow.c
@ -56,6 +56,17 @@
|
||||
#include "util.h"
|
||||
#include "XferWindow.h"
|
||||
|
||||
typedef struct _MainArrow {
|
||||
|
||||
Account *account;
|
||||
Widget arrowb; /* arrow button in the main window */
|
||||
short expand; /* expand display of subaccounts in main window */
|
||||
int PreviousArrowReason; /* arrow workaround */
|
||||
|
||||
} MainArrow;
|
||||
|
||||
static MainArrow **arrowList = NULL;
|
||||
|
||||
/** PROTOTYPES ******************************************************/
|
||||
static void xaccMainWindowRedisplayBalance (void);
|
||||
static void closeMainWindow ( Widget mw, XtPointer cd, XtPointer cb );
|
||||
@ -97,6 +108,73 @@ Boolean havePixels = False;
|
||||
#define XACC_MAIN_ACC_BALN 3
|
||||
#define XACC_MAIN_NUM_COLS 4
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
MainArrow *
|
||||
xaccMainArrow (Widget acctrix, Account *acc )
|
||||
{
|
||||
MainArrow *arrowData;
|
||||
int height;
|
||||
|
||||
FETCH_FROM_LIST (MainArrow, arrowList, acc, account, arrowData);
|
||||
|
||||
/* adjust arrow size for font size */
|
||||
height = XbaeMatrixGetRowPixelHeight (acctrix);
|
||||
arrowData->arrowb = XtVaCreateManagedWidget ("accarrow",
|
||||
xmArrowButtonWidgetClass, acctrix,
|
||||
XmNwidth, height,
|
||||
XmNheight, height,
|
||||
XmNshadowThickness, 0,
|
||||
XmNarrowDirection, XmARROW_DOWN,
|
||||
NULL);
|
||||
|
||||
XtAddCallback (arrowData->arrowb, XmNactivateCallback,
|
||||
expandListCB, (XtPointer *) arrowData);
|
||||
|
||||
#define __XACC_DO_ARROW_CALLBACK
|
||||
#ifdef __XACC_DO_ARROW_CALLBACK
|
||||
/* add a button press event handler just in case the
|
||||
* XmNactivate callback is broken. See notes for the
|
||||
* ArrowEventCallback for details. -- Linas */
|
||||
arrowData->PreviousArrowReason = 0;
|
||||
XtAddEventHandler(arrowData->arrowb,
|
||||
ButtonPressMask | ButtonReleaseMask,
|
||||
False, (XtEventHandler) ArrowEventCallback,
|
||||
(XtPointer) arrowData);
|
||||
#endif /* __XACC_DO_ARROW_CALLBACK */
|
||||
|
||||
return arrowData;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
void
|
||||
xaccDestroyMainArrow (Account *acc )
|
||||
{
|
||||
MainArrow *arrowData;
|
||||
|
||||
REMOVE_FROM_LIST (MainArrow, arrowList, acc, account, arrowData);
|
||||
|
||||
if (!arrowData) return;
|
||||
|
||||
XtRemoveCallback (arrowData->arrowb, XmNactivateCallback,
|
||||
expandListCB, (XtPointer *) arrowData);
|
||||
|
||||
#ifdef __XACC_DO_ARROW_CALLBACK
|
||||
arrowData->PreviousArrowReason = 0;
|
||||
XtRemoveEventHandler (arrowData->arrowb,
|
||||
ButtonPressMask | ButtonReleaseMask,
|
||||
False, (XtEventHandler) ArrowEventCallback,
|
||||
(XtPointer) arrowData);
|
||||
#endif /* __XACC_DO_ARROW_CALLBACK */
|
||||
XtUnmanageChild (arrowData->arrowb);
|
||||
XtDestroyWidget (arrowData->arrowb);
|
||||
arrowData->arrowb = NULL;
|
||||
free (arrowData);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
* xaccMainWindowAddAcct *
|
||||
* *
|
||||
@ -175,40 +253,14 @@ xaccMainWindowAddAcct (Widget acctrix, AccountGroup *grp, int depth )
|
||||
* will be a cell-wdiget, and will be stored with the account
|
||||
* structure */
|
||||
if (acc->children) {
|
||||
/* if the arrow button doesn't exist, add it */
|
||||
if (NULL == acc->arrowb) {
|
||||
int height;
|
||||
/* adjust arrow size for font size */
|
||||
height = XbaeMatrixGetRowPixelHeight (acctrix);
|
||||
acc->arrowb = XtVaCreateManagedWidget ("accarrow",
|
||||
xmArrowButtonWidgetClass, acctrix,
|
||||
XmNwidth, height,
|
||||
XmNheight, height,
|
||||
XmNshadowThickness, 0,
|
||||
XmNarrowDirection, XmARROW_DOWN,
|
||||
NULL);
|
||||
MainArrow *arrowData;
|
||||
|
||||
XtAddCallback (acc->arrowb, XmNactivateCallback,
|
||||
expandListCB, (XtPointer *) acc);
|
||||
|
||||
#define __XACC_DO_ARROW_CALLBACK
|
||||
#ifdef __XACC_DO_ARROW_CALLBACK
|
||||
/* add a button press event handler just in case the
|
||||
* XmNactivate callback is broken. See notes for the
|
||||
* ArrowEventCallback for details. -- Linas */
|
||||
acc->PreviousArrowReason = 0;
|
||||
XtAddEventHandler(acc->arrowb,
|
||||
ButtonPressMask | ButtonReleaseMask,
|
||||
False, (XtEventHandler) ArrowEventCallback,
|
||||
(XtPointer) acc);
|
||||
#endif /* __XACC_DO_ARROW_CALLBACK */
|
||||
|
||||
}
|
||||
XbaeMatrixSetCellWidget (acctrix, currow, XACC_MAIN_ACC_ARRW, acc->arrowb);
|
||||
XtManageChild (acc->arrowb);
|
||||
arrowData = xaccMainArrow (acctrix, acc);
|
||||
XbaeMatrixSetCellWidget (acctrix, currow, XACC_MAIN_ACC_ARRW, arrowData->arrowb);
|
||||
XtManageChild (arrowData->arrowb);
|
||||
|
||||
/* recursively display children accounts */
|
||||
if (acc->expand) {
|
||||
if (arrowData->expand) {
|
||||
xaccMainWindowAddAcct (acctrix, acc->children, depth+1);
|
||||
}
|
||||
} else {
|
||||
@ -216,22 +268,8 @@ xaccMainWindowAddAcct (Widget acctrix, AccountGroup *grp, int depth )
|
||||
* arrow too. This situation can occur if a sub-account
|
||||
* has been deleted.
|
||||
*/
|
||||
if (acc->arrowb) {
|
||||
XbaeMatrixSetCellWidget (acctrix, currow, XACC_MAIN_ACC_ARRW, NULL);
|
||||
XtRemoveCallback (acc->arrowb, XmNactivateCallback,
|
||||
expandListCB, (XtPointer *) acc);
|
||||
|
||||
#ifdef __XACC_DO_ARROW_CALLBACK
|
||||
acc->PreviousArrowReason = 0;
|
||||
XtRemoveEventHandler(acc->arrowb,
|
||||
ButtonPressMask | ButtonReleaseMask,
|
||||
False, (XtEventHandler) ArrowEventCallback,
|
||||
(XtPointer) acc);
|
||||
#endif /* __XACC_DO_ARROW_CALLBACK */
|
||||
XtUnmanageChild (acc->arrowb);
|
||||
XtDestroyWidget (acc->arrowb);
|
||||
acc->arrowb = NULL;
|
||||
}
|
||||
XbaeMatrixSetCellWidget (acctrix, currow, XACC_MAIN_ACC_ARRW, NULL);
|
||||
xaccDestroyMainArrow (acc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -365,39 +403,39 @@ static void
|
||||
expandListCB( Widget mw, XtPointer pClientData, XtPointer cb)
|
||||
{
|
||||
XmAnyCallbackStruct *info = (XmAnyCallbackStruct *) cb;
|
||||
Account *acc = (Account *)pClientData;
|
||||
MainArrow *ad = (MainArrow *)pClientData;
|
||||
|
||||
/* a "fix" to avoid double invocation */
|
||||
switch ( info->reason ) {
|
||||
case XmCR_ACTIVATE:
|
||||
/* avoid double invocation */
|
||||
if (XmCR_ACTIVATE == acc->PreviousArrowReason) return;
|
||||
acc -> PreviousArrowReason = XmCR_ACTIVATE;
|
||||
if (XmCR_ACTIVATE == ad->PreviousArrowReason) return;
|
||||
ad -> PreviousArrowReason = XmCR_ACTIVATE;
|
||||
break;
|
||||
|
||||
default:
|
||||
case XmCR_ARM:
|
||||
/* avoid double invocation */
|
||||
if (XmCR_ARM == acc->PreviousArrowReason) return;
|
||||
acc -> PreviousArrowReason = XmCR_ARM;
|
||||
if (XmCR_ARM == ad->PreviousArrowReason) return;
|
||||
ad -> PreviousArrowReason = XmCR_ARM;
|
||||
return;
|
||||
}
|
||||
|
||||
/* change arrow direction, mark account as needing expansion */
|
||||
if (acc->expand) {
|
||||
acc->expand = 0;
|
||||
if (ad->expand) {
|
||||
ad->expand = 0;
|
||||
XtVaSetValues (mw,
|
||||
XmNarrowDirection, XmARROW_DOWN,
|
||||
NULL);
|
||||
} else {
|
||||
acc->expand = 1;
|
||||
ad->expand = 1;
|
||||
XtVaSetValues (mw,
|
||||
XmNarrowDirection, XmARROW_UP,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/* redraw the main window */
|
||||
selected_acc = acc;
|
||||
selected_acc = ad->account;
|
||||
refreshMainWindow ();
|
||||
}
|
||||
|
||||
|
@ -456,10 +456,9 @@ recnWindow( Widget parent, Account *acc )
|
||||
if( !startRecnWindow(parent,acc,&ddiff) )
|
||||
return NULL;
|
||||
|
||||
FETCH_FROM_LIST (RecnWindow, recnList, acc, acc, recnData);
|
||||
|
||||
setBusyCursor(parent);
|
||||
|
||||
recnData = (RecnWindow *)_malloc(sizeof(RecnWindow));
|
||||
recnData->acc = acc;
|
||||
recnData->ddiff = ddiff;
|
||||
|
||||
sprintf( title, "%s: %s", acc->accountName, RECONCILE_STR);
|
||||
@ -840,7 +839,7 @@ recnOkCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||
}
|
||||
|
||||
/* refresh the register window */
|
||||
regRefresh(recnData->acc->regData);
|
||||
regRefresh(recnData->acc);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
|
@ -78,10 +78,15 @@ typedef struct _RegWindow {
|
||||
} RegWindow;
|
||||
|
||||
|
||||
/** GLOBALS *********************************************************/
|
||||
extern Widget toplevel;
|
||||
|
||||
static RegWindow **regList = NULL; /* single-account registers */
|
||||
static RegWindow **ledgerList = NULL; /* multiple-account registers */
|
||||
|
||||
/** PROTOTYPES ******************************************************/
|
||||
RegWindow * regWindowLedger( Widget parent, Account **acclist, int type);
|
||||
void regRefresh (RegWindow * regData);
|
||||
void regRefresh (Account *acc);
|
||||
|
||||
static void closeRegWindow( Widget mw, XtPointer cd, XtPointer cb );
|
||||
static void startRecnCB( Widget mw, XtPointer cd, XtPointer cb );
|
||||
@ -90,24 +95,6 @@ static void recordCB( Widget mw, XtPointer cd, XtPointer cb );
|
||||
static void deleteCB( Widget mw, XtPointer cd, XtPointer cb );
|
||||
static void cancelCB( Widget mw, XtPointer cd, XtPointer cb );
|
||||
|
||||
|
||||
/** GLOBALS *********************************************************/
|
||||
extern Widget toplevel;
|
||||
|
||||
/********************************************************************\
|
||||
* xaccDestroyRegWindow()
|
||||
* It is enought to call just XtDestroy Widget. Any allocated
|
||||
* memory will be freed by the close callbacks.
|
||||
\********************************************************************/
|
||||
|
||||
void
|
||||
xaccDestroyRegWindow (RegWindow *regData)
|
||||
{
|
||||
if (!regData) return;
|
||||
XtDestroyWidget(regData->dialog);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* regWindowSimple *
|
||||
* opens up a register window for Account account *
|
||||
@ -125,11 +112,6 @@ regWindowSimple( Widget parent, Account *acc )
|
||||
acclist[0] = acc;
|
||||
acclist[1] = NULL;
|
||||
|
||||
/* don't allow more than one regster window for this account */
|
||||
/* hack alert -- we should raise this window to the top, if
|
||||
* we are called, and the register already exists */
|
||||
if (acc->regData) return acc->regData;
|
||||
|
||||
retval = regWindowLedger (parent, acclist, acc->type);
|
||||
return retval;
|
||||
}
|
||||
@ -151,11 +133,7 @@ regWindowAccGroup( Widget parent, Account *acc )
|
||||
Account *le;
|
||||
int n;
|
||||
|
||||
/* don't allow more than one ledger window for this account */
|
||||
/* hack alert -- we should raise this window to the top, if
|
||||
* we are called, and the ledger already exists */
|
||||
if (acc->regLedger) return acc->regLedger;
|
||||
|
||||
/* hack alert -- should search in the ledger list */
|
||||
list = xaccGroupToList (acc);
|
||||
|
||||
switch (acc->type) {
|
||||
@ -280,10 +258,9 @@ regWindowLedger( Widget parent, Account **acclist, int ledger_type )
|
||||
* create regData, compute register display type *
|
||||
\******************************************************************/
|
||||
|
||||
setBusyCursor( parent );
|
||||
/* hack this aint right quite */
|
||||
FETCH_FROM_LIST (RegWindow, regList, acclist[0], blackacc[0], regData);
|
||||
|
||||
regData = (RegWindow *)_malloc(sizeof(RegWindow));
|
||||
|
||||
/* count the number of accounts we are supposed to display,
|
||||
* and then, store them. */
|
||||
regData->numAcc = accListCount (acclist);
|
||||
@ -296,11 +273,11 @@ regWindowLedger( Widget parent, Account **acclist, int ledger_type )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
setBusyCursor( parent );
|
||||
|
||||
regData->type = ledger_type;
|
||||
|
||||
if (1 == regData->numAcc) {
|
||||
/* avoid having two open registers for one account */
|
||||
regData->blackacc[0]->regData = regData;
|
||||
windowname = regData->blackacc[0]->accountName;
|
||||
} else {
|
||||
|
||||
@ -539,7 +516,8 @@ regWindowLedger( Widget parent, Account **acclist, int ledger_type )
|
||||
/******************************************************************/
|
||||
XtManageChild(pane);
|
||||
|
||||
regRefresh( regData );
|
||||
/* hack alert -- this is wrong */
|
||||
regRefresh (regData->blackacc[0]);
|
||||
|
||||
XtPopup( regData->dialog, XtGrabNone );
|
||||
|
||||
@ -551,8 +529,12 @@ regWindowLedger( Widget parent, Account **acclist, int ledger_type )
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
void regRefresh (RegWindow * regData)
|
||||
void regRefresh (Account *acc)
|
||||
{
|
||||
RegWindow *regData;
|
||||
|
||||
FIND_IN_LIST (RegWindow, regList, acc, blackacc[0], regData);
|
||||
|
||||
/* complete GUI initialization */
|
||||
xaccLoadXferCell (regData->ledger->xfrmCell, regData->blackacc[0]->parent);
|
||||
|
||||
@ -560,6 +542,24 @@ void regRefresh (RegWindow * regData)
|
||||
xaccLoadRegister (regData->ledger, regData->blackacc[0]->splits);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
* xaccDestroyRegWindow()
|
||||
* It is enought to call just XtDestroy Widget. Any allocated
|
||||
* memory will be freed by the close callbacks.
|
||||
\********************************************************************/
|
||||
|
||||
void
|
||||
xaccDestroyRegWindow (Account *acc)
|
||||
{
|
||||
RegWindow *regData;
|
||||
|
||||
/* hack alert -- this is not correct yeah */
|
||||
REMOVE_FROM_LIST (RegWindow, regList, acc, blackacc[0], regData);
|
||||
|
||||
XtDestroyWidget(regData->dialog);
|
||||
free (regData);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
* closeRegWindow *
|
||||
* frees memory allocated for an regWindow, and other cleanup *
|
||||
@ -572,20 +572,19 @@ void regRefresh (RegWindow * regData)
|
||||
\********************************************************************/
|
||||
static void
|
||||
closeRegWindow( Widget mw, XtPointer cd, XtPointer cb )
|
||||
{
|
||||
{
|
||||
RegWindow *regData = (RegWindow *)cd;
|
||||
|
||||
/* Save any unsaved changes */
|
||||
xaccSaveRegEntry (regData->ledger);
|
||||
|
||||
regData->blackacc[0]->regData = NULL;
|
||||
regData->blackacc[0]->regLedger = NULL;
|
||||
|
||||
ledgerListRemoveList (regData->blackacc, regData);
|
||||
_free(regData);
|
||||
free(regData);
|
||||
|
||||
DEBUG("closed RegWindow\n");
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
* startAdjBCB -- open up the adjust balance window... called *
|
||||
|
@ -483,7 +483,7 @@ xferCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||
xaccInsertSplit (((Account *) (split->acc)), split);
|
||||
|
||||
/* Refresh the "from" account register window */
|
||||
regRefresh(acc->regData);
|
||||
regRefresh(acc);
|
||||
/* Refresh the "from" account reconcile window */
|
||||
recnRefresh(acc);
|
||||
|
||||
@ -491,7 +491,7 @@ xferCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||
xaccInsertSplit (((Account *) (trans->credit_split.acc)), &(trans->credit_split));
|
||||
|
||||
/* Refresh the "to" account register window */
|
||||
regRefresh(acc->regData);
|
||||
regRefresh(acc);
|
||||
/* Refresh the "to" account reconcile window */
|
||||
recnRefresh(acc);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user