Fall back to custom external editor launcher
This commit is contained in:
@@ -318,22 +318,26 @@ bool ExtProgStore::openInPhotoshop (const Glib::ustring& fileName)
|
|||||||
return spawnCommandAsync (cmdLine);
|
return spawnCommandAsync (cmdLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ExtProgStore::openInCustomEditor (const Glib::ustring& fileName)
|
bool ExtProgStore::openInCustomEditor (const Glib::ustring& fileName, const Glib::ustring* command)
|
||||||
{
|
{
|
||||||
|
if (!command) {
|
||||||
|
command = &(options.customEditorProg);
|
||||||
|
}
|
||||||
|
|
||||||
#if defined WIN32
|
#if defined WIN32
|
||||||
|
|
||||||
const auto cmdLine = Glib::ustring("\"") + options.customEditorProg + Glib::ustring("\"");
|
const auto cmdLine = Glib::ustring("\"") + *command + Glib::ustring("\"");
|
||||||
auto success = ShellExecute( NULL, "open", cmdLine.c_str(), ('"' + fileName + '"').c_str(), NULL, SW_SHOWNORMAL );
|
auto success = ShellExecute( NULL, "open", cmdLine.c_str(), ('"' + fileName + '"').c_str(), NULL, SW_SHOWNORMAL );
|
||||||
return (uintptr_t)success > 32;
|
return (uintptr_t)success > 32;
|
||||||
|
|
||||||
#elif defined __APPLE__
|
#elif defined __APPLE__
|
||||||
|
|
||||||
const auto cmdLine = options.customEditorProg + Glib::ustring(" \"") + fileName + Glib::ustring("\"");
|
const auto cmdLine = *command + Glib::ustring(" \"") + fileName + Glib::ustring("\"");
|
||||||
return spawnCommandAsync (cmdLine);
|
return spawnCommandAsync (cmdLine);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
const auto cmdLine = options.customEditorProg + Glib::ustring(" ") + Glib::shell_quote(fileName);
|
const auto cmdLine = *command + Glib::ustring(" ") + Glib::shell_quote(fileName);
|
||||||
return spawnCommandAsync (cmdLine);
|
return spawnCommandAsync (cmdLine);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -342,13 +346,30 @@ bool ExtProgStore::openInCustomEditor (const Glib::ustring& fileName)
|
|||||||
|
|
||||||
bool ExtProgStore::openInExternalEditor(const Glib::ustring &fileName, const Glib::RefPtr<Gio::AppInfo> &editorInfo)
|
bool ExtProgStore::openInExternalEditor(const Glib::ustring &fileName, const Glib::RefPtr<Gio::AppInfo> &editorInfo)
|
||||||
{
|
{
|
||||||
|
bool success = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return editorInfo->launch(Gio::File::create_for_path(fileName));
|
success = editorInfo->launch(Gio::File::create_for_path(fileName));
|
||||||
} catch (const Glib::Error &e) {
|
} catch (const Glib::Error &e) {
|
||||||
std::cerr
|
std::cerr
|
||||||
<< "Error launching external editor.\n"
|
<< "Error launching external editor.\n"
|
||||||
<< "Error code #" << e.code() << ": " << e.what()
|
<< "Error code #" << e.code() << ": " << e.what()
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return false;
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rtengine::settings->verbose) {
|
||||||
|
std::cout << "Unable to launch external editor with Gio. Trying custom launcher." << std::endl;
|
||||||
|
}
|
||||||
|
Glib::ustring command = editorInfo->get_commandline();
|
||||||
|
#if defined WIN32
|
||||||
|
if (command.length() > 2 && command[0] == '"' && command[command.length() - 1] == '"') {
|
||||||
|
command = command.substr(1, command.length() - 2);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return openInCustomEditor(fileName, &command);
|
||||||
}
|
}
|
||||||
|
@@ -69,7 +69,7 @@ public:
|
|||||||
|
|
||||||
static bool openInGimp (const Glib::ustring& fileName);
|
static bool openInGimp (const Glib::ustring& fileName);
|
||||||
static bool openInPhotoshop (const Glib::ustring& fileName);
|
static bool openInPhotoshop (const Glib::ustring& fileName);
|
||||||
static bool openInCustomEditor (const Glib::ustring& fileName);
|
static bool openInCustomEditor (const Glib::ustring& fileName, const Glib::ustring* command = nullptr);
|
||||||
static bool openInExternalEditor(const Glib::ustring &fileName, const Glib::RefPtr<Gio::AppInfo> &editorInfo);
|
static bool openInExternalEditor(const Glib::ustring &fileName, const Glib::RefPtr<Gio::AppInfo> &editorInfo);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
class BatchQueueEntry;
|
class BatchQueueEntry;
|
||||||
class BatchQueuePanel;
|
class BatchQueuePanel;
|
||||||
class EditorPanel;
|
class EditorPanel;
|
||||||
class ExternalEditor;
|
struct ExternalEditor;
|
||||||
class FilePanel;
|
class FilePanel;
|
||||||
class PLDBridge;
|
class PLDBridge;
|
||||||
class RTWindow final :
|
class RTWindow final :
|
||||||
|
Reference in New Issue
Block a user