2 Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 /** @file src/job_manager_view.cc
21 * @brief Class generating a GTK widget to show the progress of jobs.
24 #include "job_manager_view.h"
27 #include "lib/job_manager.h"
30 #include "lib/exceptions.h"
31 #include "lib/compose.hpp"
39 using boost::shared_ptr;
40 using boost::weak_ptr;
42 /** Must be called in the GUI thread */
43 JobManagerView::JobManagerView (wxWindow* parent)
44 : wxScrolledWindow (parent)
46 _panel = new wxPanel (this);
47 wxSizer* sizer = new wxBoxSizer (wxVERTICAL);
48 sizer->Add (_panel, 1, wxEXPAND);
51 _table = new wxFlexGridSizer (4, 4, 6);
52 _table->AddGrowableCol (0, 1);
53 _panel->SetSizer (_table);
55 SetScrollRate (0, 32);
56 EnableScrolling (false, true);
58 Bind (wxEVT_TIMER, boost::bind (&JobManagerView::periodic, this));
59 _timer.reset (new wxTimer (this));
62 JobManager::instance()->JobAdded.connect (bind (&JobManagerView::job_added, this, _1));
66 JobManagerView::job_added (weak_ptr<Job> j)
68 shared_ptr<Job> job = j.lock ();
70 _job_records.push_back (shared_ptr<JobView> (new JobView (job, this, _panel, _table)));
75 JobManagerView::periodic ()
77 for (list<shared_ptr<JobView> >::iterator i = _job_records.begin(); i != _job_records.end(); ++i) {