26#include <guile-mappings.h>
32#include "gnucash-commands.hpp"
33#include "gnucash-core-app.hpp"
35#include "gnucash-locale-platform.h"
38#include <glib/gi18n.h>
39#include <dialog-new-user.h>
46#include <gnc-module.h>
49#include <gnc-plugin-csv-export.h>
50#include <gnc-plugin-csv-import.h>
53#include <gnc-plugin-log-replay.h>
54#include <gnc-plugin-qif-import.h>
55#include <gnc-plugin-report-system.h>
58#include <gnc-session.h>
59#include <gnc-splash.h>
60#include <gnucash-register.h>
61#include <search-core-type.h>
64#include <boost/locale.hpp>
65#include <boost/optional.hpp>
67#include <boost/nowide/args.hpp>
70#include <gnc-report.h>
71#include <gnc-locale-utils.hpp>
72#include <gnc-quotes.hpp>
74namespace bl = boost::locale;
77static QofLogModule log_module = GNC_MOD_GUI;
83 gnc_plugin_csv_export_create_plugin ();
84 gnc_plugin_csv_import_create_plugin();
86 gnc_plugin_qif_import_create_plugin ();
87 gnc_plugin_log_replay_create_plugin ();
100 {
"gnucash/import-export/ofx", 0, TRUE },
101 {
"gnucash/import-export/aqbanking", 0, TRUE },
102 {
"gnucash/python", 0, TRUE },
106 int len =
sizeof(modules) /
sizeof(*modules);
107 for (
int i = 0; i < len; i++)
109 DEBUG(
"Loading module %s started", modules[i].name);
110 gnc_update_splash_screen(modules[i].name, GNC_SPLASH_PERCENTAGE_UNKNOWN);
111 if (modules[i].optional)
112 gnc_module_load_optional(modules[i].name, modules[i].version);
114 gnc_module_load(modules[i].name, modules[i].version);
115 DEBUG(
"Loading module %s finished", modules[i].name);
120get_file_to_load (
const char* file_to_load)
122 if (file_to_load && *file_to_load !=
'\0')
123 return g_strdup(file_to_load);
129extern SCM scm_init_sw_gnome_module(
void);
133 const char *file_to_load;
137scm_run_gnucash (
void *data, [[maybe_unused]]
int argc, [[maybe_unused]]
char **argv)
139 auto user_file_spec =
static_cast<t_file_spec*
>(data);
141 scm_c_eval_string(
"(debug-set! stack 200000)");
143 auto main_mod = scm_c_resolve_module(
"gnucash utilities");
144 scm_set_current_module(main_mod);
145 scm_c_use_module(
"gnucash app-utils");
148 gnc_search_core_initialize ();
149 gnc_hook_add_dangler(HOOK_UI_SHUTDOWN, (GFunc)gnc_search_core_finalize, NULL, NULL);
153 load_gnucash_plugins();
154 load_gnucash_modules();
159 Gnucash::gnc_load_scm_config ([](
const gchar *msg)
161 gnc_update_splash_screen (msg, GNC_SPLASH_PERCENTAGE_UNKNOWN);
167 gnc_plugin_report_system_new();
173 gnc_hook_add_dangler(HOOK_UI_SHUTDOWN, (GFunc)gnc_file_quit, NULL, NULL);
179 const auto checking =
_(
"Checking Finance::Quote…");
180 gnc_update_splash_screen (checking, GNC_SPLASH_PERCENTAGE_UNKNOWN);
182 auto found = (bl::format (std::string{
_(
"Found Finance::Quote version {1}.")}) % quotes.
version()).str();
183 auto quote_sources = quotes.
sources();
185 gnc_update_splash_screen (found.c_str(), GNC_SPLASH_PERCENTAGE_UNKNOWN);
189 auto msg =
_(
"Unable to load Finance::Quote.");
190 PINFO (
"Attempt to load Finance::Quote returned this error message:\n");
191 PINFO (
"%s", err.what());
192 gnc_update_splash_screen (msg, GNC_SPLASH_PERCENTAGE_UNKNOWN);
195 gnc_hook_run(HOOK_STARTUP, NULL);
198 if (!user_file_spec->nofile && (fn = get_file_to_load (user_file_spec->file_to_load)) && *fn )
200 auto msg =
_(
"Loading data…");
201 gnc_update_splash_screen (msg, GNC_SPLASH_PERCENTAGE_UNKNOWN);
202 gnc_file_open_file(gnc_get_splash_screen(), fn, FALSE);
208 gnc_destroy_splash_screen();
209 gnc_ui_new_user_dialog();
215 gnc_destroy_splash_screen();
218 gnc_hook_run(HOOK_UI_POST_STARTUP, NULL);
219 gnc_ui_start_event_loop();
220 gnc_hook_remove_dangler(HOOK_UI_SHUTDOWN, (GFunc)gnc_file_quit);
231 Gnucash (
const char* app_name);
232 void parse_command_line (
int argc,
char **argv);
233 int start (
int argc,
char **argv);
236 void configure_program_options (
void);
238 bool m_nofile =
false;
243Gnucash::Gnucash::Gnucash (
const char *app_name) : Gnucash::CoreApp (app_name)
245 configure_program_options();
250Gnucash::Gnucash::parse_command_line (
int argc,
char **argv)
252 Gnucash::CoreApp::parse_command_line (argc, argv);
257Gnucash::Gnucash::configure_program_options (
void)
260 bpo::options_description app_options(
_(
"Application Options"));
261 app_options.add_options()
262 (
"nofile", bpo::bool_switch (&m_nofile),
263 _(
"Do not load the last file opened"));
265 m_opt_desc_display->add (app_options);
266 m_opt_desc_all.add (app_options);
270Gnucash::Gnucash::start ([[maybe_unused]]
int argc, [[maybe_unused]]
char **argv)
272 Gnucash::CoreApp::start();
276 gnc_module_system_init();
282 m_file_to_load ? m_file_to_load->c_str() :
""};
283 scm_boot_guile (argc, argv, scm_run_gnucash, &user_file_spec);
289main(
int argc,
char ** argv)
293 boost::nowide::args a(argc, argv);
296 if(!gtk_init_check (&argc, &argv))
298 std::cerr << bl::format (std::string{(
"Run '{1} --help' to see a full list of available command line options.")}) % *argv[0]
301 <<
_(
"Error: could not initialize graphical user interface and option add-price-quotes was not set.\n"
302 "Perhaps you need to set the $DISPLAY environment variable?")
307 set_platform_ctype_to_acp ();
310 application.parse_command_line (argc, argv);
311 return application.start (argc, argv);
const std::string & version() noexcept
Get the installed Finance::Quote version.
const QuoteSources & sources() noexcept
Get the available Finance::Quote sources as a std::vector.
All type declarations for the whole Gnucash engine.
File path resolution utility functions.
Gnome specific utility functions.
Plugin registration of the bi-import module.
Plugin registration of the customer_import module.
Functions providing the file history menu.
Preferences initialization function.
Generic api to store and retrieve preferences.
void gnc_quote_source_set_fq_installed(const char *version_string, const std::vector< std::string > &sources_list)
Update gnucash internal tables based on what Finance::Quote sources are installed.
void gnc_main_window_show_all_windows(void)
Shows all main windows.
void gnucash_register_add_cell_types(void)
Implementation.
void gnc_gnome_utils_init(void)
Initialize the gnome-utils library Should be run once before using any gnome-utils features.
GncMainWindow * gnc_gui_init(void)
Initialize the gnucash gui.
void gnc_shutdown(int exit_status)
Shutdown gnucash.
#define PINFO(format, args...)
Print an informational note.
#define DEBUG(format, args...)
Print a debugging message.
char * gnc_history_get_last(void)
Retrieve the name of the file most recently accessed.
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.
void gnc_prefs_reset_group(const gchar *group)
Reset all preferences in a group to their default values in the preferences backend.