mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Clean up date code. Move Transaction date string routines to
Transaction.c from date.c. Move Timespec definition from Transaction.h to date.h. Use 'const char *' for date routines where appropriate. Fix a memory leak in reconcile-list.c. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2685 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
808ff64f10
commit
af7ac6c3a1
@ -1,5 +1,12 @@
|
|||||||
2000-08-21 Dave Peticolas <dave@krondo.com>
|
2000-08-21 Dave Peticolas <dave@krondo.com>
|
||||||
|
|
||||||
|
* src/gnome/reconcile-list.c (gnc_reconcile_list_fill): fix
|
||||||
|
a memory leak. xaccTransGetDateStr returns a malloc'd string.
|
||||||
|
|
||||||
|
* src/engine/: Move transaction date routines from date.c to
|
||||||
|
Transaction.c. Move definition of Timespec from Transaction.h
|
||||||
|
to date.h. Some code cleanup in date.c.
|
||||||
|
|
||||||
* src/register/QuickFill.c (qfInsertTextRec): When inserting new
|
* src/register/QuickFill.c (qfInsertTextRec): When inserting new
|
||||||
strings, don't replace older strings that are prefixes of the new
|
strings, don't replace older strings that are prefixes of the new
|
||||||
string.
|
string.
|
||||||
|
@ -1865,6 +1865,22 @@ xaccTransSetDateTS (Transaction *trans, const Timespec *ts)
|
|||||||
trans->date_posted.tv_nsec = ts->tv_nsec;
|
trans->date_posted.tv_nsec = ts->tv_nsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
xaccTransGetDateStr (Transaction *trans)
|
||||||
|
{
|
||||||
|
char buf [MAX_DATE_LENGTH];
|
||||||
|
struct tm *date;
|
||||||
|
time_t secs;
|
||||||
|
|
||||||
|
secs = xaccTransGetDate (trans);
|
||||||
|
|
||||||
|
date = localtime (&secs);
|
||||||
|
|
||||||
|
printDate(buf, date->tm_mday, date->tm_mon+1, date->tm_year +1900);
|
||||||
|
|
||||||
|
return strdup (buf);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xaccTransSetDateEnteredTS (Transaction *trans, const Timespec *ts)
|
xaccTransSetDateEnteredTS (Transaction *trans, const Timespec *ts)
|
||||||
{
|
{
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include "gnc-common.h"
|
#include "gnc-common.h"
|
||||||
#include "kvp_frame.h"
|
#include "kvp_frame.h"
|
||||||
#include "GNCId.h"
|
#include "GNCId.h"
|
||||||
|
#include "date.h"
|
||||||
|
|
||||||
|
|
||||||
/* Values for the reconciled field in Transaction: */
|
/* Values for the reconciled field in Transaction: */
|
||||||
@ -58,22 +59,6 @@ typedef struct _account_group AccountGroup;
|
|||||||
typedef struct _split Split;
|
typedef struct _split Split;
|
||||||
typedef struct _transaction Transaction;
|
typedef struct _transaction Transaction;
|
||||||
|
|
||||||
/* struct timespec64 is just like timespec except that we use
|
|
||||||
* a 64-bit signed int to store the seconds. This should adequately
|
|
||||||
* cover dates in the distant future as well as the distant past, as long
|
|
||||||
* as they're not more than a couple dozen times the age of the universe.
|
|
||||||
* Note that both gcc and the IBM Toronto xlC compiler (aka CSet,
|
|
||||||
* VisualAge, etc) correctly handle long long as a 64 bit quantity,
|
|
||||||
* even on the 32-bit Intel x86 and PowerPC architectures. I'm assuming
|
|
||||||
* that all the other modern compilers are clean on this issue too ...
|
|
||||||
*/
|
|
||||||
#ifndef SWIG /* swig 1.1p5 can't hack the long long type */
|
|
||||||
struct timespec64 {
|
|
||||||
long long int tv_sec;
|
|
||||||
long int tv_nsec;
|
|
||||||
};
|
|
||||||
#endif /* SWIG */
|
|
||||||
typedef struct timespec64 Timespec;
|
|
||||||
|
|
||||||
/** PROTOTYPES ******************************************************/
|
/** PROTOTYPES ******************************************************/
|
||||||
|
|
||||||
@ -166,15 +151,14 @@ Transaction * xaccTransLookup (const GUID *guid);
|
|||||||
* strings, numbers, and structures which aren't "official" members
|
* strings, numbers, and structures which aren't "official" members
|
||||||
* of the transaction structure. */
|
* of the transaction structure. */
|
||||||
|
|
||||||
kvp_value * xaccTransGetSlot(Transaction * trans, const char * key);
|
kvp_value * xaccTransGetSlot(Transaction * trans, const char * key);
|
||||||
void xaccTransSetSlot(Transaction * trans, const char * key,
|
void xaccTransSetSlot(Transaction * trans, const char * key,
|
||||||
const kvp_value * value);
|
const kvp_value * value);
|
||||||
|
|
||||||
/* Convert a day, month, and year to a Timespec */
|
/* Convert a day, month, and year to a Timespec */
|
||||||
Timespec gnc_dmy2timespec(int day, int month, int year);
|
Timespec gnc_dmy2timespec(int day, int month, int year);
|
||||||
|
|
||||||
/*
|
/* The xaccTransSetDateSecs() method will modify the posted date
|
||||||
* The xaccTransSetDateSecs() method will modify the posted date
|
|
||||||
* of the transaction. (Footnote: this shouldn't matter to a user,
|
* of the transaction. (Footnote: this shouldn't matter to a user,
|
||||||
* but anyone modifying the engine should understand that when
|
* but anyone modifying the engine should understand that when
|
||||||
* xaccTransCommitEdit() is called, the date order of each of the
|
* xaccTransCommitEdit() is called, the date order of each of the
|
||||||
@ -264,7 +248,15 @@ long long xaccTransGetDateL (Transaction *);
|
|||||||
void xaccTransGetDateTS (Transaction *, Timespec *);
|
void xaccTransGetDateTS (Transaction *, Timespec *);
|
||||||
void xaccTransGetDateEnteredTS (Transaction *, Timespec *);
|
void xaccTransGetDateEnteredTS (Transaction *, Timespec *);
|
||||||
|
|
||||||
/* return the number of splits */
|
/* The xaccTransGetDateStr() method will return a malloc'ed string
|
||||||
|
* representing the posted date of the transaction, or NULL if
|
||||||
|
* the argument is NULL.
|
||||||
|
*/
|
||||||
|
char * xaccTransGetDateStr (Transaction *trans);
|
||||||
|
|
||||||
|
/* The xaccTransCountSplits() method returns the number of splits
|
||||||
|
* in a transaction.
|
||||||
|
*/
|
||||||
int xaccTransCountSplits (Transaction *trans);
|
int xaccTransCountSplits (Transaction *trans);
|
||||||
|
|
||||||
|
|
||||||
|
@ -133,6 +133,7 @@ void
|
|||||||
printDateSecs (char * buff, time_t t)
|
printDateSecs (char * buff, time_t t)
|
||||||
{
|
{
|
||||||
struct tm *theTime;
|
struct tm *theTime;
|
||||||
|
|
||||||
if (!buff) return;
|
if (!buff) return;
|
||||||
|
|
||||||
theTime = localtime(&t);
|
theTime = localtime(&t);
|
||||||
@ -150,10 +151,10 @@ xaccPrintDateSecs (time_t t)
|
|||||||
return strdup (buff);
|
return strdup (buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
gnc_print_date(Timespec ts)
|
gnc_print_date(Timespec ts)
|
||||||
{
|
{
|
||||||
static char buff[256];
|
static char buff[MAX_DATE_LENGTH];
|
||||||
time_t t;
|
time_t t;
|
||||||
|
|
||||||
t = ts.tv_sec + (ts.tv_nsec / 1000000000.0);
|
t = ts.tv_sec + (ts.tv_nsec / 1000000000.0);
|
||||||
@ -186,11 +187,13 @@ scanDate(const char *buff, int *day, int *month, int *year)
|
|||||||
struct tm *now;
|
struct tm *now;
|
||||||
|
|
||||||
if (!buff) return;
|
if (!buff) return;
|
||||||
dupe = strdup (buff);
|
|
||||||
|
dupe = g_strdup (buff);
|
||||||
|
|
||||||
tmp = dupe;
|
tmp = dupe;
|
||||||
first_field = 0x0;
|
first_field = NULL;
|
||||||
second_field = 0x0;
|
second_field = NULL;
|
||||||
third_field = 0x0;
|
third_field = NULL;
|
||||||
|
|
||||||
/* use strtok to find delimiters */
|
/* use strtok to find delimiters */
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
@ -246,13 +249,12 @@ scanDate(const char *buff, int *day, int *month, int *year)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
free (dupe);
|
g_free (dupe);
|
||||||
|
|
||||||
/* if the year entered is smaller than 100, assume we mean the current
|
/* if the year entered is smaller than 100, assume we mean the current
|
||||||
century (and are not revising some roman emperor's books) */
|
century (and are not revising some roman emperor's books) */
|
||||||
if(iyear<100) {
|
if (iyear < 100)
|
||||||
iyear += ((int) ((now->tm_year+1950-iyear)/100)) * 100;
|
iyear += ((int) ((now->tm_year+1950-iyear)/100)) * 100;
|
||||||
}
|
|
||||||
|
|
||||||
if (year) *year=iyear;
|
if (year) *year=iyear;
|
||||||
if (month) *month=imonth;
|
if (month) *month=imonth;
|
||||||
@ -272,6 +274,7 @@ scanDate(const char *buff, int *day, int *month, int *year)
|
|||||||
char dateSeparator()
|
char dateSeparator()
|
||||||
{
|
{
|
||||||
char separator;
|
char separator;
|
||||||
|
|
||||||
switch(dateFormat)
|
switch(dateFormat)
|
||||||
{
|
{
|
||||||
case DATE_FORMAT_CE:
|
case DATE_FORMAT_CE:
|
||||||
@ -286,39 +289,13 @@ char dateSeparator()
|
|||||||
separator='/';
|
separator='/';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return separator;
|
return separator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************\
|
/********************************************************************\
|
||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
|
|
||||||
char *
|
|
||||||
xaccTransGetDateStr (Transaction *trans)
|
|
||||||
{
|
|
||||||
char buf [MAX_DATE_LENGTH];
|
|
||||||
time_t secs;
|
|
||||||
struct tm *date;
|
|
||||||
|
|
||||||
secs = xaccTransGetDate (trans);
|
|
||||||
|
|
||||||
date = localtime (&secs);
|
|
||||||
|
|
||||||
printDate(buf, date->tm_mday, date->tm_mon+1, date->tm_year +1900);
|
|
||||||
return strdup (buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
xaccTransSetDateStr (Transaction *trans, char *str)
|
|
||||||
{
|
|
||||||
int day, month, year;
|
|
||||||
|
|
||||||
/* hack alert -- the date string should be parsed for time values */
|
|
||||||
/* cvs has some cool date parsing/guessing code .. maybe steal
|
|
||||||
* that code from there ... */
|
|
||||||
scanDate(str, &day, &month, &year);
|
|
||||||
xaccTransSetDate (trans, day, month, year);
|
|
||||||
}
|
|
||||||
|
|
||||||
time_t
|
time_t
|
||||||
xaccDMYToSec (int day, int month, int year)
|
xaccDMYToSec (int day, int month, int year)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/********************************************************************\
|
/********************************************************************\
|
||||||
* date.h -- utility functions to handle the date (adjusting, get *
|
* date.h -- utility functions to handle the date (adjusting, get *
|
||||||
* current date, etc.) for xacc (X-Accountant) *
|
* current date, etc.) for GnuCash *
|
||||||
* Copyright (C) 1997 Robin D. Clark (rclark@cs.hmc.edu) *
|
* Copyright (C) 1997 Robin D. Clark (rclark@cs.hmc.edu) *
|
||||||
* Copyright (C) 1998, 1999, 2000 Linas Vepstas *
|
* Copyright (C) 1998, 1999, 2000 Linas Vepstas *
|
||||||
* *
|
* *
|
||||||
@ -22,14 +22,60 @@
|
|||||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
|
|
||||||
/*
|
/* hack alert -- the scan and print routines should probably be moved
|
||||||
* hack alert -- the scan and print routines should probably be moved
|
* to somewhere else. The engine really isn't involved with things
|
||||||
* to somewhere else ... the engine really isn't involved with things
|
* like printing formats. This is needed mostly by the GUI and so on.
|
||||||
* like printing formats. This is needed mostl;y by the GUI and so on.
|
* If a file-io thing needs date handling, it should do it itself,
|
||||||
* If a file-io thing needs date handling, it should do it itself, instead
|
* instead of depending on the routines here. */
|
||||||
* of depending on the routines here ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
#ifndef __XACC_DATE_H__
|
||||||
|
#define __XACC_DATE_H__
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
|
/** Constants *******************************************************/
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
DATE_FORMAT_US, /* United states: mm/dd/yyyy */
|
||||||
|
DATE_FORMAT_UK, /* Britain: dd/mm/yyyy */
|
||||||
|
DATE_FORMAT_CE, /* Continental Europe: dd.mm.yyyy */
|
||||||
|
DATE_FORMAT_ISO, /* ISO: yyyy-mm-dd */
|
||||||
|
DATE_FORMAT_LOCALE /* Take from locale information */
|
||||||
|
} DateFormat;
|
||||||
|
|
||||||
|
#define DATE_FORMAT_FIRST DATE_FORMAT_US
|
||||||
|
#define DATE_FORMAT_LAST DATE_FORMAT_LOCALE
|
||||||
|
|
||||||
|
/* the maximum length of a string created by the date printers */
|
||||||
|
#define MAX_DATE_LENGTH 11
|
||||||
|
|
||||||
|
|
||||||
|
/** Datatypes *******************************************************/
|
||||||
|
|
||||||
|
/* struct timespec64 is just like timespec except that we use a 64-bit
|
||||||
|
* signed int to store the seconds. This should adequately cover
|
||||||
|
* dates in the distant future as well as the distant past, as long as
|
||||||
|
* they're not more than a couple dozen times the age of the universe.
|
||||||
|
* Note that both gcc and the IBM Toronto xlC compiler (aka CSet,
|
||||||
|
* VisualAge, etc) correctly handle long long as a 64 bit quantity,
|
||||||
|
* even on the 32-bit Intel x86 and PowerPC architectures. I'm
|
||||||
|
* assuming that all the other modern compilers are clean on this
|
||||||
|
* issue too. */
|
||||||
|
#ifndef SWIG /* swig 1.1p5 can't hack the long long type */
|
||||||
|
struct timespec64
|
||||||
|
{
|
||||||
|
long long int tv_sec;
|
||||||
|
long int tv_nsec;
|
||||||
|
};
|
||||||
|
#endif /* SWIG */
|
||||||
|
|
||||||
|
typedef struct timespec64 Timespec;
|
||||||
|
|
||||||
|
|
||||||
|
/** Prototypes ******************************************************/
|
||||||
|
void setDateFormat(DateFormat df);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* printDate
|
* printDate
|
||||||
@ -46,6 +92,11 @@
|
|||||||
*
|
*
|
||||||
* Globals: global dateFormat value
|
* Globals: global dateFormat value
|
||||||
*/
|
*/
|
||||||
|
void printDate (char * buff, int day, int month, int year);
|
||||||
|
void printDateSecs (char * buff, time_t secs);
|
||||||
|
|
||||||
|
char * xaccPrintDateSecs (time_t secs);
|
||||||
|
const char * gnc_print_date(Timespec ts);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* scanDate
|
* scanDate
|
||||||
@ -61,6 +112,8 @@
|
|||||||
*
|
*
|
||||||
* Globals: global dateFormat value
|
* Globals: global dateFormat value
|
||||||
*/
|
*/
|
||||||
|
void scanDate (const char *buff, int *day, int *monty, int *year);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dateSeparator
|
* dateSeparator
|
||||||
* Return the field separator for the current date format
|
* Return the field separator for the current date format
|
||||||
@ -71,42 +124,8 @@
|
|||||||
*
|
*
|
||||||
* Globals: global dateFormat value
|
* Globals: global dateFormat value
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __XACC_DATE_H__
|
|
||||||
#define __XACC_DATE_H__
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
#include "Transaction.h"
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
DATE_FORMAT_US, /* United states: mm/dd/yyyy */
|
|
||||||
DATE_FORMAT_UK, /* Britain: dd/mm/yyyy */
|
|
||||||
DATE_FORMAT_CE, /* Continental Europe: dd.mm.yyyy */
|
|
||||||
DATE_FORMAT_ISO, /* ISO: yyyy-mm-dd */
|
|
||||||
DATE_FORMAT_LOCALE /* Take from locale information */
|
|
||||||
} DateFormat;
|
|
||||||
|
|
||||||
#define DATE_FORMAT_FIRST DATE_FORMAT_US
|
|
||||||
#define DATE_FORMAT_LAST DATE_FORMAT_LOCALE
|
|
||||||
/* the maximum length of a string created by sprtDate() */
|
|
||||||
#define MAX_DATE_LENGTH 11
|
|
||||||
|
|
||||||
/** PROTOTYPES ******************************************************/
|
|
||||||
void setDateFormat(DateFormat df);
|
|
||||||
void printDate (char * buff, int day, int month, int year);
|
|
||||||
void printDateSecs (char * buff, time_t secs);
|
|
||||||
|
|
||||||
char * xaccPrintDateSecs (time_t secs);
|
|
||||||
char * gnc_print_date(Timespec ts);
|
|
||||||
|
|
||||||
void scanDate (const char *buff, int *day, int *monty, int *year);
|
|
||||||
char dateSeparator(void);
|
char dateSeparator(void);
|
||||||
|
|
||||||
char * xaccTransGetDateStr (Transaction *trans);
|
|
||||||
void xaccTransSetDateStr (Transaction *trans, char *str);
|
|
||||||
|
|
||||||
time_t xaccDMYToSec (int day, int month, int year);
|
time_t xaccDMYToSec (int day, int month, int year);
|
||||||
time_t xaccScanDateS (const char *buff);
|
time_t xaccScanDateS (const char *buff);
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
char * stpcpy (char *dest, const char *src);
|
char * stpcpy (char *dest, const char *src);
|
||||||
|
|
||||||
/** GLOBALS *********************************************************/
|
/** GLOBALS *********************************************************/
|
||||||
gncLogLevel loglevel[MOD_NUM] =
|
gncLogLevel loglevel[MOD_LAST + 1] =
|
||||||
{
|
{
|
||||||
GNC_LOG_NOTHING, /* DUMMY */
|
GNC_LOG_NOTHING, /* DUMMY */
|
||||||
GNC_LOG_WARNING, /* ENGINE */
|
GNC_LOG_WARNING, /* ENGINE */
|
||||||
@ -75,7 +75,7 @@ gnc_set_log_level_global(gncLogLevel level)
|
|||||||
{
|
{
|
||||||
gncModuleType module;
|
gncModuleType module;
|
||||||
|
|
||||||
for (module = GNC_LOG_NOTHING; module < MOD_NUM; module++)
|
for (module = GNC_LOG_NOTHING; module <= MOD_LAST; module++)
|
||||||
loglevel[module] = level;
|
loglevel[module] = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,7 +446,7 @@ gnc_localeconv()
|
|||||||
return &lc;
|
return &lc;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
gnc_locale_default_currency()
|
gnc_locale_default_currency()
|
||||||
{
|
{
|
||||||
static char currency[4];
|
static char currency[4];
|
||||||
@ -758,7 +758,7 @@ xaccSPrintAmount (char * bufp, double val, GNCPrintAmountFlags flags,
|
|||||||
min_trailing_zeros, curr_code);
|
min_trailing_zeros, curr_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
xaccPrintAmount (double val, GNCPrintAmountFlags flags, const char *curr_code)
|
xaccPrintAmount (double val, GNCPrintAmountFlags flags, const char *curr_code)
|
||||||
{
|
{
|
||||||
/* hack alert -- this is not thread safe ... */
|
/* hack alert -- this is not thread safe ... */
|
||||||
@ -770,7 +770,7 @@ xaccPrintAmount (double val, GNCPrintAmountFlags flags, const char *curr_code)
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
xaccPrintAmountArgs (double val, gboolean print_currency_symbol,
|
xaccPrintAmountArgs (double val, gboolean print_currency_symbol,
|
||||||
gboolean print_separators, gboolean is_shares_value,
|
gboolean print_separators, gboolean is_shares_value,
|
||||||
const char *curr_code)
|
const char *curr_code)
|
||||||
|
@ -58,8 +58,7 @@ typedef enum
|
|||||||
MOD_GUILE = 9,
|
MOD_GUILE = 9,
|
||||||
MOD_BACKEND = 10,
|
MOD_BACKEND = 10,
|
||||||
MOD_QUERY = 11,
|
MOD_QUERY = 11,
|
||||||
MOD_LAST = 11,
|
MOD_LAST = 11
|
||||||
MOD_NUM = MOD_LAST + 1
|
|
||||||
} gncModuleType;
|
} gncModuleType;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
@ -72,7 +71,7 @@ typedef enum
|
|||||||
GNC_LOG_EVERYTHING = 5
|
GNC_LOG_EVERYTHING = 5
|
||||||
} gncLogLevel;
|
} gncLogLevel;
|
||||||
|
|
||||||
extern gncLogLevel loglevel[MOD_NUM];
|
extern gncLogLevel loglevel[MOD_LAST + 1];
|
||||||
|
|
||||||
#define LERR (1 <= loglevel[module])
|
#define LERR (1 <= loglevel[module])
|
||||||
#define LWARN (2 <= loglevel[module])
|
#define LWARN (2 <= loglevel[module])
|
||||||
@ -200,7 +199,7 @@ gboolean gnc_strisnum(const char *s);
|
|||||||
struct lconv * gnc_localeconv();
|
struct lconv * gnc_localeconv();
|
||||||
|
|
||||||
/* Returns the 3 character currency code of the current locale. */
|
/* Returns the 3 character currency code of the current locale. */
|
||||||
char * gnc_locale_default_currency();
|
const char * gnc_locale_default_currency();
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -248,8 +247,8 @@ char * gnc_locale_default_currency();
|
|||||||
|
|
||||||
typedef unsigned int GNCPrintAmountFlags;
|
typedef unsigned int GNCPrintAmountFlags;
|
||||||
|
|
||||||
char * xaccPrintAmount (double val, GNCPrintAmountFlags flags,
|
const char * xaccPrintAmount (double val, GNCPrintAmountFlags flags,
|
||||||
const char *curr_code);
|
const char *curr_code);
|
||||||
int xaccSPrintAmount (char *buf, double val, GNCPrintAmountFlags flags,
|
int xaccSPrintAmount (char *buf, double val, GNCPrintAmountFlags flags,
|
||||||
const char *curr_code);
|
const char *curr_code);
|
||||||
int xaccSPrintAmountGeneral (char * bufp, double val,
|
int xaccSPrintAmountGeneral (char * bufp, double val,
|
||||||
@ -257,11 +256,11 @@ int xaccSPrintAmountGeneral (char * bufp, double val,
|
|||||||
int precision,
|
int precision,
|
||||||
int min_trailing_zeros,
|
int min_trailing_zeros,
|
||||||
const char *curr_sym);
|
const char *curr_sym);
|
||||||
char * xaccPrintAmountArgs (double val,
|
const char * xaccPrintAmountArgs (double val,
|
||||||
gboolean print_currency_symbol,
|
gboolean print_currency_symbol,
|
||||||
gboolean print_separators,
|
gboolean print_separators,
|
||||||
gboolean is_shares_value,
|
gboolean is_shares_value,
|
||||||
const char *curr_code);
|
const char *curr_code);
|
||||||
|
|
||||||
/* Parse i18n amount strings */
|
/* Parse i18n amount strings */
|
||||||
double xaccParseAmount (const char * instr, gboolean monetary);
|
double xaccParseAmount (const char * instr, gboolean monetary);
|
||||||
|
@ -144,9 +144,9 @@ gnc_xfer_update_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data)
|
|||||||
GtkEntry *entry = GTK_ENTRY(widget);
|
GtkEntry *entry = GTK_ENTRY(widget);
|
||||||
XferDialog *xferData = data;
|
XferDialog *xferData = data;
|
||||||
Account *account;
|
Account *account;
|
||||||
gchar *new_string;
|
const char *new_string;
|
||||||
const char *currency;
|
const char *currency;
|
||||||
gchar *string;
|
const char *string;
|
||||||
double value;
|
double value;
|
||||||
|
|
||||||
account = gnc_account_tree_get_current_account(xferData->from);
|
account = gnc_account_tree_get_current_account(xferData->from);
|
||||||
@ -254,7 +254,7 @@ gnc_xfer_dialog_set_amount(XferDialog *xferData, double amount)
|
|||||||
{
|
{
|
||||||
Account *account;
|
Account *account;
|
||||||
const char *currency;
|
const char *currency;
|
||||||
gchar *string;
|
const char *string;
|
||||||
|
|
||||||
if (xferData == NULL)
|
if (xferData == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -573,7 +573,7 @@ gnc_reconcile_list_set_sort_order(GNCReconcileList *list, sort_type_t key)
|
|||||||
static void
|
static void
|
||||||
gnc_reconcile_list_fill(GNCReconcileList *list)
|
gnc_reconcile_list_fill(GNCReconcileList *list)
|
||||||
{
|
{
|
||||||
gchar *strings[list->num_columns + 1];
|
const gchar *strings[list->num_columns + 1];
|
||||||
GNCPrintAmountFlags flags = PRTSEP;
|
GNCPrintAmountFlags flags = PRTSEP;
|
||||||
GNCAccountType account_type;
|
GNCAccountType account_type;
|
||||||
gboolean reconciled;
|
gboolean reconciled;
|
||||||
@ -600,6 +600,8 @@ gnc_reconcile_list_fill(GNCReconcileList *list)
|
|||||||
|
|
||||||
for ( ; *splits != NULL; splits++)
|
for ( ; *splits != NULL; splits++)
|
||||||
{
|
{
|
||||||
|
Timespec ts;
|
||||||
|
|
||||||
split = *splits;
|
split = *splits;
|
||||||
|
|
||||||
recn = xaccSplitGetReconcile(split);
|
recn = xaccSplitGetReconcile(split);
|
||||||
@ -618,16 +620,18 @@ gnc_reconcile_list_fill(GNCReconcileList *list)
|
|||||||
|
|
||||||
trans = xaccSplitGetParent(split);
|
trans = xaccSplitGetParent(split);
|
||||||
|
|
||||||
strings[0] = xaccTransGetDateStr(trans);
|
xaccTransGetDateTS(trans, &ts);
|
||||||
strings[1] = (char *) xaccTransGetNum(trans);
|
|
||||||
strings[2] = (char *) xaccTransGetDescription(trans);
|
strings[0] = gnc_print_date(ts);
|
||||||
|
strings[1] = xaccTransGetNum(trans);
|
||||||
|
strings[2] = xaccTransGetDescription(trans);
|
||||||
strings[3] = xaccPrintAmount(DABS(amount), flags, currency);
|
strings[3] = xaccPrintAmount(DABS(amount), flags, currency);
|
||||||
|
|
||||||
reconciled = g_hash_table_lookup(list->reconciled, split) != NULL;
|
reconciled = g_hash_table_lookup(list->reconciled, split) != NULL;
|
||||||
recn = reconciled ? YREC : recn;
|
recn = reconciled ? YREC : recn;
|
||||||
strings[4] = (char *) gnc_get_reconcile_str(recn);
|
strings[4] = gnc_get_reconcile_str(recn);
|
||||||
|
|
||||||
row = gtk_clist_append(GTK_CLIST(list), strings);
|
row = gtk_clist_append(GTK_CLIST(list), (gchar **) strings);
|
||||||
gtk_clist_set_row_data(GTK_CLIST(list), row, split);
|
gtk_clist_set_row_data(GTK_CLIST(list), row, split);
|
||||||
|
|
||||||
gnc_reconcile_list_set_row_style(list, row, reconciled);
|
gnc_reconcile_list_set_row_style(list, row, reconciled);
|
||||||
|
@ -157,9 +157,9 @@ gnc_adjust_update_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data)
|
|||||||
{
|
{
|
||||||
GtkEntry *entry = GTK_ENTRY(widget);
|
GtkEntry *entry = GTK_ENTRY(widget);
|
||||||
Account *account = data;
|
Account *account = data;
|
||||||
gchar *new_string;
|
const char *new_string;
|
||||||
const char *currency;
|
const char *currency;
|
||||||
gchar *string;
|
const char *string;
|
||||||
double value;
|
double value;
|
||||||
|
|
||||||
string = gtk_entry_get_text(entry);
|
string = gtk_entry_get_text(entry);
|
||||||
@ -251,8 +251,9 @@ adjBWindow(Account *account)
|
|||||||
GtkWidget *hbox, *vbox;
|
GtkWidget *hbox, *vbox;
|
||||||
GtkWidget *amount, *date;
|
GtkWidget *amount, *date;
|
||||||
GtkWidget *label, *entry;
|
GtkWidget *label, *entry;
|
||||||
|
const char *amount_str;
|
||||||
const char *currency;
|
const char *currency;
|
||||||
gchar *string;
|
char *string;
|
||||||
|
|
||||||
tooltips = gtk_tooltips_new();
|
tooltips = gtk_tooltips_new();
|
||||||
|
|
||||||
@ -296,8 +297,8 @@ adjBWindow(Account *account)
|
|||||||
gtk_tooltips_set_tip(tooltips, amount, TOOLTIP_ADJUST_AMOUNT, NULL);
|
gtk_tooltips_set_tip(tooltips, amount, TOOLTIP_ADJUST_AMOUNT, NULL);
|
||||||
|
|
||||||
currency = xaccAccountGetCurrency(account);
|
currency = xaccAccountGetCurrency(account);
|
||||||
string = xaccPrintAmount(0.0, PRTSEP, currency);
|
amount_str = xaccPrintAmount(0.0, PRTSEP, currency);
|
||||||
gtk_entry_set_text(GTK_ENTRY(amount), string);
|
gtk_entry_set_text(GTK_ENTRY(amount), amount_str);
|
||||||
gtk_entry_select_region(GTK_ENTRY(amount), 0, -1);
|
gtk_entry_select_region(GTK_ENTRY(amount), 0, -1);
|
||||||
|
|
||||||
gtk_signal_connect(GTK_OBJECT(amount), "focus-out-event",
|
gtk_signal_connect(GTK_OBJECT(amount), "focus-out-event",
|
||||||
|
@ -171,7 +171,7 @@ recnRefresh(Account *account)
|
|||||||
static double
|
static double
|
||||||
recnRecalculateBalance(RecnWindow *recnData)
|
recnRecalculateBalance(RecnWindow *recnData)
|
||||||
{
|
{
|
||||||
char *amount;
|
const char *amount;
|
||||||
const char *currency;
|
const char *currency;
|
||||||
double debit;
|
double debit;
|
||||||
double credit;
|
double credit;
|
||||||
@ -261,8 +261,8 @@ gnc_start_recn_update_cb(GtkWidget *widget, GdkEventFocus *event,
|
|||||||
Account *account = data;
|
Account *account = data;
|
||||||
int account_type;
|
int account_type;
|
||||||
const char *currency;
|
const char *currency;
|
||||||
gchar *new_string;
|
const char *new_string;
|
||||||
gchar *string;
|
const char *string;
|
||||||
double value;
|
double value;
|
||||||
|
|
||||||
flags = PRTSYM | PRTSEP;
|
flags = PRTSYM | PRTSEP;
|
||||||
@ -307,11 +307,12 @@ startRecnWindow(GtkWidget *parent, Account *account,
|
|||||||
double *new_ending, time_t *statement_date)
|
double *new_ending, time_t *statement_date)
|
||||||
{
|
{
|
||||||
GtkWidget *dialog, *end_value, *date_value;
|
GtkWidget *dialog, *end_value, *date_value;
|
||||||
char *amount, *title;
|
|
||||||
const char *currency;
|
|
||||||
GNCAccountType account_type;
|
GNCAccountType account_type;
|
||||||
GNCPrintAmountFlags flags;
|
GNCPrintAmountFlags flags;
|
||||||
|
const char *currency;
|
||||||
|
const char *amount;
|
||||||
double dendBalance;
|
double dendBalance;
|
||||||
|
char *title;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
flags = PRTSYM | PRTSEP;
|
flags = PRTSYM | PRTSEP;
|
||||||
|
@ -95,7 +95,7 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include "basiccell.h"
|
#include "basiccell.h"
|
||||||
#include "Transaction.h" /* This is where Timespec is declared. Why? */
|
#include "date.h"
|
||||||
|
|
||||||
|
|
||||||
typedef struct _DateCell {
|
typedef struct _DateCell {
|
||||||
|
Loading…
Reference in New Issue
Block a user