$Id$
*/
-#include <gtkmmext/gtk_ui.h>
-#include <gtkmmext/stop_signal.h>
-#include <gtkmmext/choice.h>
-#include <gtkmmext/bindable_button.h>
-#include <gtkmmext/doi.h>
+#include <gtkmm2ext/gtk_ui.h>
+#include <gtkmm2ext/stop_signal.h>
+#include <gtkmm2ext/choice.h>
+#include <gtkmm2ext/bindable_button.h>
+#include <gtkmm2ext/doi.h>
#include <ardour/route_group.h>
#include <ardour/diskstream.h>
#include "i18n.h"
-
-using namespace SigC;
+using namespace sigc;
using namespace Gtk;
-using namespace Gtkmmext;
+using namespace Gtkmm2ext;
using namespace ARDOUR;
xml_node = 0;
mute_menu = 0;
solo_menu = 0;
+ remote_control_menu = 0;
ignore_toggle = false;
wait_for_release = false;
route_active_menu_item = 0;
set_color (unique_random_color());
}
- _route.GoingAway.connect (slot (*this, &RouteUI::route_removed));
- _route.active_changed.connect (slot (*this, &RouteUI::route_active_changed));
+ _route.GoingAway.connect (mem_fun (*this, &RouteUI::route_removed));
+ _route.active_changed.connect (mem_fun (*this, &RouteUI::route_active_changed));
mute_button = manage (new BindableToggleButton (& _route.midi_mute_control(), m_name ));
mute_button->set_bind_button_state (2, GDK_CONTROL_MASK);
if (is_audio_track()) {
AudioTrack* at = dynamic_cast<AudioTrack*>(&_route);
- get_diskstream()->record_enable_changed.connect (slot (*this, &RouteUI::route_rec_enable_changed));
+ get_diskstream()->record_enable_changed.connect (mem_fun (*this, &RouteUI::route_rec_enable_changed));
- _session.RecordEnabled.connect (slot (*this, &RouteUI::session_rec_enable_changed));
- _session.RecordDisabled.connect (slot (*this, &RouteUI::session_rec_enable_changed));
+ _session.RecordStateChanged.connect (mem_fun (*this, &RouteUI::session_rec_enable_changed));
rec_enable_button = manage (new BindableToggleButton (& at->midi_rec_enable_control(), r_name ));
rec_enable_button->set_bind_button_state (2, GDK_CONTROL_MASK);
rec_enable_button = manage (new BindableToggleButton (0, r_name ));
}
- mute_button->unset_flags (GTK_CAN_FOCUS);
- solo_button->unset_flags (GTK_CAN_FOCUS);
- rec_enable_button->unset_flags (GTK_CAN_FOCUS);
+ mute_button->unset_flags (Gtk::CAN_FOCUS);
+ solo_button->unset_flags (Gtk::CAN_FOCUS);
+ rec_enable_button->unset_flags (Gtk::CAN_FOCUS);
/* map the current state */
}
- return stop_signal (*mute_button, "button-press-event");
+ return true;
}
gint
// undo the last op
// because the press was the last undoable thing we did
_session.undo (1U);
- stop_signal (*mute_button, "button-release-event");
}
}
- return TRUE;
+ return true;
}
gint
}
}
- return stop_signal (*solo_button, "button-press-event");
+ return true;
}
gint
RouteUI::solo_release(GdkEventButton* ev)
{
- if(!ignore_toggle){
- if (wait_for_release){
+ if (!ignore_toggle) {
+ if (wait_for_release) {
wait_for_release = false;
// undo the last op
// because the press was the last undoable thing we did
_session.undo (1U);
-
- stop_signal (*solo_button, "button-release-event");
}
}
- return TRUE;
+
+ return true;
}
gint
void
RouteUI::solo_changed(void* src)
{
- Gtkmmext::UI::instance()->call_slot (slot (*this, &RouteUI::update_solo_display));
+ Gtkmm2ext::UI::instance()->call_slot (mem_fun (*this, &RouteUI::update_solo_display));
}
void
void
RouteUI::mute_changed(void* src)
{
- Gtkmmext::UI::instance()->call_slot (slot (*this, &RouteUI::update_mute_display));
+ Gtkmm2ext::UI::instance()->call_slot (mem_fun (*this, &RouteUI::update_mute_display));
}
void
void
RouteUI::route_rec_enable_changed (void *src)
{
- Gtkmmext::UI::instance()->call_slot (slot (*this, &RouteUI::update_rec_display));
+ Gtkmm2ext::UI::instance()->call_slot (mem_fun (*this, &RouteUI::update_rec_display));
}
void
RouteUI::session_rec_enable_changed ()
{
- Gtkmmext::UI::instance()->call_slot (slot (*this, &RouteUI::update_rec_display));
+ Gtkmm2ext::UI::instance()->call_slot (mem_fun (*this, &RouteUI::update_rec_display));
}
void
switch (_session.record_status ()) {
case Session::Disabled:
case Session::Enabled:
- if (rec_enable_button->get_state() != GTK_STATE_ACTIVE) {
- rec_enable_button->set_state (GTK_STATE_ACTIVE);
+ if (rec_enable_button->get_state() != Gtk::STATE_ACTIVE) {
+ rec_enable_button->set_state (Gtk::STATE_ACTIVE);
}
break;
case Session::Recording:
- if (rec_enable_button->get_state() != GTK_STATE_SELECTED) {
- rec_enable_button->set_state (GTK_STATE_SELECTED);
+ if (rec_enable_button->get_state() != Gtk::STATE_SELECTED) {
+ rec_enable_button->set_state (Gtk::STATE_SELECTED);
}
break;
}
} else {
- if (rec_enable_button->get_state() != GTK_STATE_NORMAL) {
- rec_enable_button->set_state (GTK_STATE_NORMAL);
+ if (rec_enable_button->get_state() != Gtk::STATE_NORMAL) {
+ rec_enable_button->set_state (Gtk::STATE_NORMAL);
+ }
+ }
+}
+
+void
+RouteUI::build_remote_control_menu ()
+{
+ remote_control_menu = manage (new Menu);
+ refresh_remote_control_menu ();
+}
+
+void
+RouteUI::refresh_remote_control_menu ()
+{
+ using namespace Menu_Helpers;
+
+ RadioMenuItem::Group rc_group;
+ CheckMenuItem* rc_active;
+ uint32_t limit = _session.ntracks();
+ char buf[32];
+
+ MenuList& rc_items = remote_control_menu->items();
+ rc_items.clear ();
+
+ /* note that this menu list starts at zero, not 1, because zero
+ is a valid, if useless, ID.
+ */
+
+ limit += 4; /* leave some breathing room */
+
+ for (uint32_t i = 0; i < limit; ++i) {
+ snprintf (buf, sizeof (buf), "%u", i);
+ rc_items.push_back (RadioMenuElem (rc_group, buf));
+ rc_active = dynamic_cast<RadioMenuItem*>(&rc_items.back());
+ if (_route.remote_control_id() == i) {
+ rc_active = dynamic_cast<CheckMenuItem*> (&rc_items.back());
+ rc_active->set_active ();
}
+ rc_active->signal_activate().connect (bind (mem_fun (*this, &RouteUI::set_remote_control_id), i, rc_active));
+ }
+}
+
+void
+RouteUI::set_remote_control_id (uint32_t id, CheckMenuItem* item)
+{
+ /* this is called when the radio menu item is toggled, and so
+ is actually invoked twice per menu selection. we only
+ care about the invocation for the item that was being
+ marked active.
+ */
+
+ if (item->get_active()) {
+ _route.set_remote_control_id (id);
}
}
check = new CheckMenuItem(_("Solo-safe"));
check->set_active (_route.solo_safe());
- check->toggled.connect (bind (slot (*this, &RouteUI::toggle_solo_safe), check));
- _route.solo_safe_changed.connect(bind (slot (*this, &RouteUI::solo_safe_toggle), check));
+ check->signal_toggled().connect (bind (mem_fun (*this, &RouteUI::toggle_solo_safe), check));
+ _route.solo_safe_changed.connect(bind (mem_fun (*this, &RouteUI::solo_safe_toggle), check));
items.push_back (CheckMenuElem(*check));
check->show_all();
items.push_back (SeparatorElem());
- items.push_back (MenuElem (_("MIDI Bind"), slot (*mute_button, &BindableToggleButton::midi_learn)));
+ items.push_back (MenuElem (_("MIDI Bind"), mem_fun (*mute_button, &BindableToggleButton::midi_learn)));
}
check = new CheckMenuItem(_("Pre Fader"));
init_mute_menu(PRE_FADER, check);
- check->toggled.connect(bind (slot (*this, &RouteUI::toggle_mute_menu), PRE_FADER, check));
- _route.pre_fader_changed.connect(bind (slot (*this, &RouteUI::pre_fader_toggle), check));
+ check->signal_toggled().connect(bind (mem_fun (*this, &RouteUI::toggle_mute_menu), PRE_FADER, check));
+ _route.pre_fader_changed.connect(bind (mem_fun (*this, &RouteUI::pre_fader_toggle), check));
items.push_back (CheckMenuElem(*check));
check->show_all();
check = new CheckMenuItem(_("Post Fader"));
init_mute_menu(POST_FADER, check);
- check->toggled.connect(bind (slot (*this, &RouteUI::toggle_mute_menu), POST_FADER, check));
- _route.post_fader_changed.connect(bind (slot (*this, &RouteUI::post_fader_toggle), check));
+ check->signal_toggled().connect(bind (mem_fun (*this, &RouteUI::toggle_mute_menu), POST_FADER, check));
+ _route.post_fader_changed.connect(bind (mem_fun (*this, &RouteUI::post_fader_toggle), check));
items.push_back (CheckMenuElem(*check));
check->show_all();
check = new CheckMenuItem(_("Control Outs"));
init_mute_menu(CONTROL_OUTS, check);
- check->toggled.connect(bind (slot (*this, &RouteUI::toggle_mute_menu), CONTROL_OUTS, check));
- _route.control_outs_changed.connect(bind (slot (*this, &RouteUI::control_outs_toggle), check));
+ check->signal_toggled().connect(bind (mem_fun (*this, &RouteUI::toggle_mute_menu), CONTROL_OUTS, check));
+ _route.control_outs_changed.connect(bind (mem_fun (*this, &RouteUI::control_outs_toggle), check));
items.push_back (CheckMenuElem(*check));
check->show_all();
check = new CheckMenuItem(_("Main Outs"));
init_mute_menu(MAIN_OUTS, check);
- check->toggled.connect(bind (slot (*this, &RouteUI::toggle_mute_menu), MAIN_OUTS, check));
- _route.main_outs_changed.connect(bind (slot (*this, &RouteUI::main_outs_toggle), check));
+ check->signal_toggled().connect(bind (mem_fun (*this, &RouteUI::toggle_mute_menu), MAIN_OUTS, check));
+ _route.main_outs_changed.connect(bind (mem_fun (*this, &RouteUI::main_outs_toggle), check));
items.push_back (CheckMenuElem(*check));
check->show_all();
items.push_back (SeparatorElem());
- items.push_back (MenuElem (_("MIDI Bind"), slot (*mute_button, &BindableToggleButton::midi_learn)));
+ items.push_back (MenuElem (_("MIDI Bind"), mem_fun (*mute_button, &BindableToggleButton::midi_learn)));
}
void
RouteUI::reversibly_apply_route_boolean (string name, void (Route::*func)(bool, void *), bool yn, void *arg)
{
_session.begin_reversible_command (name);
- _session.add_undo (bind (slot (_route, func), !yn, (void *) arg));
- _session.add_redo (bind (slot (_route, func), yn, (void *) arg));
+ _session.add_undo (bind (mem_fun (_route, func), !yn, (void *) arg));
+ _session.add_redo (bind (mem_fun (_route, func), yn, (void *) arg));
_session.commit_reversible_command ();
}
RouteUI::reversibly_apply_audio_track_boolean (string name, void (AudioTrack::*func)(bool, void *), bool yn, void *arg)
{
_session.begin_reversible_command (name);
- _session.add_undo (bind (slot (*audio_track(), func), !yn, (void *) arg));
- _session.add_redo (bind (slot (*audio_track(), func), yn, (void *) arg));
+ _session.add_undo (bind (mem_fun (*audio_track(), func), !yn, (void *) arg));
+ _session.add_redo (bind (mem_fun (*audio_track(), func), yn, (void *) arg));
_session.commit_reversible_command ();
}
RouteUI::choose_color()
{
bool picked;
- GdkColor color;
- gdouble current[4];
-
- current[0] = _color.get_red() / 65535.0;
- current[1] = _color.get_green() / 65535.0;
- current[2] = _color.get_blue() / 65535.0;
- current[3] = 1.0;
+ Gdk::Color color;
- color = Gtkmmext::UI::instance()->get_color (_("ardour: color selection"), picked, current);
+ color = Gtkmm2ext::UI::instance()->get_color (_("ardour: color selection"), picked, &_color);
if (picked) {
set_color (color);
}
void
-RouteUI::set_color (Gdk_Color c)
+RouteUI::set_color (const Gdk::Color & c)
{
char buf[64];
_color = c;
ensure_xml_node ();
- snprintf (buf, sizeof (buf), "%d:%d:%d", c.red, c.green, c.blue);
+ snprintf (buf, sizeof (buf), "%d:%d:%d", c.get_red(), c.get_green(), c.get_blue());
xml_node->add_property ("color", buf);
_route.gui_changed ("color", (void *) 0); /* EMIT_SIGNAL */
}
XMLNode*
-RouteUI::get_child_xml_node (string childname)
+RouteUI::get_child_xml_node (const string & childname)
{
XMLNode* child;
if ((prop = xml_node->property ("color")) != 0) {
int r, g, b;
sscanf (prop->value().c_str(), "%d:%d:%d", &r, &g, &b);
- _color.red = r;
- _color.green = g;
- _color.blue = b;
+ _color.set_red(r);
+ _color.set_green(g);
+ _color.set_blue(b);
return 0;
}
return 1;
string prompt;
if (is_audio_track()) {
- prompt = compose (_("Do you really want to remove track \"%1\" ?\nYou may also lose the playlist used by this track.\n(cannot be undone)"), _route.name());
+ prompt = string_compose (_("Do you really want to remove track \"%1\" ?\nYou may also lose the playlist used by this track.\n(cannot be undone)"), _route.name());
} else {
- prompt = compose (_("Do you really want to remove bus \"%1\" ?\n(cannot be undone)"), _route.name());
+ prompt = string_compose (_("Do you really want to remove bus \"%1\" ?\n(cannot be undone)"), _route.name());
}
choices.push_back (_("Yes, remove it."));
Choice prompter (prompt, choices);
- prompter.chosen.connect (Gtk::Main::quit.slot());
- prompter.show_all ();
-
- Gtk::Main::run ();
-
- if (prompter.get_choice() == 0) {
- Main::idle.connect (bind (slot (&RouteUI::idle_remove_this_route), this));
+ if (prompter.run () == 0) {
+ Glib::signal_idle().connect (bind (sigc::ptr_fun (&RouteUI::idle_remove_this_route), this));
}
}
void
RouteUI::route_removed ()
{
- ENSURE_GUI_THREAD(slot (*this, &RouteUI::route_removed));
+ ENSURE_GUI_THREAD(mem_fun (*this, &RouteUI::route_removed));
delete this;
}
RouteUI::route_rename ()
{
ArdourPrompter name_prompter (true);
+ string result;
name_prompter.set_prompt (_("new name: "));
name_prompter.set_initial_text (_route.name());
- name_prompter.done.connect (Gtk::Main::quit.slot());
name_prompter.show_all ();
- Gtk::Main::run();
+ switch (name_prompter.run ()) {
- if (name_prompter.status == Gtkmmext::Prompter::cancelled) {
- return;
+ case Gtk::RESPONSE_ACCEPT:
+ name_prompter.get_result (result);
+ if (result.length()) {
+ _route.set_name (result, this);
+ }
+ break;
}
-
- string result;
- name_prompter.get_result (result);
- if (result.length() == 0) {
- return;
- }
-
- strip_whitespace_edges (result);
- _route.set_name (result, this);
+ return;
+
}
void
RouteUI::name_changed (void *src)
{
- ENSURE_GUI_THREAD(bind (slot (*this, &RouteUI::name_changed), src));
+ ENSURE_GUI_THREAD(bind (mem_fun (*this, &RouteUI::name_changed), src));
name_label.set_text (_route.name());
}
RouteUI::route_active_changed ()
{
if (route_active_menu_item) {
- Gtkmmext::UI::instance()->call_slot (bind (slot (*route_active_menu_item, &CheckMenuItem::set_active), _route.active()));
+ Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun (*route_active_menu_item, &CheckMenuItem::set_active), _route.active()));
}
}
void
RouteUI::pre_fader_toggle(void* src, Gtk::CheckMenuItem* check)
{
- ENSURE_GUI_THREAD(bind (slot (*this, &RouteUI::pre_fader_toggle), src, check));
+ ENSURE_GUI_THREAD(bind (mem_fun (*this, &RouteUI::pre_fader_toggle), src, check));
bool yn = _route.get_mute_config(PRE_FADER);
if (check->get_active() != yn) {
void
RouteUI::post_fader_toggle(void* src, Gtk::CheckMenuItem* check)
{
- ENSURE_GUI_THREAD(bind (slot (*this, &RouteUI::post_fader_toggle), src, check));
+ ENSURE_GUI_THREAD(bind (mem_fun (*this, &RouteUI::post_fader_toggle), src, check));
bool yn = _route.get_mute_config(POST_FADER);
if (check->get_active() != yn) {
void
RouteUI::control_outs_toggle(void* src, Gtk::CheckMenuItem* check)
{
- ENSURE_GUI_THREAD(bind (slot (*this, &RouteUI::control_outs_toggle), src, check));
+ ENSURE_GUI_THREAD(bind (mem_fun (*this, &RouteUI::control_outs_toggle), src, check));
bool yn = _route.get_mute_config(CONTROL_OUTS);
if (check->get_active() != yn) {
void
RouteUI::main_outs_toggle(void* src, Gtk::CheckMenuItem* check)
{
- ENSURE_GUI_THREAD(bind (slot (*this, &RouteUI::main_outs_toggle), src, check));
+ ENSURE_GUI_THREAD(bind (mem_fun (*this, &RouteUI::main_outs_toggle), src, check));
bool yn = _route.get_mute_config(MAIN_OUTS);
if (check->get_active() != yn) {
void
RouteUI::map_frozen ()
{
- ENSURE_GUI_THREAD (slot (*this, &RouteUI::map_frozen));
+ ENSURE_GUI_THREAD (mem_fun (*this, &RouteUI::map_frozen));
AudioTrack* at = dynamic_cast<AudioTrack*>(&_route);
}
}
}
+