Code

Warning cleanup.
[inkscape.git] / src / inkscape.cpp
index bf3c25e94b4bc30a36194a459e9c65ade33a1fa5..ae52589046ec1c34b5dbc2db3b156f4665fdc5a6 100644 (file)
@@ -1,9 +1,7 @@
-#define __INKSCAPE_C__
-
-/*
- * Interface to main application
- *
- * Authors:
+/** @file
+ * @brief Legacy interface to main application
+ */
+/* Authors:
  *   Lauris Kaplinski <lauris@kaplinski.com>
  *   bulia byak <buliabyak@users.sf.net>
  *
@@ -37,38 +35,33 @@ using Inkscape::Extension::Internal::PrintWin32;
 # include <shlobj.h>
 #endif
 
-#include <signal.h>
-
-#include <gtk/gtkmain.h>
-#include <gtk/gtkmessagedialog.h>
-#include <glib.h>
+#include <cstring>
 #include <glib/gstdio.h>
-
+#include <glib.h>
 #include <glibmm/i18n.h>
+#include <gtk/gtkmain.h>
+#include <gtk/gtkmessagedialog.h>
+#include <signal.h>
 #include <string>
-#include <cstring>
-#include "helper/sp-marshal.h"
-#include "dialogs/debugdialog.h"
-#include "dialogs/input.h"
 #include "application/application.h"
 #include "application/editor.h"
-
-
-#include "document.h"
 #include "desktop.h"
 #include "desktop-handles.h"
-#include "selection.h"
+#include "dialogs/input.h"
+#include "document.h"
 #include "event-context.h"
-#include "inkscape-private.h"
-#include "xml/repr.h"
-#include "preferences.h"
-#include "io/sys.h"
-#include "message-stack.h"
-
-#include "extension/init.h"
 #include "extension/db.h"
+#include "extension/init.h"
 #include "extension/output.h"
 #include "extension/system.h"
+#include "helper/sp-marshal.h"
+#include "inkscape-private.h"
+#include "io/sys.h"
+#include "message-stack.h"
+#include "preferences.h"
+#include "selection.h"
+#include "ui/dialog/debug.h"
+#include "xml/repr.h"
 
 static Inkscape::Application *inkscape = NULL;
 
@@ -303,7 +296,7 @@ static gint inkscape_autosave(gpointer)
 
     Glib::ustring autosave_dir;
     {
-        Glib::ustring tmp = prefs->getString("options.autosave", "path");
+        Glib::ustring tmp = prefs->getString("/options/autosave/path");
         if (!tmp.empty()) {
             autosave_dir = tmp;
         } else {
@@ -322,7 +315,7 @@ static gint inkscape_autosave(gpointer)
     gchar sptstr[256];
     strftime(sptstr, 256, "%Y_%m_%d_%H_%M_%S", sptm);
 
-    gint autosave_max = prefs->getInt("options.autosave", "max", 10);
+    gint autosave_max = prefs->getInt("/options/autosave/max", 10);
 
     gint docnum = 0;
 
@@ -438,14 +431,14 @@ void inkscape_autosave_init()
         autosave_timeout_id = 0;
     }
 
-    // g_debug("options.autosave.enable = %d", prefs->getBool("options.autosave", "enable", true));
+    // g_debug("options.autosave.enable = %d", prefs->getBool("/options/autosave/enable", true));
     // Is autosave enabled?
-    if (!prefs->getBool("options.autosave", "enable", true)){
+    if (!prefs->getBool("/options/autosave/enable", true)){
         autosave_timeout_id = 0;
     } else {
         // Turn on autosave
-        guint32 timeout = prefs->getInt("options.autosave", "interval", 10) * 60;
-        // g_debug("options.autosave.interval = %d", prefs->getInt("options.autosave", "interval", 10));
+        guint32 timeout = prefs->getInt("/options/autosave/interval", 10) * 60;
+        // g_debug("options.autosave.interval = %d", prefs->getInt("/options/autosave/interval", 10));
 #if GLIB_CHECK_VERSION(2,14,0)
         autosave_timeout_id = g_timeout_add_seconds(timeout, inkscape_autosave, NULL);
 #else
@@ -757,11 +750,17 @@ inkscape_application_init (const gchar *argv0, gboolean use_gui)
     inkscape->argv0 = g_strdup(argv0);
 
     /* Load the preferences and menus; Later menu layout should be merged into prefs */
-    Inkscape::Preferences::use_gui = use_gui;
-    Inkscape::Preferences::load();
     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+    prefs->load(use_gui, false);
     inkscape_load_menus(inkscape);
     sp_input_load_from_preferences();
+    
+    /* set language for user interface according setting in preferences */
+    Glib::ustring ui_language = prefs->getString("/ui/language");
+    if(!ui_language.empty())
+    {
+        setenv("LANGUAGE", ui_language, 1);
+    }
 
     /* DebugDialog redirection.  On Linux, default to OFF, on Win32, default to ON.
      * Use only if use_gui is enabled
@@ -772,15 +771,15 @@ inkscape_application_init (const gchar *argv0, gboolean use_gui)
 #define DEFAULT_LOG_REDIRECT false
 #endif
 
-    if (use_gui == TRUE && prefs->getBool("dialogs.debug", "redirect", DEFAULT_LOG_REDIRECT))
+    if (use_gui == TRUE && prefs->getBool("/dialogs/debug/redirect", DEFAULT_LOG_REDIRECT))
     {
-        Inkscape::UI::Dialogs::DebugDialog::getInstance()->captureLogMessages();
+        Inkscape::UI::Dialog::DebugDialog::getInstance()->captureLogMessages();
     }
 
     /* Check for global remapping of Alt key */
     if(use_gui)
     {
-        inkscape_mapalt(guint(prefs->getInt("options.mapalt", "value", 0)));
+        inkscape_mapalt(guint(prefs->getInt("/options/mapalt/value", 0)));
     }
 
     /* Initialize the extensions */
@@ -825,15 +824,6 @@ bool inkscape_load_menus (Inkscape::Application */*inkscape*/)
     return false;
 }
 
-/**
- * @deprecated Use the Preferences class instead, and try not to use _getNode
- */
-Inkscape::XML::Node *inkscape_get_repr(Inkscape::Application */*inkscape*/, const gchar *key)
-{
-    Inkscape::Preferences *ps = Inkscape::Preferences::get();
-    return ps->_getNode(key);
-}
-
 
 void
 inkscape_selection_modified (Inkscape::Selection *selection, guint flags)