parent
ec63f8f0c2
commit
4c5102334b
@ -338,42 +338,47 @@ void DesktopIntegrationDialog::perform_desktop_integration(bool perform_download
|
|||||||
"StartupNotify=false\n"
|
"StartupNotify=false\n"
|
||||||
"StartupWMClass=prusa-slicer\n", name_suffix, version_suffix, excutable_path);
|
"StartupWMClass=prusa-slicer\n", name_suffix, version_suffix, excutable_path);
|
||||||
|
|
||||||
|
bool candidate_found = false;
|
||||||
for (size_t i = 0; i < target_candidates.size(); ++i) {
|
for (size_t i = 0; i < target_candidates.size(); ++i) {
|
||||||
if (contains_path_dir(target_candidates[i], "applications")) {
|
if (contains_path_dir(target_candidates[i], "applications")) {
|
||||||
target_dir_desktop = target_candidates[i];
|
target_dir_desktop = target_candidates[i];
|
||||||
// Write slicer desktop file
|
// Write slicer desktop file
|
||||||
std::string path = GUI::format("%1%/applications/PrusaSlicer%2%.desktop", target_dir_desktop, version_suffix);
|
std::string path = GUI::format("%1%/applications/PrusaSlicer%2%.desktop", target_dir_desktop, version_suffix);
|
||||||
if (create_desktop_file(path, desktop_file)){
|
if (create_desktop_file(path, desktop_file)) {
|
||||||
|
candidate_found = true;
|
||||||
BOOST_LOG_TRIVIAL(debug) << "PrusaSlicer.desktop file installation success.";
|
BOOST_LOG_TRIVIAL(debug) << "PrusaSlicer.desktop file installation success.";
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
// write failed - try another path
|
else {
|
||||||
|
// write failed - try another path
|
||||||
BOOST_LOG_TRIVIAL(debug) << "Attempt to PrusaSlicer.desktop file installation failed. failed path: " << target_candidates[i];
|
BOOST_LOG_TRIVIAL(debug) << "Attempt to PrusaSlicer.desktop file installation failed. failed path: " << target_candidates[i];
|
||||||
target_dir_desktop.clear();
|
target_dir_desktop.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if all failed - try creating default home folder
|
}
|
||||||
if (i == target_candidates.size() - 1) {
|
// if all failed - try creating default home folder
|
||||||
// create $HOME/.local/share
|
if (!candidate_found) {
|
||||||
create_path(boost::nowide::narrow(wxFileName::GetHomeDir()), ".local/share/applications");
|
// create $HOME/.local/share
|
||||||
// create desktop file
|
create_path(boost::nowide::narrow(wxFileName::GetHomeDir()), ".local/share/applications");
|
||||||
target_dir_desktop = GUI::format("%1%/.local/share",wxFileName::GetHomeDir());
|
// create desktop file
|
||||||
std::string path = GUI::format("%1%/applications/PrusaSlicer%2%.desktop", target_dir_desktop, version_suffix);
|
target_dir_desktop = GUI::format("%1%/.local/share", wxFileName::GetHomeDir());
|
||||||
if (contains_path_dir(target_dir_desktop, "applications")) {
|
std::string path = GUI::format("%1%/applications/PrusaSlicer%2%.desktop", target_dir_desktop, version_suffix);
|
||||||
if (!create_desktop_file(path, desktop_file)) {
|
if (contains_path_dir(target_dir_desktop, "applications")) {
|
||||||
// Desktop file not written - end desktop integration
|
if (!create_desktop_file(path, desktop_file)) {
|
||||||
BOOST_LOG_TRIVIAL(error) << "Performing desktop integration failed - could not create desktop file";
|
// Desktop file not written - end desktop integration
|
||||||
return;
|
BOOST_LOG_TRIVIAL(error) << "Performing desktop integration failed - could not create desktop file";
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Desktop file not written - end desktop integration
|
|
||||||
BOOST_LOG_TRIVIAL(error) << "Performing desktop integration failed because the application directory was not found.";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// Desktop file not written - end desktop integration
|
||||||
|
BOOST_LOG_TRIVIAL(error) << "Performing desktop integration failed because the application directory was not found.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(target_dir_desktop.empty()) {
|
assert(!target_dir_desktop.empty());
|
||||||
// Desktop file not written - end desktop integration
|
if (target_dir_desktop.empty()) {
|
||||||
|
// Desktop file not written - end desktop integration
|
||||||
BOOST_LOG_TRIVIAL(error) << "Performing desktop integration failed because the application directory was not found.";
|
BOOST_LOG_TRIVIAL(error) << "Performing desktop integration failed because the application directory was not found.";
|
||||||
show_error(nullptr, _L("Performing desktop integration failed because the application directory was not found."));
|
show_error(nullptr, _L("Performing desktop integration failed because the application directory was not found."));
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user