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::edit_group_list_column_click (gint col)
47 if (edit_group_list_menu == 0) {
48 build_edit_group_list_menu ();
51 edit_group_list_menu->popup (0, 0);
55 Editor::build_edit_group_list_menu ()
58 using namespace Gtk::Menu_Helpers;
60 edit_group_list_menu = new Menu;
61 edit_group_list_menu->set_name ("ArdourContextMenu");
62 MenuList& items = edit_group_list_menu->items();
64 items.push_back (MenuElem (_("Show All"), mem_fun(*this, &Editor::select_all_edit_groups)));
65 items.push_back (MenuElem (_("Hide All"), mem_fun(*this, &Editor::unselect_all_edit_groups)));
69 Editor::unselect_all_edit_groups ()
75 Editor::select_all_edit_groups ()
79 /* XXX potential race with remove_track(), but the select operation
80 cannot be done with the track_lock held.
83 Gtk::TreeModel::Children children = group_model->children();
84 for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
85 edit_group_list.get_selection()->select (iter);
90 Editor::new_edit_group ()
97 ArdourPrompter prompter;
100 prompter.set_prompt (_("Name for new edit group"));
101 prompter.show_all ();
103 switch (prompter.run ()) {
104 case GTK_RESPONSE_ACCEPT:
105 prompter.get_result (result);
106 if (result.length()) {
107 session->add_edit_group (result);
114 Editor::edit_group_list_button_clicked ()
120 Editor::edit_group_list_button_press_event (GdkEventButton* ev)
124 TreeModel::Path path;
125 TreeViewColumn* column;
129 if (!edit_group_list.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
133 switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) {
137 if (Keyboard::is_edit_event (ev)) {
138 // RouteGroup* group = (RouteGroup *) edit_group_list.row(row).get_data ();
139 // edit_route_group (group);
141 return stop_signal (edit_group_list, "button_press_event");
144 /* allow regular select to occur */
150 if ((iter = group_model->get_iter (path))) {
151 /* path points to a valid node */
153 if ((group = (*iter)[group_columns.routegroup]) != 0) {
154 group->set_active (!group->is_active (), this);
160 return stop_signal (edit_group_list, "button_press_event");
164 Editor::edit_group_selection_changed ()
166 TreeModel::iterator i;
167 TreeModel::Children rows = group_model->children();
168 Glib::RefPtr<TreeSelection> selection = edit_group_list.get_selection();
170 for (i = rows.begin(); i != rows.end(); ++i) {
173 group = (*i)[group_columns.routegroup];
175 if (selection->is_selected (i)) {
176 for (TrackViewList::iterator j = track_views.begin(); j != track_views.end(); ++j) {
177 if ((*j)->edit_group() == group) {
178 select_strip_in_display (*j);
182 for (TrackViewList::iterator j = track_views.begin(); j != track_views.end(); ++j) {
183 if ((*j)->edit_group() == group) {
184 unselect_strip_in_display (*j);
192 Editor::add_edit_group (RouteGroup* group)
196 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::add_edit_group), group));
198 TreeModel::Row row = *(group_model->append());
199 row[group_columns.is_active] = group->is_active();
200 row[group_columns.text] = group->name();
201 row[group_columns.routegroup] = group;
203 group->FlagsChanged.connect (bind (mem_fun(*this, &Editor::group_flags_changed), group));
207 Editor::group_flags_changed (void* src, RouteGroup* group)
209 /* GTK2FIX not needed in gtk2?
215 CList_Helpers::RowIterator ri = edit_group_list.rows().find_data (group);
217 if (group->is_active()) {
218 edit_group_list.cell (ri->get_row_num(),0).set_pixmap (check_pixmap, check_mask);
220 edit_group_list.cell (ri->get_row_num(),0).set_pixmap (empty_pixmap, empty_mask);