- enum Operation {
- Press,
- Release
- };
-
- Bindings();
- ~Bindings ();
-
- void add (KeyboardKey, Operation, Glib::RefPtr<Gtk::Action>);
- void remove (KeyboardKey, Operation);
- bool activate (KeyboardKey, Operation);
-
- void add (MouseButton, Operation, Glib::RefPtr<Gtk::Action>);
- void remove (MouseButton, Operation);
- bool activate (MouseButton, Operation);
-
- bool load (const std::string& path);
- void load (const XMLNode& node);
- bool save (const std::string& path);
- void save (XMLNode& root);
-
- void set_action_map (ActionMap&);
-
- static void set_ignored_state (int mask) {
- _ignored_state = mask;
- }
- static uint32_t ignored_state() { return _ignored_state; }
+ enum Operation {
+ Press,
+ Release
+ };
+
+ struct ActionInfo {
+ ActionInfo (std::string const& name) : action_name (name) {}
+ ActionInfo (std::string const& name, std::string const& grp) : action_name (name), group_name (grp) {}
+
+ std::string action_name;
+ std::string group_name; /* may be empty */
+ Glib::RefPtr<Gtk::Action> action;
+ };
+ typedef std::map<KeyboardKey,ActionInfo> KeybindingMap;
+
+ Bindings (std::string const& name);
+ ~Bindings ();
+
+ std::string const& name() const { return _name; }
+
+ void associate ();
+ void dissociate ();
+
+ bool empty() const;
+ bool empty_keys () const;
+ bool empty_mouse () const;
+
+ bool add (KeyboardKey, Operation, std::string const&, XMLProperty const*, bool can_save = false);
+ bool replace (KeyboardKey, Operation, std::string const& action_name, bool can_save = true);
+ bool remove (Operation, std::string const& action_name, bool can_save = false);
+
+ bool activate (KeyboardKey, Operation);
+
+ void add (MouseButton, Operation, std::string const&, XMLProperty const*);
+ void remove (MouseButton, Operation);
+ bool activate (MouseButton, Operation);
+
+ bool is_bound (KeyboardKey const&, Operation) const;
+ std::string bound_name (KeyboardKey const&, Operation) const;
+ bool is_registered (Operation op, std::string const& action_name) const;
+
+ KeyboardKey get_binding_for_action (Glib::RefPtr<Gtk::Action>, Operation& op);
+
+ bool load (XMLNode const& node);
+ void load_operation (XMLNode const& node);
+ void save (XMLNode& root);
+ void save_as_html (std::ostream&, bool) const;
+
+ /* GTK has the following position a Gtk::Action:
+ *
+ * accel_path: <Actions>/GroupName/ActionName
+ * name: ActionName
+ *
+ * We want proper namespacing and we're not interested in
+ * the silly <Actions> "extra" namespace. So in Ardour:
+ *
+ * accel_path: <Actions>/GroupName/ActionName
+ * name: GroupName/ActionName
+ *
+ * This (static) method returns the "ardour" name for the action.
+ */
+ static std::string ardour_action_name (Glib::RefPtr<Gtk::Action>);
+
+ void set_action_map (ActionMap&);
+
+ /* used for editing bindings */
+ void get_all_actions (std::vector<std::string>& paths,
+ std::vector<std::string>& labels,
+ std::vector<std::string>& tooltips,
+ std::vector<std::string>& keys,
+ std::vector<Glib::RefPtr<Gtk::Action> >& actions);
+
+ /* all bindings currently in existence, as grouped into Bindings */
+ static void reset_bindings () { bindings.clear (); }
+ static std::list<Bindings*> bindings;
+ static Bindings* get_bindings (std::string const& name, ActionMap&);
+ static void associate_all ();
+ static void save_all_bindings_as_html (std::ostream&);
+
+ static PBD::Signal1<void,Bindings*> BindingsChanged;