replace ::cast_dynamic() with relevant ActionManager::get_*_action() calls
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 12 Dec 2018 16:22:38 +0000 (11:22 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 12 Dec 2018 16:22:38 +0000 (11:22 -0500)
gtk2_ardour/editor.cc

index 3f78e49ca775802169b9a9398056c12850737952..b8eb79a8f3a751d1d5f761a5051b7a2ff92b595d 100644 (file)
@@ -2349,10 +2349,8 @@ Editor::set_edit_point_preference (EditPoint ep, bool force)
                break;
        }
 
-       Glib::RefPtr<Action> act = ActionManager::get_action ("Editor", action);
-       if (act) {
-               Glib::RefPtr<RadioAction>::cast_dynamic(act)->set_active (true);
-       }
+       Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action ("Editor", action);
+       tact->set_active (true);
 
        samplepos_t foo;
        bool in_track_canvas;
@@ -2482,10 +2480,7 @@ Editor::set_state (const XMLNode& node, int version)
 
        if (node.get_property ("show-editor-mixer", yn)) {
 
-               Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
-               assert (act);
-
-               Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
+               Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action (X_("Editor"), X_("show-editor-mixer"));
 
                /* do it twice to force the change */
 
@@ -2495,10 +2490,7 @@ Editor::set_state (const XMLNode& node, int version)
 
        if (node.get_property ("show-editor-list", yn)) {
 
-               Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-list"));
-               assert (act);
-
-               Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
+               Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action (X_("Editor"), X_("show-editor-list"));
 
                /* do it twice to force the change */
 
@@ -2528,10 +2520,8 @@ Editor::set_state (const XMLNode& node, int version)
        }
 
        if (node.get_property ("maximised", yn)) {
-               Glib::RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleMaximalEditor"));
-               assert (act);
-               Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
-               bool fs = tact && tact->get_active();
+               Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action (X_("Common"), X_("ToggleMaximalEditor"));
+               bool fs = tact->get_active();
                if (yn ^ fs) {
                        ActionManager::do_action ("Common", "ToggleMaximalEditor");
                }
@@ -2550,24 +2540,18 @@ Editor::set_state (const XMLNode& node, int version)
                 * Not all properties may have been in XML, but
                 * those that are linked to a private variable may need changing
                 */
-               RefPtr<Action> act;
+               RefPtr<ToggleAction> tact;
 
-               act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
+               tact = ActionManager::get_toggle_action (X_("Editor"), X_("toggle-follow-playhead"));
                yn = _follow_playhead;
-               if (act) {
-                       RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
-                       if (tact->get_active() != yn) {
-                               tact->set_active (yn);
-                       }
+               if (tact->get_active() != yn) {
+                       tact->set_active (yn);
                }
 
-               act = ActionManager::get_action (X_("Editor"), X_("toggle-stationary-playhead"));
+               tact = ActionManager::get_toggle_action (X_("Editor"), X_("toggle-stationary-playhead"));
                yn = _stationary_playhead;
-               if (act) {
-                       RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
-                       if (tact->get_active() != yn) {
-                               tact->set_active (yn);
-                       }
+               if (tact->get_active() != yn) {
+                       tact->set_active (yn);
                }
        }
 
@@ -2612,17 +2596,11 @@ Editor::get_state ()
        node->set_property ("mouse-mode", mouse_mode);
        node->set_property ("join-object-range", smart_mode_action->get_active ());
 
-       Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
-       if (act) {
-               Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
-               node->set_property (X_("show-editor-mixer"), tact->get_active());
-       }
+       Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action (X_("Editor"), X_("show-editor-mixer"));
+       node->set_property (X_("show-editor-mixer"), tact->get_active());
 
-       act = ActionManager::get_action (X_("Editor"), X_("show-editor-list"));
-       if (act) {
-               Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
-               node->set_property (X_("show-editor-list"), tact->get_active());
-       }
+       tact = ActionManager::get_toggle_action (X_("Editor"), X_("show-editor-list"));
+       node->set_property (X_("show-editor-list"), tact->get_active());
 
        node->set_property (X_("editor-list-page"), _the_notebook.get_current_page ());
 
@@ -2815,7 +2793,7 @@ MusicSample
 Editor::snap_to_minsec (MusicSample presnap, RoundMode direction, SnapPref gpref)
 {
        MusicSample ret(presnap);
-       
+
        const samplepos_t one_second = _session->sample_rate();
        const samplepos_t one_minute = one_second * 60;
        const samplepos_t one_hour = one_minute * 60;
@@ -2857,7 +2835,7 @@ Editor::snap_to_minsec (MusicSample presnap, RoundMode direction, SnapPref gpref
                        }
                } break;
        }
-       
+
        return ret;
 }
 
@@ -2866,12 +2844,12 @@ Editor::snap_to_cd_frames (MusicSample presnap, RoundMode direction, SnapPref gp
 {
        if ((gpref != SnapToGrid_Unscaled) && (minsec_ruler_scale != minsec_show_msecs)) {
                return snap_to_minsec (presnap, direction, gpref);
-       }       
-       
+       }
+
        const samplepos_t one_second = _session->sample_rate();
 
        MusicSample ret(presnap);
-       
+
        if ((direction == RoundUpMaybe || direction == RoundDownMaybe) &&
                presnap.sample % (one_second/75) == 0) {
                /* start is already on a whole CD sample, do nothing */
@@ -2888,7 +2866,7 @@ MusicSample
 Editor::snap_to_bbt (MusicSample presnap, RoundMode direction, SnapPref gpref)
 {
        MusicSample ret(presnap);
-       
+
        if (gpref != SnapToGrid_Unscaled) { // use the visual grid lines which are limited by the zoom scale that the user selected
 
                int divisor = 2;
@@ -2938,7 +2916,7 @@ Editor::snap_to_bbt (MusicSample presnap, RoundMode direction, SnapPref gpref)
        } else {
                ret = _session->tempo_map().round_to_quarter_note_subdivision (presnap.sample, get_grid_beat_divisions(_grid_type), direction);
        }
-       
+
        return ret;
 }
 
@@ -2946,11 +2924,11 @@ ARDOUR::MusicSample
 Editor::snap_to_grid (MusicSample presnap, RoundMode direction, SnapPref gpref)
 {
        MusicSample ret(presnap);
-       
+
        if (grid_musical()) {
                ret = snap_to_bbt (presnap, direction, gpref);
        }
-       
+
        switch (_grid_type) {
                case GridTypeTimecode:
                        ret = snap_to_timecode(presnap, direction, gpref);
@@ -4074,11 +4052,8 @@ Editor::update_grid ()
 void
 Editor::toggle_follow_playhead ()
 {
-       RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
-       if (act) {
-               RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
-               set_follow_playhead (tact->get_active());
-       }
+       RefPtr<ToggleAction> tact = ActionManager::get_toggle_action (X_("Editor"), X_("toggle-follow-playhead"));
+       set_follow_playhead (tact->get_active());
 }
 
 /** @param yn true to follow playhead, otherwise false.
@@ -4099,11 +4074,8 @@ Editor::set_follow_playhead (bool yn, bool catch_up)
 void
 Editor::toggle_stationary_playhead ()
 {
-       RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-stationary-playhead"));
-       if (act) {
-               RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
-               set_stationary_playhead (tact->get_active());
-       }
+       RefPtr<ToggleAction> tact = ActionManager::get_toggle_action (X_("Editor"), X_("toggle-stationary-playhead"));
+       set_stationary_playhead (tact->get_active());
 }
 
 void