use WindowManager toggle API for script-manager
[ardour.git] / gtk2_ardour / editor_actions.cc
index 046d9b94e111e1a825f9ac1d1dea024946039075..39587d33e3b268ff403260ec07a50b161f8ff179 100644 (file)
@@ -475,12 +475,12 @@ Editor::register_actions ()
 
        myactions.register_action (editor_actions, X_("cycle-zoom-focus"), _("Next Zoom Focus"), sigc::mem_fun (*this, &Editor::cycle_zoom_focus));
 
-       act = reg_sens (editor_actions, "manage-action-scripts", _("Manage"),
-                               sigc::mem_fun(*this, &Editor::manage_action_scripts));
        for (int i = 1; i <= 9; ++i) {
                string const a = string_compose (X_("script-action-%1"), i);
                string const n = string_compose (_("Unset #%1"), i);
-               reg_sens (editor_actions, a.c_str(), n.c_str(), sigc::bind (sigc::mem_fun (*this, &Editor::trigger_script), i - 1));
+               act = reg_sens (editor_actions, a.c_str(), n.c_str(), sigc::bind (sigc::mem_fun (*this, &Editor::trigger_script), i - 1));
+               act->set_tooltip (_("(no action bound"));
+               act->set_sensitive (false);
        }
 
        Glib::RefPtr<ActionGroup> mouse_mode_actions = myactions.create_action_group (X_("MouseMode"));
@@ -752,7 +752,7 @@ Editor::register_actions ()
 void
 Editor::load_bindings ()
 {
-       bindings = Bindings::get_bindings (X_("editor"), myactions);
+       bindings = Bindings::get_bindings (X_("Editor"), myactions);
        global_hpacker.set_data ("ardour-bindings", bindings);
 }
 
@@ -1716,15 +1716,6 @@ Editor::parameter_changed (std::string p)
                if (_routes) {
                        _routes->reset_remote_control_ids ();
                }
-       } else if (p == "use-tooltips") {
-
-               /* this doesn't really belong here but it has to go somewhere */
-
-               if (UIConfiguration::instance().get_use_tooltips()) {
-                       Gtkmm2ext::enable_tooltips ();
-               } else {
-                       Gtkmm2ext::disable_tooltips ();
-               }
        } else if (p == "skip-playback") {
                Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-skip-playback"));
 
@@ -1739,9 +1730,40 @@ Editor::parameter_changed (std::string p)
 }
 
 void
-Editor::reset_focus ()
+Editor::reset_focus (Gtk::Widget* w)
 {
-       _track_canvas->grab_focus();
+       /* this resets focus to the first focusable parent of the given widget,
+        * or, if there is no focusable parent, cancels focus in the toplevel
+        * window that the given widget is packed into (if there is one).
+        */
+
+       if (!w) {
+               return;
+       }
+
+       Gtk::Widget* top = w->get_toplevel();
+
+       if (!top || !top->is_toplevel()) {
+               return;
+       }
+
+       w = w->get_parent ();
+
+       while (w) {
+               if (w->get_can_focus ()) {
+                       Window* win = dynamic_cast<Window*> (top);
+                       win->set_focus (*w);
+                       return;
+               }
+               w = w->get_parent ();
+       }
+
+       /* no focusable parent found, cancel focus in top level window.
+          C++ API cannot be used for this. Thanks, references.
+        */
+
+       gtk_window_set_focus (GTK_WINDOW(top->gobj()), 0);
+
 }
 
 void
@@ -1924,7 +1946,8 @@ Editor::register_region_actions ()
        reg_sens (_region_actions, "combine-regions", _("Combine"), sigc::mem_fun (*this, &Editor::combine_regions));
        reg_sens (_region_actions, "uncombine-regions", _("Uncombine"), sigc::mem_fun (*this, &Editor::uncombine_regions));
 
-       reg_sens (_region_actions, "analyze-region", _("Spectral Analysis..."), sigc::mem_fun (*this, &Editor::analyze_region_selection));
+       reg_sens (_region_actions, "loudness-analyze-region", _("Loudness Analysis..."), sigc::mem_fun (*this, &Editor::loudness_analyze_region_selection));
+       reg_sens (_region_actions, "spectral-analyze-region", _("Spectral Analysis..."), sigc::mem_fun (*this, &Editor::spectral_analyze_region_selection));
 
        reg_sens (_region_actions, "reset-region-gain-envelopes", _("Reset Envelope"), sigc::mem_fun (*this, &Editor::reset_region_gain_envelopes));