add context menus for tabbable visibility buttons
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 24 Nov 2015 15:12:07 +0000 (10:12 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 22 Feb 2016 20:31:25 +0000 (15:31 -0500)
gtk2_ardour/ardour.menus.in
gtk2_ardour/ardour_ui.h
gtk2_ardour/ardour_ui_ed.cc

index 16634f800e3d5a3f1789d609048a625b3a48b25b..1e618a49d62677449d6f6a44f1cac43fdaeb7270 100644 (file)
     </menu>
   </menubar>
 
-  <popup action="RulerMenuPopup">
+  <popup action="editorTabbableButtonMenu">
+          <menuitem action='show-editor'/>
+          <menuitem action='hide-editor'/>
+          <menuitem action='attach-editor'/>
+          <menuitem action='detach-editor'/>
+  </popup>
+
+  <popup action="mixerTabbableButtonMenu">
+          <menuitem action='show-mixer'/>
+          <menuitem action='hide-mixer'/>
+          <menuitem action='attach-mixer'/>
+          <menuitem action='detach-mixer'/>
+  </popup>
+
+  <popup action="prefsTabbableButtonMenu">
+          <menuitem action='show-preferences'/>
+          <menuitem action='hide-preferences'/>
+          <menuitem action='attach-preferences'/>
+          <menuitem action='detach-preferences'/>
+  </popup>
+
+<popup action="RulerMenuPopup">
     <menuitem action="toggle-minsec-ruler"/>
     <menuitem action="toggle-timecode-ruler"/>
     <menuitem action="toggle-samples-ruler"/>
index ab8561acd64b65ff6f431cf17e6522a0ffd342c9..df98c27765b5a2726fad06cbe947891545b40def 100644 (file)
@@ -841,6 +841,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
        bool idle_ask_about_quit ();
 
        void load_bindings ();
+       bool tabbable_visibility_button_press (GdkEventButton* ev, std::string const& tabbable_name);
 };
 
 #endif /* __ardour_gui_h__ */
index 9fdde7219f151126865b15bb5b0f6c6a9a1af859..35e8eca25d6ce68ff8f56066b9936140691f2d90 100644 (file)
@@ -577,6 +577,11 @@ ARDOUR_UI::build_menu_bar ()
        mixer_visibility_button.signal_drag_failed().connect (sigc::bind (sigc::ptr_fun (drag_failed), mixer));
        prefs_visibility_button.signal_drag_failed().connect (sigc::bind (sigc::ptr_fun (drag_failed), rc_option_editor));
 
+       /* catch context clicks so that we can show a menu on these buttons */
+
+       editor_visibility_button.signal_button_press_event().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::tabbable_visibility_button_press), X_("editor")), false);
+       mixer_visibility_button.signal_button_press_event().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::tabbable_visibility_button_press), X_("mixer")), false);
+       prefs_visibility_button.signal_button_press_event().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::tabbable_visibility_button_press), X_("preferences")), false);
 
        editor_visibility_button.set_related_action (ActionManager::get_action (X_("Common"), X_("change-editor-visibility")));
        editor_visibility_button.set_name (X_("page switch button"));
@@ -805,3 +810,21 @@ ARDOUR_UI::tabs()
 {
        return _tabs;
 }
+
+bool
+ARDOUR_UI::tabbable_visibility_button_press (GdkEventButton* ev, string const& tabbable_name)
+{
+       if (ev->button != 3) {
+               return false;
+       }
+
+       /* context menu is defined in *.menus.in
+        */
+
+       string menu_name = string ("/ui/") + tabbable_name + X_("TabbableButtonMenu");
+       Gtk::Menu* menu = dynamic_cast<Gtk::Menu*> (ActionManager::get_widget (menu_name.c_str()));
+       if (menu) {
+               menu->popup (3, ev->time);
+       }
+       return true;
+}