Code

separate updating window from updating layers
[inkscape.git] / src / file.cpp
index b350ce97b6e7756d8bf3cbc01276b095ee21efcc..568d32572874d523c83b69445f4ed41917d5c7b0 100644 (file)
@@ -8,9 +8,10 @@
  *   Chema Celorio <chema@celorio.com>
  *   bulia byak <buliabyak@users.sf.net>
  *
+ * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
  * Copyright (C) 1999-2005 Authors
- * Copyright (C) 2001-2002 Ximian, Inc.
  * Copyright (C) 2004 David Turner
+ * Copyright (C) 2001-2002 Ximian, Inc.
  *
  * Released under GNU GPL, read the file 'COPYING' for more information
  */
@@ -105,6 +106,7 @@ sp_file_new(const Glib::ustring &templ)
         sp_create_window(dtw, TRUE);
         dt = static_cast<SPDesktop*>(dtw->view);
         sp_namedview_window_from_document(dt);
+        sp_namedview_update_layers_from_document(dt);
     }
     return dt;
 }
@@ -200,9 +202,8 @@ sp_file_open(const Glib::ustring &uri,
         // everyone who cares now has a reference, get rid of ours
         sp_document_unref(doc);
         // resize the window to match the document properties
-        // (this may be redundant for new windows... if so, move to the "virgin"
-        //  section above)
         sp_namedview_window_from_document(desktop);
+        sp_namedview_update_layers_from_document(desktop);
 
         if (add_to_recent) {
             prefs_set_recent_file(SP_DOCUMENT_URI(doc), SP_DOCUMENT_NAME(doc));
@@ -462,7 +463,7 @@ sp_file_vacuum()
     unsigned int diff = vacuum_document (doc);
 
     sp_document_done(doc, SP_VERB_FILE_VACUUM, 
-                     /* TODO: annotate */ "file.cpp:515");
+                     _("Vacuum &lt;defs&gt;"));
 
     SPDesktop *dt = SP_ACTIVE_DESKTOP;
     if (diff > 0) {
@@ -535,7 +536,7 @@ static Inkscape::UI::Dialog::FileSaveDialog *saveDialogInstance = NULL;
  * \param    ascopy  (optional) wether to set the documents->uri to the new filename or not
  */
 bool
-sp_file_save_dialog(SPDocument *doc, bool bAsCopy)
+sp_file_save_dialog(SPDocument *doc, bool is_copy)
 {
 
     Inkscape::XML::Node *repr = sp_document_repr_root(doc);
@@ -588,7 +589,8 @@ sp_file_save_dialog(SPDocument *doc, bool bAsCopy)
             save_loc.append(formatBuf);
         }
     } else {
-        save_loc = Glib::path_get_dirname(doc->uri);
+        save_loc = Glib::build_filename(Glib::path_get_dirname(doc->uri),
+                                        Glib::path_get_basename(doc->uri));
     }
 
     // convert save_loc from utf-8 to locale
@@ -600,15 +602,24 @@ sp_file_save_dialog(SPDocument *doc, bool bAsCopy)
         save_loc = save_loc_local;
 
     //# Show the SaveAs dialog
+    char const * dialog_title;
+    if (is_copy) {
+        dialog_title = (char const *) _("Select file to save a copy to");
+    } else {
+        dialog_title = (char const *) _("Select file to save to");
+    }
     if (!saveDialogInstance)
         saveDialogInstance =
              Inkscape::UI::Dialog::FileSaveDialog::create(
                  save_loc,
                  Inkscape::UI::Dialog::SVG_TYPES,
-                 bAsCopy ? (char const *) _("Select file to save copy to") : (char const *) _("Select file to save to"),
+                 (char const *) _("Select file to save to"),
                  default_extension
             );
-
+    else
+        saveDialogInstance->change_path(save_loc);
+    saveDialogInstance->change_title(dialog_title);
+    
     bool success = saveDialogInstance->show();
     if (!success)
         return success;
@@ -627,12 +638,12 @@ sp_file_save_dialog(SPDocument *doc, bool bAsCopy)
         else
             g_warning( "Error converting save filename to UTF-8." );
 
-        success = file_save(doc, fileName, selectionType, TRUE, !bAsCopy);
+        success = file_save(doc, fileName, selectionType, TRUE, !is_copy);
 
         if (success)
             prefs_set_recent_file(SP_DOCUMENT_URI(doc), SP_DOCUMENT_NAME(doc));
 
-        save_path = fileName;
+        save_path = Glib::path_get_dirname(fileName);
         prefs_set_string_attribute("dialogs.save_as", "path", save_path.c_str());
 
         return success;
@@ -838,7 +849,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
 
         sp_document_unref(doc);
         sp_document_done(in_doc, SP_VERB_FILE_IMPORT,
-                         /* TODO: annotate */ "file.cpp:900");
+                         _("Import"));
 
     } else {
         gchar *text = g_strdup_printf(_("Failed to load the requested file %s"), uri.c_str());