Logo Search packages:      
Sourcecode: inkscape version File versions  Download package

int main ( int  argc,
char **  argv 
)

This is the classic main() entry point of the program, though on some architectures it might be called by something else.

Todo:
Should this be a static object (see inkscape.cpp)?

Definition at line 586 of file main.cpp.

References RegistryTool::setPathInfo().

Referenced by SPDesktop::init(), SPDesktop::onRedrawRequested(), and SPDesktop::set_display_area().

{
#ifdef HAVE_FPSETMASK
    /* This is inherited from Sodipodi code, where it was in #ifdef __FreeBSD__.  It's probably
       safe to remove: the default mask is already 0 in C99, and in current FreeBSD according to
       the fenv man page on www.freebsd.org, and in glibc according to (libc)FP Exceptions. */
    fpsetmask(fpgetmask() & ~(FP_X_DZ | FP_X_INV));
#endif

#ifdef WIN32
    gchar *exedir = g_strdup(win32_getExePath().data());
    _win32_set_inkscape_env(exedir);

# ifdef ENABLE_NLS
    // obtain short path to executable dir and pass it
    // to bindtextdomain (it doesn't understand UTF-8)
    gchar *shortexedir = g_win32_locale_filename_from_utf8(exedir);
    gchar *localepath = g_build_filename(shortexedir, PACKAGE_LOCALE_DIR, NULL);
    bindtextdomain(GETTEXT_PACKAGE, localepath);
    g_free(shortexedir);
    g_free(localepath);
# endif
    g_free(exedir);

    // Don't touch the registry (works fine without it) for Inkscape Portable
    gchar const *val = g_getenv("INKSCAPE_PORTABLE_PROFILE_DIR");
    if (!val) {
        RegistryTool rt;
        rt.setPathInfo();
    }
#elif defined(ENABLE_NLS)
# ifdef ENABLE_BINRELOC
    bindtextdomain(GETTEXT_PACKAGE, BR_LOCALEDIR(""));
# else
    bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
# endif
#endif

    // the bit below compiles regardless of platform
#ifdef ENABLE_NLS
    // Allow the user to override the locale directory by setting
    // the environment variable INKSCAPE_LOCALEDIR.
    char const *inkscape_localedir = g_getenv("INKSCAPE_LOCALEDIR");
    if (inkscape_localedir != NULL) {
        bindtextdomain(GETTEXT_PACKAGE, inkscape_localedir);
    }

    // common setup
    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
    textdomain(GETTEXT_PACKAGE);
#endif

    set_extensions_env();

    // Prevents errors like "Unable to wrap GdkPixbuf..." (in nr-filter-image.cpp for example)
    Gtk::Main::init_gtkmm_internals();

    LIBXML_TEST_VERSION

    Inkscape::GC::init();

    Inkscape::Debug::Logger::init();

    gboolean use_gui;

#ifndef WIN32
    use_gui = (g_getenv("DISPLAY") != NULL);
#else
    use_gui = TRUE;
#endif
    /* Test whether with/without GUI is forced */
    for (int i = 1; i < argc; i++) {
        if (!strcmp(argv[i], "-z")
            || !strcmp(argv[i], "--without-gui")
            || !strcmp(argv[i], "-p")
            || !strncmp(argv[i], "--print", 7)
            || !strcmp(argv[i], "-e")
            || !strncmp(argv[i], "--export-png", 12)
            || !strcmp(argv[i], "-l")
            || !strncmp(argv[i], "--export-plain-svg", 18)
            || !strcmp(argv[i], "-i")
            || !strncmp(argv[i], "--export-area-drawing", 21)
            || !strcmp(argv[i], "-D")
            || !strncmp(argv[i], "--export-area-page", 18)
            || !strcmp(argv[i], "-C")
            || !strncmp(argv[i], "--export-id", 11)
            || !strcmp(argv[i], "-P")
            || !strncmp(argv[i], "--export-ps", 11)
            || !strcmp(argv[i], "-E")
            || !strncmp(argv[i], "--export-eps", 12)
            || !strcmp(argv[i], "-A")
            || !strncmp(argv[i], "--export-pdf", 12)
            || !strncmp(argv[i], "--export-latex", 14)
#ifdef WIN32
            || !strcmp(argv[i], "-M")
            || !strncmp(argv[i], "--export-emf", 12)
#endif //WIN32
            || !strcmp(argv[i], "-W")
            || !strncmp(argv[i], "--query-width", 13)
            || !strcmp(argv[i], "-H")
            || !strncmp(argv[i], "--query-height", 14)
            || !strcmp(argv[i], "-S")
            || !strncmp(argv[i], "--query-all", 11)
            || !strcmp(argv[i], "-X")
            || !strncmp(argv[i], "--query-x", 9)
            || !strcmp(argv[i], "-Y")
            || !strncmp(argv[i], "--query-y", 9)
            || !strcmp(argv[i], "--vacuum-defs")
            || !strcmp(argv[i], "--shell")
           )
        {
            /* main_console handles any exports -- not the gui */
            use_gui = FALSE;
            break;
        } else if (!strcmp(argv[i], "-g") || !strcmp(argv[i], "--with-gui")) {
            use_gui = TRUE;
            break;
        }
    }

#ifdef WIN32
#ifndef REPLACEARGS_ANSI
    if ( PrintWin32::is_os_wide() )
#endif // REPLACEARGS_ANSI
    {
        // If the call fails, we'll need to convert charsets
        needToRecodeParams = !replaceArgs( argc, argv );
    }
#endif // WIN32

    /// \todo  Should this be a static object (see inkscape.cpp)?
    Inkscape::NSApplication::Application app(argc, argv, use_gui, sp_new_gui);

    return app.run();
}


Generated by  Doxygen 1.6.0   Back to index