radically change Keyboard/Binding API design to disconnect Gtk::Action lookup from...
[ardour.git] / libs / gtkmm2ext / gtkmm2ext / keyboard.h
index 3ffa09f036d618a3f82e866c77dff43334e8cc82..48a1bdcaad2b2817c16cef6b80e658610102c072 100644 (file)
@@ -29,6 +29,7 @@
 #include <gtkmm/accelkey.h>
 
 #include "pbd/stateful.h"
+#include "pbd/signals.h"
 
 #include "gtkmm2ext/visibility.h"
 
@@ -38,6 +39,8 @@ namespace Gtk {
 
 namespace Gtkmm2ext {
 
+class Bindings;
+
 class LIBGTKMM2EXT_API Keyboard : public sigc::trackable, PBD::Stateful
 {
   public:
@@ -70,8 +73,6 @@ class LIBGTKMM2EXT_API Keyboard : public sigc::trackable, PBD::Stateful
        static const char* secondary_modifier_name ();
        static const char* tertiary_modifier_name ();
        static const char* level4_modifier_name ();
-       static const char* copy_modifier_name ();
-       static const char* rangeselect_modifier_name ();
 
        static void set_primary_modifier (uint32_t newval) {
                set_modifier (newval, PrimaryModifier);
@@ -126,8 +127,8 @@ class LIBGTKMM2EXT_API Keyboard : public sigc::trackable, PBD::Stateful
         *  Absolute grid is for aligning objects with the grid lines.
         *  Relative grid is for maintaining an initial position relative to the grid lines.
         *  With this modifier:
-        *  - magnetic or normal grid should snap absolutely to the grid lines
-        *  - no grid should become absolute grid.
+        *  - magnetic or normal grid should snap relative to an initial grid offset
+        *  - no grid should snap relative to the grid.
         */
        static ModifierMask snap_delta_modifier () { return ModifierMask (snap_delta_mod); }
 
@@ -145,7 +146,7 @@ class LIBGTKMM2EXT_API Keyboard : public sigc::trackable, PBD::Stateful
        static void set_insert_note_button (guint);
        static guint insert_note_modifier() { return insert_note_mod; }
        static void set_insert_note_modifier(guint);
-       
+
        static bool is_edit_event (GdkEventButton*);
        static bool is_delete_event (GdkEventButton*);
        static bool is_insert_note_event (GdkEventButton*);
@@ -163,25 +164,23 @@ class LIBGTKMM2EXT_API Keyboard : public sigc::trackable, PBD::Stateful
 
        static void keybindings_changed ();
        static void save_keybindings ();
-       static bool load_keybindings (std::string path);
        static void set_can_save_keybindings (bool yn);
        static std::string current_binding_name () { return _current_binding_name; }
        static std::map<std::string,std::string> binding_files;
 
-       int reset_bindings ();
+        static bool catch_user_event_for_pre_dialog_focus (GdkEvent* ev, Gtk::Window* w);
 
-       struct AccelKeyLess {
-           bool operator() (const Gtk::AccelKey a, const Gtk::AccelKey b) const {
-                   if (a.get_key() != b.get_key()) {
-                           return a.get_key() < b.get_key();
-                   } else {
-                           return a.get_mod() < b.get_mod();
-                   }
-           }
-       };
+       static bool load_keybindings (std::string const& path);
+       static void save_keybindings (std::string const& path);
+
+       int reset_bindings ();
 
        sigc::signal0<void> ZoomVerticalModifierReleased;
 
+       static std::vector<Bindings*> bindings;
+       static Bindings* get_bindings (std::string const& name);
+       static PBD::Signal0<void> BindingsChanged;
+
   protected:
        static Keyboard* _the_keyboard;
 
@@ -205,14 +204,17 @@ class LIBGTKMM2EXT_API Keyboard : public sigc::trackable, PBD::Stateful
 
        typedef std::pair<std::string,std::string> two_strings;
 
-       static std::map<Gtk::AccelKey,two_strings,AccelKeyLess> release_keys;
-
        static gint _snooper (GtkWidget*, GdkEventKey*, gpointer);
        gint snooper (GtkWidget*, GdkEventKey*);
 
        static void set_modifier (uint32_t newval, uint32_t& variable);
 
        static bool _some_magic_widget_has_focus;
+
+        static Gtk::Window* pre_dialog_active_window;
+
+       static int read_keybindings (std::string const& path);
+       static int store_keybindings (std::string const& path);
 };
 
 } /* namespace */