Fix 1367916: don't use set_keep_below for the toolbox/etc, allowing the dock/etc...
[synfig.git] / synfig-studio / trunk / src / gtkmm / app.cpp
index e726bf6..14fc4b1 100644 (file)
 #endif
 
 #ifdef WIN32
+#define _WIN32_WINNT 0x0500
 #include <windows.h>
 #endif
 #include <gtkmm/accelmap.h>
+#include <gtkmm/filechooser.h>
+#include <gtkmm/filechooserdialog.h>
 
 #endif
 
@@ -658,7 +661,7 @@ public:
        }
 };
 
-static Preferences _preferences;
+static ::Preferences _preferences;
 
 void
 init_ui_manager()
@@ -1653,6 +1656,21 @@ App::dialog_open_file(const std::string &title, std::string &filename)
        if(!_preferences.get_value("curr_path",prev_path))
                prev_path=".";
        
+    Gtk::FileChooserDialog *dialog=new Gtk::FileChooserDialog(title,Gtk::FILE_CHOOSER_ACTION_OPEN);
+    dialog->set_current_folder(prev_path);
+    dialog->add_button(Gtk::StockID("gtk-ok"),GTK_RESPONSE_ACCEPT);
+    dialog->add_button(Gtk::StockID("gtk-cancel"),GTK_RESPONSE_CANCEL);
+    if(!filename.empty())
+        dialog->set_filename(filename);
+    if(dialog->run()==GTK_RESPONSE_ACCEPT) {
+        filename=dialog->get_filename();
+        delete dialog;
+        return true;
+    }
+    delete dialog;
+    return false;
+    /*
+    
        GtkWidget *ok;
        GtkWidget *cancel;
        int val=0;
@@ -1694,6 +1712,7 @@ App::dialog_open_file(const std::string &title, std::string &filename)
        }
        gtk_widget_destroy(fileselection);
        return true;
+    */
 #endif
 }
 
@@ -1742,7 +1761,24 @@ App::dialog_save_file(const std::string &title, std::string &filename)
        }
        return false;
 #else
-       return dialog_open_file(title, filename);
+       synfig::String prev_path;
+       if(!_preferences.get_value("curr_path",prev_path))
+               prev_path=".";
+       
+    Gtk::FileChooserDialog *dialog=new Gtk::FileChooserDialog(title,Gtk::FILE_CHOOSER_ACTION_SAVE);
+    dialog->set_current_folder(prev_path);
+    dialog->add_button(Gtk::StockID("gtk-ok"),GTK_RESPONSE_ACCEPT);
+    dialog->add_button(Gtk::StockID("gtk-cancel"),GTK_RESPONSE_CANCEL);
+    if(!filename.empty())
+        dialog->set_filename(filename);
+    if(dialog->run()==GTK_RESPONSE_ACCEPT) {
+        filename=dialog->get_filename();
+        delete dialog;
+        return true;
+    }
+    delete dialog;
+    return false;
+//     return dialog_open_file(title, filename);
 #endif
 }
 
@@ -1791,7 +1827,24 @@ App::dialog_saveas_file(const std::string &title, std::string &filename)
        }
        return false;
 #else
-       return dialog_open_file(title, filename);
+       synfig::String prev_path;
+       if(!_preferences.get_value("curr_path",prev_path))
+               prev_path=".";
+       
+    Gtk::FileChooserDialog *dialog=new Gtk::FileChooserDialog(title,Gtk::FILE_CHOOSER_ACTION_SAVE);
+    dialog->set_current_folder(prev_path);
+    dialog->add_button(Gtk::StockID("gtk-ok"),GTK_RESPONSE_ACCEPT);
+    dialog->add_button(Gtk::StockID("gtk-cancel"),GTK_RESPONSE_CANCEL);
+    if(!filename.empty())
+        dialog->set_filename(filename);
+    if(dialog->run()==GTK_RESPONSE_ACCEPT) {
+        filename=dialog->get_filename();
+        delete dialog;
+        return true;
+    }
+    delete dialog;
+    return false;
+//     return dialog_open_file(title, filename);
 #endif
 }
 
@@ -1927,6 +1980,12 @@ App::open(std::string filename)
 bool
 App::open_as(std::string filename,std::string as)
 {
+#ifdef WIN32
+    char long_name[1024];
+    if(GetLongPathName(as.c_str(),long_name,sizeof(long_name)));
+    as=long_name;
+#endif
+
        try
        {
                OneMoment one_moment;