Route dialog work directory picker through platform services
This commit is contained in:
@@ -188,29 +188,25 @@ void NodeDialogSave::init_controls()
|
||||
if (btn_ok->on_click)
|
||||
btn_ok->on_click(btn_ok);
|
||||
};
|
||||
#if defined(_WIN32) || defined(__OSX__)
|
||||
static char path_buffer[256];
|
||||
btn_path = find<NodeButton>("btn-path");
|
||||
btn_path->on_click = [this](Node*){
|
||||
App::I->pick_dir([this](std::string path){
|
||||
LOG("change working path to %s", path.c_str());
|
||||
App::I->work_path = path;
|
||||
#ifdef _WIN32
|
||||
GetFullPathNameA(path.c_str(), sizeof(path_buffer), path_buffer, nullptr);
|
||||
#else
|
||||
realpath(path.c_str(), path_buffer);
|
||||
#endif
|
||||
working_path->set_text_format("Working dir: %s", path_buffer);
|
||||
});
|
||||
};
|
||||
working_path = find<NodeText>("path");
|
||||
#ifdef _WIN32
|
||||
GetFullPathNameA(App::I->work_path.c_str(), sizeof(path_buffer), path_buffer, nullptr);
|
||||
#else
|
||||
realpath(App::I->work_path.c_str(), path_buffer);
|
||||
#endif
|
||||
working_path->set_text_format("Working dir: %s", path_buffer);
|
||||
#endif
|
||||
if (App::I->supports_working_directory_picker())
|
||||
{
|
||||
btn_path = find<NodeButton>("btn-path");
|
||||
btn_path->on_click = [this](Node*) {
|
||||
App::I->pick_dir([this](std::string path) {
|
||||
LOG("change working path to %s", path.c_str());
|
||||
App::I->work_path = path;
|
||||
const auto display_path = App::I->format_working_directory_path(path);
|
||||
working_path->set_text_format(
|
||||
"Working dir: %s",
|
||||
display_path.c_str());
|
||||
});
|
||||
};
|
||||
working_path = find<NodeText>("path");
|
||||
const auto display_path = App::I->format_working_directory_path(App::I->work_path);
|
||||
working_path->set_text_format(
|
||||
"Working dir: %s",
|
||||
display_path.c_str());
|
||||
}
|
||||
}
|
||||
void NodeDialogSave::loaded()
|
||||
{
|
||||
@@ -253,29 +249,25 @@ void NodeDialogNewDoc::init_controls()
|
||||
if (btn_ok->on_click)
|
||||
btn_ok->on_click(btn_ok);
|
||||
};
|
||||
#if defined(_WIN32) || defined(__OSX__)
|
||||
static char path_buffer[256];
|
||||
btn_path = find<NodeButton>("btn-path");
|
||||
btn_path->on_click = [this](Node*){
|
||||
App::I->pick_dir([this](std::string path){
|
||||
LOG("change working path to %s", path.c_str());
|
||||
App::I->work_path = path;
|
||||
#ifdef _WIN32
|
||||
GetFullPathNameA(path.c_str(), sizeof(path_buffer), path_buffer, nullptr);
|
||||
#else
|
||||
realpath(path.c_str(), path_buffer);
|
||||
#endif
|
||||
working_path->set_text_format("Working dir: %s", path_buffer);
|
||||
});
|
||||
};
|
||||
working_path = find<NodeText>("path");
|
||||
#ifdef _WIN32
|
||||
GetFullPathNameA(App::I->work_path.c_str(), sizeof(path_buffer), path_buffer, nullptr);
|
||||
#else
|
||||
realpath(App::I->work_path.c_str(), path_buffer);
|
||||
#endif
|
||||
working_path->set_text_format("Working dir: %s", path_buffer);
|
||||
#endif
|
||||
if (App::I->supports_working_directory_picker())
|
||||
{
|
||||
btn_path = find<NodeButton>("btn-path");
|
||||
btn_path->on_click = [this](Node*) {
|
||||
App::I->pick_dir([this](std::string path) {
|
||||
LOG("change working path to %s", path.c_str());
|
||||
App::I->work_path = path;
|
||||
const auto display_path = App::I->format_working_directory_path(path);
|
||||
working_path->set_text_format(
|
||||
"Working dir: %s",
|
||||
display_path.c_str());
|
||||
});
|
||||
};
|
||||
working_path = find<NodeText>("path");
|
||||
const auto display_path = App::I->format_working_directory_path(App::I->work_path);
|
||||
working_path->set_text_format(
|
||||
"Working dir: %s",
|
||||
display_path.c_str());
|
||||
}
|
||||
}
|
||||
void NodeDialogNewDoc::loaded()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user