diff --git a/rtdata/languages/default b/rtdata/languages/default
index b2c1cf890..4129bf314 100644
--- a/rtdata/languages/default
+++ b/rtdata/languages/default
@@ -2111,11 +2111,13 @@ QUEUE_LOCATION_TEMPLATE_TOOLTIP;Specify the output location based on characteris
QUEUE_LOCATION_TEMPLATE_HELP_TITLE;Creating an output template
QUEUE_LOCATION_TEMPLATE_HELP_INTRO;The output template field allows you to to dynamically customize the destination folder and filename. When you include certain specifiers, which begin with %, they are replaced by the program when each file is being saved.\n\nThe sections below describe each type of specifier.
QUEUE_LOCATION_TEMPLATE_HELP_PATHS_TITLE;Directories and partial paths
-QUEUE_LOCATION_TEMPLATE_HELP_PATHS_INTRO;The %dN, %d-N, %pN, %p-N, %PN and %P-N (N = 1..9) specifiers will be replaced by elements of the image file's directory path.\nThe format specifiers operate as follows:\n %dN = Nth directory from the end of the path\n %d-N = Nth directory from the start of the path\n %pN = all directories up to the Nth from the end of the path\n %p-N = the first N directories in the path\n %PN = the last N directories in the path\n %P-N = all directories from the Nth to the end of the path\n %f = base filename (no extension)\nFor Windows paths, %d-1 is the drive letter and colon, and %d-2 is the base directory on that drive.
+QUEUE_LOCATION_TEMPLATE_HELP_PATHS_INTRO;The %dN, %d-N, %pN, %p-N, %PN and %P-N (N = 1..9) specifiers will be replaced by elements of the image file's directory path.\nThe format specifiers operate as follows:\n %dN = Nth directory from the end of the path\n %d-N = Nth directory from the start of the path\n %pN = all directories up to the Nth from the end of the path\n %p-N = the first N directories in the path\n %PN = the last N directories in the path\n %P-N = all directories from the Nth to the end of the path\n %f = base filename (no extension)
+QUEUE_LOCATION_TEMPLATE_HELP_PATHS_INTRO_WINDOWS;For Windows paths, %d-1 is the drive letter and colon, and %d-2 is the base directory on that drive.
QUEUE_LOCATION_TEMPLATE_HELP_PATHS_BODY_1;Using this pathname as an example:
QUEUE_LOCATION_TEMPLATE_HELP_PATHS_EXAMPLE_LINUX;/home/tom/photos/2010-10-31/photo1.raw
QUEUE_LOCATION_TEMPLATE_HELP_PATHS_EXAMPLE_WINDOWS;C:\users\tom\photos\2010-10-31\photo1.raw
QUEUE_LOCATION_TEMPLATE_HELP_PATHS_BODY_2;The meanings of the formatting strings are:
+QUEUE_LOCATION_TEMPLATE_HELP_RESULT_MISMATCH;ERROR: 2nd result is different:
QUEUE_LOCATION_TITLE;Output Location
QUEUE_STARTSTOP_TOOLTIP;Start or stop processing the images in the queue.\n\nShortcut: Ctrl+s
diff --git a/rtgui/batchqueuepanel.cc b/rtgui/batchqueuepanel.cc
index d150adc94..f4e97689b 100644
--- a/rtgui/batchqueuepanel.cc
+++ b/rtgui/batchqueuepanel.cc
@@ -1,3 +1,4 @@
+#define CHECKPOINT printf("CHECKPOINT: %d\n", __LINE__); // FIXME: REMOVE
/*
* This file is part of RawTherapee.
*
@@ -345,6 +346,8 @@ void BatchQueuePanel::templateHelpButtonToggled()
if (buffer->get_text().empty()) {
// Populate the help text the first time it's shown
populateTemplateHelpBuffer(buffer);
+ auto fullWidth = middleSplitPane->get_width();
+ middleSplitPane->set_position(fullWidth / 2);
}
scrolledTemplateHelpWindow->set_visible(visible);
templateHelpTextView->set_visible(visible);
@@ -362,38 +365,82 @@ void BatchQueuePanel::populateTemplateHelpBuffer(Glib::RefPtr b
insertHeading1(M("QUEUE_LOCATION_TEMPLATE_HELP_TITLE"));
pos = buffer->insert_markup(pos, M("QUEUE_LOCATION_TEMPLATE_HELP_INTRO"));
insertHeading2(M("QUEUE_LOCATION_TEMPLATE_HELP_PATHS_TITLE"));
- printf("[[[%s]]]", M("QUEUE_LOCATION_TEMPLATE_HELP_PATHS_INTRO").c_str());
pos = buffer->insert_markup(pos, M("QUEUE_LOCATION_TEMPLATE_HELP_PATHS_INTRO"));
pos = buffer->insert(pos, "\n");
+#ifdef _WIN32
+ pos = buffer->insert_markup(pos, M("QUEUE_LOCATION_TEMPLATE_HELP_PATHS_INTRO_WINDOWS"));
+ pos = buffer->insert(pos, "\n");
+#endif
+ pos = buffer->insert(pos, "\n");
pos = buffer->insert_markup(pos, M("QUEUE_LOCATION_TEMPLATE_HELP_PATHS_BODY_1"));
#ifdef _WIN32
- auto exampleString = M("QUEUE_LOCATION_TEMPLATE_HELP_PATHS_EXAMPLE_WINDOWS");
+ auto exampleFilePath = M("QUEUE_LOCATION_TEMPLATE_HELP_PATHS_EXAMPLE_WINDOWS");
#else
- auto exampleString = M("QUEUE_LOCATION_TEMPLATE_HELP_PATHS_EXAMPLE_LINUX");
+ auto exampleFilePath = M("QUEUE_LOCATION_TEMPLATE_HELP_PATHS_EXAMPLE_LINUX");
#endif
- pos = buffer->insert_markup(pos, Glib::ustring::format("\n ", exampleString, "\n"));
+ pos = buffer->insert_markup(pos, Glib::ustring::format("\n ", exampleFilePath, "\n"));
pos = buffer->insert_markup(pos, M("QUEUE_LOCATION_TEMPLATE_HELP_PATHS_BODY_2"));
- pos = buffer->insert(pos, "\n");
+ // Examples are generated from exampleFilePath using the actual template processing function
+ Options savedOptions = options; // to be restored after generating example results
+ options.saveUsePathTemplate = true;
+ // Since this code only ever runs once (the first time the help text is presented), no attempt is
+ // made to be efficient. Use a brute-force method to discover the number of elements in exampleFilePath.
+ int pathElementCount = 0;
+ for (int n=9; n>=0; n--)
+ {
+ options.savePathTemplate = Glib::ustring::format("%d",n);
+ auto result = BatchQueue::calcAutoFileNameBase(exampleFilePath);
+ if (!result.empty())
+ {
+ // The 'd' specifier returns an empty string if N exceeds the number of path elements, so
+ // the largest N that does not return an empty string is the number of elements in exampleFilePath.
+ pathElementCount = n;
+ break;
+ }
+ }
+ // Function inserts examples for a particular specifier, with every valid N value for the
+ // number of elements in the path.
+ auto insertPathExamples = [&buffer, &pos, pathElementCount, exampleFilePath](char letter, int offset1, int mult1, int offset2, int mult2)
+ {
+ Glib::ustring startMonospace("");
+ Glib::ustring endMonospace("");
+ auto buildBuffer = Gtk::TextBuffer::create();
+ auto buildpos = buildBuffer->begin();
+ buildpos = buildBuffer->insert(buildpos, startMonospace);
+ for (int n=0; n%d4 = %d-1 = home
+ auto path1 = Glib::ustring::format("%",letter,offset1+n*mult1);
+ auto path2 = Glib::ustring::format("%",letter,offset2+n*mult2);
+ options.savePathTemplate = path1;
+ auto result1 = BatchQueue::calcAutoFileNameBase(exampleFilePath);
+ options.savePathTemplate = path2;
+ auto result2 = BatchQueue::calcAutoFileNameBase(exampleFilePath);
+ buildpos = buildBuffer->insert (buildpos, Glib::ustring::format("\n ", path1, " = ", path2, " = ", result1, ""));
+ if (result1 != result2)
+ {
+ buildpos = buildBuffer->insert(buildpos, Glib::ustring::format(" ", M("QUEUE_LOCATION_TEMPLATE_HELP_RESULT_MISMATCH"), " ", result2));
+ }
+ }
+ buildpos = buildBuffer->insert(buildpos, endMonospace);
+ pos = buffer->insert_markup(pos, buildBuffer->get_text());
+ };
+ // Example outputs in comments below are for a 4-element path.
+ // %d4 = %d-1 = home
+ insertPathExamples('d', pathElementCount, -1, -1, -1);
+ // %p1 = %p-4 = /home/tom/photos/2010-10-31/
+ insertPathExamples('p', 1, 1, -pathElementCount, 1);
+ // %P1 = %P-4 = 2010-10-31/
+ insertPathExamples('P', 1, 1, -pathElementCount, 1);
+
/* FIXME: Still to do here:
- Generate text like the original below, but use the actual conversion function to create it:
- %d4 = %d-1 = home
- %d3 = %d-2 = tom
- %d2 = %d-3 = photos
- %d1 = %d-4 = 2010-10-31
- %p1 = %p-4 = /home/tom/photos/2010-10-31/
- %p2 = %p-3 = /home/tom/photos/
- %p3 = %p-2 = /home/tom/
- %p4 = %p-1 = /home/
- %P1 = %P-4 = 2010-10-31/
- %P2 = %P-3 = photos/2010-10-31/
- %P3 = %P-2 = tom/photos/2010-10-31/
- %P4 = %P-1 = /home/tom/photos/2010-10-31/
- %f = photo1
Insert sections for the remaining specifiers:
%r = rank
%s# = queue position, with padding
Insert an examples section
*/
+ options = savedOptions;
}
void BatchQueuePanel::addBatchQueueJobs(const std::vector& entries, bool head)