2001-08-17 00:44:01 +00:00
|
|
|
/********************************************************************\
|
2006-10-15 19:02:05 +00:00
|
|
|
* gnc-helpers.c -- gnucash app-util helper functions *
|
2001-08-17 00:44:01 +00:00
|
|
|
* Copyright (C) 2000 Linas Vepstas *
|
|
|
|
|
* *
|
|
|
|
|
* 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, contact: *
|
|
|
|
|
* *
|
|
|
|
|
* Free Software Foundation Voice: +1-617-542-5942 *
|
2005-11-17 05:35:02 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
|
|
|
|
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
2001-08-17 00:44:01 +00:00
|
|
|
* *
|
|
|
|
|
\********************************************************************/
|
|
|
|
|
|
2017-10-26 11:14:21 +02:00
|
|
|
#include <config.h>
|
2001-08-17 00:44:01 +00:00
|
|
|
|
2003-02-22 08:15:53 +00:00
|
|
|
#include <libguile.h>
|
2001-08-17 00:44:01 +00:00
|
|
|
#include <string.h>
|
2006-10-15 19:02:05 +00:00
|
|
|
#include "swig-runtime.h"
|
2019-04-27 13:23:54 -07:00
|
|
|
#include "guile-mappings.h"
|
2001-08-17 00:44:01 +00:00
|
|
|
|
2005-11-02 03:32:36 +00:00
|
|
|
#include "gnc-engine.h"
|
2019-10-05 16:48:37 +02:00
|
|
|
#include "gnc-engine-guile.h"
|
2001-08-18 08:18:58 +00:00
|
|
|
#include "gnc-helpers.h"
|
|
|
|
|
#include "gnc-ui-util.h"
|
|
|
|
|
|
|
|
|
|
|
2001-08-17 00:44:01 +00:00
|
|
|
/* Type converters for GNCPrintAmountInfo */
|
|
|
|
|
SCM
|
|
|
|
|
gnc_printinfo2scm(GNCPrintAmountInfo info)
|
|
|
|
|
{
|
2009-12-29 20:12:48 +00:00
|
|
|
SCM info_scm = SCM_EOL;
|
2001-08-17 00:44:01 +00:00
|
|
|
|
2009-12-29 20:12:48 +00:00
|
|
|
info_scm = scm_cons (SCM_BOOL (info.round), info_scm);
|
|
|
|
|
info_scm = scm_cons (SCM_BOOL (info.force_fit), info_scm);
|
|
|
|
|
info_scm = scm_cons (SCM_BOOL (info.monetary), info_scm);
|
|
|
|
|
info_scm = scm_cons (SCM_BOOL (info.use_locale), info_scm);
|
|
|
|
|
info_scm = scm_cons (SCM_BOOL (info.use_symbol), info_scm);
|
|
|
|
|
info_scm = scm_cons (SCM_BOOL (info.use_separators), info_scm);
|
2001-08-17 00:44:01 +00:00
|
|
|
|
2012-12-15 17:58:58 +00:00
|
|
|
info_scm = scm_cons (scm_from_int (info.min_decimal_places), info_scm);
|
|
|
|
|
info_scm = scm_cons (scm_from_int (info.max_decimal_places), info_scm);
|
2001-08-17 00:44:01 +00:00
|
|
|
|
2009-12-29 20:12:48 +00:00
|
|
|
info_scm = scm_cons (gnc_commodity_to_scm (info.commodity), info_scm);
|
2001-08-17 00:44:01 +00:00
|
|
|
|
2012-12-15 17:58:58 +00:00
|
|
|
info_scm = scm_cons (scm_from_locale_symbol ("print-info"), info_scm);
|
2001-08-17 00:44:01 +00:00
|
|
|
|
2009-12-29 20:12:48 +00:00
|
|
|
return info_scm;
|
2001-08-17 00:44:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GNCPrintAmountInfo
|
|
|
|
|
gnc_scm2printinfo(SCM info_scm)
|
|
|
|
|
{
|
2009-12-29 20:12:48 +00:00
|
|
|
GNCPrintAmountInfo info;
|
2001-08-17 00:44:01 +00:00
|
|
|
|
2009-12-29 20:12:48 +00:00
|
|
|
/* skip type */
|
|
|
|
|
info_scm = SCM_CDR (info_scm);
|
|
|
|
|
info.commodity = gnc_scm_to_commodity (SCM_CAR (info_scm));
|
2001-08-17 00:44:01 +00:00
|
|
|
|
2009-12-29 20:12:48 +00:00
|
|
|
info_scm = SCM_CDR (info_scm);
|
2012-12-15 17:58:58 +00:00
|
|
|
info.max_decimal_places = scm_to_int (SCM_CAR (info_scm));
|
2001-08-17 00:44:01 +00:00
|
|
|
|
2009-12-29 20:12:48 +00:00
|
|
|
info_scm = SCM_CDR (info_scm);
|
2012-12-15 17:58:58 +00:00
|
|
|
info.min_decimal_places = scm_to_int (SCM_CAR (info_scm));
|
2001-08-17 00:44:01 +00:00
|
|
|
|
2009-12-29 20:12:48 +00:00
|
|
|
info_scm = SCM_CDR (info_scm);
|
2009-12-31 14:41:12 +00:00
|
|
|
info.use_separators = scm_is_true (SCM_CAR (info_scm));
|
2001-08-17 00:44:01 +00:00
|
|
|
|
2009-12-29 20:12:48 +00:00
|
|
|
info_scm = SCM_CDR (info_scm);
|
2009-12-31 14:41:12 +00:00
|
|
|
info.use_symbol = scm_is_true (SCM_CAR (info_scm));
|
2001-08-17 00:44:01 +00:00
|
|
|
|
2009-12-29 20:12:48 +00:00
|
|
|
info_scm = SCM_CDR (info_scm);
|
2009-12-31 14:41:12 +00:00
|
|
|
info.use_locale = scm_is_true (SCM_CAR (info_scm));
|
2001-08-17 00:44:01 +00:00
|
|
|
|
2009-12-29 20:12:48 +00:00
|
|
|
info_scm = SCM_CDR (info_scm);
|
2009-12-31 14:41:12 +00:00
|
|
|
info.monetary = scm_is_true (SCM_CAR (info_scm));
|
2001-08-17 00:44:01 +00:00
|
|
|
|
2009-12-29 20:12:48 +00:00
|
|
|
info_scm = SCM_CDR (info_scm);
|
2009-12-31 14:41:12 +00:00
|
|
|
info.force_fit = scm_is_true (SCM_CAR (info_scm));
|
2002-12-16 01:40:26 +00:00
|
|
|
|
2009-12-29 20:12:48 +00:00
|
|
|
info_scm = SCM_CDR (info_scm);
|
2009-12-31 14:41:12 +00:00
|
|
|
info.round = scm_is_true (SCM_CAR (info_scm));
|
2002-12-16 01:40:26 +00:00
|
|
|
|
2009-12-29 20:12:48 +00:00
|
|
|
return info;
|
2001-08-17 00:44:01 +00:00
|
|
|
}
|