Add details button to job manager; stretch jobs across the whole of the bottom of...
authorCarl Hetherington <cth@carlh.net>
Tue, 12 Feb 2013 21:48:06 +0000 (21:48 +0000)
committerCarl Hetherington <cth@carlh.net>
Tue, 12 Feb 2013 21:48:06 +0000 (21:48 +0000)
src/lib/job.cc
src/lib/job.h
src/tools/dvdomatic.cc
src/wx/film_viewer.cc
src/wx/job_manager_view.cc
src/wx/job_manager_view.h

index 896862d143f7c9c7c26514d4e17d1e7d966652f5..2ddcf5335cdb42111388530281d9c32149d6cd50 100644 (file)
@@ -67,19 +67,33 @@ Job::run_wrapper ()
                
                set_progress (1);
                set_state (FINISHED_ERROR);
-               set_error (String::compose ("%1 (%2)", e.what(), boost::filesystem::path (e.filename()).leaf()));
                
+               string m = String::compose ("An error occurred whilst handling the file %1.", boost::filesystem::path (e.filename()).leaf());
+               
+               boost::filesystem::space_info const s = boost::filesystem::space (e.filename());
+               if (s.available < pow (1024, 3)) {
+                       m += "\n\nThe drive that the film is stored on is low in disc space.  Free some more space and try again.";
+               }
+
+               set_error (e.what(), m);
+               
        } catch (std::exception& e) {
 
                set_progress (1);
                set_state (FINISHED_ERROR);
-               set_error (e.what ());
+               set_error (
+                       e.what (),
+                       "It is not known what caused this error.  The best idea is to report the problem to the DVD-o-matic mailing list (dvdomatic@carlh.net)"
+                       );
 
        } catch (...) {
 
                set_progress (1);
                set_state (FINISHED_ERROR);
-               set_error ("unknown exception");
+               set_error (
+                       "Unknown error",
+                       "It is not known what caused this error.  The best idea is to report the problem to the DVD-o-matic mailing list (dvdomatic@carlh.net)"
+                       );
 
        }
 }
@@ -211,22 +225,30 @@ Job::descend (float a)
        _stack.push_back (Level (a));
 }
 
-/** @return Any error string that the job has generated */
 string
-Job::error () const
+Job::error_details () const
+{
+       boost::mutex::scoped_lock lm (_state_mutex);
+       return _error_details;
+}
+
+/** @return A summary of any error that the job has generated */
+string
+Job::error_summary () const
 {
        boost::mutex::scoped_lock lm (_state_mutex);
-       return _error;
+       return _error_summary;
 }
 
 /** Set the current error string.
  *  @param e New error string.
  */
 void
-Job::set_error (string e)
+Job::set_error (string s, string d)
 {
        boost::mutex::scoped_lock lm (_state_mutex);
-       _error = e;
+       _error_summary = s;
+       _error_details = d;
 }
 
 /** Say that this job's progress will be unknown until further notice */
@@ -253,7 +275,7 @@ Job::status () const
        } else if (finished_ok ()) {
                s << "OK (ran for " << seconds_to_hms (_ran_for) << ")";
        } else if (finished_in_error ()) {
-               s << "Error (" << error() << ")";
+               s << "Error (" << error_summary() << ")";
        }
 
        return s.str ();
index f32cfa811ad58c19d10c320bcb323120099354ba..1ea0a9b17373793693c45eaaa2c64c1c749d5e57 100644 (file)
@@ -53,7 +53,8 @@ public:
        bool finished_ok () const;
        bool finished_in_error () const;
 
-       std::string error () const;
+       std::string error_summary () const;
+       std::string error_details () const;
 
        int elapsed_time () const;
        virtual std::string status () const;
@@ -83,7 +84,7 @@ protected:
        };
        
        void set_state (State);
-       void set_error (std::string e);
+       void set_error (std::string s, std::string d);
 
        /** Film for this job */
        boost::shared_ptr<Film> _film;
@@ -98,8 +99,9 @@ private:
        mutable boost::mutex _state_mutex;
        /** current state of the job */
        State _state;
-       /** message for an error that has occurred (when state == FINISHED_ERROR) */
-       std::string _error;
+       /** summary of an error that has occurred (when state == FINISHED_ERROR) */
+       std::string _error_summary;
+       std::string _error_details;
 
        /** time that this job was started */
        time_t _start_time;
index be47b4fe6c43dc19530e5e3a05f08569d7e83696..bab49c2dcc8f9401c9a28d9124b8675ad4184e18 100644 (file)
@@ -224,13 +224,13 @@ public:
                film_viewer = new FilmViewer (film, panel);
                JobManagerView* job_manager_view = new JobManagerView (panel);
 
-               wxSizer* rhs_sizer = new wxBoxSizer (wxVERTICAL);
-               rhs_sizer->Add (film_viewer, 3, wxEXPAND | wxALL);
-               rhs_sizer->Add (job_manager_view, 1, wxEXPAND | wxALL);
+               wxSizer* top_sizer = new wxBoxSizer (wxHORIZONTAL);
+               top_sizer->Add (film_editor, 0, wxALL, 6);
+               top_sizer->Add (film_viewer, 1, wxEXPAND | wxALL, 6);
 
-               wxBoxSizer* main_sizer = new wxBoxSizer (wxHORIZONTAL);
-               main_sizer->Add (film_editor, 0, wxALL, 6);
-               main_sizer->Add (rhs_sizer, 1, wxEXPAND | wxALL, 6);
+               wxBoxSizer* main_sizer = new wxBoxSizer (wxVERTICAL);
+               main_sizer->Add (top_sizer, 2, wxEXPAND | wxALL, 6);
+               main_sizer->Add (job_manager_view, 1, wxEXPAND | wxALL, 6);
                panel->SetSizer (main_sizer);
 
                set_menu_sensitivity ();
index a619edf7c7bfa9fd70e8ed64fbb53d7828ef44a5..e685b7b353564a3e6b6c81f9b318edb7855f19c8 100644 (file)
@@ -70,7 +70,7 @@ FilmViewer::FilmViewer (shared_ptr<Film> f, wxWindow* p)
        h_sizer->Add (_play_button, 0, wxEXPAND);
        h_sizer->Add (_slider, 1, wxEXPAND);
 
-       _v_sizer->Add (h_sizer, 0, wxEXPAND);
+       _v_sizer->Add (h_sizer, 0, wxEXPAND | wxALL, 6);
 
        _panel->Connect (wxID_ANY, wxEVT_PAINT, wxPaintEventHandler (FilmViewer::paint_panel), 0, this);
        _panel->Connect (wxID_ANY, wxEVT_SIZE, wxSizeEventHandler (FilmViewer::panel_sized), 0, this);
index a5c02b16336ea636b9ce3b19fcfeb736270bf522..75842a8d4e5569cc3746728032201169d5326ca2 100644 (file)
@@ -30,6 +30,7 @@
 
 using std::string;
 using std::list;
+using std::map;
 using boost::shared_ptr;
 
 /** Must be called in the GUI thread */
@@ -41,7 +42,7 @@ JobManagerView::JobManagerView (wxWindow* parent)
        sizer->Add (_panel, 1, wxEXPAND);
        SetSizer (sizer);
        
-       _table = new wxFlexGridSizer (3, 6, 6);
+       _table = new wxFlexGridSizer (4, 6, 6);
        _table->AddGrowableCol (1, 1);
        _panel->SetSizer (_table);
 
@@ -83,6 +84,11 @@ JobManagerView::update ()
                        
                        r.message = new wxStaticText (_panel, wxID_ANY, std_to_wx (""));
                        _table->Insert (index + 2, r.message, 1, wxALIGN_CENTER_VERTICAL | wxALL, 6);
+
+                       r.details = new wxButton (_panel, wxID_ANY, _("Details..."));
+                       r.details->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (JobManagerView::details_clicked), 0, this);
+                       r.details->Enable (false);
+                       _table->Insert (index + 3, r.details, 1, wxALIGN_CENTER_VERTICAL | wxALL, 6);
                        
                        _job_records[*i] = r;
                }
@@ -104,6 +110,9 @@ JobManagerView::update ()
                        _job_records[*i].gauge->SetValue (100);
                        _job_records[*i].message->SetLabel (std_to_wx (st));
                        _job_records[*i].finalised = true;
+                       if (!(*i)->error_details().empty ()) {
+                               _job_records[*i].details->Enable (true);
+                       }
                }
 
                index += 3;
@@ -112,3 +121,17 @@ JobManagerView::update ()
        _table->Layout ();
        FitInside ();
 }
+
+void
+JobManagerView::details_clicked (wxCommandEvent& ev)
+{
+       wxObject* o = ev.GetEventObject ();
+
+       for (map<boost::shared_ptr<Job>, JobRecord>::iterator i = _job_records.begin(); i != _job_records.end(); ++i) {
+               if (i->second.details == o) {
+                       string s = i->first->error_summary();
+                       s[0] = toupper (s[0]);
+                       error_dialog (this, String::compose ("%1.\n\n%2", s, i->first->error_details()));
+               }
+       }
+}
index 5c10890ef01391966c9131af3de312e25eb9bceb..d43e795ea59797da395a6486060f8b9b9dd3706a 100644 (file)
@@ -39,6 +39,7 @@ public:
 
 private:
        void periodic (wxTimerEvent &);
+       void details_clicked (wxCommandEvent &);
 
        boost::shared_ptr<wxTimer> _timer;
        wxPanel* _panel;
@@ -46,6 +47,7 @@ private:
        struct JobRecord {
                wxGauge* gauge;
                wxStaticText* message;
+               wxButton* details;
                bool finalised;
        };