save keybindings to file used at startup; allow keybindings file to be cmdline-specif...
[ardour.git] / gtk2_ardour / ardour_ui_ed.cc
index eebe33bf58fdadb3dc5697ecc98a76b68445dc77..33307e61ec80de6979c0163bcdf18e680c7108e6 100644 (file)
@@ -26,6 +26,8 @@
 
 #include <pbd/pathscanner.h>
 
+#include <gtkmm2ext/utils.h>
+
 #include "ardour_ui.h"
 #include "public_editor.h"
 #include "audio_clock.h"
 
 #include "i18n.h"
 
+using namespace std;
 using namespace ARDOUR;
 using namespace PBD;
-using namespace Gtk;
 using namespace Gtkmm2ext;
+using namespace Gtk;
+using namespace Glib;
 using namespace sigc;
 
 int
@@ -76,7 +80,7 @@ ARDOUR_UI::install_actions ()
        ActionManager::register_action (main_actions, X_("Sync"), _("Sync"));
        ActionManager::register_action (main_actions, X_("Options"), _("Options"));
        ActionManager::register_action (main_actions, X_("TransportOptions"), _("Options"));
-        ActionManager::register_action (main_actions, X_("Help"), _("Help"));
+       ActionManager::register_action (main_actions, X_("Help"), _("Help"));
        ActionManager::register_action (main_actions, X_("KeyMouse Actions"), _("KeyMouse Actions"));
        ActionManager::register_action (main_actions, X_("AudioFileFormat"), _("Audio File Format"));
        ActionManager::register_action (main_actions, X_("AudioFileFormatHeader"), _("Header"));
@@ -474,10 +478,39 @@ ARDOUR_UI::toggle_control_protocol (ControlProtocolInfo* cpi)
        }
 }
 
+void
+ARDOUR_UI::toggle_control_protocol_feedback (ControlProtocolInfo* cpi, const char* group, string action)
+{
+       if (!session) {
+               /* this happens when we build the menu bar when control protocol support
+                  has been used in the past for some given protocol - the item needs
+                  to be made active, but there is no session yet.
+               */
+               return;
+       }
+
+       if (cpi->protocol) {
+               Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (group, action.c_str());
+
+               if (act) {
+                       Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
+
+                       if (tact) {
+                               bool x = tact->get_active();
+
+                               if (x != cpi->protocol->get_feedback()) {
+                                       cpi->protocol->set_feedback (x);
+                               }
+                       }
+               }
+       }
+}
+
 void
 ARDOUR_UI::build_control_surface_menu ()
 {
        list<ControlProtocolInfo*>::iterator i;
+       bool with_feedback;
 
        /* !!! this has to match the top level entry from ardour.menus */
 
@@ -497,6 +530,8 @@ ARDOUR_UI::build_control_surface_menu ()
                                                                                          (bind (mem_fun (*this, &ARDOUR_UI::toggle_control_protocol), *i)));
                        
                        Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
+
+                       with_feedback = false;
                        
                        if ((*i)->protocol || (*i)->requested) {
                                tact->set_active ();
@@ -505,6 +540,34 @@ ARDOUR_UI::build_control_surface_menu ()
                        ui += "<menuitem action='";
                        ui += action_name;
                        ui += "'/>\n";
+
+                       if ((*i)->supports_feedback) {
+
+                               string submenu_name = action_name;
+                               
+                               submenu_name += "SubMenu";
+
+                               ActionManager::register_action (editor->editor_actions, submenu_name.c_str(), _("Controls"));
+
+                               action_name += "Feedback";
+
+                               Glib::RefPtr<Action> act = ActionManager::register_toggle_action (editor->editor_actions, action_name.c_str(), _("Feedback"),
+                                                                                                 (bind (mem_fun (*this, &ARDOUR_UI::toggle_control_protocol_feedback), 
+                                                                                                        *i, 
+                                                                                                        "Editor",
+                                                                                                        action_name)));
+                               
+                               ui += "<menu action='";
+                               ui += submenu_name;
+                               ui += "'>\n<menuitem action='";
+                               ui += action_name;
+                               ui += "'/>\n</menu>\n";
+                               
+                               if ((*i)->protocol) {
+                                       Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
+                                       tact->set_active ((*i)->protocol->get_feedback ());
+                               }
+                       }
                }
        }
 
@@ -558,3 +621,24 @@ ARDOUR_UI::build_menu_bar ()
        menu_bar_base.set_name ("MainMenuBar");
        menu_bar_base.add (menu_hbox);
 }
+
+void
+ARDOUR_UI::setup_clock ()
+{
+       ARDOUR_UI::Clock.connect (bind (mem_fun (big_clock, &AudioClock::set), false));
+       
+       big_clock_window = new Window (WINDOW_TOPLEVEL);
+       
+       big_clock_window->set_border_width (0);
+       big_clock_window->add  (big_clock);
+       big_clock_window->set_title (_("ardour: clock"));
+       big_clock_window->set_type_hint (Gdk::WINDOW_TYPE_HINT_MENU);
+       big_clock_window->signal_realize().connect (bind (sigc::ptr_fun (set_decoration), big_clock_window,  (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH)));
+       big_clock_window->signal_unmap().connect (bind (sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleBigClock")));
+
+       if (editor) {
+               editor->ensure_float (*big_clock_window);
+       }
+
+       manage_window (*big_clock_window);
+}