2 Copyright (C) 2000 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <gtkmm2ext/stop_signal.h>
25 #include <gtkmm2ext/gtk_ui.h>
26 #include <ardour/route_group.h>
31 #include "time_axis_view.h"
33 #include "gui_thread.h"
35 #include <ardour/route.h>
40 using namespace ARDOUR;
44 Editor::build_edit_group_list_menu ()
46 using namespace Gtk::Menu_Helpers;
48 edit_group_list_menu = new Menu;
49 edit_group_list_menu->set_name ("ArdourContextMenu");
50 MenuList& items = edit_group_list_menu->items();
52 items.push_back (MenuElem (_("Activate All"), mem_fun(*this, &Editor::activate_all_edit_groups)));
53 items.push_back (MenuElem (_("Disable All"), mem_fun(*this, &Editor::disable_all_edit_groups)));
54 items.push_back (SeparatorElem());
55 items.push_back (MenuElem (_("Add group"), mem_fun(*this, &Editor::new_edit_group)));
60 Editor::activate_all_edit_groups ()
62 Gtk::TreeModel::Children children = group_model->children();
63 for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
64 (*iter)[group_columns.is_active] = true;
69 Editor::disable_all_edit_groups ()
71 Gtk::TreeModel::Children children = group_model->children();
72 for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
73 (*iter)[group_columns.is_active] = false;
78 Editor::new_edit_group ()
80 session->add_edit_group ("");
84 Editor::remove_selected_edit_group ()
86 Glib::RefPtr<TreeSelection> selection = edit_group_display.get_selection();
87 TreeView::Selection::ListHandle_Path rows = selection->get_selected_rows ();
93 TreeView::Selection::ListHandle_Path::iterator i = rows.begin();
96 /* selection mode is single, so rows.begin() is it */
98 if ((iter = group_model->get_iter (*i))) {
100 RouteGroup* rg = (*iter)[group_columns.routegroup];
103 session->remove_edit_group (*rg);
109 Editor::edit_group_list_button_clicked ()
115 Editor::edit_group_list_button_press_event (GdkEventButton* ev)
117 if (Keyboard::is_context_menu_event (ev)) {
118 if (edit_group_list_menu == 0) {
119 build_edit_group_list_menu ();
121 edit_group_list_menu->popup (1, 0);
128 TreeModel::Path path;
129 TreeViewColumn* column;
133 if (!edit_group_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
137 switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) {
139 if (Keyboard::is_edit_event (ev)) {
140 if ((iter = group_model->get_iter (path))) {
141 if ((group = (*iter)[group_columns.routegroup]) != 0) {
142 // edit_route_group (group);
151 if ((iter = group_model->get_iter (path))) {
152 bool visible = (*iter)[group_columns.is_visible];
153 (*iter)[group_columns.is_visible] = !visible;
159 if ((iter = group_model->get_iter (path))) {
160 bool active = (*iter)[group_columns.is_active];
161 (*iter)[group_columns.is_active] = !active;
174 Editor::edit_group_row_change (const Gtk::TreeModel::Path& path,const Gtk::TreeModel::iterator& iter)
178 if (in_edit_group_row_change) {
182 if ((group = (*iter)[group_columns.routegroup]) == 0) {
186 if ((*iter)[group_columns.is_visible]) {
187 for (TrackViewList::iterator j = track_views.begin(); j != track_views.end(); ++j) {
188 if ((*j)->edit_group() == group) {
189 show_track_in_display (**j);
193 for (TrackViewList::iterator j = track_views.begin(); j != track_views.end(); ++j) {
194 if ((*j)->edit_group() == group) {
195 hide_track_in_display (**j);
200 bool active = (*iter)[group_columns.is_active];
201 group->set_active (active, this);
204 string name = (*iter)[group_columns.text];
206 if (name != group->name()) {
207 group->set_name (name);
212 Editor::add_edit_group (RouteGroup* group)
214 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::add_edit_group), group));
217 TreeModel::Row row = *(group_model->append());
218 row[group_columns.is_active] = group->is_active();
219 row[group_columns.is_visible] = !group->is_hidden();
221 row[group_columns.routegroup] = group;
222 if (!group->name().empty()) {
223 row[group_columns.text] = group->name();
225 row[group_columns.text] = _("unnamed");
229 group->FlagsChanged.connect (bind (mem_fun(*this, &Editor::group_flags_changed), group));
232 TreeViewColumn* col = edit_group_display.get_column (0);
233 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(edit_group_display.get_column_cell_renderer (0));
234 edit_group_display.set_cursor (group_model->get_path (row), *col, *name_cell, true);
239 Editor::edit_groups_changed ()
241 ENSURE_GUI_THREAD (mem_fun (*this, &Editor::edit_groups_changed));
243 /* just rebuild the while thing */
245 group_model->clear ();
249 row = *(group_model->append());
250 row[group_columns.is_active] = false;
251 row[group_columns.is_visible] = true;
252 row[group_columns.text] = (_("-all-"));
253 row[group_columns.routegroup] = 0;
256 session->foreach_edit_group (mem_fun (*this, &Editor::add_edit_group));
260 Editor::group_flags_changed (void* src, RouteGroup* group)
262 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::group_flags_changed), src, group));
264 in_edit_group_row_change = true;
266 Gtk::TreeModel::Children children = group_model->children();
267 for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
268 if (group == (*iter)[group_columns.routegroup]) {
269 (*iter)[group_columns.is_active] = group->is_active();
270 (*iter)[group_columns.is_visible] = !group->is_hidden();
271 (*iter)[group_columns.text] = group->name();
275 in_edit_group_row_change = false;
279 Editor::edit_group_name_edit (const Glib::ustring& path, const Glib::ustring& new_text)
284 if ((iter = group_model->get_iter (path))) {
286 if ((group = (*iter)[group_columns.routegroup]) == 0) {
290 if (new_text != group->name()) {
291 group->set_name (new_text);