Logo Search packages:      
Sourcecode: inkscape version File versions

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.

Call bindtextdomain() for various machines's paths

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

Definition at line 547 of file main.cpp.

References set_extensions_env(), and 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
    /*
      Set the current directory to the directory of the
      executable.  This seems redundant, but is needed for
      when inkscape.exe is executed from another directory.
      We use relative paths on win32.
      HKCR\svgfile\shell\open\command is a good example
    */
    Glib::ustring homedir = _win32_getExePath();
    // TODO these should use xxxW() calls explicitly and convert UTF-16 <--> UTF-8
    SetCurrentDirectory(homedir.c_str());
    _win32_set_inkscape_env(homedir);
    RegistryTool rt;
    rt.setPathInfo();
#endif

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

    // Bug #197475
    set_extensions_env();

   /**
    * Call bindtextdomain() for various machines's paths
    */
#ifdef ENABLE_NLS
#ifdef WIN32
    Glib::ustring localePath = homedir;
    localePath += "\\";
    localePath += PACKAGE_LOCALE_DIR;
    bindtextdomain(GETTEXT_PACKAGE, localePath.c_str());
#else
#ifdef ENABLE_BINRELOC
    bindtextdomain(GETTEXT_PACKAGE, BR_LOCALEDIR(""));
#else
    bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
#endif
#endif
    // Allow the user to override the locale directory by setting
    // the environment variable INKSCAPE_LOCALEDIR.
    char *inkscape_localedir = getenv("INKSCAPE_LOCALEDIR");
    if (inkscape_localedir != NULL) {
        bindtextdomain(GETTEXT_PACKAGE, inkscape_localedir);
    }
#endif

    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");

#ifdef ENABLE_NLS
    textdomain(GETTEXT_PACKAGE);
#endif

    LIBXML_TEST_VERSION

    Inkscape::GC::init();

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

    gboolean use_gui;

#ifndef WIN32
    // TODO use g_getenv() and g_setenv() that use filename encoding, which is UTF-8 on Windows
    use_gui = (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", 12)
            || !strcmp(argv[i], "-i")
            || !strncmp(argv[i], "--export-area-drawing", 21)
            || !strcmp(argv[i], "-D")
            || !strncmp(argv[i], "--export-area-canvas", 20)
            || !strcmp(argv[i], "-C")
            || !strncmp(argv[i], "--export-id", 12)
            || !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)
#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", 13)
            || !strcmp(argv[i], "-Y")
            || !strncmp(argv[i], "--query-y", 14)
            || !strcmp(argv[i], "--vacuum-defs")
            || !strncmp(argv[i], "--shell", 7)
           )
        {
            /* 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