Skip to content

Commit

Permalink
Fix "Open Containing Folder" on Linux (SoftFever#6469)
Browse files Browse the repository at this point in the history
Fix "Open Containing Folder" on Linux (SoftFever#6449)
  • Loading branch information
Noisyfox authored Aug 18, 2024
1 parent 4dd7d79 commit 12c4ff0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/slic3r/GUI/GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ void desktop_open_datadir_folder()
#endif
}

void desktop_open_any_folder( const std::string path )
void desktop_open_any_folder( const std::string& path )
{
// Execute command to open a file explorer, platform dependent.
// FIXME: The const_casts aren't needed in wxWidgets 3.1, remove them when we upgrade.
Expand All @@ -558,7 +558,14 @@ void desktop_open_any_folder( const std::string path )
#elif __APPLE__
openFolderForFile(from_u8(path));
#else
const char *argv[] = {"xdg-open", path.data(), nullptr};

// Orca#6449: Open containing dir instead of opening the file directly.
std::string new_path = path;
boost::filesystem::path p(new_path);
if (!fs::is_directory(p)) {
new_path = p.parent_path().string();
}
const char* argv[] = {"xdg-open", new_path.data(), nullptr};

// Check if we're running in an AppImage container, if so, we need to remove AppImage's env vars,
// because they may mess up the environment expected by the file manager.
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/GUI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ extern void login();
// Ask the destop to open the datadir using the default file explorer.
extern void desktop_open_datadir_folder();
// Ask the destop to open one folder
extern void desktop_open_any_folder(const std::string path);
extern void desktop_open_any_folder(const std::string& path);
} // namespace GUI
} // namespace Slic3r

Expand Down

0 comments on commit 12c4ff0

Please sign in to comment.