Move the special directory query helpers into the places browser.
This commit is contained in:
parent
e78d29ef35
commit
b62b78e2f8
@ -20,23 +20,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "safegtk.h"
|
#include "safegtk.h"
|
||||||
#include "../rtgui/guiutils.h"
|
|
||||||
#include <glib/gstdio.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#ifdef WIN32
|
|
||||||
#include <windows.h>
|
|
||||||
// for GCC32
|
|
||||||
#ifndef _WIN32_IE
|
|
||||||
#define _WIN32_IE 0x0600
|
|
||||||
#endif
|
|
||||||
#include <shlobj.h>
|
|
||||||
#include <Shlwapi.h>
|
|
||||||
#else
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#endif
|
|
||||||
#include "../rtgui/rtimage.h"
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include <glib/gstdio.h>
|
||||||
|
|
||||||
|
#include "../rtgui/guiutils.h"
|
||||||
|
|
||||||
Glib::RefPtr<Gio::FileInfo> safe_query_file_info (Glib::RefPtr<Gio::File> &file)
|
Glib::RefPtr<Gio::FileInfo> safe_query_file_info (Glib::RefPtr<Gio::File> &file)
|
||||||
{
|
{
|
||||||
@ -285,97 +276,3 @@ int safe_g_mkdir_with_parents(const Glib::ustring& dirName, int mode)
|
|||||||
{
|
{
|
||||||
return ::g_mkdir_with_parents(dirName.c_str(), mode);
|
return ::g_mkdir_with_parents(dirName.c_str(), mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
Glib::ustring safe_get_user_picture_dir()
|
|
||||||
{
|
|
||||||
#ifdef WIN32
|
|
||||||
// get_user_special_dir/pictures crashes on some Windows configurations.
|
|
||||||
// so we use the safe native functions here
|
|
||||||
WCHAR pathW[MAX_PATH] = {0};
|
|
||||||
|
|
||||||
if (SHGetSpecialFolderPathW(NULL, pathW, CSIDL_MYPICTURES, false)) {
|
|
||||||
char pathA[MAX_PATH];
|
|
||||||
WideCharToMultiByte(CP_UTF8, 0, pathW, -1, pathA, MAX_PATH, 0, 0);
|
|
||||||
return Glib::ustring(pathA);
|
|
||||||
} else {
|
|
||||||
return Glib::ustring("C:\\");
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
return Glib::get_user_special_dir (G_USER_DIRECTORY_PICTURES);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
Glib::ustring safe_get_user_home_dir()
|
|
||||||
{
|
|
||||||
#ifdef WIN32
|
|
||||||
// get_user_special_dir/pictures crashes on some Windows configurations.
|
|
||||||
// so we use the safe native functions here
|
|
||||||
WCHAR pathW[MAX_PATH] = {0};
|
|
||||||
|
|
||||||
if (SHGetSpecialFolderPathW(NULL, pathW, CSIDL_PERSONAL, false)) {
|
|
||||||
char pathA[MAX_PATH];
|
|
||||||
WideCharToMultiByte(CP_UTF8, 0, pathW, -1, pathA, MAX_PATH, 0, 0);
|
|
||||||
return Glib::ustring(pathA);
|
|
||||||
} else {
|
|
||||||
return Glib::ustring("C:\\");
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
return Glib::get_home_dir();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
Glib::ustring safe_get_user_profile_dir()
|
|
||||||
{
|
|
||||||
WCHAR pathW[MAX_PATH] = {0};
|
|
||||||
|
|
||||||
if (SHGetSpecialFolderPathW(NULL, pathW, CSIDL_PROFILE, false)) {
|
|
||||||
char pathA[MAX_PATH];
|
|
||||||
WideCharToMultiByte(CP_UTF8, 0, pathW, -1, pathA, MAX_PATH, 0, 0);
|
|
||||||
return Glib::ustring(pathA);
|
|
||||||
} else {
|
|
||||||
return Glib::ustring("C:\\");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
Glib::ustring safe_get_user_desktop_dir()
|
|
||||||
{
|
|
||||||
#ifdef WIN32
|
|
||||||
// get_user_special_dir/pictures crashes on some Windows configurations.
|
|
||||||
// so we use the safe native functions here
|
|
||||||
WCHAR pathW[MAX_PATH] = {0};
|
|
||||||
|
|
||||||
if (SHGetSpecialFolderPathW(NULL, pathW, CSIDL_DESKTOP, false)) {
|
|
||||||
char pathA[MAX_PATH];
|
|
||||||
WideCharToMultiByte(CP_UTF8, 0, pathW, -1, pathA, MAX_PATH, 0, 0);
|
|
||||||
return Glib::ustring(pathA);
|
|
||||||
} else {
|
|
||||||
return Glib::ustring("C:\\");
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
return Glib::get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
|
|
||||||
|
|
||||||
#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_shortcut_dir (const Glib::ustring& path)
|
|
||||||
{
|
|
||||||
return PathIsRootA(path.c_str()) || safe_get_user_home_dir() == path || safe_get_user_desktop_dir() == path || safe_get_user_profile_dir() == path; // || safe_get_user_picture_dir() == path;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
@ -25,13 +25,4 @@ int safe_g_remove(const Glib::ustring& filename);
|
|||||||
int safe_g_rename(const Glib::ustring& oldFilename, const Glib::ustring& newFilename);
|
int safe_g_rename(const Glib::ustring& oldFilename, const Glib::ustring& newFilename);
|
||||||
int safe_g_mkdir_with_parents(const Glib::ustring& dirName, int mode);
|
int safe_g_mkdir_with_parents(const Glib::ustring& dirName, int mode);
|
||||||
|
|
||||||
Glib::ustring safe_get_user_picture_dir();
|
|
||||||
Glib::ustring safe_get_user_home_dir();
|
|
||||||
Glib::ustring safe_get_user_desktop_dir();
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
Glib::ustring safe_get_user_profile_dir();
|
|
||||||
bool safe_is_shortcut_dir (const Glib::ustring& filename);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -18,18 +18,21 @@
|
|||||||
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "editorpanel.h"
|
#include "editorpanel.h"
|
||||||
#include "options.h"
|
|
||||||
#include "progressconnector.h"
|
#include <iostream>
|
||||||
#include "rtwindow.h"
|
|
||||||
#include "guiutils.h"
|
|
||||||
#include "procparamchangers.h"
|
|
||||||
#include "../rtengine/safegtk.h"
|
#include "../rtengine/safegtk.h"
|
||||||
#include "../rtengine/imagesource.h"
|
#include "../rtengine/imagesource.h"
|
||||||
#include "../rtengine/iccstore.h"
|
#include "../rtengine/iccstore.h"
|
||||||
#include "soundman.h"
|
#include "soundman.h"
|
||||||
#include "rtimage.h"
|
#include "rtimage.h"
|
||||||
#include <iostream>
|
#include "rtwindow.h"
|
||||||
|
#include "guiutils.h"
|
||||||
#include "popupbutton.h"
|
#include "popupbutton.h"
|
||||||
|
#include "options.h"
|
||||||
|
#include "progressconnector.h"
|
||||||
|
#include "procparamchangers.h"
|
||||||
|
#include "placesbrowser.h"
|
||||||
|
|
||||||
using namespace rtengine::procparams;
|
using namespace rtengine::procparams;
|
||||||
|
|
||||||
@ -1543,7 +1546,7 @@ void EditorPanel::saveAsPressed ()
|
|||||||
if (safe_file_test (options.lastSaveAsPath, Glib::FILE_TEST_IS_DIR)) {
|
if (safe_file_test (options.lastSaveAsPath, Glib::FILE_TEST_IS_DIR)) {
|
||||||
saveAsDialog = new SaveAsDialog (options.lastSaveAsPath);
|
saveAsDialog = new SaveAsDialog (options.lastSaveAsPath);
|
||||||
} else {
|
} else {
|
||||||
saveAsDialog = new SaveAsDialog (safe_get_user_picture_dir());
|
saveAsDialog = new SaveAsDialog (PlacesBrowser::userPicturesDir ());
|
||||||
}
|
}
|
||||||
|
|
||||||
saveAsDialog->set_default_size (options.saveAsDialogWidth, options.saveAsDialogHeight);
|
saveAsDialog->set_default_size (options.saveAsDialogWidth, options.saveAsDialogHeight);
|
||||||
|
@ -17,22 +17,26 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include <glib/gstdio.h>
|
#include "filecatalog.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include "../rtengine/rt_math.h"
|
|
||||||
|
|
||||||
#include "filecatalog.h"
|
#include <glib/gstdio.h>
|
||||||
#include "filepanel.h"
|
|
||||||
|
#include "../rtengine/rt_math.h"
|
||||||
|
#include "../rtengine/safegtk.h"
|
||||||
|
|
||||||
|
#include "guiutils.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
#include "rtimage.h"
|
||||||
#include "cachemanager.h"
|
#include "cachemanager.h"
|
||||||
#include "multilangmgr.h"
|
#include "multilangmgr.h"
|
||||||
#include "guiutils.h"
|
#include "filepanel.h"
|
||||||
#include "renamedlg.h"
|
#include "renamedlg.h"
|
||||||
#include "thumbimageupdater.h"
|
#include "thumbimageupdater.h"
|
||||||
#include "../rtengine/safegtk.h"
|
|
||||||
#include "batchqueue.h"
|
#include "batchqueue.h"
|
||||||
#include "rtimage.h"
|
#include "placesbrowser.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -2027,10 +2031,9 @@ void FileCatalog::buttonBrowsePathPressed ()
|
|||||||
FirstChar = BrowsePathValue.substr (0, 1);
|
FirstChar = BrowsePathValue.substr (0, 1);
|
||||||
|
|
||||||
if (FirstChar == "~") { // home directory
|
if (FirstChar == "~") { // home directory
|
||||||
DecodedPathPrefix = Glib::get_home_dir();
|
DecodedPathPrefix = PlacesBrowser::userHomeDir ();
|
||||||
} else if (FirstChar == "!") { // user's pictures directory
|
} else if (FirstChar == "!") { // user's pictures directory
|
||||||
//DecodedPathPrefix = g_get_user_special_dir(G_USER_DIRECTORY_PICTURES);
|
DecodedPathPrefix = PlacesBrowser::userPicturesDir ();
|
||||||
DecodedPathPrefix = safe_get_user_picture_dir();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DecodedPathPrefix.empty()) {
|
if (!DecodedPathPrefix.empty()) {
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is part of RawTherapee.
|
* This file is part of RawTherapee.
|
||||||
*
|
*
|
||||||
@ -18,9 +17,12 @@
|
|||||||
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "filepanel.h"
|
#include "filepanel.h"
|
||||||
#include "rtwindow.h"
|
|
||||||
#include "../rtengine/safegtk.h"
|
#include "../rtengine/safegtk.h"
|
||||||
|
|
||||||
|
#include "rtwindow.h"
|
||||||
#include "inspector.h"
|
#include "inspector.h"
|
||||||
|
#include "placesbrowser.h"
|
||||||
|
|
||||||
int FilePanelInitUI (void* data)
|
int FilePanelInitUI (void* data)
|
||||||
{
|
{
|
||||||
@ -181,7 +183,7 @@ void FilePanel::init ()
|
|||||||
dirBrowser->open (argv1);
|
dirBrowser->open (argv1);
|
||||||
} else {
|
} else {
|
||||||
if (options.startupDir == STARTUPDIR_HOME) {
|
if (options.startupDir == STARTUPDIR_HOME) {
|
||||||
dirBrowser->open (safe_get_user_picture_dir());
|
dirBrowser->open (PlacesBrowser::userPicturesDir ());
|
||||||
} else if (options.startupDir == STARTUPDIR_CURRENT) {
|
} else if (options.startupDir == STARTUPDIR_CURRENT) {
|
||||||
dirBrowser->open (argv0);
|
dirBrowser->open (argv0);
|
||||||
} else if (options.startupDir == STARTUPDIR_CUSTOM || options.startupDir == STARTUPDIR_LAST) {
|
} else if (options.startupDir == STARTUPDIR_CUSTOM || options.startupDir == STARTUPDIR_LAST) {
|
||||||
@ -189,7 +191,7 @@ void FilePanel::init ()
|
|||||||
dirBrowser->open (options.startupPath);
|
dirBrowser->open (options.startupPath);
|
||||||
} else {
|
} else {
|
||||||
// Fallback option if the path is empty or the folder doesn't exist
|
// Fallback option if the path is empty or the folder doesn't exist
|
||||||
dirBrowser->open (safe_get_user_picture_dir());
|
dirBrowser->open (PlacesBrowser::userPicturesDir ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -392,28 +392,21 @@ void FlatField::flatFieldAutoSelectChanged()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlatField::setShortcutPath(Glib::ustring path)
|
void FlatField::setShortcutPath(const Glib::ustring& path)
|
||||||
{
|
{
|
||||||
if (path == "") {
|
if (path.empty ()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
|
|
||||||
// Dirty workaround, waiting for a clean solution by using exceptions!
|
|
||||||
if (!safe_is_shortcut_dir(path))
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
if (lastShortcutPath != "") {
|
|
||||||
try {
|
try {
|
||||||
flatFieldFile->remove_shortcut_folder(lastShortcutPath);
|
|
||||||
} catch (Glib::Error &err) {}
|
if (!lastShortcutPath.empty ()) {
|
||||||
|
flatFieldFile->remove_shortcut_folder (lastShortcutPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flatFieldFile->add_shortcut_folder (path);
|
||||||
|
|
||||||
lastShortcutPath = path;
|
lastShortcutPath = path;
|
||||||
|
|
||||||
try {
|
} catch (Glib::Error&) {}
|
||||||
flatFieldFile->add_shortcut_folder(path);
|
|
||||||
} catch (Glib::Error &err) {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ public:
|
|||||||
void flatFieldFile_Reset ();
|
void flatFieldFile_Reset ();
|
||||||
void flatFieldAutoSelectChanged ();
|
void flatFieldAutoSelectChanged ();
|
||||||
void flatFieldBlurTypeChanged ();
|
void flatFieldBlurTypeChanged ();
|
||||||
void setShortcutPath(Glib::ustring path);
|
void setShortcutPath (const Glib::ustring& path);
|
||||||
void setFFProvider (FFProvider* p)
|
void setFFProvider (FFProvider* p)
|
||||||
{
|
{
|
||||||
ffp = p;
|
ffp = p;
|
||||||
|
@ -17,11 +17,17 @@
|
|||||||
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "placesbrowser.h"
|
#include "placesbrowser.h"
|
||||||
#include "options.h"
|
|
||||||
#include "toolpanel.h"
|
#ifdef WIN32
|
||||||
#include "../rtengine/safegtk.h"
|
#include <windows.h>
|
||||||
|
#include <shlobj.h>
|
||||||
|
#include <Shlwapi.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "guiutils.h"
|
#include "guiutils.h"
|
||||||
#include "rtimage.h"
|
#include "rtimage.h"
|
||||||
|
#include "options.h"
|
||||||
|
#include "toolpanel.h"
|
||||||
|
|
||||||
PlacesBrowser::PlacesBrowser ()
|
PlacesBrowser::PlacesBrowser ()
|
||||||
{
|
{
|
||||||
@ -86,17 +92,14 @@ bool compareMountByRoot (Glib::RefPtr<Gio::Mount> a, Glib::RefPtr<Gio::Mount> b)
|
|||||||
|
|
||||||
void PlacesBrowser::refreshPlacesList ()
|
void PlacesBrowser::refreshPlacesList ()
|
||||||
{
|
{
|
||||||
|
|
||||||
placesModel->clear ();
|
placesModel->clear ();
|
||||||
|
|
||||||
// append home directory
|
// append home directory
|
||||||
Glib::RefPtr<Gio::File> hfile = Gio::File::create_for_path (safe_get_user_home_dir()); // Will send back "My documents" on Windows now, which has no restricted access
|
Glib::RefPtr<Gio::File> hfile = Gio::File::create_for_path (userHomeDir()); // Will send back "My documents" on Windows now, which has no restricted access
|
||||||
|
|
||||||
if (hfile && hfile->query_exists()) {
|
if (hfile && hfile->query_exists()) {
|
||||||
try {
|
try {
|
||||||
Glib::RefPtr<Gio::FileInfo> info = safe_query_file_info (hfile);
|
if (auto info = hfile->query_info ()) {
|
||||||
|
|
||||||
if (info) {
|
|
||||||
Gtk::TreeModel::Row newrow = *(placesModel->append());
|
Gtk::TreeModel::Row newrow = *(placesModel->append());
|
||||||
newrow[placesColumns.label] = info->get_display_name ();
|
newrow[placesColumns.label] = info->get_display_name ();
|
||||||
newrow[placesColumns.icon] = info->get_icon ();
|
newrow[placesColumns.icon] = info->get_icon ();
|
||||||
@ -104,19 +107,15 @@ void PlacesBrowser::refreshPlacesList ()
|
|||||||
newrow[placesColumns.type] = 4;
|
newrow[placesColumns.type] = 4;
|
||||||
newrow[placesColumns.rowSeparator] = false;
|
newrow[placesColumns.rowSeparator] = false;
|
||||||
}
|
}
|
||||||
} catch (Gio::Error&) {
|
} catch (Gio::Error&) {}
|
||||||
/* This will be thrown if the path doesn't exist */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// append pictures directory
|
// append pictures directory
|
||||||
hfile = Gio::File::create_for_path (safe_get_user_picture_dir());
|
hfile = Gio::File::create_for_path (userPicturesDir());
|
||||||
|
|
||||||
if (hfile && hfile->query_exists()) {
|
if (hfile && hfile->query_exists()) {
|
||||||
try {
|
try {
|
||||||
Glib::RefPtr<Gio::FileInfo> info = safe_query_file_info (hfile);
|
if (auto info = hfile->query_info ()) {
|
||||||
|
|
||||||
if (info) {
|
|
||||||
Gtk::TreeModel::Row newrow = *(placesModel->append());
|
Gtk::TreeModel::Row newrow = *(placesModel->append());
|
||||||
newrow[placesColumns.label] = info->get_display_name ();
|
newrow[placesColumns.label] = info->get_display_name ();
|
||||||
newrow[placesColumns.icon] = info->get_icon ();
|
newrow[placesColumns.icon] = info->get_icon ();
|
||||||
@ -124,9 +123,7 @@ void PlacesBrowser::refreshPlacesList ()
|
|||||||
newrow[placesColumns.type] = 4;
|
newrow[placesColumns.type] = 4;
|
||||||
newrow[placesColumns.rowSeparator] = false;
|
newrow[placesColumns.rowSeparator] = false;
|
||||||
}
|
}
|
||||||
} catch (Gio::Error&) {
|
} catch (Gio::Error&) {}
|
||||||
/* This will be thrown if the path doesn't exist */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!placesModel->children().empty()) {
|
if (!placesModel->children().empty()) {
|
||||||
@ -225,9 +222,8 @@ void PlacesBrowser::refreshPlacesList ()
|
|||||||
Glib::RefPtr<Gio::File> hfile = Gio::File::create_for_path (options.favoriteDirs[i]);
|
Glib::RefPtr<Gio::File> hfile = Gio::File::create_for_path (options.favoriteDirs[i]);
|
||||||
|
|
||||||
if (hfile && hfile->query_exists()) {
|
if (hfile && hfile->query_exists()) {
|
||||||
Glib::RefPtr<Gio::FileInfo> info = safe_query_file_info (hfile);
|
try {
|
||||||
|
if (auto info = hfile->query_info ()) {
|
||||||
if (info) {
|
|
||||||
Gtk::TreeModel::Row newrow = *(placesModel->append());
|
Gtk::TreeModel::Row newrow = *(placesModel->append());
|
||||||
newrow[placesColumns.label] = info->get_display_name ();
|
newrow[placesColumns.label] = info->get_display_name ();
|
||||||
newrow[placesColumns.icon] = info->get_icon ();
|
newrow[placesColumns.icon] = info->get_icon ();
|
||||||
@ -235,6 +231,7 @@ void PlacesBrowser::refreshPlacesList ()
|
|||||||
newrow[placesColumns.type] = 5;
|
newrow[placesColumns.type] = 5;
|
||||||
newrow[placesColumns.rowSeparator] = false;
|
newrow[placesColumns.rowSeparator] = false;
|
||||||
}
|
}
|
||||||
|
} catch(Gio::Error&) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -315,12 +312,12 @@ void PlacesBrowser::addPressed ()
|
|||||||
Glib::RefPtr<Gio::File> hfile = Gio::File::create_for_path (lastSelectedDir);
|
Glib::RefPtr<Gio::File> hfile = Gio::File::create_for_path (lastSelectedDir);
|
||||||
|
|
||||||
if (hfile && hfile->query_exists()) {
|
if (hfile && hfile->query_exists()) {
|
||||||
Glib::RefPtr<Gio::FileInfo> info = safe_query_file_info (hfile);
|
try {
|
||||||
|
if (auto info = hfile->query_info ()) {
|
||||||
if (info) {
|
|
||||||
options.favoriteDirs.push_back (hfile->get_parse_name ());
|
options.favoriteDirs.push_back (hfile->get_parse_name ());
|
||||||
refreshPlacesList ();
|
refreshPlacesList ();
|
||||||
}
|
}
|
||||||
|
} catch(Gio::Error&) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,3 +339,52 @@ void PlacesBrowser::delPressed ()
|
|||||||
refreshPlacesList ();
|
refreshPlacesList ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Glib::ustring PlacesBrowser::userHomeDir ()
|
||||||
|
{
|
||||||
|
#ifdef WIN32
|
||||||
|
|
||||||
|
// get_home_dir crashes on some Windows configurations,
|
||||||
|
// so we rather use the safe native functions here.
|
||||||
|
WCHAR pathW[MAX_PATH];
|
||||||
|
if (SHGetSpecialFolderPathW (NULL, pathW, CSIDL_PERSONAL, false)) {
|
||||||
|
|
||||||
|
char pathA[MAX_PATH];
|
||||||
|
if (WideCharToMultiByte (CP_UTF8, 0, pathW, -1, pathA, MAX_PATH, 0, 0)) {
|
||||||
|
|
||||||
|
return Glib::ustring (pathA);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Glib::ustring ("C:\\");
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
return Glib::get_home_dir ();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
Glib::ustring PlacesBrowser::userPicturesDir ()
|
||||||
|
{
|
||||||
|
#ifdef WIN32
|
||||||
|
|
||||||
|
// get_user_special_dir crashes on some Windows configurations,
|
||||||
|
// so we rather use the safe native functions here.
|
||||||
|
WCHAR pathW[MAX_PATH];
|
||||||
|
if (SHGetSpecialFolderPathW (NULL, pathW, CSIDL_MYPICTURES, false)) {
|
||||||
|
|
||||||
|
char pathA[MAX_PATH];
|
||||||
|
if (WideCharToMultiByte (CP_UTF8, 0, pathW, -1, pathA, MAX_PATH, 0, 0)) {
|
||||||
|
|
||||||
|
return Glib::ustring (pathA);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Glib::ustring ("C:\\");
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
return Glib::get_user_special_dir (G_USER_DIRECTORY_PICTURES);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
@ -72,6 +72,12 @@ public:
|
|||||||
void selectionChanged ();
|
void selectionChanged ();
|
||||||
void addPressed ();
|
void addPressed ();
|
||||||
void delPressed ();
|
void delPressed ();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
static Glib::ustring userHomeDir ();
|
||||||
|
static Glib::ustring userPicturesDir ();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void PlacesBrowser::setDirSelector (const PlacesBrowser::DirSelectionSlot& selectDir)
|
inline void PlacesBrowser::setDirSelector (const PlacesBrowser::DirSelectionSlot& selectDir)
|
||||||
|
@ -293,24 +293,14 @@ void ProfilePanel::save_clicked (GdkEventButton* event)
|
|||||||
dialog.set_current_name (lastFilename);
|
dialog.set_current_name (lastFilename);
|
||||||
|
|
||||||
//Add the user's default (or global if multiuser=false) profile path to the Shortcut list
|
//Add the user's default (or global if multiuser=false) profile path to the Shortcut list
|
||||||
#ifdef WIN32
|
|
||||||
|
|
||||||
// Dirty workaround, waiting for a clean solution by using exceptions!
|
|
||||||
if (!safe_is_shortcut_dir(options.getPreferredProfilePath()))
|
|
||||||
#endif
|
|
||||||
try {
|
try {
|
||||||
dialog.add_shortcut_folder(options.getPreferredProfilePath());
|
dialog.add_shortcut_folder(options.getPreferredProfilePath());
|
||||||
} catch (Glib::Error &err) {}
|
} catch (Glib::Error&) {}
|
||||||
|
|
||||||
//Add the image's path to the Shortcut list
|
//Add the image's path to the Shortcut list
|
||||||
#ifdef WIN32
|
|
||||||
|
|
||||||
// Dirty workaround, waiting for a clean solution by using exceptions!
|
|
||||||
if (!safe_is_shortcut_dir(imagePath))
|
|
||||||
#endif
|
|
||||||
try {
|
try {
|
||||||
dialog.add_shortcut_folder(imagePath);
|
dialog.add_shortcut_folder(imagePath);
|
||||||
} catch (Glib::Error &err) {}
|
} catch (Glib::Error&) {}
|
||||||
|
|
||||||
//Add response buttons the the dialog:
|
//Add response buttons the the dialog:
|
||||||
dialog.add_button(Gtk::StockID("gtk-cancel"), Gtk::RESPONSE_CANCEL);
|
dialog.add_button(Gtk::StockID("gtk-cancel"), Gtk::RESPONSE_CANCEL);
|
||||||
@ -468,24 +458,14 @@ void ProfilePanel::load_clicked (GdkEventButton* event)
|
|||||||
bindCurrentFolder (dialog, options.loadSaveProfilePath);
|
bindCurrentFolder (dialog, options.loadSaveProfilePath);
|
||||||
|
|
||||||
//Add the user's default (or global if multiuser=false) profile path to the Shortcut list
|
//Add the user's default (or global if multiuser=false) profile path to the Shortcut list
|
||||||
#ifdef WIN32
|
|
||||||
|
|
||||||
// Dirty workaround, waiting for a clean solution by using exceptions!
|
|
||||||
if (!safe_is_shortcut_dir(options.getPreferredProfilePath()))
|
|
||||||
#endif
|
|
||||||
try {
|
try {
|
||||||
dialog.add_shortcut_folder(options.getPreferredProfilePath());
|
dialog.add_shortcut_folder(options.getPreferredProfilePath());
|
||||||
} catch (Glib::Error &err) {}
|
} catch (Glib::Error&) {}
|
||||||
|
|
||||||
//Add the image's path to the Shortcut list
|
//Add the image's path to the Shortcut list
|
||||||
#ifdef WIN32
|
|
||||||
|
|
||||||
// Dirty workaround, waiting for a clean solution by using exceptions!
|
|
||||||
if (!safe_is_shortcut_dir(imagePath))
|
|
||||||
#endif
|
|
||||||
try {
|
try {
|
||||||
dialog.add_shortcut_folder(imagePath);
|
dialog.add_shortcut_folder(imagePath);
|
||||||
} catch (Glib::Error &err) {}
|
} catch (Glib::Error&) {}
|
||||||
|
|
||||||
//Add response buttons the the dialog:
|
//Add response buttons the the dialog:
|
||||||
dialog.add_button(Gtk::StockID("gtk-cancel"), Gtk::RESPONSE_CANCEL);
|
dialog.add_button(Gtk::StockID("gtk-cancel"), Gtk::RESPONSE_CANCEL);
|
||||||
|
@ -286,20 +286,13 @@ void SaveAsDialog::setInitialFileName (Glib::ustring fname)
|
|||||||
fchooser->set_current_name(fname);
|
fchooser->set_current_name(fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveAsDialog::setImagePath (Glib::ustring ipath)
|
void SaveAsDialog::setImagePath (const Glib::ustring& imagePath)
|
||||||
{
|
{
|
||||||
|
const auto dirName = Glib::path_get_dirname (imagePath);
|
||||||
|
|
||||||
Glib::ustring path = Glib::path_get_dirname(ipath);
|
|
||||||
|
|
||||||
//Add the image's path to the Shortcut list
|
|
||||||
#ifdef WIN32
|
|
||||||
|
|
||||||
// Dirty workaround, waiting for a clean solution by using exceptions!
|
|
||||||
if (!safe_is_shortcut_dir(path))
|
|
||||||
#endif
|
|
||||||
try {
|
try {
|
||||||
fchooser->add_shortcut_folder(path);
|
fchooser->add_shortcut_folder (dirName);
|
||||||
} catch (Glib::Error &err) {}
|
} catch (Glib::Error&) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ public:
|
|||||||
int getSaveMethodNum ();
|
int getSaveMethodNum ();
|
||||||
|
|
||||||
void setInitialFileName (Glib::ustring iname);
|
void setInitialFileName (Glib::ustring iname);
|
||||||
void setImagePath (Glib::ustring ipath);
|
void setImagePath (const Glib::ustring& imagePath);
|
||||||
|
|
||||||
void okPressed ();
|
void okPressed ();
|
||||||
void cancelPressed ();
|
void cancelPressed ();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user