summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2014-06-24 09:56:08 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2014-06-24 09:56:16 -0400
commitf147846863c27dfa13ef83b696f198a5092721fa (patch)
treef52baa144cf760138c862f7cdc4ab8fd80a1159d
parentdae3b26f188c17b1e74c17284539979a92ea630f (diff)
add ability to save current action sensitivities and restore them, and to disable all action sensitivity.
This is needed to be able to lock the application fully on OS X, where the global menu bar would still allow interaction even when a modal dialog is displayed.
-rw-r--r--gtk2_ardour/ardour.menus.in2
-rw-r--r--gtk2_ardour/editor.h6
-rw-r--r--gtk2_ardour/editor_actions.cc5
-rw-r--r--gtk2_ardour/editor_canvas.cc5
-rw-r--r--gtk2_ardour/editor_ops.cc13
-rw-r--r--gtk2_ardour/verbose_cursor.cc2
-rw-r--r--libs/gtkmm2ext/actions.cc78
-rw-r--r--libs/gtkmm2ext/gtkmm2ext/actions.h5
8 files changed, 115 insertions, 1 deletions
diff --git a/gtk2_ardour/ardour.menus.in b/gtk2_ardour/ardour.menus.in
index 3793004bc6..96fee554b7 100644
--- a/gtk2_ardour/ardour.menus.in
+++ b/gtk2_ardour/ardour.menus.in
@@ -56,6 +56,8 @@
<menuitem action='toggle-about'/>
<menuitem action='toggle-rc-options-editor'/>
#endif
+ <separator/>
+ <menuitem action='lock'/>
#ifndef GTKOSX
<separator/>
<menuitem action='Quit'/>
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index e405f3be41..0c05b7c2f2 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -452,6 +452,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
}
ArdourCanvas::Container* get_trackview_group () const { return _trackview_group; }
+ ArdourCanvas::Container* get_noscroll_group () const { return no_scroll_group; }
ArdourCanvas::ScrollGroup* get_hscroll_group () const { return h_scroll_group; }
ArdourCanvas::ScrollGroup* get_vscroll_group () const { return v_scroll_group; }
ArdourCanvas::ScrollGroup* get_hvscroll_group () const { return hv_scroll_group; }
@@ -759,6 +760,9 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
ArdourCanvas::ScrollGroup* h_scroll_group;
/* The group containing all trackviews. */
+ ArdourCanvas::Container* no_scroll_group;
+
+ /* The group containing all trackviews. */
ArdourCanvas::Container* _trackview_group;
/* The group holding things (mostly regions) while dragging so they
@@ -1352,6 +1356,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
DragManager* _drags;
void escape ();
+ void lock ();
+ void unlock ();
Gtk::Menu fade_context_menu;
diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc
index d8889a9c81..bab2caaf8c 100644
--- a/gtk2_ardour/editor_actions.cc
+++ b/gtk2_ardour/editor_actions.cc
@@ -150,6 +150,11 @@ Editor::register_actions ()
ActionManager::register_action (editor_actions, "escape", _("Break drag or deselect all"), sigc::mem_fun (*this, &Editor::escape));
+ /* We don't bother registering "unlock" because it would be insensitive
+ when required. Editor::unlock() must be invoked directly.
+ */
+ ActionManager::register_action (editor_actions, "lock", _("Lock"), sigc::mem_fun (*this, &Editor::lock));
+
toggle_reg_sens (editor_actions, "show-editor-mixer", _("Show Editor Mixer"), sigc::mem_fun (*this, &Editor::editor_mixer_button_toggled));
toggle_reg_sens (editor_actions, "show-editor-list", _("Show Editor List"), sigc::mem_fun (*this, &Editor::editor_list_button_toggled));
diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc
index 90bec7db6c..2f37a877ea 100644
--- a/gtk2_ardour/editor_canvas.cc
+++ b/gtk2_ardour/editor_canvas.cc
@@ -68,6 +68,11 @@ Editor::initialize_canvas ()
_track_canvas_viewport = new ArdourCanvas::GtkCanvasViewport (horizontal_adjustment, vertical_adjustment);
_track_canvas = _track_canvas_viewport->canvas ();
+ /* scroll group for items that should not automatically scroll
+ * (e.g verbose cursor). It shares the canvas coordinate space.
+ */
+ no_scroll_group = new ArdourCanvas::Container (_track_canvas->root());
+
ArdourCanvas::ScrollGroup* hsg;
ArdourCanvas::ScrollGroup* hg;
ArdourCanvas::ScrollGroup* vg;
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index e7618d9168..0c36a4587d 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -57,6 +57,7 @@
#include "canvas/canvas.h"
+#include "actions.h"
#include "ardour_ui.h"
#include "audio_region_view.h"
#include "audio_streamview.h"
@@ -7116,3 +7117,15 @@ Editor::toggle_midi_input_active (bool flip_others)
_session->set_exclusive_input_active (rl, onoff, flip_others);
}
+
+void
+Editor::lock ()
+{
+ ActionManager::disable_all_actions ();
+}
+
+void
+Editor::unlock ()
+{
+ ActionManager::pop_action_state ();
+}
diff --git a/gtk2_ardour/verbose_cursor.cc b/gtk2_ardour/verbose_cursor.cc
index abe145d4bf..66071c8e84 100644
--- a/gtk2_ardour/verbose_cursor.cc
+++ b/gtk2_ardour/verbose_cursor.cc
@@ -44,7 +44,7 @@ VerboseCursor::VerboseCursor (Editor* editor)
, _xoffset (0)
, _yoffset (0)
{
- _canvas_item = new ArdourCanvas::Text (_editor->get_hvscroll_group());
+ _canvas_item = new ArdourCanvas::Text (_editor->get_noscroll_group());
CANVAS_DEBUG_NAME (_canvas_item, "verbose canvas cursor");
_canvas_item->set_ignore_events (true);
_canvas_item->set_font_description (Pango::FontDescription (ARDOUR_UI::config()->get_canvasvar_LargerBoldFont()));
diff --git a/libs/gtkmm2ext/actions.cc b/libs/gtkmm2ext/actions.cc
index 200308a254..f4159c71e2 100644
--- a/libs/gtkmm2ext/actions.cc
+++ b/libs/gtkmm2ext/actions.cc
@@ -21,8 +21,11 @@
#include <vector>
#include <string>
#include <list>
+#include <stack>
#include <stdint.h>
+#include <boost/shared_ptr.hpp>
+
#include <gtk/gtkaccelmap.h>
#include <gtk/gtkuimanager.h>
#include <gtk/gtkactiongroup.h>
@@ -232,6 +235,81 @@ ActionManager::get_all_actions (vector<string>& names, vector<string>& paths, ve
}
}
+struct ActionState {
+ GtkAction* action;
+ bool sensitive;
+ ActionState (GtkAction* a, bool s) : action (a), sensitive (s) {}
+};
+
+typedef std::vector<ActionState> ActionStates;
+
+static std::stack<boost::shared_ptr<ActionStates> > state_stack;
+
+static boost::shared_ptr<ActionStates>
+get_action_state ()
+{
+ boost::shared_ptr<ActionStates> state = boost::shared_ptr<ActionStates>(new ActionStates);
+
+ /* the C++ API for functions used here appears to be broken in
+ gtkmm2.6, so we fall back to the C level.
+ */
+
+ GList* list = gtk_ui_manager_get_action_groups (ActionManager::ui_manager->gobj());
+ GList* node;
+ GList* acts;
+
+ for (node = list; node; node = g_list_next (node)) {
+
+ GtkActionGroup* group = (GtkActionGroup*) node->data;
+
+ /* first pass: collect them all */
+
+ typedef std::list<Glib::RefPtr<Gtk::Action> > action_list;
+ action_list the_acts;
+
+ for (acts = gtk_action_group_list_actions (group); acts; acts = g_list_next (acts)) {
+ GtkAction* action = (GtkAction*) acts->data;
+
+ state->push_back (ActionState (action, gtk_action_get_sensitive (action)));
+ }
+ }
+
+ return state;
+}
+
+void
+ActionManager::push_action_state ()
+{
+ state_stack.push (get_action_state());
+}
+
+void
+ActionManager::pop_action_state ()
+{
+ if (state_stack.empty()) {
+ warning << string_compose (_("programming error: %1"), X_("ActionManager::pop_action_state called with empty stack")) << endmsg;
+ return;
+ }
+
+ boost::shared_ptr<ActionStates> as = state_stack.top ();
+ state_stack.pop ();
+
+ for (ActionStates::iterator i = as->begin(); i != as->end(); ++i) {
+ gtk_action_set_sensitive ((*i).action, (*i).sensitive);
+ }
+}
+
+void
+ActionManager::disable_all_actions ()
+{
+ push_action_state ();
+ boost::shared_ptr<ActionStates> as = state_stack.top ();
+
+ for (ActionStates::iterator i = as->begin(); i != as->end(); ++i) {
+ gtk_action_set_sensitive ((*i).action, false);
+ }
+}
+
void
ActionManager::add_action_group (RefPtr<ActionGroup> grp)
{
diff --git a/libs/gtkmm2ext/gtkmm2ext/actions.h b/libs/gtkmm2ext/gtkmm2ext/actions.h
index d92f85bb6e..536bd326be 100644
--- a/libs/gtkmm2ext/gtkmm2ext/actions.h
+++ b/libs/gtkmm2ext/gtkmm2ext/actions.h
@@ -91,6 +91,11 @@ namespace ActionManager {
LIBGTKMM2EXT_API extern void check_toggleaction (std::string);
LIBGTKMM2EXT_API extern void uncheck_toggleaction (std::string);
LIBGTKMM2EXT_API extern void set_toggleaction_state (std::string, bool);
+
+
+ LIBGTKMM2EXT_API extern void push_action_state ();
+ LIBGTKMM2EXT_API extern void pop_action_state ();
+ LIBGTKMM2EXT_API extern void disable_all_actions ();
};
#endif /* __libgtkmm2ext_actions_h__ */