13
0

replace ::cast_dynamic() with relevant ActionManager::get_*_action() calls

This commit is contained in:
Paul Davis 2018-12-12 11:00:43 -05:00
parent 758d0ca263
commit 360261f110

View File

@ -49,29 +49,20 @@ Maschine2::connect_signals ()
session->history().Changed.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&Maschine2::notify_history_changed, this), this);
/* Actions */
Glib::RefPtr<Gtk::Action> act;
Glib::RefPtr<Gtk::ToggleAction> tact;
Glib::RefPtr<Gtk::RadioAction> ract;
#if 0
act = ActionManager::find_action (X_("Editor"), X_("ToggleMeasureVisibility"));
if (act) {
Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic (act);
tact = ActionManager::find_toggle_action (X_("Editor"), X_("ToggleMeasureVisibility"));
tact->signal_toggled ().connect (sigc::mem_fun (*this, &Maschine2::notify_grid_change));
}
#endif
act = ActionManager::find_action (X_("Editor"), X_("snap-off"));
if (act) {
Glib::RefPtr<Gtk::RadioAction> ract = Glib::RefPtr<Gtk::RadioAction>::cast_dynamic (act);
ract = ActionManager::find_radio_action (X_("Editor"), X_("snap-off"));
ract->signal_toggled ().connect (sigc::mem_fun (*this, &Maschine2::notify_snap_change));
}
act = ActionManager::find_action (X_("Editor"), X_("snap-magnetic"));
if (act) {
Glib::RefPtr<Gtk::RadioAction> ract = Glib::RefPtr<Gtk::RadioAction>::cast_dynamic (act);
ract = ActionManager::find_radio_action (X_("Editor"), X_("snap-magnetic"));
ract->signal_toggled ().connect (sigc::mem_fun (*this, &Maschine2::notify_snap_change));
}
act = ActionManager::find_action (X_("Editor"), X_("snap-normal"));
if (act) {
Glib::RefPtr<Gtk::RadioAction> ract = Glib::RefPtr<Gtk::RadioAction>::cast_dynamic (act);
ract = ActionManager::find_radio_action (X_("Editor"), X_("snap-normal"));
ract->signal_toggled ().connect (sigc::mem_fun (*this, &Maschine2::notify_snap_change));
}
/* Surface events */
_ctrl->button (M2Contols::Play)->released.connect_same_thread (button_connections, boost::bind (&Maschine2::button_play, this));
@ -167,12 +158,9 @@ Maschine2::notify_parameter_changed (std::string param)
void
Maschine2::notify_grid_change ()
{
Glib::RefPtr<Gtk::Action> act = ActionManager::find_action (X_("Editor"), X_("ToggleMeasureVisibility"));
if (act) {
Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic (act);
Glib::RefPtr<Gtk::ToggleAction> tact = ActionManager::find_toggle_action (X_("Editor"), X_("ToggleMeasureVisibility"));
_ctrl->button (M2Contols::Grid)->set_color (tact->get_active () ? COLOR_WHITE : 0);
}
}
#endif
void
@ -183,16 +171,10 @@ Maschine2::notify_snap_change ()
return;
}
Glib::RefPtr<Gtk::Action> act = ActionManager::find_action (X_("Editor"), X_("snap-magnetic"));
if (act) {
Glib::RefPtr<Gtk::RadioAction> ract = Glib::RefPtr<Gtk::RadioAction>::cast_dynamic (act);
Glib::RefPtr<Gtk::RadioAction> ract = ActionManager::find_radio_action (X_("Editor"), X_("snap-magnetic"));
if (ract->get_active ()) { rgba = COLOR_GRAY; }
}
act = ActionManager::find_action (X_("Editor"), X_("snap-normal"));
if (act) {
Glib::RefPtr<Gtk::RadioAction> ract = Glib::RefPtr<Gtk::RadioAction>::cast_dynamic (act);
ract = ActionManager::find_radio_action (X_("Editor"), X_("snap-normal"));
if (ract->get_active ()) { rgba = COLOR_WHITE; }
}
_ctrl->button (M2Contols::Grid)->set_color (rgba);
}
@ -257,12 +239,9 @@ Maschine2::button_action (const std::string& group, const std::string& item)
void
Maschine2::button_grid ()
{
Glib::RefPtr<Gtk::Action> act = ActionManager::find_action (X_("Editor"), X_("ToggleMeasureVisibility"));
if (act) {
Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic (act);
Glib::RefPtr<Gtk::ToggleAction> tact = ActionManager::find_toggle_action (X_("Editor"), X_("ToggleMeasureVisibility"));
tact->set_active (!tact->get_active ());
}
}
#endif
void
@ -288,35 +267,19 @@ Maschine2::button_snap_released ()
_ctrl->button (M2Contols::Grid)->set_blinking (false);
const char* action = 0;
Glib::RefPtr<Gtk::Action> act = ActionManager::find_action (X_("Editor"), X_("snap-off"));
if (act) {
Glib::RefPtr<Gtk::RadioAction> ract = Glib::RefPtr<Gtk::RadioAction>::cast_dynamic (act);
Glib::RefPtr<Gtk::RadioAction> ract = ActionManager::find_radio_action (X_("Editor"), X_("snap-off"));
if (ract->get_active ()) { action = "snap-normal"; }
}
act = ActionManager::find_action (X_("Editor"), X_("snap-normal"));
if (act) {
Glib::RefPtr<Gtk::RadioAction> ract = Glib::RefPtr<Gtk::RadioAction>::cast_dynamic (act);
ract = ActionManager::find_radio_action (X_("Editor"), X_("snap-normal"));
if (ract->get_active ()) { action = "snap-magnetic"; }
}
act = ActionManager::find_action (X_("Editor"), X_("snap-magnetic"));
if (act) {
Glib::RefPtr<Gtk::RadioAction> ract = Glib::RefPtr<Gtk::RadioAction>::cast_dynamic (act);
ract = ActionManager::find_radio_action (X_("Editor"), X_("snap-magnetic"));
if (ract->get_active ()) { action = "snap-off"; }
}
if (!action) {
assert (0);
return;
}
act = ActionManager::find_action (X_("Editor"), action);
if (act) {
Glib::RefPtr<Gtk::RadioAction> ract = Glib::RefPtr<Gtk::RadioAction>::cast_dynamic (act);
ract = ActionManager::find_radio_action (X_("Editor"), action);
ract->set_active (true);
}
}
/* Master mode + state -- main encoder fn */