Fix typo.
[dcpomatic.git] / src / wx / batch_job_view.cc
1 /*
2     Copyright (C) 2012-2017 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
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.
10
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.
15
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/>.
18
19 */
20
21 #include "batch_job_view.h"
22 #include "lib/job_manager.h"
23 #include <wx/sizer.h>
24 #include <wx/button.h>
25
26 using std::list;
27 using boost::shared_ptr;
28
29 BatchJobView::BatchJobView (shared_ptr<Job> job, wxWindow* parent, wxWindow* container, wxFlexGridSizer* table)
30         : JobView (job, parent, container, table)
31 {
32
33 }
34
35 int
36 BatchJobView::insert_position () const
37 {
38         return _table->GetEffectiveRowsCount() * _table->GetEffectiveColsCount();
39 }
40
41 void
42 BatchJobView::finish_setup (wxWindow* parent, wxSizer* sizer)
43 {
44         _higher_priority = new wxButton (parent, wxID_ANY, _("Higher priority"));
45         _higher_priority->Bind (wxEVT_BUTTON, boost::bind (&BatchJobView::higher_priority_clicked, this));
46         sizer->Add (_higher_priority, 1, wxALIGN_CENTER_VERTICAL);
47         _lower_priority = new wxButton (parent, wxID_ANY, _("Lower priority"));
48         _lower_priority->Bind (wxEVT_BUTTON, boost::bind (&BatchJobView::lower_priority_clicked, this));
49         sizer->Add (_lower_priority, 1, wxALIGN_CENTER_VERTICAL);
50 }
51 void
52 BatchJobView::higher_priority_clicked ()
53 {
54         JobManager::instance()->increase_priority (_job);
55 }
56
57 void
58 BatchJobView::lower_priority_clicked ()
59 {
60         JobManager::instance()->decrease_priority (_job);
61 }
62
63 void
64 BatchJobView::job_list_changed ()
65 {
66         bool high = false;
67         bool low = false;
68         list<shared_ptr<Job> > jobs = JobManager::instance()->get();
69         if (!jobs.empty ()) {
70                 if (_job != jobs.front()) {
71                         high = true;
72                 }
73                 if (_job != jobs.back()) {
74                         low = true;
75                 }
76         }
77
78         _higher_priority->Enable (high);
79         _lower_priority->Enable (low);
80 }