Code

remove g++ 4.1.1 compiler errors
[inkscape.git] / src / inkscape.cpp
index 9c0d93173b8ae4cc084259df75dcb7585147a453..d3cc1aa0064a3e748d5b78f15da76a9102e9c6ca 100644 (file)
@@ -98,7 +98,7 @@ static void inkscape_dispose (GObject *object);
 static void inkscape_activate_desktop_private (Inkscape::Application *inkscape, SPDesktop *desktop);
 static void inkscape_deactivate_desktop_private (Inkscape::Application *inkscape, SPDesktop *desktop);
 
-static bool inkscape_init_config (Inkscape::XML::Document *doc, const gchar *config_name, const gchar *skeleton, 
+static bool inkscape_init_config (Inkscape::XML::Document *doc, const gchar *config_name, const gchar *skeleton,
                                  unsigned int skel_size,
                                  const gchar *e_mkdir,
                                  const gchar *e_notdir,
@@ -152,7 +152,7 @@ static void (* segv_handler) (int) = NULL;
 
 /**
  *  Retrieves the GType for the Inkscape Application object.
- */ 
+ */
 GType
 inkscape_get_type (void)
 {
@@ -473,9 +473,9 @@ inkscape_segv_handler (int signum)
 
     /* Show nice dialog box */
 
-    char const *istr = N_("Inkscape encountered an internal error and will close now.\n");
-    char const *sstr = N_("Automatic backups of unsaved documents were done to the following locations:\n");
-    char const *fstr = N_("Automatic backup of the following documents failed:\n");
+    char const *istr = _("Inkscape encountered an internal error and will close now.\n");
+    char const *sstr = _("Automatic backups of unsaved documents were done to the following locations:\n");
+    char const *fstr = _("Automatic backup of the following documents failed:\n");
     gint nllen = strlen ("\n");
     gint len = strlen (istr) + strlen (sstr) + strlen (fstr);
     for (GSList *l = savednames; l != NULL; l = l->next) {
@@ -544,13 +544,13 @@ inkscape_application_init (const gchar *argv0, gboolean use_gui)
 {
     inkscape = (Inkscape::Application *)g_object_new (SP_TYPE_INKSCAPE, NULL);
     /* fixme: load application defaults */
-  
+
     segv_handler = signal (SIGSEGV, inkscape_segv_handler);
     signal (SIGFPE,  inkscape_segv_handler);
     signal (SIGILL,  inkscape_segv_handler);
-#ifndef WIN32    
+#ifndef WIN32
     signal (SIGBUS,  inkscape_segv_handler);
-#endif    
+#endif
     signal (SIGABRT, inkscape_segv_handler);
 
     inkscape->use_gui = use_gui;
@@ -561,16 +561,18 @@ inkscape_application_init (const gchar *argv0, gboolean use_gui)
     Inkscape::Preferences::load();
     inkscape_load_menus(inkscape);
 
-    /* DebugDialog redirection.  On Linux, default to OFF, on Win32, default to ON */
+    /* DebugDialog redirection.  On Linux, default to OFF, on Win32, default to ON.
+        * Use only if use_gui is enabled 
+        */
 #ifdef WIN32
 #define DEFAULT_LOG_REDIRECT true
 #else
 #define DEFAULT_LOG_REDIRECT false
 #endif
 
-    if (prefs_get_int_attribute("dialogs.debug", "redirect", DEFAULT_LOG_REDIRECT))
+    if (use_gui == TRUE && prefs_get_int_attribute("dialogs.debug", "redirect", DEFAULT_LOG_REDIRECT))
     {
-        Inkscape::UI::Dialogs::DebugDialog::getInstance()->captureLogMessages();
+               Inkscape::UI::Dialogs::DebugDialog::getInstance()->captureLogMessages();
     }
 
     /* Initialize the extensions */
@@ -596,24 +598,24 @@ gboolean inkscape_app_use_gui( Inkscape::Application const * app )
 /**
  * Preference management
  * We use '.' as separator
- * 
+ *
  * Returns TRUE if the config file was successfully loaded, FALSE if not.
  */
 bool
-inkscape_load_config (const gchar *filename, Inkscape::XML::Document *config, const gchar *skeleton, 
-                     unsigned int skel_size, const gchar *e_notreg, const gchar *e_notxml, 
+inkscape_load_config (const gchar *filename, Inkscape::XML::Document *config, const gchar *skeleton,
+                     unsigned int skel_size, const gchar *e_notreg, const gchar *e_notxml,
                      const gchar *e_notsp, const gchar *warn)
 {
     gchar *fn = profile_path(filename);
     if (!Inkscape::IO::file_test(fn, G_FILE_TEST_EXISTS)) {
         bool result;
         /* No such file */
-        result = inkscape_init_config (config, filename, skeleton, 
+        result = inkscape_init_config (config, filename, skeleton,
                                        skel_size,
                                        _("Cannot create directory %s.\n%s"),
                                        _("%s is not a valid directory.\n%s"),
                                        _("Cannot create file %s.\n%s"),
-                                       _("Cannot write file %s.\n%s"), 
+                                       _("Cannot write file %s.\n%s"),
                                        _("Although Inkscape will run, it will use default settings,\n"
                                          "and any changes made in preferences will not be saved."));
         g_free (fn);
@@ -672,7 +674,7 @@ inkscape_load_config (const gchar *filename, Inkscape::XML::Document *config, co
 
 /**
  *  Menus management
- * 
+ *
  */
 bool
 inkscape_load_menus (Inkscape::Application *inkscape)
@@ -680,9 +682,9 @@ inkscape_load_menus (Inkscape::Application *inkscape)
     gchar *fn = profile_path(MENUS_FILE);
     bool retval = false;
     if (Inkscape::IO::file_test(fn, G_FILE_TEST_EXISTS)) {
-        retval = inkscape_load_config (MENUS_FILE, 
-                                inkscape->menus, 
-                                menus_skeleton, 
+        retval = inkscape_load_config (MENUS_FILE,
+                                inkscape->menus,
+                                menus_skeleton,
                                 MENUS_SKELETON_SIZE,
                                 _("%s is not a regular file.\n%s"),
                                 _("%s not a valid XML file, or\n"
@@ -724,7 +726,7 @@ inkscape_get_repr (Inkscape::Application *inkscape, const gchar *key)
         } else {
             len = strlen (s);
         }
-        
+
         Inkscape::XML::Node* child;
         for (child = repr->firstChild(); child != NULL; child = child->next()) {
             gchar const *id = child->attribute("id");
@@ -825,7 +827,7 @@ void
 inkscape_add_desktop (SPDesktop * desktop)
 {
     g_return_if_fail (desktop != NULL);
-    
+
     if (Inkscape::NSApplication::Application::getNewGui())
     {
         Inkscape::NSApplication::Editor::addDesktop (desktop);
@@ -839,9 +841,9 @@ inkscape_add_desktop (SPDesktop * desktop)
 
     if (DESKTOP_IS_ACTIVE (desktop)) {
         g_signal_emit (G_OBJECT (inkscape), inkscape_signals[ACTIVATE_DESKTOP], 0, desktop);
-        g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, SP_DT_EVENTCONTEXT (desktop));
-        g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_SELECTION], 0, SP_DT_SELECTION (desktop));
-        g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, SP_DT_SELECTION (desktop));
+        g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, sp_desktop_event_context (desktop));
+        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));
     }
 }
 
@@ -867,13 +869,13 @@ inkscape_remove_desktop (SPDesktop * desktop)
             inkscape->desktops = g_slist_remove (inkscape->desktops, new_desktop);
             inkscape->desktops = g_slist_prepend (inkscape->desktops, new_desktop);
             g_signal_emit (G_OBJECT (inkscape), inkscape_signals[ACTIVATE_DESKTOP], 0, new_desktop);
-            g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, SP_DT_EVENTCONTEXT (new_desktop));
-            g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_SELECTION], 0, SP_DT_SELECTION (new_desktop));
-            g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, SP_DT_SELECTION (new_desktop));
+            g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, sp_desktop_event_context (new_desktop));
+            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));
         } else {
             g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, NULL);
-            if (SP_DT_SELECTION(desktop))
-                SP_DT_SELECTION(desktop)->clear();
+            if (sp_desktop_selection(desktop))
+                sp_desktop_selection(desktop)->clear();
         }
     }
 
@@ -912,9 +914,9 @@ inkscape_activate_desktop (SPDesktop * desktop)
     inkscape->desktops = g_slist_prepend (inkscape->desktops, desktop);
 
     g_signal_emit (G_OBJECT (inkscape), inkscape_signals[ACTIVATE_DESKTOP], 0, desktop);
-    g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, SP_DT_EVENTCONTEXT (desktop));
-    g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_SELECTION], 0, SP_DT_SELECTION (desktop));
-    g_signal_emit (G_OBJECT (inkscape), inkscape_signals[CHANGE_SELECTION], 0, SP_DT_SELECTION (desktop));
+    g_signal_emit (G_OBJECT (inkscape), inkscape_signals[SET_EVENTCONTEXT], 0, sp_desktop_event_context (desktop));
+    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));
 }
 
 
@@ -1145,7 +1147,7 @@ inkscape_active_document (void)
         return Inkscape::NSApplication::Editor::getActiveDocument();
 
     if (SP_ACTIVE_DESKTOP) {
-        return SP_DT_DOCUMENT (SP_ACTIVE_DESKTOP);
+        return sp_desktop_document (SP_ACTIVE_DESKTOP);
     }
 
     return NULL;
@@ -1170,7 +1172,7 @@ SPEventContext *
 inkscape_active_event_context (void)
 {
     if (SP_ACTIVE_DESKTOP) {
-        return SP_DT_EVENTCONTEXT (SP_ACTIVE_DESKTOP);
+        return sp_desktop_event_context (SP_ACTIVE_DESKTOP);
     }
 
     return NULL;
@@ -1183,12 +1185,12 @@ inkscape_active_event_context (void)
 #####################*/
 
 static bool
-inkscape_init_config (Inkscape::XML::Document *doc, const gchar *config_name, const gchar *skeleton, 
+inkscape_init_config (Inkscape::XML::Document *doc, const gchar *config_name, const gchar *skeleton,
                      unsigned int skel_size,
-                     const gchar *e_mkdir, 
-                     const gchar *e_notdir, 
-                     const gchar *e_ccf, 
-                     const gchar *e_cwf, 
+                     const gchar *e_mkdir,
+                     const gchar *e_notdir,
+                     const gchar *e_ccf,
+                     const gchar *e_cwf,
                      const gchar *warn)
 {
     gchar *dn = profile_path(NULL);
@@ -1290,7 +1292,7 @@ void
 inkscape_exit (Inkscape::Application *inkscape)
 {
     g_assert (INKSCAPE);
-        
+
     //emit shutdown signal so that dialogs could remember layout
     g_signal_emit (G_OBJECT (INKSCAPE), inkscape_signals[SHUTDOWN_SIGNAL], 0);
 
@@ -1399,6 +1401,14 @@ inkscape_get_menus (Inkscape::Application * inkscape)
     return repr->firstChild();
 }
 
+void
+inkscape_get_all_desktops(std::list< SPDesktop* >& listbuf)
+{
+    for(GSList* l = inkscape->desktops; l != NULL; l = l->next) {
+        listbuf.push_back(static_cast< SPDesktop* >(l->data));
+    }
+}
+
 
 
 /*