Make populateTemplateHelpBuffer a private member of class BatchQueuePanel

This commit is contained in:
Scott Gilbertson 2024-02-10 13:49:19 -05:00
parent 3fb7296cd1
commit ed5792bb9f
2 changed files with 47 additions and 51 deletions

View File

@ -23,57 +23,6 @@
#include "soundman.h"
#include "rtimage.h"
namespace // helper functions
{
// Populate the buffer of a Gtk::TextView with help text for the location template field
void populateTemplateHelpBuffer(Glib::RefPtr<Gtk::TextBuffer> buffer)
{
auto pos = buffer->begin();
auto insertHeading1 = [&pos, buffer](const Glib::ustring& text) {
pos = buffer->insert_markup(pos, Glib::ustring::format("<big><b>", text, "</b></big>\n"));
};
auto insertHeading2 = [&pos, buffer](const Glib::ustring& text) {
pos = buffer->insert_markup(pos, Glib::ustring::format("\n\n<u><b>", text, "</b></u>\n"));
};
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");
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");
#else
auto exampleString = 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, M("QUEUE_LOCATION_TEMPLATE_HELP_PATHS_BODY_2"));
pos = buffer->insert(pos, "\n");
/* FIXME: Still to do here:
Generate text like the original below, but use the actual conversion function to create it:
<b>%d4</b> = <b>%d-1</b> = <i>home</i>
<b>%d3</b> = <b>%d-2</b> = <i>tom</i>
<b>%d2</b> = <b>%d-3</b> = <i>photos</i>
<b>%d1</b> = <b>%d-4</b> = <i>2010-10-31</i>
<b>%p1</b> = <b>%p-4</b> = <i>/home/tom/photos/2010-10-31/</i>
<b>%p2</b> = <b>%p-3</b> = <i>/home/tom/photos/</i>
<b>%p3</b> = <b>%p-2</b> = <i>/home/tom/</i>
<b>%p4</b> = <b>%p-1</b> = <i>/home/</i>
<b>%P1</b> = <b>%P-4</b> = <i>2010-10-31/</i>
<b>%P2</b> = <b>%P-3</b> = <i>photos/2010-10-31/</i>
<b>%P3</b> = <b>%P-2</b> = <i>tom/photos/2010-10-31/</i>
<b>%P4</b> = <b>%P-1</b> = <i>/home/tom/photos/2010-10-31/</i>
<b>%f</b> = <i>photo1</i>
Insert sections for the remaining specifiers:
%r = rank
%s# = queue position, with padding
Insert an examples section
*/
}
}
static Glib::ustring makeFolderLabel(Glib::ustring path)
{
if (!Glib::file_test (path, Glib::FILE_TEST_IS_DIR)) {
@ -401,6 +350,52 @@ void BatchQueuePanel::templateHelpButtonToggled()
templateHelpTextView->set_visible(visible);
}
void BatchQueuePanel::populateTemplateHelpBuffer(Glib::RefPtr<Gtk::TextBuffer> buffer)
{
auto pos = buffer->begin();
auto insertHeading1 = [&pos, buffer](const Glib::ustring& text) {
pos = buffer->insert_markup(pos, Glib::ustring::format("<big><b>", text, "</b></big>\n"));
};
auto insertHeading2 = [&pos, buffer](const Glib::ustring& text) {
pos = buffer->insert_markup(pos, Glib::ustring::format("\n\n<u><b>", text, "</b></u>\n"));
};
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");
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");
#else
auto exampleString = 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, M("QUEUE_LOCATION_TEMPLATE_HELP_PATHS_BODY_2"));
pos = buffer->insert(pos, "\n");
/* FIXME: Still to do here:
Generate text like the original below, but use the actual conversion function to create it:
<b>%d4</b> = <b>%d-1</b> = <i>home</i>
<b>%d3</b> = <b>%d-2</b> = <i>tom</i>
<b>%d2</b> = <b>%d-3</b> = <i>photos</i>
<b>%d1</b> = <b>%d-4</b> = <i>2010-10-31</i>
<b>%p1</b> = <b>%p-4</b> = <i>/home/tom/photos/2010-10-31/</i>
<b>%p2</b> = <b>%p-3</b> = <i>/home/tom/photos/</i>
<b>%p3</b> = <b>%p-2</b> = <i>/home/tom/</i>
<b>%p4</b> = <b>%p-1</b> = <i>/home/</i>
<b>%P1</b> = <b>%P-4</b> = <i>2010-10-31/</i>
<b>%P2</b> = <b>%P-3</b> = <i>photos/2010-10-31/</i>
<b>%P3</b> = <b>%P-2</b> = <i>tom/photos/2010-10-31/</i>
<b>%P4</b> = <b>%P-1</b> = <i>/home/tom/photos/2010-10-31/</i>
<b>%f</b> = <i>photo1</i>
Insert sections for the remaining specifiers:
%r = rank
%s# = queue position, with padding
Insert an examples section
*/
}
void BatchQueuePanel::addBatchQueueJobs(const std::vector<BatchQueueEntry*>& entries, bool head)
{
batchQueue->addEntries(entries, head);

View File

@ -85,6 +85,7 @@ private:
void startOrStopBatchProc();
void setGuiFromBatchState(bool queueRunning, int qsize);
void templateHelpButtonToggled();
void populateTemplateHelpBuffer(Glib::RefPtr<Gtk::TextBuffer> buffer);
void pathFolderChanged ();
void pathFolderButtonPressed ();