1 /********************************************************************\ 2 * This program is free software; you can redistribute it and/or * 3 * modify it under the terms of the GNU General Public License as * 4 * published by the Free Software Foundation; either version 2 of * 5 * the License, or (at your option) any later version. * 6 * * 7 * This program is distributed in the hope that it will be useful, * 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 10 * GNU General Public License for more details. * 11 * * 12 * You should have received a copy of the GNU General Public License* 13 * along with this program; if not, contact: * 14 * * 15 * Free Software Foundation Voice: +1-617-542-5942 * 16 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 * 17 * Boston, MA 02110-1301, USA gnu@gnu.org * 18 * * 19 \********************************************************************/ 20 21 %module sw_app_utils 22 %{ 23 /* Includes the header in the wrapper code */ 24 #include <config.h> 25 #include <option-util.h> 26 #include <gnc-euro.h> 27 #include <gnc-exp-parser.h> 28 #include <gnc-ui-util.h> 29 #include <gnc-prefs-utils.h> 30 #include <gnc-helpers.h> 31 #include <gnc-accounting-period.h> 32 #include <gnc-session.h> 33 #include <gnc-sx-instance-model.h> 34 35 #include "gnc-engine-guile.h" 36 %} 37 38 #if defined(SWIGGUILE) 39 %{ 40 #include "guile-mappings.h" 41 42 SCM scm_init_sw_app_utils_module (void); 43 %} 44 #endif 45 46 #if defined(SWIGPYTHON) 47 %{ 48 /* avoid no previous prototype warning/error */ 49 PyObject* SWIG_init (void); 50 %} 51 %import <gnucash_core.i> 52 #endif 53 54 %import "base-typemaps.i" 55 56 typedef void (*GNCOptionChangeCallback) (gpointer user_data); 57 typedef int GNCOptionDBHandle; 58 59 void gnc_prefs_init(); 60 61 QofBook * gnc_get_current_book (void); 62 QofSession * gnc_get_current_session (void); 63 const gchar * gnc_get_current_book_tax_name (void); 64 const gchar * gnc_get_current_book_tax_type (void); 65 Account * gnc_get_current_root_account (void); 66 67 GNCOptionDB * gnc_option_db_new(SCM guile_options); 68 void gnc_option_db_destroy(GNCOptionDB *odb); 69 70 void gnc_option_db_set_option_selectable_by_name(SCM guile_option, 71 const char *section, const char *name, gboolean selectable); 72 73 #if defined(SWIGGUILE) 74 %typemap(out) GncCommodityList * { 75 SCM list = SCM_EOL; 76 GList *node; 77 78 for (node = $1; node; node = node->next) 79 list = scm_cons(gnc_quoteinfo2scm(node->data), list); 80 81 $result = scm_reverse(list); 82 } 83 84 %inline %{ 85 typedef GList GncCommodityList; 86 87 GncCommodityList * 88 gnc_commodity_table_get_quotable_commodities(const gnc_commodity_table * table); 89 %} 90 91 gnc_commodity * gnc_default_currency (void); 92 gnc_commodity * gnc_default_report_currency (void); 93 94 void gncp_option_invoke_callback(GNCOptionChangeCallback callback, void *data); 95 void gnc_option_db_register_option(GNCOptionDBHandle handle, 96 SCM guile_option); 97 98 GNCPrintAmountInfo gnc_default_print_info (gboolean use_symbol); 99 GNCPrintAmountInfo gnc_account_print_info (const Account *account, 100 gboolean use_symbol); 101 GNCPrintAmountInfo gnc_commodity_print_info (const gnc_commodity *commodity, 102 gboolean use_symbol); 103 GNCPrintAmountInfo gnc_price_print_info (const gnc_commodity *curr, 104 gboolean use_symbol); 105 GNCPrintAmountInfo gnc_share_print_info_places (int decplaces); 106 const char * xaccPrintAmount (gnc_numeric val, GNCPrintAmountInfo info); 107 108 gchar *number_to_words(gdouble val, gint64 denom); 109 const gchar *printable_value (gdouble val, gint denom); 110 111 gboolean gnc_using_unreversed_budgets (QofBook* book); 112 gboolean gnc_reverse_budget_balance (const Account *account, gboolean unreversed); 113 gboolean gnc_reverse_balance (const Account *account); 114 115 gboolean gnc_is_euro_currency(const gnc_commodity * currency); 116 gnc_numeric gnc_convert_to_euro(const gnc_commodity * currency, 117 gnc_numeric value); 118 gnc_numeric gnc_convert_from_euro(const gnc_commodity * currency, 119 gnc_numeric value); 120 121 time64 gnc_accounting_period_fiscal_start(void); 122 time64 gnc_accounting_period_fiscal_end(void); 123 124 void gnc_register_kvp_option_generator(QofIdType id_type, SCM generator); 125 126 %typemap(out) GHashTable * { 127 SCM table = scm_c_make_hash_table (g_hash_table_size($1) + 17); 128 GHashTableIter iter; 129 gpointer key, value; 130 131 g_hash_table_iter_init (&iter, $1); 132 while (g_hash_table_iter_next (&iter, &key, &value)) { 133 const GncGUID* c_guid = (const GncGUID*) key; 134 const gnc_numeric* c_numeric = (const gnc_numeric*) value; 135 SCM scm_guid = gnc_guid2scm(*c_guid); 136 SCM scm_numeric = gnc_numeric_to_scm(*c_numeric); 137 138 scm_hash_set_x(table, scm_guid, scm_numeric); 139 } 140 g_hash_table_destroy($1); 141 $result = table; 142 } 143 GHashTable* gnc_sx_all_instantiate_cashflow_all(GDate range_start, GDate range_end); 144 %clear GHashTable *; 145 #endif 146