Better fix for compiling cleanly on a glib 2.9/2.10 system without

using deprecated functions.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@12195 57a11ea4-9604-0410-9ed3-97b8803252fd
zzzoldfeatures/register-rewrite
David Hampton 21 years ago
parent 9165c82cf6
commit 127f4ed2cc

@ -1,3 +1,22 @@
2005-12-28 David Hampton <hampton@employees.org>
* src/glib-compat.h:
* 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/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.[ch]: Better fix for
compiling cleanly on a glib 2.9/2.10 system without using
deprecated functions.
2005-12-28 Christian Stimming <stimming@tuhh.de>
* src/gnome-utils/dialog-options.c: Improve tooltip display for

@ -58,11 +58,7 @@ 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) {
@ -150,11 +146,7 @@ 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) {

@ -45,6 +45,7 @@
#define GNC_ACCOUNTING_PERIOD_H
#include <glib.h>
#include "glib-compat.h"
#include <time.h>
/**

@ -77,6 +77,7 @@
#include <glib.h>
#include <glib/gi18n.h>
#include "glib-compat.h"
#include <string.h>
#include <time.h>
@ -1296,11 +1297,7 @@ 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;

@ -21,6 +21,7 @@
#include "config.h"
#include <time.h>
#include <glib.h>
#include "glib-compat.h"
#include <string.h>
#include "Recurrence.h"
#include "gnc-date.h"
@ -66,11 +67,7 @@ recurrenceSet(Recurrence *r, guint16 mult, PeriodType pt, const GDate *_start)
if (_start && g_date_valid(_start)) {
r->start = *_start;
} 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

@ -0,0 +1,23 @@
/*
* glib-compat.h - GLib version compatability mappings
* Copyright (C) 2005, David Hampton <hampton@employees.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef HAVE_GLIB29
#define g_date_set_time_t g_date_set_time
#endif

@ -28,6 +28,7 @@
#include "config.h"
#include <gnome.h>
#include "glib-compat.h"
#include <glade/glade.h>
#include <gmodule.h>
#include <dlfcn.h>
@ -596,11 +597,7 @@ 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;
}

@ -24,6 +24,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include "glib-compat.h"
#include <math.h>
#include "gnc-dense-cal.h"
@ -362,11 +363,7 @@ 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 );

@ -25,6 +25,7 @@
#include "config.h"
#include <gtk/gtk.h>
#include "glib-compat.h"
#include <math.h>
#include <time.h>
@ -644,11 +645,7 @@ 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;
@ -661,11 +658,7 @@ 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;
@ -703,11 +696,7 @@ 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" */
@ -731,11 +720,7 @@ 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++ ) {
@ -781,11 +766,7 @@ 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 );
@ -793,11 +774,7 @@ 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 */
@ -805,11 +782,7 @@ 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 );
@ -825,11 +798,7 @@ 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;

@ -33,6 +33,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include "glib-compat.h"
#include "gnc-date.h"
#include "gnc-gconf-utils.h"
@ -320,11 +321,7 @@ 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);

@ -25,6 +25,7 @@
#include "config.h"
#include <gnome.h>
#include "glib-compat.h"
#include <glade/glade.h>
#include "dialog-utils.h"
@ -131,11 +132,7 @@ 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);
@ -243,11 +240,7 @@ 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) {

@ -25,6 +25,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include "glib-compat.h"
#include <locale.h>
#include <time.h>
@ -471,15 +472,9 @@ 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;
@ -976,15 +971,9 @@ 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
@ -1039,15 +1028,9 @@ 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 );
@ -1773,11 +1756,7 @@ 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 );

@ -26,6 +26,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include "glib-compat.h"
#include "gnc-engine.h"
#include "SX-book.h"
@ -185,11 +186,7 @@ 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;
}
@ -425,11 +422,7 @@ 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 );
@ -482,11 +475,7 @@ 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 );
@ -608,11 +597,7 @@ 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 );

@ -51,6 +51,7 @@
#include <gnome.h>
#include <glib/gi18n.h>
#include "glib-compat.h"
#include <limits.h>
#include "Account.h"
@ -2131,11 +2132,7 @@ sxsincelast_populate( sxSinceLastData *sxsld )
sx_state = 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 );

@ -26,6 +26,7 @@
#include <gnome.h>
#include <glib/gi18n.h>
#include "glib-compat.h"
#include "FreqSpec.h"
#include "Group.h"
@ -223,11 +224,7 @@ prepare_remarks (AcctPeriodInfo *info)
g_date_clear (&date_now, 1);
nperiods = 0;
period_end = info->closing_date;
#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 ))
{
@ -364,11 +361,7 @@ ap_validate_menu (GnomeDruidPage *druidpage,
}
g_date_clear (&date_now, 1);
#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 "
@ -538,11 +531,7 @@ 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);

@ -25,6 +25,7 @@
#include <gnome.h>
#include <glib/gi18n.h>
#include "glib-compat.h"
#include <string.h>
#include <glade/glade.h>
#include <math.h>
@ -810,11 +811,7 @@ 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 );
@ -2488,13 +2485,8 @@ 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 );
}
@ -2562,11 +2554,7 @@ 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 );
}
@ -2577,20 +2565,12 @@ 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;
@ -2598,17 +2578,10 @@ 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 );

Loading…
Cancel
Save