GnuCash  5.6-150-g038405b370+
gnc-helpers.c
1 /********************************************************************\
2  * gnc-helpers.c -- gnucash app-util helper functions *
3  * Copyright (C) 2000 Linas Vepstas *
4  * *
5  * This program is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU General Public License as *
7  * published by the Free Software Foundation; either version 2 of *
8  * the License, or (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License*
16  * along with this program; if not, contact: *
17  * *
18  * Free Software Foundation Voice: +1-617-542-5942 *
19  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
20  * Boston, MA 02110-1301, USA gnu@gnu.org *
21  * *
22 \********************************************************************/
23 
24 #include <config.h>
25 
26 #include <libguile.h>
27 #include <string.h>
28 #include "swig-runtime.h"
29 #include "guile-mappings.h"
30 
31 #include "gnc-engine.h"
32 #include "gnc-engine-guile.h"
33 #include "gnc-helpers.h"
34 #include "gnc-ui-util.h"
35 
36 
37 /* Type converters for GNCPrintAmountInfo */
38 SCM
39 gnc_printinfo2scm(GNCPrintAmountInfo info)
40 {
41  SCM info_scm = SCM_EOL;
42 
43  info_scm = scm_cons (SCM_BOOL (info.round), info_scm);
44  info_scm = scm_cons (SCM_BOOL (info.force_fit), info_scm);
45  info_scm = scm_cons (SCM_BOOL (info.monetary), info_scm);
46  info_scm = scm_cons (SCM_BOOL (info.use_locale), info_scm);
47  info_scm = scm_cons (SCM_BOOL (info.use_symbol), info_scm);
48  info_scm = scm_cons (SCM_BOOL (info.use_separators), info_scm);
49 
50  info_scm = scm_cons (scm_from_int (info.min_decimal_places), info_scm);
51  info_scm = scm_cons (scm_from_int (info.max_decimal_places), info_scm);
52 
53  info_scm = scm_cons (gnc_commodity_to_scm (info.commodity), info_scm);
54 
55  info_scm = scm_cons (scm_from_locale_symbol ("print-info"), info_scm);
56 
57  return info_scm;
58 }
59 
61 gnc_scm2printinfo(SCM info_scm)
62 {
63  GNCPrintAmountInfo info;
64 
65  /* skip type */
66  info_scm = SCM_CDR (info_scm);
67  info.commodity = gnc_scm_to_commodity (SCM_CAR (info_scm));
68 
69  info_scm = SCM_CDR (info_scm);
70  info.max_decimal_places = scm_to_int (SCM_CAR (info_scm));
71 
72  info_scm = SCM_CDR (info_scm);
73  info.min_decimal_places = scm_to_int (SCM_CAR (info_scm));
74 
75  info_scm = SCM_CDR (info_scm);
76  info.use_separators = scm_is_true (SCM_CAR (info_scm));
77 
78  info_scm = SCM_CDR (info_scm);
79  info.use_symbol = scm_is_true (SCM_CAR (info_scm));
80 
81  info_scm = SCM_CDR (info_scm);
82  info.use_locale = scm_is_true (SCM_CAR (info_scm));
83 
84  info_scm = SCM_CDR (info_scm);
85  info.monetary = scm_is_true (SCM_CAR (info_scm));
86 
87  info_scm = SCM_CDR (info_scm);
88  info.force_fit = scm_is_true (SCM_CAR (info_scm));
89 
90  info_scm = SCM_CDR (info_scm);
91  info.round = scm_is_true (SCM_CAR (info_scm));
92 
93  return info;
94 }
utility functions for the GnuCash UI
All type declarations for the whole Gnucash engine.