void gnc_environment_setup (void) { gchar *config_path; gchar *env_path; gchar *env_parm; /* Export default parameters to the environment */ env_parm = gnc_path_get_prefix(); if (!g_setenv("GNC_HOME", env_parm, FALSE)) g_warning ("Couldn't set/override environment variable GNC_HOME."); g_free (env_parm); env_parm = gnc_path_get_bindir(); if (!g_setenv("GNC_BIN", env_parm, FALSE)) g_warning ("Couldn't set/override environment variable GNC_BIN."); g_free (env_parm); env_parm = gnc_path_get_pkglibdir(); if (!g_setenv("GNC_LIB", env_parm, FALSE)) g_warning ("Couldn't set/override environment variable GNC_LIB."); g_free (env_parm); env_parm = gnc_path_get_pkgdatadir(); if (!g_setenv("GNC_DATA", env_parm, FALSE)) g_warning ("Couldn't set/override environment variable GNC_DATA."); g_free (env_parm); env_parm = gnc_path_get_pkgsysconfdir(); if (!g_setenv("GNC_CONF", env_parm, FALSE)) g_warning ("Couldn't set/override environment variable GNC_CONF."); g_free (env_parm); env_parm = gnc_path_get_libdir(); if (!g_setenv("SYS_LIB", env_parm, FALSE)) g_warning ("Couldn't set/override environment variable SYS_LIB."); g_free (env_parm); config_path = gnc_path_get_pkgsysconfdir(); #ifdef G_OS_WIN32 { /* unhide files without extension */ gchar *pathext = g_build_path(";", ".", g_getenv("PATHEXT"), (gchar*) NULL); g_setenv("PATHEXT", pathext, TRUE); g_free(pathext); } #endif /* Parse the environment file that got installed with gnucash */ env_path = g_build_filename (config_path, "environment", NULL); gnc_environment_parse_one(env_path); g_free (env_path); /* Parse local overrides for this file */ env_path = g_build_filename (config_path, "environment.local", NULL); gnc_environment_parse_one(env_path); g_free (env_path); g_free (config_path); }
void gnc_gnome_init (int argc, char **argv, const char * version) { GError *error = NULL; gchar *prefix = gnc_path_get_prefix (); gchar *pkgsysconfdir = gnc_path_get_pkgsysconfdir (); gchar *pkgdatadir = gnc_path_get_pkgdatadir (); gchar *pkglibdir = gnc_path_get_pkglibdir (); gboolean installation_ok = TRUE; /* Verify all the various directory before proceeding */ if (!g_file_test(pkgdatadir, G_FILE_TEST_IS_DIR)) { g_critical("The installation data directory \"%s\" was not found. Your installation is incomplete and cannot be run.", pkgdatadir); installation_ok = FALSE; } if (!g_file_test(pkglibdir, G_FILE_TEST_IS_DIR)) { g_critical("The installation lib directory \"%s\" was not found. Your installation is incomplete and cannot be run.", pkglibdir); installation_ok = FALSE; } if (!g_file_test(pkgsysconfdir, G_FILE_TEST_IS_DIR)) { g_critical("The installation sysconf directory \"%s\" was not found. Your installation is incomplete and cannot be run.", pkgsysconfdir); installation_ok = FALSE; } gnc_gtk_add_rc_file(); gnucash_program = gnome_program_init( "gnucash", version, LIBGNOMEUI_MODULE, argc, argv, GNOME_PARAM_APP_PREFIX, prefix, GNOME_PARAM_APP_SYSCONFDIR, pkgsysconfdir, GNOME_PARAM_APP_DATADIR, pkgdatadir, GNOME_PARAM_APP_LIBDIR, pkglibdir, GNOME_PARAM_NONE); if (!installation_ok) { /* The following string does not need translation because if * it shows up, the program is unusable anyway. */ gnc_error_dialog(NULL, "The installation directories were not found.\n\ndatadir=%s\nlibdir=%s\nsysconfdir=%s\n\nYour installation is incomplete and cannot be run.", pkgdatadir, pkglibdir, pkgsysconfdir); /* gnc_error_dialog must not be called before gnome_program_init. */ } g_free (prefix); g_free (pkgsysconfdir); g_free (pkgdatadir); g_free (pkglibdir); /* Did the installation directory check fail? Terminate * immediately because it will inevitably fail in the glade file * lookup. */ if (!installation_ok) { /* No correct installation? Shut down immediately. */ exit(-1); } #ifdef G_OS_WIN32 /* workaround for bug #421792 */ xmlCleanupInputCallbacks(); #endif /* initialization required for gtkhtml (is it also needed for webkit?) */ gtk_widget_set_default_colormap (gdk_rgb_get_colormap ()); /* use custom icon */ { int idx; char *icon_filenames[] = {"gnucash-icon-16x16.png", "gnucash-icon-32x32.png", "gnucash-icon-48x48.png", NULL }; GList *icons = NULL; char *fullname, *name_iter; for (idx = 0; icon_filenames[idx] != NULL; idx++) { GdkPixbuf *buf = NULL; fullname = gnc_gnome_locate_pixmap(icon_filenames[idx]); if (fullname == NULL) { g_warning("couldn't find icon file [%s]", icon_filenames[idx]); continue; } buf = gnc_gnome_get_gdkpixbuf(fullname); if (buf == NULL) { g_warning("error loading image from [%s]", fullname); g_free(fullname); continue; } g_free(fullname); icons = g_list_append(icons, buf); } gtk_window_set_default_icon_list(icons); g_list_foreach(icons, (GFunc)g_object_unref, NULL); g_list_free(icons); } assistant_gconf_install_check_schemas(); return; }
int main(int argc, char ** argv) { #if !defined(G_THREADS_ENABLED) || defined(G_THREADS_IMPL_NONE) # error "No GLib thread implementation available!" #endif g_thread_init(NULL); #ifdef ENABLE_BINRELOC { GError *binreloc_error = NULL; if (!gnc_gbr_init(&binreloc_error)) { g_print("main: Error on gnc_gbr_init: %s\n", binreloc_error->message); g_error_free(binreloc_error); } } #else g_message("main: binreloc relocation support was disabled at configure time.\n"); #endif /* This should be called before gettext is initialized * The user may have configured a different language via * the environment file. */ environment_override(); #ifdef HAVE_GETTEXT { gchar *localedir = gnc_path_get_localedir(); /* setlocale(LC_ALL, ""); is already called by gtk_set_locale() via gtk_init(). */ bindtextdomain(GETTEXT_PACKAGE, localedir); textdomain(GETTEXT_PACKAGE); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); g_free(localedir); } #endif qof_log_init(); qof_log_set_default(QOF_LOG_INFO); gnucash_command_line(&argc, argv); gnc_print_unstable_message(); gnc_log_init(); gnc_module_system_init(); if (add_quotes_file) { gchar *prefix = gnc_path_get_prefix (); gchar *pkgsysconfdir = gnc_path_get_pkgsysconfdir (); gchar *pkgdatadir = gnc_path_get_pkgdatadir (); gchar *pkglibdir = gnc_path_get_pkglibdir (); /* This option needs to run without a display, so we can't initialize any GUI libraries. */ gnome_program_init( "gnucash", VERSION, LIBGNOME_MODULE, argc, argv, GNOME_PARAM_APP_PREFIX, prefix, GNOME_PARAM_APP_SYSCONFDIR, pkgsysconfdir, GNOME_PARAM_APP_DATADIR, pkgdatadir, GNOME_PARAM_APP_LIBDIR, pkglibdir, GNOME_PARAM_NONE); g_free (prefix); g_free (pkgsysconfdir); g_free (pkgdatadir); g_free (pkglibdir); scm_boot_guile(argc, argv, inner_main_add_price_quotes, 0); exit(0); /* never reached */ } gnc_gnome_init (argc, argv, VERSION); gnc_gui_init(); scm_boot_guile(argc, argv, inner_main, 0); exit(0); /* never reached */ }
void gnc_gnome_init (int argc, char **argv, const char * version) { GError *error = NULL; gchar *prefix = gnc_path_get_prefix (); gchar *pkgsysconfdir = gnc_path_get_pkgsysconfdir (); gchar *pkgdatadir = gnc_path_get_pkgdatadir (); gchar *pkglibdir = gnc_path_get_pkglibdir (); gnc_gtk_add_rc_file(); gnucash_program = gnome_program_init( "gnucash", version, LIBGNOMEUI_MODULE, argc, argv, GNOME_PARAM_APP_PREFIX, prefix, GNOME_PARAM_APP_SYSCONFDIR, pkgsysconfdir, GNOME_PARAM_APP_DATADIR, pkgdatadir, GNOME_PARAM_APP_LIBDIR, pkglibdir, GNOME_PARAM_NONE); g_free (prefix); g_free (pkgsysconfdir); g_free (pkgdatadir); g_free (pkglibdir); #ifdef G_OS_WIN32 /* workaround for bug #421792 */ xmlCleanupInputCallbacks(); #endif /* initialization required for gtkhtml */ gtk_widget_set_default_colormap (gdk_rgb_get_colormap ()); /* use custom icon */ { int idx; char *icon_filenames[] = {"gnucash-icon-16x16.png", "gnucash-icon-32x32.png", "gnucash-icon-48x48.png", NULL }; GList *icons = NULL; char *fullname, *name_iter; for (idx = 0; icon_filenames[idx] != NULL; idx++) { GdkPixbuf *buf = NULL; fullname = gnc_gnome_locate_pixmap(icon_filenames[idx]); if (fullname == NULL) { g_warning("couldn't find icon file [%s]", icon_filenames[idx]); continue; } buf = gnc_gnome_get_gdkpixbuf(fullname); if (buf == NULL) { g_warning("error loading image from [%s]", fullname); g_free(fullname); continue; } g_free(fullname); icons = g_list_append(icons, buf); } gtk_window_set_default_icon_list(icons); g_list_foreach(icons, (GFunc)g_object_unref, NULL); g_list_free(icons); } druid_gconf_install_check_schemas(); return; }