Ejemplo n.º 1
0
/* Searches for a file fragment paths set via GNC_DOC_PATH environment
 * variable. If this variable is not set, fall back to search in
 * - a html directory in the local user's gnucash settings directory
 *   (typically $HOME/.gnucash/html)
 * - the gnucash documentation directory
 *   (typically /usr/share/doc/gnucash)
 * - the gnucash data directory
 *   (typically /usr/share/gnucash)
 * It searches in this order.
 *
 * This is used by gnc_path_find_localized_file to search for
 * localized versions of files if they exist.
 */
static gchar *
gnc_path_find_localized_html_file_internal (const gchar * file_name)
{
    gchar *full_path = NULL;
    int i;
    const gchar *env_doc_path = g_getenv("GNC_DOC_PATH");
    const gchar *default_dirs[] =
        {
            gnc_build_dotgnucash_path ("html"),
            gnc_path_get_pkgdocdir (),
            gnc_path_get_pkgdatadir (),
            NULL
        };
    gchar **dirs;

    if (!file_name || *file_name == '\0')
        return NULL;

    /* Allow search path override via GNC_DOC_PATH environment variable */
    if (env_doc_path)
        dirs = g_strsplit (env_doc_path, G_SEARCHPATH_SEPARATOR_S, -1);
    else
        dirs = (gchar **)default_dirs;

    for (i = 0; dirs[i]; i++)
    {
        full_path = g_build_filename (dirs[i], file_name, (gchar *)NULL);
        DEBUG ("Checking for existence of %s", full_path);
        full_path = check_path_return_if_valid (full_path);
        if (full_path != NULL)
            return full_path;
    }

    return NULL;
}
Ejemplo n.º 2
0
/** Returns the file path to the report directory, usually
 * "$prefix/share/gnucash/scm/gnucash/report".
 *
 * @returns A newly allocated string. */
gchar *gnc_path_get_reportdir()
{
    gchar *result;
    const gchar *builddir = g_getenv ("GNC_BUILDDIR");
    if (g_getenv ("GNC_UNINSTALLED") && builddir)
    {
        result = g_build_filename (builddir, "gnucash", "report", NULL);
    }
    else
    {
        /* Careful: if the autoconf macro GNC_SCM_INSTALL_DIR gets changed
         * in configure.ac, this path should probably change as well.
         * Currently this code assumes GNC_SCM_INSTALL_DIR is set to
         * pkgdatadir/scm
         * We can't use the AC_MACRO GNC_SCM_INSTALL_DIR here directly
         * because that's expanded at build time. On Windows and OS X
         * the final path may get installed in a different location
         * than assumed during build, invalidating the build path at
         * runtime.
         */
        gchar *pkgdatadir = gnc_path_get_pkgdatadir ();
        result = g_build_filename (pkgdatadir, "scm",
                                   "gnucash", "report", (char*)NULL);
        g_free (pkgdatadir);
    }
    //printf("Returning stdreportsdir %s\n", result);
    return result;
}
Ejemplo n.º 3
0
/** Returns the gtkbuilder file path, usually
 * "$prefix/share/gnucash/gtkbuilder".
 *
 * @returns A newly allocated string. */
gchar *gnc_path_get_gtkbuilderdir()
{
    gchar *pkgdatadir = gnc_path_get_pkgdatadir ();
    gchar *result = g_build_filename (pkgdatadir, "gtkbuilder", (char*)NULL);
    g_free (pkgdatadir);
    //printf("Returning gtkbuilderdir %s\n", result);
    return result;
}
Ejemplo n.º 4
0
/** Returns the accounts file path, usually
 * "$prefix/share/gnucash/accounts".
 *
 * @returns A newly allocated string. */
gchar *gnc_path_get_accountsdir()
{
    gchar *pkgdatadir = gnc_path_get_pkgdatadir ();
    gchar *result = g_build_filename (pkgdatadir, "accounts", (char*)NULL);
    g_free (pkgdatadir);
    //printf("Returning accountsdir %s\n", result);
    return result;
}
Ejemplo n.º 5
0
/** Returns the file path to the report directory, usually
 * "$prefix/share/gnucash/guile-modules/gnucash/report".
 *
 * @returns A newly allocated string. */
gchar *gnc_path_get_reportdir()
{
    gchar *pkgdatadir = gnc_path_get_pkgdatadir ();
    gchar *result = g_build_filename (pkgdatadir, "guile-modules",
            "gnucash", "report", (char*)NULL);
    g_free (pkgdatadir);
    //printf("Returning stdreportsdir %s\n", result);
    return result;
}
Ejemplo n.º 6
0
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);
}
Ejemplo n.º 7
0
/** @brief Create an absolute path when given a relative path;
 *  otherwise return the argument.
 *
 *  @warning filefrag should be a simple path fragment. It shouldn't
 *  contain xml:// or http:// or <whatever>:// other protocol specifiers.
 *
 *  If passed a string which g_path_is_absolute declares an absolute
 *  path, return the argument.
 *
 *  Otherwise, assume that filefrag is a well-formed relative path and
 *  try to find a file with its path relative to
 *  \li  the current working directory,
 *  \li the installed system-wide data directory (e.g., /usr/local/share/gnucash),
 *  \li the installed system configuration directory (e.g., /usr/local/etc/gnucash),
 *  \li or in the user's configuration directory (e.g., $HOME/.gnucash/data)
 *
 *  The paths are searched for in that order. If a matching file is
 *  found, return the absolute path to it.

 *  If one isn't found, return a absolute path relative to the
 *  user's configuration directory and note in the trace file that it
 *  needs to be created.
 *
 *  @param filefrag The file path to resolve
 *
 *  @return An absolute file path.
 */
gchar *
gnc_resolve_file_path (const gchar * filefrag)
{
    gchar *fullpath = NULL, *tmp_path = NULL;

    /* seriously invalid */
    if (!filefrag)
    {
        g_critical("filefrag is NULL");
        return NULL;
    }

    /* ---------------------------------------------------- */
    /* OK, now we try to find or build an absolute file path */

    /* check for an absolute file path */
    if (g_path_is_absolute(filefrag))
        return g_strdup (filefrag);

    /* Look in the current working directory */
    tmp_path = g_get_current_dir();
    fullpath = g_build_filename(tmp_path, filefrag, (gchar *)NULL);
    g_free(tmp_path);
    fullpath = check_path_return_if_valid(fullpath);
    if (fullpath != NULL)
        return fullpath;

    /* Look in the data dir (e.g. $PREFIX/share/gnucash) */
    tmp_path = gnc_path_get_pkgdatadir();
    fullpath = g_build_filename(tmp_path, filefrag, (gchar *)NULL);
    g_free(tmp_path);
    fullpath = check_path_return_if_valid(fullpath);
    if (fullpath != NULL)
        return fullpath;

    /* Look in the config dir (e.g. $PREFIX/share/gnucash/accounts) */
    tmp_path = gnc_path_get_accountsdir();
    fullpath = g_build_filename(tmp_path, filefrag, (gchar *)NULL);
    g_free(tmp_path);
    fullpath = check_path_return_if_valid(fullpath);
    if (fullpath != NULL)
        return fullpath;

    /* Look in the users config dir (e.g. $HOME/.gnucash/data) */
    fullpath = gnc_build_data_path(filefrag);
    if (g_file_test(fullpath, G_FILE_TEST_IS_REGULAR))
        return fullpath;

    /* OK, it's not there. Note that it needs to be created and pass it
     * back anyway */
    g_warning("create new file %s", fullpath);
    return fullpath;

}
Ejemplo n.º 8
0
gchar *
gnc_filepath_locate_ui_file (const gchar *name)
{
    gchar *default_path;
    gchar *fullname;

    default_path = g_build_filename (gnc_path_get_pkgdatadir (), "ui", NULL);
    fullname = gnc_filepath_locate_file (default_path, name);
    g_free(default_path);

    return fullname;
}
Ejemplo n.º 9
0
/** Returns the file path to the report directory, usually
 * "$prefix/share/gnucash/scm/gnucash/report".
 *
 * @returns A newly allocated string. */
gchar *gnc_path_get_reportdir()
{
    /* Careful: if the cmake variable SCHEME_INSTALLED_SOURCE_DIR gets changed
     * in toplevel CMakeLists.txt, this path should probably change as well.
     * Currently this code assumes SCHEME_INSTALLED_SOURCE_DIR is set to
     * pkgdatadir/scm
     * We can't use GNC_SCM_INSTALL_DIR directly at build time to
     * get this information, because on Windows and OS X
     * the final path may get installed in a different location
     * than assumed during build, invalidating the build path at
     * runtime.
     */
    gchar *pkgdatadir = gnc_path_get_pkgdatadir ();
    gchar *result = g_build_filename (pkgdatadir, "scm",
                                      "gnucash", "report", (char*)NULL);
    g_free (pkgdatadir);

    return result;
}
Ejemplo n.º 10
0
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;
}
Ejemplo n.º 11
0
gchar *
gnc_filepath_locate_data_file (const gchar *name)
{
    return gnc_filepath_locate_file (gnc_path_get_pkgdatadir(), name);
}
Ejemplo n.º 12
0
/* Tool to migrate existing user settings from GConf to GSettings
 *
 * This tool will first run some sanity checks to see if migration
 * is necessary/possible. The actual migration works directly from
 * the GConf .xml files. Using an xsl transform it will convert them
 * in a guile script to set most settings found.
 *
 * Notes:
 * - due to some limitations in the xslt code, all the gconf xml files are
 *   first copied into a temporary directory. After the migration has finished,
 *   that temporary directory and its contents are removed.
 * - not all settings can be migrated. All the important ones are though.
 *   The ones that are missing are mostly with respect to window position
 *   and size.
 * - column widths/visibilities, sorting orders,... are no longer stored
 *   in gsettings, so these will obviously not be migrated either.
 * - upon a successful run, a flag will be set to prevent the migration
 *   from running again. So in normal circumstances the migration will
 *   be executed only once.
 */
static void gnc_gsettings_migrate_from_gconf (void)
{
    gchar *pkgdatadir, *stylesheet, *input, *output, *command;
    gchar *gconf_root, *gconf_apps, *gconf_gnucash;
    gchar *base_dir, *iter;
    SCM migr_script;
    xsltStylesheetPtr stylesheetptr = NULL;
    xmlDocPtr inputxml, transformedxml;
    FILE *outfile;
    gboolean migration_ok = FALSE;

    ENTER ();

    base_dir = g_strdup (g_get_home_dir ());
    for (iter = base_dir; *iter != 0; iter++)
    {
        if ( *iter == '\\')
            *iter = '/';
    }

    /* Only attempt to migrate if there is something to migrate */
    gconf_root    = g_build_filename(base_dir, ".gconf", NULL);
    gconf_apps    = g_build_filename(gconf_root, "apps", NULL);
    gconf_gnucash = g_build_filename(gconf_apps, "gnucash", NULL);
    migration_ok = (g_file_test (gconf_root, G_FILE_TEST_IS_DIR) &&
                    g_file_test (gconf_apps, G_FILE_TEST_IS_DIR) &&
                    g_file_test (gconf_gnucash, G_FILE_TEST_IS_DIR));
    g_free (gconf_root);
    g_free (gconf_apps);
    g_free (gconf_gnucash);
    if (!migration_ok)
    {
        g_free (base_dir);
        gnc_gsettings_set_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_MIGRATE_PREFS_DONE, TRUE);
        PINFO ("No pre-existing GConf gnucash section found.\n"
               "Most likely this system never ran GnuCash before.\n"
               "Assume migration is not needed.");
        LEAVE ();
        return;
    }

    pkgdatadir = gnc_path_get_pkgdatadir();
    stylesheet = g_build_filename(pkgdatadir, "make-prefs-migration-script.xsl", NULL);
    input      = g_build_filename(pkgdatadir, "migratable-prefs.xml", NULL);
    g_free (pkgdatadir);

    migration_ok = (g_file_test (stylesheet, G_FILE_TEST_IS_REGULAR) &&
                    g_file_test (input, G_FILE_TEST_IS_REGULAR));
    if (!migration_ok)
    {
        /* Critical files not found, abort migration */
        g_free (base_dir);
        g_free (stylesheet);
        g_free (input);
        PWARN ("Migration input file and stylesheet missing. Skip migration.");
        return;
    }

    command = g_strconcat ("(use-modules (migrate-prefs))(migration-prepare \"",
                           base_dir, "\")", NULL);
    DEBUG ("command = %s", command);
    migration_ok = scm_is_true (scm_c_eval_string (command));
    g_free (command);
    if (!migration_ok)
    {
        /* Preparation step failed */
        g_free (base_dir);
        g_free (stylesheet);
        g_free (input);
        PWARN ("Migration preparation step failed. Skip migration.");
        LEAVE ();
        return;
    }

    output  = g_build_filename(base_dir, ".gnc-migration-tmp", "migrate-prefs-user.scm", NULL);
    xmlSubstituteEntitiesDefault(1);
    xmlLoadExtDtdDefaultValue = 1;
    defaultEntityLoader = xmlGetExternalEntityLoader();
    xmlSetExternalEntityLoader(xsltprocExternalEntityLoader);
    stylesheetptr = xsltParseStylesheetFile((const xmlChar *)stylesheet);
    inputxml = xmlParseFile(input);
    transformedxml = xsltApplyStylesheet(stylesheetptr, inputxml, NULL);

    outfile = fopen(output, "w");
    xsltSaveResultToFile(outfile, transformedxml, stylesheetptr);
    fclose(outfile);

    xsltFreeStylesheet(stylesheetptr);
    xmlFreeDoc(inputxml);
    xmlFreeDoc(transformedxml);

    xsltCleanupGlobals();
    xmlCleanupParser();
    g_free (stylesheet);
    g_free (input);

    migr_script = scm_from_locale_string (output);
    scm_primitive_load (migr_script);
    g_free (output);

    migration_ok = scm_is_true (scm_c_eval_string ("(use-modules (migrate-prefs-user))(run-migration)"));
    if (!migration_ok)
    {
        /* Actual migration step failed */
        g_free (base_dir);
        PWARN ("Actual migration step failed. Skip migration.");
        LEAVE ();
        return;
    }

    /* If we got here, the preferences were migrated successfully
     * Mark this success in gsettings, so we won't run the migration again.
     */
    gnc_gsettings_set_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_MIGRATE_PREFS_DONE, TRUE);

    /* All that is left now is to cleanup... */
    command = g_strconcat ("(use-modules (migrate-prefs))(migration-cleanup \"",
                           base_dir, "\")", NULL);
    DEBUG ("command = %s", command);
    migration_ok = scm_is_true (scm_c_eval_string (command));
    g_free (command);
    if (!migration_ok) /* Cleanup step failed, not critical */
        PWARN ("Cleanup step failed. You may need to delete %s/.gnc-migration-tmp manually.", base_dir);
    else
        PINFO ("Preferences migration completed successfully");

    LEAVE ("");
    g_free (base_dir);

}
Ejemplo n.º 13
0
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 */
}
Ejemplo n.º 14
0
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;
}
Ejemplo n.º 15
-1
int
libgncmod_python_gnc_module_init(int refcount)
{
    /* There isn't yet a python module to init.
    PyObject *pName, *pModule;
    */
    FILE *fp;
    gchar *pkgdatadir, *init_filename;

    Py_Initialize();
#if PY_VERSION_HEX >= 0x03000000
    PyInit__sw_app_utils();
    PyInit__sw_core_utils();
#else
    init_sw_app_utils();
    init_sw_core_utils();
#endif

    /* There isn't yet a python module to init.
    pName = PyString_FromString("path/to/init.py");
    pModule = PyImport_Import(pName);

    if (!pModule) {
        PyErr_Print();
        return FALSE;
    }

    Py_DECREF(pName);
    Py_DECREF(pModule);
    */

    pkgdatadir = gnc_path_get_pkgdatadir();
    init_filename = g_build_filename(pkgdatadir, "python/init.py", (char*)NULL);
    g_debug("Looking for python init script at %s", (init_filename ? init_filename : "<null>"));
    fp = fopen(init_filename, "r");
    if (fp)
    {
        PyRun_SimpleFile(fp, init_filename);
        fclose(fp);

        /* PyRun_InteractiveLoop(stdin, "foo"); */
    }
    else
    {
        g_warning("Unable to initialize Python module (unable to open %s)", init_filename);
    }
    g_free(init_filename);
    g_free(pkgdatadir);

    return TRUE;
}