_content->Bind (wxEVT_DROP_FILES, boost::bind (&ContentPanel::files_dropped, this, _1));
_add_file->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ContentPanel::add_file_clicked, this));
_add_folder->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ContentPanel::add_folder_clicked, this));
- _remove->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ContentPanel::remove_clicked, this));
+ _remove->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ContentPanel::remove_clicked, this, false));
_earlier->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ContentPanel::earlier_clicked, this));
_later->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ContentPanel::later_clicked, this));
_timeline->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ContentPanel::timeline_clicked, this));
if (go_to) {
_film_viewer->set_position (go_to.get ());
}
+
+ if (_timeline_dialog) {
+ _timeline_dialog->set_selection (selected ());
+ }
}
void
}
void
-ContentPanel::remove_clicked ()
+ContentPanel::remove_clicked (bool hotkey)
{
- ContentList c = selected ();
- if (c.size() == 1) {
- _film->remove_content (c.front ());
+ /* If the method was called because Delete was pressed check that our notebook page
+ is visible and that the content list is focussed.
+ */
+ if (hotkey && (_parent->GetCurrentPage() != _panel || !_content->HasFocus())) {
+ return;
+ }
+
+ BOOST_FOREACH (shared_ptr<Content> i, selected ()) {
+ _film->remove_content (i);
}
selection_changed ();
VideoContentList video_selection = selected_video ();
AudioContentList audio_selection = selected_audio ();
- _remove->Enable (selection.size() == 1 && _generally_sensitive);
+ _remove->Enable (!selection.empty() && _generally_sensitive);
_earlier->Enable (selection.size() == 1 && _generally_sensitive);
_later->Enable (selection.size() == 1 && _generally_sensitive);
_timeline->Enable (!_film->content().empty() && _generally_sensitive);
{
ContentList content = _film->content ();
- /* First, check to see if anything has changed and bail if not; this avoids
- flickering on OS X.
- */
-
- vector<string> existing;
- for (int i = 0; i < _content->GetItemCount(); ++i) {
- existing.push_back (wx_to_std (_content->GetItemText (i)));
- }
-
- vector<string> proposed;
- BOOST_FOREACH (shared_ptr<Content> i, content) {
- bool const valid = i->paths_valid ();
-
- string s = i->summary ();
- if (!valid) {
- s = _("MISSING: ") + s;
- }
-
- proposed.push_back (s);
- }
-
- if (existing == proposed) {
- return;
- }
-
- /* Something has changed: set up the control */
-
- string selected_summary;
+ Content* selected_content = 0;
int const s = _content->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
if (s != -1) {
- selected_summary = wx_to_std (_content->GetItemText (s));
+ wxListItem item;
+ item.SetId (s);
+ item.SetMask (wxLIST_MASK_DATA);
+ _content->GetItem (item);
+ selected_content = reinterpret_cast<Content*> (item.GetData ());
}
_content->DeleteAllItems ();
s = _("NEEDS KDM: ") + s;
}
- _content->InsertItem (t, std_to_wx (s));
+ wxListItem item;
+ item.SetId (t);
+ item.SetText (std_to_wx (s));
+ item.SetData (i.get ());
+ _content->InsertItem (item);
- if (i->summary() == selected_summary) {
+ if (i.get() == selected_content) {
_content->SetItemState (t, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
}
}
}
- if (selected_summary.empty () && !content.empty ()) {
+ if (!selected_content && !content.empty ()) {
/* Select the item of content if none was selected before */
_content->SetItemState (0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
}