From c52bdcf69d049a4afa107e6247321afb93c65e1b Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 26 Jun 2012 02:11:06 +0000 Subject: [PATCH] Remove unused named selection / chunk code. git-svn-id: svn://localhost/ardour2/branches/3.0@12939 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor.h | 1 - gtk2_ardour/editor_selection_list.cc | 208 ------------------------- libs/ardour/ardour/named_selection.h | 57 ------- libs/ardour/ardour/session.h | 22 --- libs/ardour/ardour/session_selection.h | 39 ----- libs/ardour/named_selection.cc | 131 ---------------- libs/ardour/session.cc | 54 ------- libs/ardour/session_state.cc | 49 ------ libs/ardour/wscript | 1 - 9 files changed, 562 deletions(-) delete mode 100644 gtk2_ardour/editor_selection_list.cc delete mode 100644 libs/ardour/ardour/named_selection.h delete mode 100644 libs/ardour/ardour/session_selection.h delete mode 100644 libs/ardour/named_selection.cc diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 59014b04e7..23da8d7c6d 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -83,7 +83,6 @@ namespace ARDOUR { class Region; class Location; class TempoSection; - class NamedSelection; class Session; class Filter; class ChanCount; diff --git a/gtk2_ardour/editor_selection_list.cc b/gtk2_ardour/editor_selection_list.cc deleted file mode 100644 index 3991dc5aae..0000000000 --- a/gtk2_ardour/editor_selection_list.cc +++ /dev/null @@ -1,208 +0,0 @@ -/* - Copyright (C) 2000 Paul Davis - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#include -#include -#include - -#include - -#include "ardour/named_selection.h" -#include "ardour/session_selection.h" -#include "ardour/playlist.h" - -#include "editor.h" -#include "keyboard.h" -#include "selection.h" -#include "time_axis_view.h" -#include "ardour_ui.h" -#include "prompter.h" - -#include "i18n.h" - -using namespace std; -using namespace ARDOUR; -using namespace PBD; -using namespace Gtk; -using namespace Gtkmm2ext; - -void -Editor::handle_new_named_selection () -{ - ARDOUR_UI::instance()->call_slot (boost::bind (&Editor::redisplay_named_selections, this)); -} - -void -Editor::add_named_selection_to_named_selection_display (boost::shared_ptr selection) -{ - TreeModel::Row row = *(named_selection_model->append()); - row[named_selection_columns.text] = selection.name; - row[named_selection_columns.selection] = selection; -} - -void -Editor::redisplay_named_selections () -{ - named_selection_model->clear (); - session->foreach_named_selection (*this, &Editor::add_named_selection_to_named_selection_display); -} - -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(); - - for (i = rows.begin(); i != rows.end(); ++i) { - if (selection->is_selected (i)) { - switch (ev->button) { - case 1: - if (Keyboard::is_delete_event (ev)) { - session->remove_named_selection ((*i)[named_selection_columns.selection]); - return true; - } - break; - case 2: - break; - case 3: - break; - default: - break; - } - } - } - - return false; -} - - -void -Editor::named_selection_display_selection_changed () -{ -} - -void -Editor::create_named_selection () -{ - string name; - - if (session == 0) { - return; - } - - /* check for a range-based selection */ - - if (selection->time.empty()) { - return; - } - - TrackViewList *views = get_valid_views (selection->time.track, selection->time.group); - - if (views->empty()) { - delete views; - return; - } - - boost::shared_ptr what_we_found; - list > thelist; - - for (TrackViewList::iterator i = views->begin(); i != views->end(); ++i) { - - boost::shared_ptr pl = (*i)->playlist(); - - if (pl && (what_we_found = pl->copy (selection->time, false)) != 0) { - thelist.push_back (what_we_found); - } - } - - if (!thelist.empty()) { - - 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; - } - - boost::shared_ptr ns (new NamedSelection (name, thelist)); - - /* 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; - } -} - diff --git a/libs/ardour/ardour/named_selection.h b/libs/ardour/ardour/named_selection.h deleted file mode 100644 index c120848328..0000000000 --- a/libs/ardour/ardour/named_selection.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - Copyright (C) 2003 Paul Davis - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#ifndef __ardour_named_selection_h__ -#define __ardour_named_selection_h__ - -#include -#include -#include - -#include "pbd/stateful.h" - -class XMLNode; - -namespace ARDOUR -{ - -class Session; -class Playlist; - -class NamedSelection : public PBD::Stateful -{ -public: - NamedSelection (std::string, std::list >&); - NamedSelection (Session&, const XMLNode&); - virtual ~NamedSelection (); - - std::string name; - std::list > playlists; - - XMLNode& get_state (void); - - int set_state (const XMLNode&, int version); - - static PBD::Signal1 NamedSelectionCreated; -}; - -}/* namespace ARDOUR */ - -#endif /* __ardour_named_selection_h__ */ - diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 4c87b759b1..518a99d961 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -111,7 +111,6 @@ class MidiControlUI; class MidiRegion; class MidiSource; class MidiTrack; -class NamedSelection; class Playlist; class PluginInsert; class PluginInfo; @@ -578,16 +577,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi void add_playlist (boost::shared_ptr, bool unused = false); - /* named selections */ - - boost::shared_ptr named_selection_by_name (std::string name); - void add_named_selection (boost::shared_ptr); - void remove_named_selection (boost::shared_ptr); - - template void foreach_named_selection (T& obj, void (T::*func)(boost::shared_ptr)); - PBD::Signal0 NamedSelectionAdded; - PBD::Signal0 NamedSelectionRemoved; - /* Curves and AutomationLists (TODO when they go away) */ void add_automation_list(AutomationList*); @@ -1306,17 +1295,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi void playlist_ranges_moved (std::list > const &); void playlist_regions_extended (std::list > const &); - /* NAMED SELECTIONS */ - - mutable Glib::Mutex named_selection_lock; - typedef std::set > NamedSelectionList; - NamedSelectionList named_selections; - - int load_named_selections (const XMLNode&); - - NamedSelection *named_selection_factory (std::string name); - NamedSelection *XMLNamedSelectionFactory (const XMLNode&); - /* CURVES and AUTOMATION LISTS */ std::map automation_lists; diff --git a/libs/ardour/ardour/session_selection.h b/libs/ardour/ardour/session_selection.h deleted file mode 100644 index 52c7ab0e0e..0000000000 --- a/libs/ardour/ardour/session_selection.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - Copyright (C) 2002 Paul Davis - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#ifndef __ardour_session_named_selection_h__ -#define __ardour_session_named_selection_h__ - -#include "ardour/session.h" -#include "ardour/named_selection.h" - -namespace ARDOUR { - -template void -Session::foreach_named_selection (T& obj, void (T::*func)(NamedSelection&)) -{ - Glib::Mutex::Lock lm (named_selection_lock); - for (NamedSelectionList::iterator i = named_selections.begin(); i != named_selections.end(); i++) { - (obj.*func) (**i); - } -} - -} /* namespace */ - -#endif /* __ardour_session_named_selection_h__ */ diff --git a/libs/ardour/named_selection.cc b/libs/ardour/named_selection.cc deleted file mode 100644 index 4bcc3f3b72..0000000000 --- a/libs/ardour/named_selection.cc +++ /dev/null @@ -1,131 +0,0 @@ -/* - Copyright (C) 2003 Paul Davis - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#include "pbd/failed_constructor.h" -#include "pbd/error.h" - -#include "ardour/session.h" -#include "ardour/utils.h" -#include "ardour/playlist.h" -#include "ardour/named_selection.h" -#include "ardour/session_playlists.h" - -#include "i18n.h" - -using namespace std; -using namespace ARDOUR; -using namespace PBD; - -PBD::Signal1 NamedSelection::NamedSelectionCreated; - -typedef std::list > PlaylistList; - -NamedSelection::NamedSelection (string n, PlaylistList& l) - : name (n) -{ - playlists = l; - for (PlaylistList::iterator i = playlists.begin(); i != playlists.end(); ++i) { - string new_name; - - /* rename playlists to reflect our ownership */ - - new_name = name; - new_name += '/'; - new_name += (*i)->name(); - - (*i)->set_name (new_name); - (*i)->use(); - } -} - -NamedSelection::NamedSelection (Session& session, const XMLNode& node) -{ - XMLNode* lists_node; - const XMLProperty* property; - - if ((property = node.property ("name")) == 0) { - throw failed_constructor(); - } - - name = property->value(); - - if ((lists_node = find_named_node (node, "Playlists")) == 0) { - return; - } - - XMLNodeList nlist = lists_node->children(); - XMLNodeConstIterator niter; - - for (niter = nlist.begin(); niter != nlist.end(); ++niter) { - - const XMLNode* plnode; - string playlist_name; - boost::shared_ptr playlist; - - plnode = *niter; - - if ((property = plnode->property ("name")) != 0) { - if ((playlist = session.playlists->by_name (property->value())) != 0) { - playlist->use(); - playlists.push_back (playlist); - } else { - warning << string_compose (_("Chunk %1 uses an unknown playlist \"%2\""), name, property->value()) << endmsg; - } - } else { - error << string_compose (_("Chunk %1 contains misformed playlist information"), name) << endmsg; - throw failed_constructor(); - } - } - - NamedSelectionCreated (this); -} - -NamedSelection::~NamedSelection () -{ - for (PlaylistList::iterator i = playlists.begin(); i != playlists.end(); ++i) { - /* XXX who really owns these? us or the session? */ - (*i)->drop_references (); - (*i)->release (); - } -} - -int -NamedSelection::set_state (const XMLNode& /*node*/, int /*version*/) -{ - return 0; -} - -XMLNode& -NamedSelection::get_state () -{ - XMLNode* root = new XMLNode ("NamedSelection"); - XMLNode* child; - - root->add_property ("name", name); - child = root->add_child ("Playlists"); - - for (PlaylistList::iterator i = playlists.begin(); i != playlists.end(); ++i) { - XMLNode* plnode = new XMLNode ("Playlist"); - - plnode->add_property ("name", (*i)->name()); - child->add_child_nocopy (*plnode); - } - - return *root; -} diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index bcba42f01d..9dacdc34cb 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -68,7 +68,6 @@ #include "ardour/graph.h" #include "ardour/midi_track.h" #include "ardour/midi_ui.h" -#include "ardour/named_selection.h" #include "ardour/operations.h" #include "ardour/playlist.h" #include "ardour/plugin.h" @@ -280,9 +279,6 @@ Session::destroy () /* tell everyone to drop references and delete objects as we go */ - DEBUG_TRACE (DEBUG::Destruction, "delete named selections\n"); - named_selections.clear (); - DEBUG_TRACE (DEBUG::Destruction, "delete regions\n"); RegionFactory::delete_all_regions (); @@ -3786,56 +3782,6 @@ Session::unmark_insert_id (uint32_t id) } } - -/* Named Selection management */ - -boost::shared_ptr -Session::named_selection_by_name (string name) -{ - Glib::Mutex::Lock lm (named_selection_lock); - for (NamedSelectionList::iterator i = named_selections.begin(); i != named_selections.end(); ++i) { - if ((*i)->name == name) { - return *i; - } - } - return boost::shared_ptr(); -} - -void -Session::add_named_selection (boost::shared_ptr named_selection) -{ - { - Glib::Mutex::Lock lm (named_selection_lock); - named_selections.insert (named_selections.begin(), named_selection); - } - - set_dirty(); - - NamedSelectionAdded (); /* EMIT SIGNAL */ -} - -void -Session::remove_named_selection (boost::shared_ptr named_selection) -{ - bool removed = false; - - { - Glib::Mutex::Lock lm (named_selection_lock); - - NamedSelectionList::iterator i = find (named_selections.begin(), named_selections.end(), named_selection); - - if (i != named_selections.end()) { - named_selections.erase (i); - set_dirty(); - removed = true; - } - } - - if (removed) { - NamedSelectionRemoved (); /* EMIT SIGNAL */ - } -} - void Session::reset_native_file_format () { diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 1509a757eb..40cb364d73 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -93,7 +93,6 @@ #include "ardour/midi_region.h" #include "ardour/midi_source.h" #include "ardour/midi_track.h" -#include "ardour/named_selection.h" #include "ardour/pannable.h" #include "ardour/playlist_factory.h" #include "ardour/port.h" @@ -1159,15 +1158,6 @@ Session::state (bool full_state) gain_child->add_child_nocopy (_click_gain->state (full_state)); } - if (full_state) { - XMLNode* ns_child = node->add_child ("NamedSelections"); - for (NamedSelectionList::iterator i = named_selections.begin(); i != named_selections.end(); ++i) { - if (full_state) { - ns_child->add_child_nocopy ((*i)->get_state()); - } - } - } - node->add_child_nocopy (_speakers->get_state()); node->add_child_nocopy (_tempo_map->get_state()); node->add_child_nocopy (get_control_protocol_state()); @@ -1327,12 +1317,6 @@ Session::set_state (const XMLNode& node, int version) } } - if ((child = find_named_node (node, "NamedSelections")) != 0) { - if (load_named_selections (*child)) { - goto out; - } - } - if (version >= 3000) { if ((child = find_named_node (node, "Bundles")) == 0) { warning << _("Session: XML state has no bundles section") << endmsg; @@ -2224,39 +2208,6 @@ Session::get_best_session_directory_for_new_source () return result; } -int -Session::load_named_selections (const XMLNode& node) -{ - XMLNodeList nlist; - XMLNodeConstIterator niter; - NamedSelection *ns; - - nlist = node.children(); - - set_dirty(); - - for (niter = nlist.begin(); niter != nlist.end(); ++niter) { - - if ((ns = XMLNamedSelectionFactory (**niter)) == 0) { - error << _("Session: cannot create Named Selection from XML description.") << endmsg; - } - } - - return 0; -} - -NamedSelection * -Session::XMLNamedSelectionFactory (const XMLNode& node) -{ - try { - return new NamedSelection (*this, node); - } - - catch (failed_constructor& err) { - return 0; - } -} - string Session::automation_dir () const { diff --git a/libs/ardour/wscript b/libs/ardour/wscript index 4cece8f132..4c05af8c77 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -138,7 +138,6 @@ libardour_sources = [ 'mtc_slave.cc', 'mtdm.cc', 'mute_master.cc', - 'named_selection.cc', 'onset_detector.cc', 'operations.cc', 'pan_controllable.cc',