No-op; fix GPL address and use the explicit-program-name version.
[dcpomatic.git] / src / wx / film_editor.cc
1 /*
2     Copyright (C) 2012-2015 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 /** @file src/wx/film_editor.cc
22  *  @brief FilmEditor class.
23  */
24
25 #include "lib/film.h"
26 #include "lib/job_manager.h"
27 #include "lib/content.h"
28 #include "lib/dcp_content.h"
29 #include "wx_util.h"
30 #include "film_editor.h"
31 #include "dcp_panel.h"
32 #include "content_panel.h"
33 #include <wx/wx.h>
34 #include <wx/notebook.h>
35 #include <iostream>
36
37 using std::cout;
38 using std::string;
39 using boost::shared_ptr;
40 using boost::optional;
41
42 /** @param f Film to edit */
43 FilmEditor::FilmEditor (wxWindow* parent, FilmViewer* viewer)
44         : wxPanel (parent)
45 {
46         wxBoxSizer* s = new wxBoxSizer (wxVERTICAL);
47
48         _main_notebook = new wxNotebook (this, wxID_ANY);
49         s->Add (_main_notebook, 1);
50
51         _content_panel = new ContentPanel (_main_notebook, _film, viewer);
52         _main_notebook->AddPage (_content_panel->panel (), _("Content"), true);
53         _dcp_panel = new DCPPanel (_main_notebook, _film);
54         _main_notebook->AddPage (_dcp_panel->panel (), _("DCP"), false);
55
56         JobManager::instance()->ActiveJobsChanged.connect (
57                 bind (&FilmEditor::active_jobs_changed, this, _2)
58                 );
59
60         set_film (shared_ptr<Film> ());
61         SetSizerAndFit (s);
62 }
63
64
65 /** Called when the metadata stored in the Film object has changed;
66  *  so that we can update the GUI.
67  *  @param p Property of the Film that has changed.
68  */
69 void
70 FilmEditor::film_changed (Film::Property p)
71 {
72         ensure_ui_thread ();
73
74         if (!_film) {
75                 return;
76         }
77
78         _content_panel->film_changed (p);
79         _dcp_panel->film_changed (p);
80
81         if (p == Film::CONTENT && !_film->content().empty ()) {
82                 /* Select newly-added content */
83                 _content_panel->set_selection (_film->content().back ());
84         }
85 }
86
87 void
88 FilmEditor::film_content_changed (int property)
89 {
90         ensure_ui_thread ();
91
92         if (!_film) {
93                 /* We call this method ourselves (as well as using it as a signal handler)
94                    so _film can be 0.
95                 */
96                 return;
97         }
98
99         _content_panel->film_content_changed (property);
100         _dcp_panel->film_content_changed (property);
101 }
102
103 /** Sets the Film that we are editing */
104 void
105 FilmEditor::set_film (shared_ptr<Film> film)
106 {
107         set_general_sensitivity (film != 0);
108
109         if (_film == film) {
110                 return;
111         }
112
113         _film = film;
114
115         _content_panel->set_film (_film);
116         _dcp_panel->set_film (_film);
117
118         if (_film) {
119                 _film->Changed.connect (bind (&FilmEditor::film_changed, this, _1));
120                 _film->ContentChanged.connect (bind (&FilmEditor::film_content_changed, this, _2));
121         }
122
123         if (_film) {
124                 FileChanged (_film->directory ());
125         } else {
126                 FileChanged ("");
127         }
128
129         if (!_film->content().empty ()) {
130                 _content_panel->set_selection (_film->content().front ());
131         }
132 }
133
134 void
135 FilmEditor::set_general_sensitivity (bool s)
136 {
137         _content_panel->set_general_sensitivity (s);
138         _dcp_panel->set_general_sensitivity (s);
139 }
140
141 void
142 FilmEditor::active_jobs_changed (optional<string> j)
143 {
144         set_general_sensitivity (!j || *j == "analyse_audio");
145 }