26 #include <guile-mappings.h> 32 #include "gnucash-commands.hpp" 33 #include "gnucash-core-app.hpp" 35 #include <glib/gi18n.h> 36 #include <dialog-new-user.h> 42 #include <gnc-hooks.h> 43 #include <gnc-module.h> 46 #include <gnc-plugin-csv-export.h> 47 #include <gnc-plugin-csv-import.h> 50 #include <gnc-plugin-log-replay.h> 51 #include <gnc-plugin-qif-import.h> 52 #include <gnc-plugin-report-system.h> 55 #include <gnc-session.h> 56 #include <gnc-splash.h> 57 #include <gnucash-register.h> 58 #include <search-core-type.h> 59 #include <top-level.h> 61 #include <boost/locale.hpp> 62 #include <boost/optional.hpp> 64 #include <boost/nowide/args.hpp> 67 #include <gnc-report.h> 68 #include <gnc-locale-utils.hpp> 69 #include <gnc-quotes.hpp> 71 namespace bl = boost::locale;
74 static QofLogModule log_module = GNC_MOD_GUI;
77 load_gnucash_plugins()
80 gnc_plugin_csv_export_create_plugin ();
81 gnc_plugin_csv_import_create_plugin();
83 gnc_plugin_qif_import_create_plugin ();
84 gnc_plugin_log_replay_create_plugin ();
88 load_gnucash_modules()
97 {
"gnucash/import-export/ofx", 0, TRUE },
98 {
"gnucash/import-export/aqbanking", 0, TRUE },
99 {
"gnucash/python", 0, TRUE },
103 int len =
sizeof(modules) /
sizeof(*modules);
104 for (
int i = 0; i < len; i++)
106 DEBUG(
"Loading module %s started", modules[i].name);
107 gnc_update_splash_screen(modules[i].name, GNC_SPLASH_PERCENTAGE_UNKNOWN);
108 if (modules[i].optional)
109 gnc_module_load_optional(modules[i].name, modules[i].version);
111 gnc_module_load(modules[i].name, modules[i].version);
112 DEBUG(
"Loading module %s finished", modules[i].name);
117 get_file_to_load (
const char* file_to_load)
119 if (file_to_load && *file_to_load !=
'\0')
120 return g_strdup(file_to_load);
126 extern SCM scm_init_sw_gnome_module(
void);
130 const char *file_to_load;
134 scm_run_gnucash (
void *data, [[maybe_unused]]
int argc, [[maybe_unused]]
char **argv)
136 auto user_file_spec =
static_cast<t_file_spec*
>(data);
138 scm_c_eval_string(
"(debug-set! stack 200000)");
140 auto main_mod = scm_c_resolve_module(
"gnucash utilities");
141 scm_set_current_module(main_mod);
142 scm_c_use_module(
"gnucash app-utils");
145 gnc_search_core_initialize ();
146 gnc_hook_add_dangler(HOOK_UI_SHUTDOWN, (GFunc)gnc_search_core_finalize, NULL, NULL);
150 load_gnucash_plugins();
151 load_gnucash_modules();
156 Gnucash::gnc_load_scm_config ([](
const gchar *msg)
158 gnc_update_splash_screen (msg, GNC_SPLASH_PERCENTAGE_UNKNOWN);
164 gnc_plugin_report_system_new();
170 gnc_hook_add_dangler(HOOK_UI_SHUTDOWN, (GFunc)gnc_file_quit, NULL, NULL);
176 const auto checking = _(
"Checking Finance::Quote…");
177 gnc_update_splash_screen (checking, GNC_SPLASH_PERCENTAGE_UNKNOWN);
179 auto found = (bl::format (std::string{_(
"Found Finance::Quote version {1}.")}) % quotes.
version()).str();
180 auto quote_sources = quotes.
sources();
182 gnc_update_splash_screen (found.c_str(), GNC_SPLASH_PERCENTAGE_UNKNOWN);
186 auto msg = _(
"Unable to load Finance::Quote.");
187 PINFO (
"Attempt to load Finance::Quote returned this error message:\n");
188 PINFO (
"%s", err.what());
189 gnc_update_splash_screen (msg, GNC_SPLASH_PERCENTAGE_UNKNOWN);
192 gnc_hook_run(HOOK_STARTUP, NULL);
195 if (!user_file_spec->nofile && (fn = get_file_to_load (user_file_spec->file_to_load)) && *fn )
197 auto msg = _(
"Loading data…");
198 gnc_update_splash_screen (msg, GNC_SPLASH_PERCENTAGE_UNKNOWN);
199 gnc_file_open_file(gnc_get_splash_screen(), fn, FALSE);
205 gnc_destroy_splash_screen();
206 gnc_ui_new_user_dialog();
212 gnc_destroy_splash_screen();
215 gnc_hook_run(HOOK_UI_POST_STARTUP, NULL);
216 gnc_ui_start_event_loop();
217 gnc_hook_remove_dangler(HOOK_UI_SHUTDOWN, (GFunc)gnc_file_quit);
228 Gnucash (
const char* app_name);
229 void parse_command_line (
int argc,
char **argv);
230 int start (
int argc,
char **argv);
233 void configure_program_options (
void);
235 bool m_nofile =
false;
240 Gnucash::Gnucash::Gnucash (
const char *app_name) :
Gnucash::CoreApp (app_name)
242 configure_program_options();
247 Gnucash::Gnucash::parse_command_line (
int argc,
char **argv)
249 Gnucash::CoreApp::parse_command_line (argc, argv);
254 Gnucash::Gnucash::configure_program_options (
void)
257 bpo::options_description app_options(_(
"Application Options"));
258 app_options.add_options()
259 (
"nofile", bpo::bool_switch (&m_nofile),
260 _(
"Do not load the last file opened"));
262 m_opt_desc_display->add (app_options);
263 m_opt_desc_all.add (app_options);
267 Gnucash::Gnucash::start ([[maybe_unused]]
int argc, [[maybe_unused]]
char **argv)
269 Gnucash::CoreApp::start();
273 gnc_module_system_init();
279 m_file_to_load ? m_file_to_load->c_str() :
""};
280 scm_boot_guile (argc, argv, scm_run_gnucash, &user_file_spec);
286 main(
int argc,
char ** argv)
290 boost::nowide::args a(argc, argv);
293 if(!gtk_init_check (&argc, &argv))
295 std::cerr << bl::format (std::string{(
"Run '{1} --help' to see a full list of available command line options.")}) % *argv[0]
298 << _(
"Error: could not initialize graphical user interface and option add-price-quotes was not set.\n" 299 "Perhaps you need to set the $DISPLAY environment variable?")
304 application.parse_command_line (argc, argv);
305 return application.start (argc, argv);
void gnc_prefs_reset_group(const gchar *group)
Reset all preferences in a group to their default values in the preferences backend.
#define PINFO(format, args...)
Print an informational note.
#define DEBUG(format, args...)
Print a debugging message.
void gnc_shutdown(int exit_status)
Shutdown gnucash.
void gnc_main_window_show_all_windows(void)
Shows all main windows.
char * gnc_history_get_last(void)
Retrieve the name of the file most recently accessed.
Functions providing the file history menu.
Preferences initialization function.
Gnome specific utility functions.
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.
All type declarations for the whole Gnucash engine.
void gnc_gnome_utils_init(void)
Initialize the gnome-utils library Should be run once before using any gnome-utils features...
Generic api to store and retrieve preferences.
Plugin registration of the bi-import module.
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.
GncMainWindow * gnc_gui_init(void)
Initialize the gnucash gui.
void gnucash_register_add_cell_types(void)
Implementation.
File path resolution utility functions.
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.
Plugin registration of the customer_import module.