inkscape.cpp revision c5424ab93868fb819e42ef2daa8f5031cf43d130
0N/A#ifdef HAVE_CONFIG_H
0N/A#include "debug/simple-event.h"
0N/A#include "debug/event-tracker.h"
#define HAS_GetModuleFileName
# include <shlobj.h>
#include <cstring>
#include <signal.h>
#include <string>
#include "desktop.h"
#include "desktop-handles.h"
#include "device-manager.h"
#include "document.h"
#include "event-context.h"
#include "inkscape-private.h"
#include "layer-model.h"
#include "message-stack.h"
#include "preferences.h"
#include "resource-manager.h"
#include "selection.h"
#include "helper/action-context.h"
#include "helper/sp-marshal.h"
#include "menus-skeleton.h"
namespace Inkscape {
struct ApplicationClass;
static void inkscape_activate_desktop_private (Inkscape::Application *inkscape, SPDesktop *desktop);
static void inkscape_deactivate_desktop_private (Inkscape::Application *inkscape, SPDesktop *desktop);
class AppSelectionModel {
void (* modify_selection) (Inkscape::Application * inkscape, Inkscape::Selection * selection, guint flags);
#ifndef WIN32
inkscape_get_type (void)
if (!type) {
return type;
G_TYPE_NONE, 0);
G_TYPE_NONE, 0);
G_TYPE_NONE, 0);
G_TYPE_NONE, 0);
#ifdef WIN32
typedef int uid_t;
#define getuid() 0
return TRUE;
if( !autosave_dir_ptr ){
return TRUE;
if( !autosave_dir_ptr ){
return TRUE;
++iter) {
++docnum;
// g_debug("Document %d: \"%s\" %s", docnum, doc ? doc->getName() : "(null)", doc ? (doc->isModifiedSinceSave() ? "(dirty)" : "(clean)") : "(null)");
if ( oldest_autosave ) {
count ++;
if ( oldest_autosave ) {
if ( oldest_autosave ) {
oldest_autosave = 0;
baseName = 0;
if (file) {
if (errortext) {
return TRUE;
void inkscape_autosave_init()
if ( autosave_timeout_id ) {
autosave_timeout_id = 0;
autosave_timeout_id = 0;
if (!inkscape) {
gtk_main_quit ();
inkscape_ref (void)
if (inkscape)
inkscape_unref (void)
if (inkscape)
/* Needs to be a guint because gdktypes.h does not define a 'no-modifier' value */
inkscape_mapalt() {
/* Sets the keyboard modifer to map to Alt. Zero switches off mapping, as does '1', which is the default */
static bool crashIsHappening = false;
bool inkscapeIsCrashing()
return crashIsHappening;
#ifndef WIN32
if (recursion) {
abort ();
crashIsHappening = true;
++iter) {
if (docname) {
const char* d = d0;
unsigned int dots = 0;
docname = n;
const char* locations[] = {
if (file) {
g_snprintf (c, 1024, "%s", filename); // we want the complete path to be stored in c (for reporting purposes)
if (file) {
failednames = g_slist_prepend (failednames, (doc->getName()) ? g_strdup(doc->getName()) : g_strdup (_("Untitled document")));
count++;
if (savednames) {
if (failednames) {
fprintf (stderr, "with a detailed description of the steps leading to the crash, so we can fix it.\n");
char const *sstr = _("Automatic backups of unsaved documents were done to the following locations:\n");
if (savednames) {
if (failednames) {
GtkWidget *msgbox = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", b);
g_free (b);
virtual ~InkErrorHandler() {}
if (_useGui) {
bool _useGui;
#ifndef WIN32
if (use_gui) {
#ifdef WIN32
#define DEFAULT_LOG_REDIRECT true
#define DEFAULT_LOG_REDIRECT false
if (use_gui)
return inkscape;
menus_xml = 0;
fn = 0;
g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, desktop->getEventContext());
g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_SELECTION], 0, sp_desktop_selection (desktop));
g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, sp_desktop_selection (desktop));
g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, new_desktop->getEventContext());
g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_SELECTION], 0, sp_desktop_selection (new_desktop));
g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, sp_desktop_selection (new_desktop));
g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, desktop->getEventContext());
g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_SELECTION], 0, sp_desktop_selection (desktop));
g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, sp_desktop_selection (desktop));
* Resends ACTIVATE_DESKTOP for current desktop; needed when a new desktop has got its window that dialogs will transientize to
return NULL;
unsigned int dkey = 0;
return dkey;
static SPDesktop *
d = inkscape_find_desktop_by_dkey (i);
for (unsigned int i = 0; i <= inkscape_maximum_dkey(); i++) {
d = inkscape_find_desktop_by_dkey (i);
g_assert (d);
static SPDesktop *
if (dkey_current > 0) {
d = inkscape_find_desktop_by_dkey (i);
g_assert (d);
++iter) {
++iter) {
std::map<SPDocument *, AppSelectionModel *>::iterator sel_iter = inkscape->selection_models.find(document);
inkscape_active_desktop (void)
return NULL;
inkscape_active_document (void)
if (SP_ACTIVE_DESKTOP) {
return NULL;
if (!document) {
if (SP_ACTIVE_DESKTOP) {
return NULL;
if (SP_ACTIVE_DESKTOP) {
if (!doc) {
std::map<SPDocument *, AppSelectionModel *>::iterator sel_iter = inkscape->selection_models.find(doc);
gtk_main_quit ();
if (!homedir) {
if (!homedir) {
* Get, or guess, or decide the location where the preferences.xml
gchar *
if (!prefdir) {
if (val) {
if (!prefdir) {
if ( utf8Path ) {
utf8Path = 0;
if (prefdir) {
if (!prefdir) {
bool needsMigration = ( !Inkscape::IO::file_test( prefdir, G_FILE_TEST_EXISTS ) && Inkscape::IO::file_test( legacyDir, G_FILE_TEST_EXISTS ) );
if (needsMigration) {
bool needsRenameWarning = ( !Inkscape::IO::file_test( prefdir, G_FILE_TEST_EXISTS ) && Inkscape::IO::file_test( dev47Dir, G_FILE_TEST_EXISTS ) );
if (needsRenameWarning) {
legacyDir = 0;
dev47Dir = 0;
#ifdef S_IRGRP
#ifdef S_IXGRP
#ifdef S_IXOTH