Code

convert almost all libnrtype to Geom::
[inkscape.git] / src / ui / dialog / filedialogimpl-gtkmm.cpp
index 1405e11aa0700c4f62f116c6ab210ee0acbabff4..541eb388baae16d15e7547c5e78e86b2b721a2ac 100644 (file)
@@ -9,8 +9,8 @@
  *
  * Copyright (C) 2004-2007 Bob Jamison
  * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
+ * Copyright (C) 2007-2008 Joel Holdsworth
  * Copyright (C) 2004-2007 The Inkscape Organization
- * Copyright (C) 2007 Joel Holdsworth
  *
  * Released under GNU GPL, read the file 'COPYING' for more information
  */
@@ -686,11 +686,13 @@ FileOpenDialogImplGtk::FileOpenDialogImplGtk(Gtk::Window& parentWindow,
 
     add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
     set_default(*add_button(Gtk::Stock::OPEN,   Gtk::RESPONSE_OK));
-       
-       //###### Allow easy access to our examples folder                
-    if(Inkscape::IO::file_test(INKSCAPE_EXAMPLESDIR,
-               (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)))
-       {
+
+    //###### Allow easy access to our examples folder
+    if ( Inkscape::IO::file_test(INKSCAPE_EXAMPLESDIR, G_FILE_TEST_EXISTS)
+         && Inkscape::IO::file_test(INKSCAPE_EXAMPLESDIR, G_FILE_TEST_IS_DIR)
+         && g_path_is_absolute(INKSCAPE_EXAMPLESDIR)
+        )
+    {
         add_shortcut_folder(INKSCAPE_EXAMPLESDIR);
     }
 }
@@ -759,10 +761,6 @@ void FileOpenDialogImplGtk::createFilterMenu()
 bool
 FileOpenDialogImplGtk::show()
 {
-    Glib::ustring s = Glib::filename_to_utf8 (get_current_folder());
-    if (s.length() == 0)
-        s = getcwd (NULL, 0);
-    set_current_folder(Glib::filename_from_utf8(s)); //hack to force initial dir listing
     set_modal (TRUE);                      //Window
     sp_transientize((GtkWidget *)gobj());  //Make transient
     gint b = run();                        //Dialog
@@ -851,9 +849,12 @@ FileSaveDialogImplGtk::FileSaveDialogImplGtk( Gtk::Window &parentWindow,
                                               const Glib::ustring &dir,
                                               FileDialogType fileTypes,
                                               const Glib::ustring &title,
-                                              const Glib::ustring &/*default_key*/ ) :
+                                              const Glib::ustring &/*default_key*/,
+                                              const gchar* docTitle) :
     FileDialogBaseGtk(parentWindow, title, Gtk::FILE_CHOOSER_ACTION_SAVE, fileTypes, "dialogs.save_as")
 {
+    FileSaveDialog::myDocTitle = docTitle;
+
     /* One file at a time */
     set_select_multiple(false);
 
@@ -928,13 +929,18 @@ FileSaveDialogImplGtk::FileSaveDialogImplGtk( Gtk::Window &parentWindow,
         expander->set_expanded(true);
         }
 
-       // allow easy access to the user's own templates folder          
+    // allow easy access to the user's own templates folder
     gchar *templates = profile_path ("templates");
-    if (Inkscape::IO::file_test(templates, (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)))
+    if ( Inkscape::IO::file_test(templates, G_FILE_TEST_EXISTS)
+         && Inkscape::IO::file_test(templates, G_FILE_TEST_IS_DIR)
+         && g_path_is_absolute(templates)
+        )
+    {
         add_shortcut_folder(templates);
+    }
     g_free (templates);
-       
-       
+
+
     //if (extension == NULL)
     //    checkbox.set_sensitive(FALSE);
 
@@ -1141,7 +1147,7 @@ void FileSaveDialogImplGtk::setSelectionType( Inkscape::Extension::Extension * k
 
 Glib::ustring FileSaveDialogImplGtk::getCurrentDirectory()
 {
-       return get_current_folder();
+    return get_current_folder();
 }
 
 
@@ -1157,8 +1163,8 @@ FileSaveDialogImplGtk::change_title(const Glib::ustring& title)
 void
 FileSaveDialogImplGtk::change_path(const Glib::ustring& path)
 {
-       myFilename = path;
-       
+    myFilename = path;
+
     if (Glib::file_test(myFilename, Glib::FILE_TEST_IS_DIR)) {
         //fprintf(stderr,"set_current_folder(%s)\n",myFilename.c_str());
         set_current_folder(myFilename);
@@ -1199,8 +1205,8 @@ void FileSaveDialogImplGtk::updateNameAndExtension()
 
     Inkscape::Extension::Output* newOut = extension ? dynamic_cast<Inkscape::Extension::Output*>(extension) : 0;
     if ( fileTypeCheckbox.get_active() && newOut ) {
-               // Append the file extension if it's not already present
-               appendExtension(myFilename, newOut);
+        // Append the file extension if it's not already present
+        appendExtension(myFilename, newOut);
     }
 }