X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_selection_list.cc;h=fab22e8f8917a5dbdd43443a5404c1aafd20a8d9;hb=3162ffb4f418d85088d53d5e0a4a5d6ce7235e04;hp=8e88ee497bbb9a74bd7fb8dbd878b101b0e5cf64;hpb=af12adb34f62dc82f694a03ea3b2a6c99ba426ef;p=ardour.git diff --git a/gtk2_ardour/editor_selection_list.cc b/gtk2_ardour/editor_selection_list.cc index 8e88ee497b..fab22e8f89 100644 --- a/gtk2_ardour/editor_selection_list.cc +++ b/gtk2_ardour/editor_selection_list.cc @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #include @@ -24,13 +23,14 @@ #include -#include -#include -#include +#include "ardour/named_selection.h" +#include "ardour/session_selection.h" +#include "ardour/playlist.h" #include #include "editor.h" +#include "keyboard.h" #include "selection.h" #include "time_axis_view.h" #include "ardour_ui.h" @@ -38,6 +38,7 @@ #include "i18n.h" +using namespace std; using namespace sigc; using namespace ARDOUR; using namespace PBD; @@ -65,10 +66,48 @@ Editor::redisplay_named_selections () session->foreach_named_selection (*this, &Editor::add_named_selection_to_named_selection_display); } -gint -Editor::named_selection_display_button_press (GdkEventButton *ev) +bool +Editor::named_selection_display_key_release (GdkEventKey* ev) { + if (session == 0) { + return true; + } + + switch (ev->keyval) { + case GDK_Delete: + remove_selected_named_selections (); + return true; + break; + default: + return false; + break; + } + +} + +void +Editor::remove_selected_named_selections () +{ + Glib::RefPtr selection = named_selection_display.get_selection(); + TreeView::Selection::ListHandle_Path rows = selection->get_selected_rows (); + + if (selection->count_selected_rows() == 0) { + return; + } + + for (TreeView::Selection::ListHandle_Path::iterator i = rows.begin(); i != rows.end(); ++i) { + + TreeIter iter; + if ((iter = named_selection_model->get_iter (*i))) { + session->remove_named_selection ((*iter)[named_selection_columns.selection]); + } + } +} + +bool +Editor::named_selection_display_button_release (GdkEventButton *ev) +{ TreeModel::Children rows = named_selection_model->children(); TreeModel::Children::iterator i; Glib::RefPtr selection = named_selection_display.get_selection(); @@ -91,7 +130,8 @@ Editor::named_selection_display_button_press (GdkEventButton *ev) } } } - return FALSE; + + return false; } @@ -101,37 +141,10 @@ Editor::named_selection_display_selection_changed () } void -Editor::name_selection () +Editor::create_named_selection () { - ArdourPrompter p; - - p.set_prompt (_("Name for Chunk:")); - p.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT); - p.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false); - p.change_labels (_("Create Chunk"), _("Forget it")); - p.show_all (); - - switch (p.run ()) { - case Gtk::RESPONSE_ACCEPT: - string name; - p.get_result (name); - if (name.length()) { - create_named_selection (name); - } - break; - } + string name; -} - -void -Editor::named_selection_name_chosen () -{ - Gtk::Main::quit (); -} - -void -Editor::create_named_selection (const string & name) -{ if (session == 0) { return; } @@ -141,7 +154,6 @@ Editor::create_named_selection (const string & name) if (selection->time.empty()) { return; } - TrackViewList *views = get_valid_views (selection->time.track, selection->time.group); @@ -157,25 +169,42 @@ Editor::create_named_selection (const string & name) boost::shared_ptr pl = (*i)->playlist(); - if (pl) { - - if ((what_we_found = pl->copy (selection->time, false)) != 0) { - - thelist.push_back (what_we_found); - } + if (pl && (what_we_found = pl->copy (selection->time, false)) != 0) { + thelist.push_back (what_we_found); } } - NamedSelection* ns; - TreeModel::Row row = *(named_selection_model->append()); - - ns = new NamedSelection (name, thelist); - row[named_selection_columns.selection] = ns; - row[named_selection_columns.text] = name; + if (!thelist.empty()) { - /* make the one we just added be selected */ + ArdourPrompter p; + + p.set_prompt (_("Name for Chunk:")); + p.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT); + p.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false); + p.change_labels (_("Create Chunk"), _("Forget it")); + p.show_all (); + + switch (p.run ()) { + + case Gtk::RESPONSE_ACCEPT: + p.get_result (name); + if (name.empty()) { + return; + } + break; + default: + return; + } - named_selection_display.get_selection()->select (row); + new NamedSelection (name, thelist); // creation will add it to the model + /* make the one we just added be selected */ + + TreeModel::Children::iterator added = named_selection_model->children().end(); + --added; + named_selection_display.get_selection()->select (*added); + } else { + error << _("No selectable material found in the currently selected time range") << endmsg; + } }