Update to compile cleanly on a glib 2.9 system without using

deprecated functions.  Change the default so that glib deprecated
functions are not allowed with glib <= 2.10.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@12185 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
David Hampton 2005-12-27 17:20:19 +00:00
parent e9149d926a
commit 47e14c3c73
17 changed files with 304 additions and 35 deletions

View File

@ -1,3 +1,27 @@
2005-12-27 David Hampton <hampton@employees.org>
* src/gnome-utils/gnc-recurrence.c:
* src/gnome-utils/gnc-period-select.c:
* src/gnome-utils/gnc-dense-cal.c:
* src/gnome-utils/dialog-utils.c:
* src/gnome-utils/gnc-frequency.c:
* src/gnome-utils/gnc-plugin-manager.c:
* src/engine/FreqSpec.c:
* src/engine/Recurrence.c:
* src/gnome/druid-loan.c:
* src/gnome/druid-acct-period.c:
* src/gnome/dialog-sx-from-trans.c:
* src/gnome/dialog-scheduledxaction.c:
* src/gnome/dialog-sxsincelast.c:
* src/app-utils/gnc-accounting-period.c:
* lib/libqof/qof/guid.c: Update to compile cleanly on a glib
2.9/2.10 system without using deprecated functions.
* configure.in: Detect a glib 2.9 system and set appropriate
flags. Change the default so that glib deprecated functions are
not allowed with glib <= 2.10. Add arguments to allow disabling
deprecated gdk functions.
2005-12-27 Derek Atkins <derek@ihtfp.com>
* lib/goffice-0.0.4/plugins/plot_radar/gog-radar.c:

View File

@ -136,6 +136,24 @@ else
fi
AM_CONDITIONAL(HAVE_GLIB26, test "x$HAVE_GLIB26" = "xyes" )
AC_MSG_CHECKING(for GLIB - version >= 2.9.0)
if $PKG_CONFIG 'glib-2.0 >= 2.9.0'
then
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_GLIB29,1,[System has glib 2.9.0 or better])
HAVE_GLIB29=yes
else
AC_MSG_RESULT(no)
fi
AC_MSG_CHECKING([for untested GLIB versions (glib >= 2.11.0)])
if $PKG_CONFIG 'glib-2.0 >= 2.11.0'
then
AC_MSG_RESULT(yes)
HAVE_UNTESTED_GLIB=yes
else
AC_MSG_RESULT(no)
fi
AC_CHECK_HEADERS(dlfcn.h dl.h utmp.h locale.h mcheck.h unistd.h wctype.h)
DL_LIB=
@ -1257,32 +1275,6 @@ fi
### --------------------------------------------------------------------------
### Variables
### Set up all the initial variable values...
AC_ARG_ENABLE(deprecated-glib,
[ --disable-deprecated-glib don't use deprecated glib functions],
[case "${enableval}" in
no) AC_DEFINE(G_DISABLE_DEPRECATED,1,
[Don't use deprecated glib functions]) ;;
yes) ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-deprecated-glib) ;;
esac])
AC_ARG_ENABLE(deprecated-gtk,
[ --disable-deprecated-gtk don't use deprecated gtk functions],
[case "${enableval}" in
no) AC_DEFINE(GTK_DISABLE_DEPRECATED,1,
[Don't use deprecated gtk functions]) ;;
yes) ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-deprecated-gtk) ;;
esac])
AC_ARG_ENABLE(deprecated-gnome,
[ --disable-deprecated-gnome don't use deprecated gnome functions],
[case "${enableval}" in
no) AC_DEFINE(GNOME_DISABLE_DEPRECATED,1,
[Don't use deprecated gnome functions]) ;;
yes) ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-deprecated-gnome) ;;
esac])
AC_ARG_ENABLE(opt-style-install,
[ --enable-opt-style-install install everything in subdirs of --prefix],
[case "${enableval}" in
@ -1759,12 +1751,14 @@ then
AS_SCRUB_INCLUDE(GTK_CFLAGS)
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
HAVE_UNTESTED_GDK=yes
HAVE_UNTESTED_GTK=yes
PKG_CHECK_MODULES(GNOME, libgnomeui-2.0 >= 2.4)
AS_SCRUB_INCLUDE(GNOME_CFLAGS)
AC_SUBST(GNOME_CFLAGS)
AC_SUBST(GNOME_LIBS)
HAVE_UNTESTED_GNOME=yes
PKG_CHECK_MODULES(GDK_PIXBUF, gdk-pixbuf-2.0)
AS_SCRUB_INCLUDE(GDK_PIXBUF_CFLAGS)
@ -1853,6 +1847,85 @@ else
fi
fi
###-------------------------------------------------------------------------
### Selectively disable deprecated bits of glib/gdk/gtk/gnome
###-------------------------------------------------------------------------
if test x${HAVE_UNTESTED_GLIB} = "xyes"
then
allow_deprecated=true
else
allow_deprecated=false
fi
AC_ARG_ENABLE(deprecated-glib,
[ --disable-deprecated-glib don't use deprecated glib functions],
[case "${enableval}" in
no) allow_deprecated=false ;;
*) allow_deprecated=true ;;
esac]
)
if test x${allow_deprecated} != "xtrue"
then
AC_DEFINE(G_DISABLE_DEPRECATED,1, [Don't use deprecated glib functions])
fi
if test x${HAVE_UNTESTED_GDK} = "xyes"
then
allow_deprecated=true
else
allow_deprecated=false
fi
AC_ARG_ENABLE(deprecated-gdk,
[ --disable-deprecated-gdk don't use deprecated gdk functions],
[case "${enableval}" in
no) allow_deprecated=false ;;
*) allow_deprecated=true ;;
esac]
)
if test x${allow_deprecated} != "xtrue"
then
AC_DEFINE(GDK_DISABLE_DEPRECATED,1, [Don't use deprecated gdk functions])
AC_DEFINE(GDK_PIXBUF_DISABLE_DEPRECATED,1, [Don't use deprecated gdk-pixbuf functions])
fi
if test x${HAVE_UNTESTED_GTK} = "xyes"
then
allow_deprecated=true
else
allow_deprecated=false
fi
AC_ARG_ENABLE(deprecated-gtk,
[ --disable-deprecated-gtk don't use deprecated gtk functions],
[case "${enableval}" in
no) allow_deprecated=false ;;
*) allow_deprecated=true ;;
esac]
)
if test x${allow_deprecated} != "xtrue"
then
AC_DEFINE(GTK_DISABLE_DEPRECATED,1, [Don't use deprecated gtk functions])
fi
if test x${HAVE_UNTESTED_GNOME} = "xyes"
then
allow_deprecated=true
else
allow_deprecated=false
fi
AC_ARG_ENABLE(deprecated-gnome,
[ --disable-deprecated-gnome don't use deprecated gnome functions],
[case "${enableval}" in
no) allow_deprecated=false ;;
*) allow_deprecated=true ;;
esac]
)
if test x${allow_deprecated} != "xtrue"
then
AC_DEFINE(GNOME_DISABLE_DEPRECATED,1, [Don't use deprecated gnome functions])
fi
###-------------------------------------------------------------------------
### Stuff from Mac OS X Port
###-------------------------------------------------------------------------

View File

@ -57,12 +57,30 @@
/** Static global variables *****************************************/
static gboolean guid_initialized = FALSE;
static struct md5_ctx guid_context;
#ifndef HAVE_GLIB29
static GMemChunk *guid_memchunk = NULL;
#endif
/* This static indicates the debugging module that this .o belongs to. */
static QofLogModule log_module = QOF_MOD_ENGINE;
/** Memory management routines ***************************************/
#ifdef HAVE_GLIB29
GUID *
guid_malloc (void)
{
return g_slice_new(GUID);
}
void
guid_free (GUID *guid)
{
if (!guid)
return;
g_slice_free(GUID, guid);
}
#else /* !HAVE_GLIB29 */
static void
guid_memchunk_init (void)
{
@ -95,6 +113,7 @@ guid_free (GUID *guid)
g_chunk_free (guid, guid_memchunk);
}
#endif
const GUID *
@ -449,7 +468,9 @@ guid_init_only_salt(const void *salt, size_t salt_len)
void
guid_shutdown (void)
{
#ifndef HAVE_GLIB29
guid_memchunk_shutdown();
#endif
}
#define GUID_PERIOD 5000

View File

@ -58,7 +58,11 @@ gnc_accounting_period_start_gdate (GncAccountingPeriod which,
g_date_get_year(contains));
} else {
date = g_date_new();
#ifdef HAVE_GLIB29
g_date_set_time_t(date, time(NULL));
#else
g_date_set_time(date, time(NULL));
#endif
}
switch (which) {
@ -146,7 +150,11 @@ gnc_accounting_period_end_gdate (GncAccountingPeriod which,
g_date_get_year(contains));
} else {
date = g_date_new();
#ifdef HAVE_GLIB29
g_date_set_time_t(date, time(NULL));
#else
g_date_set_time(date, time(NULL));
#endif
}
switch (which) {

View File

@ -1296,7 +1296,11 @@ qofFreqSpecSetBaseDate(FreqSpec *fs, Timespec start_date)
when = g_date_new();
type = xaccFreqSpecGetType(fs);
start_t = timespecToTime_t(start_date);
#ifdef HAVE_GLIB29
g_date_set_time_t(when, start_t);
#else
g_date_set_time(when, (GTime)start_t);
#endif
/* QOF sets this before a type is assigned. */
if(type == INVALID) {
fs->type = ONCE;

View File

@ -63,10 +63,15 @@ recurrenceSet(Recurrence *r, guint16 mult, PeriodType pt, const GDate *_start)
r->ptype = VALID_PERIOD_TYPE(pt) ? pt : PERIOD_MONTH;
r->mult = (pt == PERIOD_ONCE) ? 0 : (mult > 0 ? mult : 1);
if (_start && g_date_valid(_start))
if (_start && g_date_valid(_start)) {
r->start = *_start;
else
} else {
#ifdef HAVE_GLIB29
g_date_set_time_t(&r->start, time(NULL));
#else
g_date_set_time(&r->start, time(NULL));
#endif
}
/* Some of the unusual period types also specify phase. For those
types, we ensure that the start date agrees with that phase. */

View File

@ -596,7 +596,11 @@ gnc_handle_date_accelerator (GdkEventKey *event,
GTime gtime;
gtime = time (NULL);
#ifdef HAVE_GLIB29
g_date_set_time_t (&gdate, gtime);
#else
g_date_set_time (&gdate, gtime);
#endif
break;
}

View File

@ -362,7 +362,11 @@ gnc_dense_cal_init (GncDenseCal *dcal)
GDate *tmpDate;
tmpDate = g_date_new();
#ifdef HAVE_GLIB29
g_date_set_time_t( tmpDate, time(NULL) );
#else
g_date_set_time( tmpDate, time(NULL) );
#endif
gnc_dense_cal_set_month( dcal, g_date_get_month(tmpDate) );
gnc_dense_cal_set_year( dcal, g_date_get_year(tmpDate) );
g_date_free( tmpDate );

View File

@ -644,7 +644,11 @@ gnc_frequency_save_state( GNCFrequency *gf, FreqSpec *fs, GDate *outDate )
tmpTimeT = gnc_date_edit_get_date( gf->startDate );
if ( NULL != outDate )
{
#ifdef HAVE_GLIB29
g_date_set_time_t( outDate, tmpTimeT );
#else
g_date_set_time( outDate, tmpTimeT );
#endif
}
if (NULL == fs) return;
@ -657,7 +661,11 @@ gnc_frequency_save_state( GNCFrequency *gf, FreqSpec *fs, GDate *outDate )
gnc_suspend_gui_refresh();
g_date_clear (&gd, 1);
#ifdef HAVE_GLIB29
g_date_set_time_t( &gd, tmpTimeT );
#else
g_date_set_time( &gd, tmpTimeT );
#endif
/*uift = xaccFreqSpecGetUIType( fs );*/
uift = PAGES[page].uiFTVal;
@ -695,7 +703,11 @@ gnc_frequency_save_state( GNCFrequency *gf, FreqSpec *fs, GDate *outDate )
/* month-day += (week-day - current-week-day ) % 7 */
/* week-day <- 0 */
stm.tm_mday -= ( stm.tm_wday ) % 7;
#ifdef HAVE_GLIB29
g_date_set_time_t( &gd, mktime(&stm) );
#else
g_date_set_time( &gd, mktime(&stm) );
#endif
}
/* 1 == "mon", 5 == "fri" */
@ -719,7 +731,11 @@ gnc_frequency_save_state( GNCFrequency *gf, FreqSpec *fs, GDate *outDate )
/* for-now hack: normalize to Sunday. */
g_date_to_struct_tm( &gd, &stm);
stm.tm_mday -= stm.tm_wday % 7;
#ifdef HAVE_GLIB29
g_date_set_time_t( &gd, mktime(&stm) );
#else
g_date_set_time( &gd, mktime(&stm) );
#endif
/* now, go through the check boxes and add composites based on that date. */
for ( i=0; CHECKBOX_NAMES[i]!=NULL; i++ ) {
@ -765,7 +781,11 @@ gnc_frequency_save_state( GNCFrequency *gf, FreqSpec *fs, GDate *outDate )
}
/* else, this month */
stm.tm_mday = day;
#ifdef HAVE_GLIB29
g_date_set_time_t( &gd, mktime( &stm) );
#else
g_date_set_time( &gd, mktime( &stm) );
#endif
xaccFreqSpecSetMonthly( tmpFS, &gd, tmpInt );
xaccFreqSpecCompositeAdd( fs, tmpFS );
@ -773,7 +793,11 @@ gnc_frequency_save_state( GNCFrequency *gf, FreqSpec *fs, GDate *outDate )
day = gnc_option_menu_get_active( GTK_WIDGET(o) )+1;
tmpFS = xaccFreqSpecMalloc(gnc_get_current_book ());
tmpTimeT = gnc_date_edit_get_date( gf->startDate );
#ifdef HAVE_GLIB29
g_date_set_time_t( &gd, tmpTimeT );
#else
g_date_set_time( &gd, tmpTimeT );
#endif
g_date_to_struct_tm( &gd, &stm);
if ( day >= stm.tm_mday ) {
/* next month */
@ -781,7 +805,11 @@ gnc_frequency_save_state( GNCFrequency *gf, FreqSpec *fs, GDate *outDate )
}
/* else, this month */
stm.tm_mday = day;
#ifdef HAVE_GLIB29
g_date_set_time_t( &gd, mktime( &stm ) );
#else
g_date_set_time( &gd, mktime( &stm ) );
#endif
xaccFreqSpecSetMonthly( tmpFS, &gd, tmpInt );
xaccFreqSpecCompositeAdd( fs, tmpFS );
@ -797,7 +825,11 @@ gnc_frequency_save_state( GNCFrequency *gf, FreqSpec *fs, GDate *outDate )
o = glade_xml_get_widget( gf->gxml, "monthly_day" );
day = gnc_option_menu_get_active( GTK_WIDGET(o) ) + 1;
stm.tm_mday = day;
#ifdef HAVE_GLIB29
g_date_set_time_t( &gd, mktime( &stm ) );
#else
g_date_set_time( &gd, mktime( &stm ) );
#endif
xaccFreqSpecSetMonthly( fs, &gd, tmpInt );
xaccFreqSpecSetUIType( fs, uift );
break;

View File

@ -320,7 +320,11 @@ gnc_period_select_set_show_date (GncPeriodSelect *period, const gboolean show_da
if (show_date) {
g_date_clear(&date, 1);
#ifdef HAVE_GLIB29
g_date_set_time_t(&date, time (NULL));
#else
g_date_set_time(&date, time (NULL));
#endif
gnc_period_select_set_date_common(period, &date);
} else {
gnc_period_select_set_date_common(period, NULL);

View File

@ -193,7 +193,7 @@ gnc_plugin_manager_class_init (GncPluginManagerClass *klass)
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GncPluginManagerClass, plugin_added),
NULL, NULL,
g_cclosure_marshal_VOID__POINTER,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE,
1,
GNC_TYPE_PLUGIN);
@ -202,7 +202,7 @@ gnc_plugin_manager_class_init (GncPluginManagerClass *klass)
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GncPluginManagerClass, plugin_removed),
NULL, NULL,
g_cclosure_marshal_VOID__POINTER,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE,
1,
GNC_TYPE_PLUGIN);

View File

@ -131,7 +131,11 @@ something_changed( GtkWidget *wid, gpointer d )
pt = get_pt_ui(gr);
t = gnome_date_edit_get_time(gr->gde_start);
#ifdef HAVE_GLIB29
g_date_set_time_t(&start, t);
#else
g_date_set_time(&start, t);
#endif
if (pt == GNCR_MONTH)
g_object_set(G_OBJECT(gr->nth_weekday), "visible", TRUE, NULL);
@ -239,7 +243,11 @@ gnc_recurrence_get(GncRecurrence *gr)
mult = (guint) gtk_spin_button_get_value_as_int(gr->gsb_mult);
t = gnome_date_edit_get_time(gr->gde_start);
#ifdef HAVE_GLIB29
g_date_set_time_t(&start, t);
#else
g_date_set_time(&start, t);
#endif
period = get_pt_ui(gr);
switch (period) {

View File

@ -471,9 +471,15 @@ gnc_sxed_check_changed( SchedXactionEditorDialog *sxed )
return TRUE;
}
sxEndDate = *xaccSchedXactionGetEndDate( sxed->sx );
#ifdef HAVE_GLIB29
g_date_set_time_t( &dlgEndDate,
gnc_date_edit_get_date( sxed->
endDateEntry ) );
#else
g_date_set_time( &dlgEndDate,
gnc_date_edit_get_date( sxed->
endDateEntry ) );
#endif
if ( g_date_compare( &sxEndDate, &dlgEndDate ) != 0 ) {
return TRUE;
@ -970,9 +976,15 @@ gnc_sxed_check_consistent( SchedXactionEditorDialog *sxed )
g_date_clear( &endDate, 1 );
if ( gtk_toggle_button_get_active(sxed->optEndDate) ) {
#ifdef HAVE_GLIB29
g_date_set_time_t( &endDate,
gnc_date_edit_get_date( sxed->
endDateEntry ) );
#else
g_date_set_time( &endDate,
gnc_date_edit_get_date( sxed->
endDateEntry ) );
#endif
}
/* Now, see if the user is attempting to create a SX that can't exist
@ -1027,9 +1039,15 @@ gnc_sxed_save_sx( SchedXactionEditorDialog *sxed )
if ( gtk_toggle_button_get_active(sxed->optEndDate) ) {
/* get the end date data */
#ifdef HAVE_GLIB29
g_date_set_time_t( &gdate,
gnc_date_edit_get_date(
sxed->endDateEntry ) );
#else
g_date_set_time( &gdate,
gnc_date_edit_get_date(
sxed->endDateEntry ) );
#endif
xaccSchedXactionSetEndDate( sxed->sx, &gdate );
/* set the num occurances data */
xaccSchedXactionSetNumOccur( sxed->sx, 0 );
@ -1755,7 +1773,11 @@ new_button_clicked( GtkButton *b, gpointer d )
/* Give decent initial FreqSpec for SX */
fs = xaccSchedXactionGetFreqSpec( tmpSX );
gd = g_date_new();
#ifdef HAVE_GLIB29
g_date_set_time_t( gd, time(NULL) );
#else
g_date_set_time( gd, time(NULL) );
#endif
xaccFreqSpecSetMonthly( fs, gd, 1 );
xaccFreqSpecSetUIType ( fs, UIFREQ_MONTHLY );
g_date_free( gd );

View File

@ -185,7 +185,11 @@ sxftd_get_end_info(SXFromTransInfo *sxfti)
retval.type = END_ON_DATE;
g_date_clear( &(retval.end_date), 1 );
end_tt = gnc_date_edit_get_date(sxfti->endDateGDE);
#ifdef HAVE_GLIB29
g_date_set_time_t( &(retval.end_date), end_tt);
#else
g_date_set_time( &(retval.end_date), end_tt);
#endif
return retval;
}
@ -421,7 +425,11 @@ sxftd_init( SXFromTransInfo *sxfti )
/* Setup the initial start date for user display/confirmation */
/* compute good initial date. */
start_tt = xaccTransGetDate( sxfti->trans );
#ifdef HAVE_GLIB29
g_date_set_time_t( &date, start_tt );
#else
g_date_set_time( &date, start_tt );
#endif
fs = xaccFreqSpecMalloc( gnc_get_current_book() );
sxftd_update_fs( sxfti, &date, fs );
xaccFreqSpecGetNextInstance( fs, &date, &nextDate );
@ -474,7 +482,11 @@ sxftd_compute_sx(SXFromTransInfo *sxfti)
xaccSchedXactionSetName(sx, name);
g_free(name);
#ifdef HAVE_GLIB29
g_date_set_time_t( &date, gnc_date_edit_get_date( sxfti->startDateGDE ) );
#else
g_date_set_time( &date, gnc_date_edit_get_date( sxfti->startDateGDE ) );
#endif
fs = xaccFreqSpecMalloc(gnc_get_current_book ());
sxftd_update_fs( sxfti, &date, fs );
@ -596,7 +608,11 @@ sxftd_freq_option_changed( GtkWidget *w, gpointer user_data )
FreqSpec *fs;
tmp_tt = xaccTransGetDate( sxfti->trans );
#ifdef HAVE_GLIB29
g_date_set_time_t( &date, tmp_tt );
#else
g_date_set_time( &date, tmp_tt );
#endif
fs = xaccFreqSpecMalloc( gnc_get_current_book() );
sxftd_update_fs( sxfti, &date, fs );

View File

@ -2131,7 +2131,11 @@ sxsincelast_populate( sxSinceLastData *sxsld )
sx_state = NULL;
}
g_date_set_time( &end, time(NULL) );
#ifdef HAVE_GLIB29
g_date_set_time_t( &end, time(NULL) );
#else
g_date_set_time( &end, time(NULL) );
#endif
daysInAdvance = xaccSchedXactionGetAdvanceCreation( sx );
g_date_add_days( &end, daysInAdvance );

View File

@ -223,7 +223,11 @@ prepare_remarks (AcctPeriodInfo *info)
g_date_clear (&date_now, 1);
nperiods = 0;
period_end = info->closing_date;
g_date_set_time (&date_now, time(0));
#ifdef HAVE_GLIB29
g_date_set_time_t (&date_now, time(NULL));
#else
g_date_set_time (&date_now, time(NULL));
#endif
while (0 > g_date_compare(&period_end, &date_now ))
{
@ -360,7 +364,11 @@ ap_validate_menu (GnomeDruidPage *druidpage,
}
g_date_clear (&date_now, 1);
g_date_set_time (&date_now, time(0));
#ifdef HAVE_GLIB29
g_date_set_time_t (&date_now, time(NULL));
#else
g_date_set_time (&date_now, time(NULL));
#endif
if (0 < g_date_compare(&info->closing_date, &date_now))
{
const char *msg = _("You must select closing date "
@ -460,7 +468,7 @@ ap_close_period (GnomeDruidPage *druidpage,
xaccFreqSpecGetNextInstance (info->period, &info->prev_closing_date, &info->closing_date);
/* If the next closing date is in the future, then we are done. */
if (time(0) < gnc_timet_get_day_end_gdate (&info->closing_date))
if (time(NULL) < gnc_timet_get_day_end_gdate (&info->closing_date))
{
return FALSE;
}
@ -530,7 +538,11 @@ ap_druid_create (AcctPeriodInfo *info)
info->earliest, ctime (&info->earliest));
g_date_clear (&info->closing_date, 1);
#ifdef HAVE_GLIB29
g_date_set_time_t (&info->closing_date, info->earliest);
#else
g_date_set_time (&info->closing_date, info->earliest);
#endif
g_date_clear (&info->prev_closing_date, 1);
info->prev_closing_date = info->closing_date;
g_date_add_years (&info->closing_date, 1);

View File

@ -810,7 +810,11 @@ gnc_loan_druid_data_init( LoanDruidData *ldd )
ldd->ld.principal = gnc_numeric_zero();
ldd->ld.startDate = g_date_new();
ldd->ld.varStartDate = g_date_new();
#ifdef HAVE_GLIB29
g_date_set_time_t( ldd->ld.startDate, time(NULL) );
#else
g_date_set_time( ldd->ld.startDate, time(NULL) );
#endif
ldd->ld.loanFreq = xaccFreqSpecMalloc( gnc_get_current_book() );
ldd->ld.repFreq = xaccFreqSpecMalloc( gnc_get_current_book() );
xaccFreqSpecSetMonthly( ldd->ld.repFreq, ldd->ld.startDate, 1 );
@ -2484,8 +2488,13 @@ ld_calc_upd_rem_payments( GtkWidget *w, gpointer ud )
g_date_clear( &start, 1 );
g_date_clear( &now, 1 );
#ifdef HAVE_GLIB29
g_date_set_time_t( &start, gnc_date_edit_get_date( ldd->prmStartDateGDE ) );
g_date_set_time_t( &now, time(NULL) );
#else
g_date_set_time( &start, gnc_date_edit_get_date( ldd->prmStartDateGDE ) );
g_date_set_time( &now, time(NULL) );
#endif
for ( i=0; g_date_compare( &start, &now ) < 0; i++ ) {
g_date_add_months( &start, 1 );
}
@ -2553,7 +2562,11 @@ ld_get_loan_range( LoanDruidData *ldd, GDate *start, GDate *end )
monthsTotal = ( (ldd->ld.numPer - 1)
* ( ldd->ld.perSize == MONTHS ? 1 : 12 ) );
endDateMath->tm_mon += monthsTotal;
#ifdef HAVE_GLIB29
g_date_set_time_t( end, mktime( endDateMath ) );
#else
g_date_set_time( end, mktime( endDateMath ) );
#endif
g_free( endDateMath );
}
@ -2564,12 +2577,20 @@ ld_rev_get_dates( LoanDruidData *ldd, GDate *start, GDate *end )
int range = gnc_option_menu_get_active( GTK_WIDGET(ldd->revRangeOpt) );
switch ( range ) {
case CURRENT_YEAR:
#ifdef HAVE_GLIB29
g_date_set_time_t( start, time(NULL) );
#else
g_date_set_time( start, time(NULL) );
#endif
g_date_set_dmy( start, 1, G_DATE_JANUARY, g_date_get_year( start ) );
g_date_set_dmy( end, 31, G_DATE_DECEMBER, g_date_get_year( start ) );
break;
case NOW_PLUS_ONE:
#ifdef HAVE_GLIB29
g_date_set_time_t( start, time(NULL) );
#else
g_date_set_time( start, time(NULL) );
#endif
*end = *start;
g_date_add_years( end, 1 );
break;
@ -2577,10 +2598,17 @@ ld_rev_get_dates( LoanDruidData *ldd, GDate *start, GDate *end )
ld_get_loan_range( ldd, start, end );
break;
case CUSTOM:
#ifdef HAVE_GLIB29
g_date_set_time_t( start,
gnc_date_edit_get_date( ldd->revStartDate ) );
g_date_set_time_t( end,
gnc_date_edit_get_date( ldd->revEndDate ) );
#else
g_date_set_time( start,
gnc_date_edit_get_date( ldd->revStartDate ) );
g_date_set_time( end,
gnc_date_edit_get_date( ldd->revEndDate ) );
#endif
break;
default:
PERR( "Unknown review date range option %d", range );