2 Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 /** @file src/job_manager_view.cc
22 * @brief Class generating a GTK widget to show the progress of jobs.
25 #include "job_manager_view.h"
28 #include "lib/job_manager.h"
31 #include "lib/exceptions.h"
32 #include "lib/compose.hpp"
40 using boost::shared_ptr;
41 using boost::weak_ptr;
43 /** Must be called in the GUI thread */
44 JobManagerView::JobManagerView (wxWindow* parent)
45 : wxScrolledWindow (parent)
47 _panel = new wxPanel (this);
48 wxSizer* sizer = new wxBoxSizer (wxVERTICAL);
49 sizer->Add (_panel, 1, wxEXPAND);
52 _table = new wxFlexGridSizer (4, 4, 6);
53 _table->AddGrowableCol (0, 1);
54 _panel->SetSizer (_table);
56 SetScrollRate (0, 32);
57 EnableScrolling (false, true);
59 Bind (wxEVT_TIMER, boost::bind (&JobManagerView::periodic, this));
60 _timer.reset (new wxTimer (this));
63 JobManager::instance()->JobAdded.connect (bind (&JobManagerView::job_added, this, _1));
67 JobManagerView::job_added (weak_ptr<Job> j)
69 shared_ptr<Job> job = j.lock ();
71 _job_records.push_back (shared_ptr<JobView> (new JobView (job, this, _panel, _table)));
76 JobManagerView::periodic ()
78 for (list<shared_ptr<JobView> >::iterator i = _job_records.begin(); i != _job_records.end(); ++i) {