Fix conversion of _X to underlined X with GTK (via gtk_label_set_text_with_mnemonic...
[dcpomatic.git] / src / wx / job_view.cc
index 231176e4fd96c773d1f96a779de648647f0ddf3a..efe17f4deba2a01c1939f9764464c5fa8b021cba 100644 (file)
 */
 
 
+#include "check_box.h"
+#include "dcpomatic_button.h"
 #include "job_view.h"
-#include "wx_util.h"
 #include "message_dialog.h"
 #include "static_text.h"
-#include "check_box.h"
-#include "dcpomatic_button.h"
-#include "lib/job.h"
-#include "lib/job_manager.h"
+#include "wx_util.h"
+#include "lib/analyse_audio_job.h"
 #include "lib/compose.hpp"
 #include "lib/config.h"
+#include "lib/job.h"
+#include "lib/job_manager.h"
 #include "lib/send_notification_email_job.h"
 #include "lib/transcode_job.h"
-#include "lib/analyse_audio_job.h"
+#include <dcp/warnings.h>
+LIBDCP_DISABLE_WARNINGS
 #include <wx/wx.h>
+LIBDCP_ENABLE_WARNINGS
 #include <boost/algorithm/string.hpp>
 
 
-using std::string;
 using std::min;
 using std::shared_ptr;
+using std::string;
 using boost::bind;
-using std::dynamic_pointer_cast;
 
 
 JobView::JobView (shared_ptr<Job> job, wxWindow* parent, wxWindow* container, wxFlexGridSizer* table)
@@ -85,7 +87,7 @@ JobView::setup ()
        _controls = new wxBoxSizer (wxVERTICAL);
        _controls->Add (_buttons);
        _notify = new CheckBox (_container, _("Notify when complete"));
-       _notify->Bind (wxEVT_CHECKBOX, bind (&JobView::notify_clicked, this));
+       _notify->bind(&JobView::notify_clicked, this);
        _notify->SetValue (Config::instance()->default_notify());
        _controls->Add (_notify, 0, wxTOP, DCPOMATIC_BUTTON_STACK_GAP);
 
@@ -103,8 +105,11 @@ JobView::setup ()
 void
 JobView::maybe_pulse ()
 {
-       if (_gauge && _job->running() && !_job->progress()) {
-               _gauge->Pulse ();
+       if (_gauge && _job->running()) {
+               auto elapsed = _job->seconds_since_last_progress_update();
+               if (!_job->progress() || !elapsed || *elapsed > 4) {
+                       _gauge->Pulse ();
+               }
        }
 }
 
@@ -120,6 +125,9 @@ JobView::progress ()
        /* Watch out for < > in the error string */
        boost::algorithm::replace_all (s, "<", "&lt;");
        boost::algorithm::replace_all (s, ">", "&gt;");
+#ifdef DCPOMATIC_LINUX
+       boost::algorithm::replace_all(s, "_", "__");
+#endif
        whole += s;
        if (whole != _last_message) {
                _message->SetLabelMarkup (std_to_wx (whole));
@@ -151,12 +159,11 @@ JobView::finished ()
        }
 
        if (_job->message()) {
-               auto d = new MessageDialog (_parent, std_to_wx(_job->name()), std_to_wx(_job->message().get()));
-               d->ShowModal ();
-               d->Destroy ();
+               MessageDialog dialog(_parent, std_to_wx(_job->name()), std_to_wx(_job->message().get()));
+               dialog.ShowModal();
        }
 
-       if ((dynamic_pointer_cast<TranscodeJob>(_job) || dynamic_pointer_cast<AnalyseAudioJob>(_job)) && _notify->GetValue()) {
+       if (_job->enable_notify() && _notify->GetValue()) {
                if (Config::instance()->notification(Config::MESSAGE_BOX)) {
                        wxMessageBox (std_to_wx(_job->name() + ": " + _job->status()), _("DCP-o-matic"), wxICON_INFORMATION);
                }