desktop: Rename open_in_file_manager() function to open_object()

The new name is shorter, simpler, and its scope as broad as the
implementation.
This commit is contained in:
Ignacio R. Morelle 2014-02-12 03:09:04 -03:00
parent f426931b13
commit 95aa24cd53
4 changed files with 15 additions and 15 deletions

View File

@ -39,15 +39,15 @@ static lg::log_domain log_desktop("desktop");
namespace desktop {
bool open_in_file_manager(const std::string& path)
bool open_object(const std::string& path_or_url)
{
#if defined(_X11) || defined(__APPLE__)
#ifndef __APPLE__
LOG_DU << "open_in_file_manager(): on X11, will use xdg-open\n";
LOG_DU << "open_object(): on X11, will use xdg-open\n";
const char launcher[] = "xdg-open";
#else
LOG_DU << "open_in_file_manager(): on OS X, will use open\n";
LOG_DU << "open_object(): on OS X, will use open\n";
const char launcher[] = "open";
#endif
@ -55,22 +55,22 @@ bool open_in_file_manager(const std::string& path)
const pid_t child = fork();
if(child == -1) {
ERR_DU << "open_in_file_manager(): fork() failed\n";
ERR_DU << "open_object(): fork() failed\n";
return false;
} else if(child == 0) {
execlp(launcher, launcher, path.c_str(), reinterpret_cast<char*>(NULL));
execlp(launcher, launcher, path_or_url.c_str(), reinterpret_cast<char*>(NULL));
_exit(1); // This shouldn't happen.
} else if(waitpid(child, &child_status, 0) == -1) {
ERR_DU << "open_in_file_manager(): waitpid() failed\n";
ERR_DU << "open_object(): waitpid() failed\n";
return false;
}
if(child_status) {
if(WIFEXITED(child_status)) {
ERR_DU << "open_in_file_manager(): " << launcher << " returned "
ERR_DU << "open_object(): " << launcher << " returned "
<< WEXITSTATUS(child_status) << '\n';
} else {
ERR_DU << "open_in_file_manager(): " << launcher << " failed\n";
ERR_DU << "open_object(): " << launcher << " failed\n";
}
return false;
@ -80,14 +80,14 @@ bool open_in_file_manager(const std::string& path)
#elif defined(_WIN32)
LOG_DU << "open_in_file_manager(): on Win32, will use ShellExecute()\n";
LOG_DU << "open_object(): on Win32, will use ShellExecute()\n";
wide_string wpath = utils::string_to_wstring(path);
wide_string wpath = utils::string_to_wstring(path_or_url);
wpath.push_back(wchar_t(0)); // Make wpath NULL-terminated
const ptrdiff_t res = reinterpret_cast<ptrdiff_t>(ShellExecute(NULL, L"open", &wpath.front(), NULL, NULL, SW_SHOW));
if(res <= 32) {
ERR_DU << "open_in_file_manager(): ShellExecute() failed (" << res << ")\n";
ERR_DU << "open_object(): ShellExecute() failed (" << res << ")\n";
return false;
}
@ -95,7 +95,7 @@ bool open_in_file_manager(const std::string& path)
#else
ERR_DU << "open_in_file_manager(): unsupported platform\n";
ERR_DU << "open_object(): unsupported platform\n";
return false;
#endif

View File

@ -24,7 +24,7 @@
namespace desktop {
bool open_in_file_manager(const std::string& path);
bool open_object(const std::string& path_or_url);
}

View File

@ -358,7 +358,7 @@ void taddon_description::browse_url_callback()
{
/* TODO: ask for confirmation */
desktop::open_in_file_manager(feedback_url_);
desktop::open_object(feedback_url_);
}
void taddon_description::copy_url_callback()

View File

@ -110,7 +110,7 @@ void tgame_paths::pre_show(CVideo& /*video*/, twindow& window)
void tgame_paths::browse_directory_callback(const std::string& path)
{
desktop::open_in_file_manager(path);
desktop::open_object(path);
}
void tgame_paths::copy_to_clipboard_callback(const std::string& path)