+
+void
+ContentPanel::add_files (vector<boost::filesystem::path> paths)
+{
+ /* It has been reported that the paths returned from e.g. wxFileDialog are not always sorted;
+ I can't reproduce that, but sort them anyway. Don't use ImageFilenameSorter as a normal
+ alphabetical sort is expected here.
+ */
+
+ std::sort (paths.begin(), paths.end(), CaseInsensitiveSorter());
+
+ /* XXX: check for lots of files here and do something */
+
+ try {
+ for (auto i: paths) {
+ for (auto j: content_factory(i)) {
+ _film->examine_and_add_content (j);
+ }
+ }
+ } catch (exception& e) {
+ error_dialog (_parent, e.what());
+ }
+}
+
+
+list<ContentSubPanel*>
+ContentPanel::panels () const
+{
+ list<ContentSubPanel*> p;
+ if (_video_panel) {
+ p.push_back (_video_panel);
+ }
+ if (_audio_panel) {
+ p.push_back (_audio_panel);
+ }
+ for (int i = 0; i < static_cast<int>(TextType::COUNT); ++i) {
+ if (_text_panel[i]) {
+ p.push_back (_text_panel[i]);
+ }
+ }
+ p.push_back (_timing_panel);
+ return p;
+}
+
+
+void
+ContentPanel::set_selected_state(int item, bool state)
+{
+ _content->SetItemState(item, state ? wxLIST_STATE_SELECTED : 0, wxLIST_STATE_SELECTED);
+ _content->SetItemState(item, state ? wxLIST_STATE_FOCUSED : 0, wxLIST_STATE_FOCUSED);
+}
+
+
+LimitedSplitter::LimitedSplitter (wxWindow* parent)
+ : wxSplitterWindow (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_NOBORDER | wxSP_3DSASH | wxSP_LIVE_UPDATE)
+ , _first_shown (false)
+ , _top_panel_minimum_size (350)
+{
+ /* This value doesn't really mean much but we just want to stop double-click on the
+ divider from shrinking the bottom panel (#1601).
+ */
+ SetMinimumPaneSize (64);
+
+ Bind (wxEVT_SIZE, boost::bind(&LimitedSplitter::sized, this, _1));
+}
+
+
+void
+LimitedSplitter::first_shown (wxWindow* top, wxWindow* bottom)
+{
+ int const sn = wxDisplay::GetFromWindow(this);
+ if (sn >= 0) {
+ wxRect const screen = wxDisplay(sn).GetClientArea();
+ /* This is a hack to try and make the content notebook a sensible size; large on big displays but small
+ enough on small displays to leave space for the content area.
+ */
+ SplitHorizontally (top, bottom, screen.height > 800 ? -600 : -_top_panel_minimum_size);
+ } else {
+ /* Fallback for when GetFromWindow fails for reasons that aren't clear */
+ SplitHorizontally (top, bottom, -600);
+ }
+ _first_shown = true;
+}
+
+
+void
+LimitedSplitter::sized (wxSizeEvent& ev)
+{
+ if (_first_shown && GetSize().GetHeight() > _top_panel_minimum_size && GetSashPosition() < _top_panel_minimum_size) {
+ /* The window is now fairly big but the top panel is small; this happens when the DCP-o-matic window
+ * is shrunk and then made larger again. Try to set a sensible top panel size in this case (#1839).
+ */
+ SetSashPosition (_top_panel_minimum_size);
+ }
+
+ ev.Skip ();
+}