Merge pull request #3946 from Beep6581/remote-app
new feature: open images in an already-running instance of RT
This commit is contained in:
@@ -59,7 +59,7 @@ Glib::ustring argv0;
|
||||
Glib::ustring creditsPath;
|
||||
Glib::ustring licensePath;
|
||||
Glib::ustring argv1;
|
||||
bool simpleEditor;
|
||||
//bool simpleEditor;
|
||||
//Glib::Threads::Thread* mainThread;
|
||||
|
||||
namespace
|
||||
|
654
rtgui/main.cc
654
rtgui/main.cc
@@ -63,6 +63,7 @@ Glib::ustring argv1;
|
||||
Glib::ustring argv2;
|
||||
bool simpleEditor = false;
|
||||
bool gimpPlugin = false;
|
||||
bool remote = false;
|
||||
Glib::RefPtr<Gtk::CssProvider> cssForced;
|
||||
Glib::RefPtr<Gtk::CssProvider> cssRT;
|
||||
//Glib::Threads::Thread* mainThread;
|
||||
@@ -89,8 +90,6 @@ Glib::ustring fname_to_utf8 (const char* fname)
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// This recursive mutex will be used by gdk_threads_enter/leave instead of a simple mutex
|
||||
static Glib::Threads::RecMutex myGdkRecMutex;
|
||||
|
||||
@@ -110,6 +109,7 @@ static void myGdkLockLeave()
|
||||
myGdkRecMutex.unlock();
|
||||
}
|
||||
|
||||
|
||||
/* Process line command options
|
||||
* Returns
|
||||
* 0 if process in batch has executed
|
||||
@@ -118,169 +118,102 @@ static void myGdkLockLeave()
|
||||
* -1 if there is an error in parameters
|
||||
* -2 if an error occurred during processing
|
||||
* -3 if at least one required procparam file was not found */
|
||||
int processLineParams( int argc, char **argv );
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int processLineParams( int argc, char **argv )
|
||||
{
|
||||
setlocale(LC_ALL, "");
|
||||
setlocale(LC_NUMERIC, "C"); // to set decimal point to "."
|
||||
|
||||
Glib::init(); // called by Gtk::Main, but this may be important for thread handling, so we call it ourselves now
|
||||
gdk_threads_set_lock_functions(G_CALLBACK(myGdkLockEnter), (G_CALLBACK(myGdkLockLeave)));
|
||||
gdk_threads_init();
|
||||
gtk_init (&argc, &argv); // use the "--g-fatal-warnings" command line flag to make warnings fatal
|
||||
Gio::init ();
|
||||
|
||||
//mainThread = Glib::Threads::Thread::self();
|
||||
|
||||
#ifdef BUILD_BUNDLE
|
||||
char exname[512] = {0};
|
||||
Glib::ustring exePath;
|
||||
// get the path where the rawtherapee executable is stored
|
||||
for( int iArg = 1; iArg < argc; iArg++) {
|
||||
Glib::ustring currParam(argv[iArg]);
|
||||
#if ECLIPSE_ARGS
|
||||
currParam = currParam.substr(1, currParam.length()-2);
|
||||
#endif
|
||||
if( currParam.at(0) == '-' ) {
|
||||
switch( currParam.at(1) ) {
|
||||
#ifdef WIN32
|
||||
WCHAR exnameU[512] = {0};
|
||||
GetModuleFileNameW (NULL, exnameU, 511);
|
||||
WideCharToMultiByte(CP_UTF8, 0, exnameU, -1, exname, 511, 0, 0 );
|
||||
#else
|
||||
|
||||
if (readlink("/proc/self/exe", exname, 511) < 0) {
|
||||
strncpy(exname, argv[0], 511);
|
||||
}
|
||||
|
||||
case 'w': // This case is handled outside this function
|
||||
break;
|
||||
#endif
|
||||
exePath = Glib::path_get_dirname(exname);
|
||||
case 'v':
|
||||
return 0;
|
||||
|
||||
// set paths
|
||||
if (Glib::path_is_absolute(DATA_SEARCH_PATH)) {
|
||||
argv0 = DATA_SEARCH_PATH;
|
||||
} else {
|
||||
argv0 = Glib::build_filename(exePath, DATA_SEARCH_PATH);
|
||||
#ifndef __APPLE__ // TODO agriggio - there seems to be already some "single instance app" support for OSX in rtwindow. Disabling it here until I understand how to merge the two
|
||||
case 'R':
|
||||
if (!gimpPlugin) {
|
||||
remote = true;
|
||||
}
|
||||
|
||||
if (Glib::path_is_absolute(CREDITS_SEARCH_PATH)) {
|
||||
creditsPath = CREDITS_SEARCH_PATH;
|
||||
} else {
|
||||
creditsPath = Glib::build_filename(exePath, CREDITS_SEARCH_PATH);
|
||||
}
|
||||
|
||||
if (Glib::path_is_absolute(LICENCE_SEARCH_PATH)) {
|
||||
licensePath = LICENCE_SEARCH_PATH;
|
||||
} else {
|
||||
licensePath = Glib::build_filename(exePath, LICENCE_SEARCH_PATH);
|
||||
}
|
||||
|
||||
#else
|
||||
argv0 = DATA_SEARCH_PATH;
|
||||
creditsPath = CREDITS_SEARCH_PATH;
|
||||
licensePath = LICENCE_SEARCH_PATH;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case 'g':
|
||||
if (currParam == "-gimp") {
|
||||
gimpPlugin = true;
|
||||
simpleEditor = true;
|
||||
remote = false;
|
||||
break;
|
||||
}
|
||||
// no break here on purpose
|
||||
|
||||
case 'h':
|
||||
case '?':
|
||||
default: {
|
||||
Glib::ustring pparamsExt = paramFileExtension.substr(1);
|
||||
std::cout << " An advanced, cross-platform program for developing raw photos." << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << " Website: http://www.rawtherapee.com/" << std::endl;
|
||||
std::cout << " Documentation: http://rawpedia.rawtherapee.com/" << std::endl;
|
||||
std::cout << " Forum: https://discuss.pixls.us/c/software/rawtherapee" << std::endl;
|
||||
std::cout << " Code and bug reports: https://github.com/Beep6581/RawTherapee" << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << "Symbols:" << std::endl;
|
||||
std::cout << " <Chevrons> indicate parameters you can change." << std::endl;
|
||||
//std::cout << " [Square brackets] mean the parameter is optional." << std::endl;
|
||||
//std::cout << " The pipe symbol | indicates a choice of one or the other." << std::endl;
|
||||
//std::cout << " The dash symbol - denotes a range of possible values from one to the other." << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << "Usage:" << std::endl;
|
||||
std::cout << " " << Glib::path_get_basename(argv[0]) << " <folder> Start File Browser inside folder." << std::endl;
|
||||
std::cout << " " << Glib::path_get_basename(argv[0]) << " <file> Start Image Editor with file." << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << "Options:" << std::endl;
|
||||
#ifdef WIN32
|
||||
std::cout << " -w Do not open the Windows console" << std::endl;
|
||||
#endif
|
||||
std::cout << " -v Print RawTherapee version number and exit" << std::endl;
|
||||
#ifndef __APPLE__
|
||||
std::cout << " -R Raise an already running RawTherapee instance (if available)" << std::endl;
|
||||
#endif
|
||||
std::cout << " -h -? Display this help message" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (argv1.empty()) {
|
||||
argv1 = Glib::ustring(fname_to_utf8(argv[iArg]));
|
||||
#if ECLIPSE_ARGS
|
||||
argv1 = argv1.substr(1, argv1.length()-2);
|
||||
#endif
|
||||
} else if (gimpPlugin) {
|
||||
argv2 = Glib::ustring(fname_to_utf8(argv[iArg]));
|
||||
break;
|
||||
}
|
||||
if (!gimpPlugin) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
bool init_rt()
|
||||
{
|
||||
if (!Options::load ()) {
|
||||
Gtk::Main m(&argc, &argv);
|
||||
Gtk::MessageDialog msgd ("Fatal error!\nThe RT_SETTINGS and/or RT_PATH environment variables are set, but use a relative path. The path must be absolute!", true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
|
||||
msgd.run ();
|
||||
return -2;
|
||||
return false;
|
||||
}
|
||||
|
||||
extProgStore->init();
|
||||
SoundManager::init();
|
||||
|
||||
#ifdef WIN32
|
||||
bool consoleOpened = false;
|
||||
|
||||
// suppression of annoying error boxes
|
||||
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
|
||||
|
||||
if (argc > 1 || options.rtSettings.verbose) {
|
||||
if (options.rtSettings.verbose || ( !Glib::file_test (fname_to_utf8 (argv[1]), Glib::FILE_TEST_EXISTS ) && !Glib::file_test (fname_to_utf8 (argv[1]), Glib::FILE_TEST_IS_DIR))) {
|
||||
bool stdoutRedirectedtoFile = (GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)) == 0x0001);
|
||||
bool stderrRedirectedtoFile = (GetFileType(GetStdHandle(STD_ERROR_HANDLE)) == 0x0001);
|
||||
|
||||
// no console, if stdout and stderr both are redirected to file
|
||||
if( !(stdoutRedirectedtoFile && stderrRedirectedtoFile)) {
|
||||
// check if parameter -w was passed.
|
||||
// We have to do that in this step, because it controls whether to open a console to show the output of following steps
|
||||
bool Console = true;
|
||||
|
||||
for(int i = 1; i < argc; i++)
|
||||
if(!strcmp(argv[i], "-w")) {
|
||||
Console = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if(Console && AllocConsole()) {
|
||||
AttachConsole( GetCurrentProcessId() ) ;
|
||||
// Don't allow CTRL-C in console to terminate RT
|
||||
SetConsoleCtrlHandler( NULL, true );
|
||||
// Set title of console
|
||||
char consoletitle[128];
|
||||
sprintf(consoletitle, "RawTherapee %s Console", RTVERSION);
|
||||
SetConsoleTitle(consoletitle);
|
||||
// increase size of screen buffer
|
||||
COORD c;
|
||||
c.X = 200;
|
||||
c.Y = 1000;
|
||||
SetConsoleScreenBufferSize( GetStdHandle( STD_OUTPUT_HANDLE ), c );
|
||||
// Disable console-Cursor
|
||||
CONSOLE_CURSOR_INFO cursorInfo;
|
||||
cursorInfo.dwSize = 100;
|
||||
cursorInfo.bVisible = false;
|
||||
SetConsoleCursorInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &cursorInfo );
|
||||
|
||||
if(!stdoutRedirectedtoFile) {
|
||||
freopen( "CON", "w", stdout ) ;
|
||||
}
|
||||
|
||||
if(!stderrRedirectedtoFile) {
|
||||
freopen( "CON", "w", stderr ) ;
|
||||
}
|
||||
|
||||
freopen( "CON", "r", stdin ) ;
|
||||
|
||||
consoleOpened = true;
|
||||
|
||||
// printing RT's version in every case, particularly useful for the 'verbose' mode, but also for the batch processing
|
||||
std::cout << "RawTherapee, version " << RTVERSION << std::endl;
|
||||
std::cout << "WARNING: closing this window will close RawTherapee!" << std::endl << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(argc > 1) {
|
||||
int ret = processLineParams( argc, argv);
|
||||
|
||||
if( ret <= 0 ) {
|
||||
if(consoleOpened) {
|
||||
printf("Press any key to exit RawTherapee\n");
|
||||
FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE));
|
||||
getch();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
if (argc > 1 || options.rtSettings.verbose) {
|
||||
// printing RT's version in all case, particularly useful for the 'verbose' mode, but also for the batch processing
|
||||
std::cout << "RawTherapee, version " << RTVERSION << std::endl;
|
||||
#ifdef WIN32
|
||||
std::cout << "WARNING: closing this window will close RawTherapee!" << std::endl << std::endl;
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
int ret = processLineParams( argc, argv);
|
||||
|
||||
if( ret <= 0 ) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if( !options.rtSettings.verbose ) {
|
||||
TIFFSetWarningHandler(nullptr); // avoid annoying message boxes
|
||||
}
|
||||
@@ -294,24 +227,18 @@ int main(int argc, char **argv)
|
||||
|
||||
#endif
|
||||
|
||||
if (!argv1.empty()) {
|
||||
if( Glib::file_test(argv1, Glib::FILE_TEST_EXISTS) && !Glib::file_test(argv1, Glib::FILE_TEST_IS_DIR)) {
|
||||
simpleEditor = true;
|
||||
}
|
||||
}
|
||||
if (gimpPlugin) {
|
||||
if (!Glib::file_test(argv1, Glib::FILE_TEST_EXISTS) || Glib::file_test(argv1, Glib::FILE_TEST_IS_DIR)) {
|
||||
printf("Error: argv1 doesn't exist\n");
|
||||
return 1;
|
||||
}
|
||||
if (argv2.empty()) {
|
||||
printf("Error: -gimp requires two arguments\n");
|
||||
return 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Gtk::Main m(&argc, &argv);
|
||||
|
||||
void cleanup_rt()
|
||||
{
|
||||
rtengine::cleanup();
|
||||
}
|
||||
|
||||
|
||||
RTWindow *create_rt_window()
|
||||
{
|
||||
Glib::ustring icon_path = Glib::build_filename(argv0, "images");
|
||||
Glib::RefPtr<Gtk::IconTheme> defaultIconTheme = Gtk::IconTheme::get_default();
|
||||
defaultIconTheme->append_search_path(icon_path);
|
||||
@@ -379,8 +306,8 @@ int main(int argc, char **argv)
|
||||
|
||||
// ------- end loading theme files
|
||||
|
||||
gdk_threads_enter ();
|
||||
RTWindow *rtWindow = new class RTWindow();
|
||||
//gdk_threads_enter ();
|
||||
RTWindow *rtWindow = new RTWindow();
|
||||
|
||||
// alerting users if the default raw and image profiles are missing
|
||||
if (options.is_defProfRawMissing()) {
|
||||
@@ -393,23 +320,305 @@ int main(int argc, char **argv)
|
||||
msgd.run ();
|
||||
}
|
||||
|
||||
// opening the main window
|
||||
m.run(*rtWindow);
|
||||
return rtWindow;
|
||||
}
|
||||
|
||||
if (gimpPlugin && rtWindow->epanel && rtWindow->epanel->isRealized()) {
|
||||
|
||||
class RTApplication: public Gtk::Application {
|
||||
public:
|
||||
RTApplication():
|
||||
Gtk::Application("com.rawtherapee.application",
|
||||
Gio::APPLICATION_HANDLES_OPEN),
|
||||
rtWindow(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
~RTApplication()
|
||||
{
|
||||
if (rtWindow) {
|
||||
delete rtWindow;
|
||||
}
|
||||
cleanup_rt();
|
||||
}
|
||||
|
||||
private:
|
||||
bool create_window()
|
||||
{
|
||||
if (rtWindow) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!init_rt()) {
|
||||
Gtk::MessageDialog msgd ("Fatal error!\nThe RT_SETTINGS and/or RT_PATH environment variables are set, but use a relative path. The path must be absolute!", true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
|
||||
add_window(msgd);
|
||||
msgd.run ();
|
||||
return false;
|
||||
} else {
|
||||
rtWindow = create_rt_window();
|
||||
add_window(*rtWindow);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Override default signal handlers:
|
||||
void on_activate() override
|
||||
{
|
||||
if (create_window()) {
|
||||
rtWindow->present();
|
||||
}
|
||||
}
|
||||
|
||||
void on_open(const Gio::Application::type_vec_files& files,
|
||||
const Glib::ustring& hint) override
|
||||
{
|
||||
if (create_window()) {
|
||||
struct Data {
|
||||
std::vector<Thumbnail *> entries;
|
||||
Glib::ustring lastfilename;
|
||||
FileCatalog *filecatalog;
|
||||
};
|
||||
Data *d = new Data;
|
||||
d->filecatalog = rtWindow->fpanel->fileCatalog;
|
||||
|
||||
for (const auto &f : files) {
|
||||
Thumbnail *thm = cacheMgr->getEntry(f->get_path());
|
||||
if (thm) {
|
||||
d->entries.push_back(thm);
|
||||
d->lastfilename = f->get_path();
|
||||
}
|
||||
}
|
||||
|
||||
if (!d->entries.empty()) {
|
||||
const auto doit =
|
||||
[](gpointer data) -> gboolean
|
||||
{
|
||||
Data *d = static_cast<Data *>(data);
|
||||
d->filecatalog->openRequested(d->entries);
|
||||
d->filecatalog->selectImage(d->lastfilename, true);
|
||||
delete d;
|
||||
return FALSE;
|
||||
};
|
||||
gdk_threads_add_idle(doit, d);
|
||||
} else {
|
||||
delete d;
|
||||
}
|
||||
rtWindow->present();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
RTWindow *rtWindow;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
setlocale(LC_ALL, "");
|
||||
setlocale(LC_NUMERIC, "C"); // to set decimal point to "."
|
||||
|
||||
simpleEditor = false;
|
||||
gimpPlugin = false;
|
||||
remote = false;
|
||||
argv0 = "";
|
||||
argv1 = "";
|
||||
argv2 = "";
|
||||
|
||||
Glib::init(); // called by Gtk::Main, but this may be important for thread handling, so we call it ourselves now
|
||||
gdk_threads_set_lock_functions(G_CALLBACK(myGdkLockEnter), (G_CALLBACK(myGdkLockLeave)));
|
||||
gdk_threads_init();
|
||||
gtk_init (&argc, &argv); // use the "--g-fatal-warnings" command line flag to make warnings fatal
|
||||
Gio::init ();
|
||||
|
||||
|
||||
#ifdef BUILD_BUNDLE
|
||||
char exname[512] = {0};
|
||||
Glib::ustring exePath;
|
||||
// get the path where the rawtherapee executable is stored
|
||||
#ifdef WIN32
|
||||
WCHAR exnameU[512] = {0};
|
||||
GetModuleFileNameW (NULL, exnameU, 511);
|
||||
WideCharToMultiByte(CP_UTF8, 0, exnameU, -1, exname, 511, 0, 0 );
|
||||
#else
|
||||
|
||||
if (readlink("/proc/self/exe", exname, 511) < 0) {
|
||||
strncpy(exname, argv[0], 511);
|
||||
}
|
||||
|
||||
#endif
|
||||
exePath = Glib::path_get_dirname(exname);
|
||||
|
||||
// set paths
|
||||
if (Glib::path_is_absolute(DATA_SEARCH_PATH)) {
|
||||
argv0 = DATA_SEARCH_PATH;
|
||||
} else {
|
||||
argv0 = Glib::build_filename(exePath, DATA_SEARCH_PATH);
|
||||
}
|
||||
|
||||
if (Glib::path_is_absolute(CREDITS_SEARCH_PATH)) {
|
||||
creditsPath = CREDITS_SEARCH_PATH;
|
||||
} else {
|
||||
creditsPath = Glib::build_filename(exePath, CREDITS_SEARCH_PATH);
|
||||
}
|
||||
|
||||
if (Glib::path_is_absolute(LICENCE_SEARCH_PATH)) {
|
||||
licensePath = LICENCE_SEARCH_PATH;
|
||||
} else {
|
||||
licensePath = Glib::build_filename(exePath, LICENCE_SEARCH_PATH);
|
||||
}
|
||||
|
||||
#else
|
||||
argv0 = DATA_SEARCH_PATH;
|
||||
creditsPath = CREDITS_SEARCH_PATH;
|
||||
licensePath = LICENCE_SEARCH_PATH;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
bool consoleOpened = false;
|
||||
|
||||
// suppression of annoying error boxes
|
||||
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
|
||||
|
||||
if(argc > 1) {
|
||||
int ret = processLineParams( argc, argv);
|
||||
if (options.rtSettings.verbose || (!remote && !Glib::file_test (argv1, Glib::FILE_TEST_EXISTS ) && !Glib::file_test (argv1, Glib::FILE_TEST_IS_DIR))) {
|
||||
bool stdoutRedirectedtoFile = (GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)) == 0x0001);
|
||||
bool stderrRedirectedtoFile = (GetFileType(GetStdHandle(STD_ERROR_HANDLE)) == 0x0001);
|
||||
|
||||
// no console, if stdout and stderr both are redirected to file
|
||||
if( !(stdoutRedirectedtoFile && stderrRedirectedtoFile)) {
|
||||
// check if parameter -w was passed.
|
||||
// We have to do that in this step, because it controls whether to open a console to show the output of following steps
|
||||
bool Console = true;
|
||||
|
||||
for(int i = 1; i < argc; i++)
|
||||
if(!strcmp(argv[i], "-w")) {
|
||||
Console = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if(Console && AllocConsole()) {
|
||||
AttachConsole( GetCurrentProcessId() ) ;
|
||||
// Don't allow CTRL-C in console to terminate RT
|
||||
SetConsoleCtrlHandler( NULL, true );
|
||||
// Set title of console
|
||||
char consoletitle[128];
|
||||
sprintf(consoletitle, "RawTherapee %s Console", RTVERSION);
|
||||
SetConsoleTitle(consoletitle);
|
||||
// increase size of screen buffer
|
||||
COORD c;
|
||||
c.X = 200;
|
||||
c.Y = 1000;
|
||||
SetConsoleScreenBufferSize( GetStdHandle( STD_OUTPUT_HANDLE ), c );
|
||||
// Disable console-Cursor
|
||||
CONSOLE_CURSOR_INFO cursorInfo;
|
||||
cursorInfo.dwSize = 100;
|
||||
cursorInfo.bVisible = false;
|
||||
SetConsoleCursorInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &cursorInfo );
|
||||
|
||||
if(!stdoutRedirectedtoFile) {
|
||||
freopen( "CON", "w", stdout ) ;
|
||||
}
|
||||
|
||||
if(!stderrRedirectedtoFile) {
|
||||
freopen( "CON", "w", stderr ) ;
|
||||
}
|
||||
|
||||
freopen( "CON", "r", stdin ) ;
|
||||
|
||||
consoleOpened = true;
|
||||
|
||||
// printing RT's version in every case, particularly useful for the 'verbose' mode, but also for the batch processing
|
||||
std::cout << "RawTherapee, version " << RTVERSION << std::endl;
|
||||
std::cout << "WARNING: closing this window will close RawTherapee!" << std::endl << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( ret <= 0 ) {
|
||||
if(consoleOpened) {
|
||||
printf("Press any key to exit RawTherapee\n");
|
||||
FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE));
|
||||
getch();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
if (argc > 1 || options.rtSettings.verbose) {
|
||||
// printing RT's version in all case, particularly useful for the 'verbose' mode, but also for the batch processing
|
||||
std::cout << "RawTherapee, version " << RTVERSION << std::endl;
|
||||
#ifdef WIN32
|
||||
std::cout << "WARNING: closing this window will close RawTherapee!" << std::endl << std::endl;
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
int ret = processLineParams( argc, argv);
|
||||
|
||||
if( ret <= 0 ) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (gimpPlugin) {
|
||||
if (!Glib::file_test(argv1, Glib::FILE_TEST_EXISTS) || Glib::file_test(argv1, Glib::FILE_TEST_IS_DIR)) {
|
||||
printf("Error: argv1 doesn't exist\n");
|
||||
return 1;
|
||||
}
|
||||
if (argv2.empty()) {
|
||||
printf("Error: -gimp requires two arguments\n");
|
||||
return 1;
|
||||
}
|
||||
} else if (!remote && Glib::file_test(argv1, Glib::FILE_TEST_EXISTS)) {
|
||||
simpleEditor = true;
|
||||
}
|
||||
|
||||
int ret = 0;
|
||||
if (remote) {
|
||||
char *app_argv[2] = { const_cast<char *>(argv0.c_str()) };
|
||||
int app_argc = 1;
|
||||
if (!argv1.empty()) {
|
||||
app_argc = 2;
|
||||
app_argv[1] = const_cast<char *>(argv1.c_str());
|
||||
}
|
||||
RTApplication app;
|
||||
ret = app.run(app_argc, app_argv);
|
||||
} else {
|
||||
if (init_rt()) {
|
||||
Gtk::Main m(&argc, &argv);
|
||||
gdk_threads_enter();
|
||||
const std::unique_ptr<RTWindow> rtWindow(create_rt_window());
|
||||
m.run(*rtWindow);
|
||||
gdk_threads_leave();
|
||||
|
||||
if (gimpPlugin &&
|
||||
rtWindow->epanel && rtWindow->epanel->isRealized()) {
|
||||
SaveFormat sf;
|
||||
sf.format = "tif";
|
||||
sf.tiffBits = 16;
|
||||
sf.tiffUncompressed = true;
|
||||
sf.saveParams = true;
|
||||
|
||||
rtWindow->epanel->saveImmediately(argv2, sf);
|
||||
if (!rtWindow->epanel->saveImmediately(argv2, sf)) {
|
||||
ret = -2;
|
||||
}
|
||||
}
|
||||
cleanup_rt();
|
||||
} else {
|
||||
Gtk::Main m(&argc, &argv);
|
||||
Gtk::MessageDialog msgd ("Fatal error!\nThe RT_SETTINGS and/or RT_PATH environment variables are set, but use a relative path. The path must be absolute!", true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
|
||||
msgd.run ();
|
||||
ret = -2;
|
||||
}
|
||||
}
|
||||
|
||||
gdk_threads_leave ();
|
||||
|
||||
delete rtWindow;
|
||||
rtengine::cleanup();
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
@@ -421,95 +630,6 @@ int main(int argc, char **argv)
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void deleteProcParams(std::vector<rtengine::procparams::PartialProfile*> &pparams)
|
||||
{
|
||||
for (unsigned int i = 0; i < pparams.size(); i++) {
|
||||
pparams[i]->deleteInstance();
|
||||
delete pparams[i];
|
||||
pparams[i] = NULL;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int processLineParams( int argc, char **argv )
|
||||
{
|
||||
|
||||
for( int iArg = 1; iArg < argc; iArg++) {
|
||||
Glib::ustring currParam(argv[iArg]);
|
||||
#if ECLIPSE_ARGS
|
||||
currParam = currParam.substr(1, currParam.length()-2);
|
||||
#endif
|
||||
if( currParam.at(0) == '-' ) {
|
||||
switch( currParam.at(1) ) {
|
||||
#ifdef WIN32
|
||||
|
||||
case 'w': // This case is handled outside this function
|
||||
break;
|
||||
#endif
|
||||
case 'g':
|
||||
if (currParam == "-gimp") {
|
||||
simpleEditor = true;
|
||||
gimpPlugin = true;
|
||||
break;
|
||||
}
|
||||
// no break here on purpose
|
||||
|
||||
case 'v':
|
||||
return 0;
|
||||
|
||||
case 'h':
|
||||
case '?':
|
||||
default: {
|
||||
Glib::ustring pparamsExt = paramFileExtension.substr(1);
|
||||
std::cout << " An advanced, cross-platform program for developing raw photos." << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << " Website: http://www.rawtherapee.com/" << std::endl;
|
||||
std::cout << " Documentation: http://rawpedia.rawtherapee.com/" << std::endl;
|
||||
std::cout << " Forum: https://discuss.pixls.us/c/software/rawtherapee" << std::endl;
|
||||
std::cout << " Code and bug reports: https://github.com/Beep6581/RawTherapee" << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << "Symbols:" << std::endl;
|
||||
std::cout << " <Chevrons> indicate parameters you can change." << std::endl;
|
||||
//std::cout << " [Square brackets] mean the parameter is optional." << std::endl;
|
||||
//std::cout << " The pipe symbol | indicates a choice of one or the other." << std::endl;
|
||||
//std::cout << " The dash symbol - denotes a range of possible values from one to the other." << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << "Usage:" << std::endl;
|
||||
std::cout << " " << Glib::path_get_basename(argv[0]) << " <folder> Start File Browser inside folder." << std::endl;
|
||||
std::cout << " " << Glib::path_get_basename(argv[0]) << " <file> Start Image Editor with file." << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << "Options:" << std::endl;
|
||||
#ifdef WIN32
|
||||
std::cout << " -w Do not open the Windows console" << std::endl;
|
||||
#endif
|
||||
std::cout << " -v Print RawTherapee version number and exit" << std::endl;
|
||||
std::cout << " -h -? Display this help message" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (argv1.empty()) {
|
||||
argv1 = Glib::ustring(fname_to_utf8(argv[iArg]));
|
||||
#if ECLIPSE_ARGS
|
||||
argv1 = argv1.substr(1, argv1.length()-2);
|
||||
#endif
|
||||
} else if (gimpPlugin) {
|
||||
argv2 = Glib::ustring(fname_to_utf8(argv[iArg]));
|
||||
break;
|
||||
}
|
||||
if (!gimpPlugin) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !argv1.empty() ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -367,6 +367,7 @@ extern Glib::ustring argv0;
|
||||
extern Glib::ustring argv1;
|
||||
extern bool simpleEditor;
|
||||
extern bool gimpPlugin;
|
||||
extern bool remote;
|
||||
extern Glib::ustring versionString;
|
||||
extern Glib::ustring paramFileExtension;
|
||||
|
||||
|
@@ -271,7 +271,7 @@ RTWindow::RTWindow ()
|
||||
|
||||
bpanel->init (this);
|
||||
|
||||
if (!argv1.empty()) {
|
||||
if (!argv1.empty() && !remote) {
|
||||
Thumbnail* thm = cacheMgr->getEntry(argv1);
|
||||
if (thm) {
|
||||
fpanel->fileCatalog->openRequested({thm});
|
||||
|
Reference in New Issue
Block a user