mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 07:27:41 -06:00
fix url protocol integration under linux (#5535)
This commit is contained in:
parent
276e03683f
commit
47ab3a050e
3 changed files with 26 additions and 27 deletions
|
@ -455,9 +455,9 @@ void DesktopIntegrationDialog::undo_desktop_intgration()
|
||||||
wxGetApp().plater()->get_notification_manager()->push_notification(NotificationType::UndoDesktopIntegrationSuccess);
|
wxGetApp().plater()->get_notification_manager()->push_notification(NotificationType::UndoDesktopIntegrationSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DesktopIntegrationDialog::perform_downloader_desktop_integration()
|
void DesktopIntegrationDialog::perform_downloader_desktop_integration(std::string url_prefix)
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(debug) << "performing downloader desktop integration.";
|
BOOST_LOG_TRIVIAL(debug) << "performing downloader desktop integration. " << url_prefix ;
|
||||||
// Path to appimage
|
// Path to appimage
|
||||||
const char* appimage_env = std::getenv("APPIMAGE");
|
const char* appimage_env = std::getenv("APPIMAGE");
|
||||||
std::string excutable_path;
|
std::string excutable_path;
|
||||||
|
@ -531,34 +531,21 @@ void DesktopIntegrationDialog::perform_downloader_desktop_integration()
|
||||||
|
|
||||||
std::string desktop_file_downloader = GUI::format(
|
std::string desktop_file_downloader = GUI::format(
|
||||||
"[Desktop Entry]\n"
|
"[Desktop Entry]\n"
|
||||||
"Name=OrcaSlicer URL Protocol%1%\n"
|
"Name=OrcaSlicer URL Protocol %1% %2%\n"
|
||||||
"Exec=\"%2%\" %%u\n"
|
"Exec=%3% %%u\n"
|
||||||
"Terminal=false\n"
|
"Terminal=false\n"
|
||||||
"Type=Application\n"
|
"Type=Application\n"
|
||||||
"MimeType=x-scheme-handler/prusaslicer;\n"
|
"MimeType=x-scheme-handler/%1%;\n"
|
||||||
"StartupNotify=false\n"
|
"StartupNotify=false\n"
|
||||||
"NoDisplay=true\n"
|
"NoDisplay=true\n"
|
||||||
, name_suffix, excutable_path);
|
, url_prefix, name_suffix, excutable_path);
|
||||||
|
|
||||||
// desktop file for downloader as part of main app
|
|
||||||
std::string desktop_path = GUI::format("%1%/applications/OrcaSlicerURLProtocol%2%.desktop", target_dir_desktop, version_suffix);
|
|
||||||
if (create_desktop_file(desktop_path, desktop_file_downloader)) {
|
|
||||||
// save path to desktop file
|
|
||||||
app_config->set("desktop_integration_URL_path", desktop_path);
|
|
||||||
// finish registration on mime type
|
|
||||||
std::string command = GUI::format("xdg-mime default OrcaSlicerURLProtocol%1%.desktop x-scheme-handler/prusaslicer", version_suffix);
|
|
||||||
BOOST_LOG_TRIVIAL(debug) << "system command: " << command;
|
|
||||||
int r = system(command.c_str());
|
|
||||||
BOOST_LOG_TRIVIAL(debug) << "system result: " << r;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool candidate_found = false;
|
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/OrcaSlicerURLProtocol%2%.desktop", target_dir_desktop, version_suffix);
|
std::string path = GUI::format("%1%/applications/OrcaSlicerURLProtocol-%2%%3%.desktop", target_dir_desktop, url_prefix, version_suffix);
|
||||||
if (create_desktop_file(path, desktop_file_downloader)) {
|
if (create_desktop_file(path, desktop_file_downloader)) {
|
||||||
app_config->set("desktop_integration_URL_path", path);
|
app_config->set("desktop_integration_URL_path", path);
|
||||||
candidate_found = true;
|
candidate_found = true;
|
||||||
|
@ -578,7 +565,7 @@ void DesktopIntegrationDialog::perform_downloader_desktop_integration()
|
||||||
create_path(boost::nowide::narrow(wxFileName::GetHomeDir()), ".local/share/applications");
|
create_path(boost::nowide::narrow(wxFileName::GetHomeDir()), ".local/share/applications");
|
||||||
// create desktop file
|
// create desktop file
|
||||||
target_dir_desktop = GUI::format("%1%/.local/share", wxFileName::GetHomeDir());
|
target_dir_desktop = GUI::format("%1%/.local/share", wxFileName::GetHomeDir());
|
||||||
std::string path = GUI::format("%1%/applications/OrcaSlicerURLProtocol%2%.desktop", target_dir_desktop, version_suffix);
|
std::string path = GUI::format("%1%/applications/OrcaSlicerURLProtocol-%2%%3%.desktop", target_dir_desktop, url_prefix, version_suffix);
|
||||||
if (contains_path_dir(target_dir_desktop, "applications")) {
|
if (contains_path_dir(target_dir_desktop, "applications")) {
|
||||||
if (!create_desktop_file(path, desktop_file_downloader)) {
|
if (!create_desktop_file(path, desktop_file_downloader)) {
|
||||||
// Desktop file not written - end desktop integration
|
// Desktop file not written - end desktop integration
|
||||||
|
@ -601,8 +588,20 @@ void DesktopIntegrationDialog::perform_downloader_desktop_integration()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// desktop file for downloader as part of main app
|
||||||
|
std::string desktop_path = GUI::format("%1%/applications/OrcaSlicerURLProtocol-%2%%3%.desktop", target_dir_desktop, url_prefix, version_suffix);
|
||||||
|
if (create_desktop_file(desktop_path, desktop_file_downloader)) {
|
||||||
|
// save path to desktop file
|
||||||
|
app_config->set("desktop_integration_URL_path", desktop_path);
|
||||||
|
// finish registration on mime type
|
||||||
|
std::string command = GUI::format("xdg-mime default OrcaSlicerURLProtocol-%1%%2%.desktop x-scheme-handler/%1%", url_prefix, version_suffix);
|
||||||
|
BOOST_LOG_TRIVIAL(debug) << "system command: " << command;
|
||||||
|
int r = system(command.c_str());
|
||||||
|
BOOST_LOG_TRIVIAL(debug) << "system result: " << r;
|
||||||
|
}
|
||||||
|
|
||||||
// finish registration on mime type
|
// finish registration on mime type
|
||||||
std::string command = GUI::format("xdg-mime default OrcaSlicerURLProtocol%1%.desktop x-scheme-handler/prusaslicer", version_suffix);
|
std::string command = GUI::format("xdg-mime default OrcaSlicerURLProtocol-%1%%2%.desktop x-scheme-handler/%1%", url_prefix, version_suffix);
|
||||||
BOOST_LOG_TRIVIAL(debug) << "system command: " << command;
|
BOOST_LOG_TRIVIAL(debug) << "system command: " << command;
|
||||||
int r = system(command.c_str());
|
int r = system(command.c_str());
|
||||||
BOOST_LOG_TRIVIAL(debug) << "system result: " << r;
|
BOOST_LOG_TRIVIAL(debug) << "system result: " << r;
|
||||||
|
@ -668,4 +667,4 @@ DesktopIntegrationDialog::~DesktopIntegrationDialog()
|
||||||
|
|
||||||
} // namespace GUI
|
} // namespace GUI
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
#endif // __linux__
|
#endif // __linux__
|
||||||
|
|
|
@ -30,7 +30,7 @@ public:
|
||||||
// Deletes Desktop files and icons for both PrusaSlicer and GcodeViewer at paths stored in App Config.
|
// Deletes Desktop files and icons for both PrusaSlicer and GcodeViewer at paths stored in App Config.
|
||||||
static void undo_desktop_intgration();
|
static void undo_desktop_intgration();
|
||||||
|
|
||||||
static void perform_downloader_desktop_integration();
|
static void perform_downloader_desktop_integration(std::string url_prefix);
|
||||||
static void undo_downloader_registration();
|
static void undo_downloader_registration();
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -39,4 +39,4 @@ private:
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|
||||||
#endif // slic3r_DesktopIntegrationDialog_hpp_
|
#endif // slic3r_DesktopIntegrationDialog_hpp_
|
||||||
#endif // __linux__
|
#endif // __linux__
|
||||||
|
|
|
@ -6601,8 +6601,8 @@ void GUI_App::associate_url(std::wstring url_prefix)
|
||||||
key_full.Create(false);
|
key_full.Create(false);
|
||||||
}
|
}
|
||||||
key_full = key_string;
|
key_full = key_string;
|
||||||
#elif defined(__linux__) && defined(SLIC3R_DESKTOP_INTEGRATION)
|
#elif defined(__linux__) && defined(SLIC3R_DESKTOP_INTEGRATION)
|
||||||
DesktopIntegrationDialog::perform_downloader_desktop_integration();
|
DesktopIntegrationDialog::perform_downloader_desktop_integration(boost::nowide::narrow(url_prefix));
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue