diff --git a/rtengine/safegtk.cc b/rtengine/safegtk.cc index c0cf1e4d3..d55efdf3f 100644 --- a/rtengine/safegtk.cc +++ b/rtengine/safegtk.cc @@ -406,3 +406,16 @@ Glib::ustring safe_get_user_picture_dir() { #endif } + +#ifdef WIN32 +/* + * Test if the path is a root path based on the content of the string + * + * Warning: this function is a workaround for Windows platform, and not necessarily bullet proof + */ +bool safe_is_root_dir (const Glib::ustring& path) { + Glib::ustring t = Glib::path_skip_root(path); + return t.empty(); +} +#endif + diff --git a/rtengine/safegtk.h b/rtengine/safegtk.h index c9e832b00..ec8743ff4 100644 --- a/rtengine/safegtk.h +++ b/rtengine/safegtk.h @@ -41,4 +41,9 @@ int safe_g_rename(const Glib::ustring& oldFilename, const Glib::ustring& newFile int safe_g_mkdir_with_parents(const Glib::ustring& dirName, int mode); Glib::ustring safe_get_user_picture_dir(); + +#ifdef WIN32 +bool safe_is_root_dir (const Glib::ustring& filename); +#endif + #endif diff --git a/rtgui/profilepanel.cc b/rtgui/profilepanel.cc index 94f2d6576..c4a92ded1 100644 --- a/rtgui/profilepanel.cc +++ b/rtgui/profilepanel.cc @@ -138,9 +138,23 @@ void ProfilePanel::save_clicked (GdkEventButton* event) { dialog.set_current_name (lastFilename); //Add the user's default (or global if multiuser=false) profile path to the Shortcut list - dialog.add_shortcut_folder(options.getPreferredProfilePath()); +#ifdef WIN32 + // Dirty workaround, waiting for a clean solution by using exceptions! + if (!safe_is_root_dir(options.getPreferredProfilePath())) +#endif + try { + dialog.add_shortcut_folder(options.getPreferredProfilePath()); + } + catch (Gtk::FileChooserError &err) {} //Add the image's path to the Shortcut list - dialog.add_shortcut_folder(imagePath); +#ifdef WIN32 + // Dirty workaround, waiting for a clean solution by using exceptions! + if (!safe_is_root_dir(imagePath)) +#endif + try { + dialog.add_shortcut_folder(imagePath); + } + catch (Gtk::FileChooserError &err) {} //Add response buttons the the dialog: dialog.add_button(Gtk::StockID("gtk-cancel"), Gtk::RESPONSE_CANCEL); @@ -272,9 +286,24 @@ void ProfilePanel::load_clicked (GdkEventButton* event) { FileChooserLastFolderPersister persister( &dialog, options.loadSaveProfilePath ); //Add the user's default (or global if multiuser=false) profile path to the Shortcut list - dialog.add_shortcut_folder(options.getPreferredProfilePath()); +#ifdef WIN32 + // Dirty workaround, waiting for a clean solution by using exceptions! + if (!safe_is_root_dir(options.getPreferredProfilePath())) +#endif + try { + dialog.add_shortcut_folder(options.getPreferredProfilePath()); + } + catch (Gtk::FileChooserError &err) {} + //Add the image's path to the Shortcut list - dialog.add_shortcut_folder(imagePath); +#ifdef WIN32 + // Dirty workaround, waiting for a clean solution by using exceptions! + if (!safe_is_root_dir(imagePath)) +#endif + try { + dialog.add_shortcut_folder(imagePath); + } + catch (Gtk::FileChooserError &err) {} //Add response buttons the the dialog: dialog.add_button(Gtk::StockID("gtk-cancel"), Gtk::RESPONSE_CANCEL); diff --git a/rtgui/saveasdlg.cc b/rtgui/saveasdlg.cc index bb18a3fcf..6024ec250 100644 --- a/rtgui/saveasdlg.cc +++ b/rtgui/saveasdlg.cc @@ -255,6 +255,15 @@ void SaveAsDialog::setInitialFileName (Glib::ustring fname) { void SaveAsDialog::setImagePath (Glib::ustring ipath) { + Glib::ustring path = Glib::path_get_dirname(ipath); + //Add the image's path to the Shortcut list - fchooser->add_shortcut_folder(Glib::path_get_dirname(ipath)); +#ifdef WIN32 + // Dirty workaround, waiting for a clean solution by using exceptions! + if (!safe_is_root_dir(path)) +#endif + try { + fchooser->add_shortcut_folder(Glib::path_get_dirname(path)); + } + catch (Gtk::FileChooserError &err) {} }