From add6c7b48021b10db45aa31d22034a718439eaa0 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 8 Mar 2016 08:36:05 -0500 Subject: [PATCH] fix up indentation in libs/gtkmm2ext/bindings code, probably messed up by emacs on OS X --- libs/gtkmm2ext/bindings.cc | 846 ++++++++++++++-------------- libs/gtkmm2ext/gtkmm2ext/bindings.h | 236 ++++---- 2 files changed, 541 insertions(+), 541 deletions(-) diff --git a/libs/gtkmm2ext/bindings.cc b/libs/gtkmm2ext/bindings.cc index 637cd633a0..168e2cd24c 100644 --- a/libs/gtkmm2ext/bindings.cc +++ b/libs/gtkmm2ext/bindings.cc @@ -1,19 +1,19 @@ /* - Copyright (C) 2012 Paul Davis + Copyright (C) 2012 Paul Davis - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ @@ -52,7 +52,7 @@ template struct ActionNameRegistered { ActionNameRegistered(std::string const& name) - : action_name(name) + : action_name(name) {} bool operator()(IteratorValueType elem) const { @@ -64,106 +64,106 @@ struct ActionNameRegistered /*================================ MouseButton ================================*/ MouseButton::MouseButton (uint32_t state, uint32_t keycode) { - uint32_t ignore = ~Keyboard::RelevantModifierKeyMask; + uint32_t ignore = ~Keyboard::RelevantModifierKeyMask; - /* this is a slightly wierd test that relies on - * gdk_keyval_is_{upper,lower}() returning true for keys that have no - * case-sensitivity. This covers mostly non-alphanumeric keys. - */ + /* this is a slightly wierd test that relies on + * gdk_keyval_is_{upper,lower}() returning true for keys that have no + * case-sensitivity. This covers mostly non-alphanumeric keys. + */ - if (gdk_keyval_is_upper (keycode) && gdk_keyval_is_lower (keycode)) { - /* key is not subject to case, so ignore SHIFT - */ - ignore |= GDK_SHIFT_MASK; - } + if (gdk_keyval_is_upper (keycode) && gdk_keyval_is_lower (keycode)) { + /* key is not subject to case, so ignore SHIFT + */ + ignore |= GDK_SHIFT_MASK; + } - _val = (state & ~ignore); - _val <<= 32; - _val |= keycode; + _val = (state & ~ignore); + _val <<= 32; + _val |= keycode; }; bool MouseButton::make_button (const string& str, MouseButton& b) { - int s = 0; + int s = 0; - if (str.find ("Primary") != string::npos) { - s |= Keyboard::PrimaryModifier; - } + if (str.find ("Primary") != string::npos) { + s |= Keyboard::PrimaryModifier; + } - if (str.find ("Secondary") != string::npos) { - s |= Keyboard::SecondaryModifier; - } + if (str.find ("Secondary") != string::npos) { + s |= Keyboard::SecondaryModifier; + } - if (str.find ("Tertiary") != string::npos) { - s |= Keyboard::TertiaryModifier; - } + if (str.find ("Tertiary") != string::npos) { + s |= Keyboard::TertiaryModifier; + } - if (str.find ("Level4") != string::npos) { - s |= Keyboard::Level4Modifier; - } + if (str.find ("Level4") != string::npos) { + s |= Keyboard::Level4Modifier; + } - string::size_type lastmod = str.find_last_of ('-'); - uint32_t button_number; + string::size_type lastmod = str.find_last_of ('-'); + uint32_t button_number; - if (lastmod == string::npos) { - button_number = PBD::atoi (str); - } else { - button_number = PBD::atoi (str.substr (lastmod+1)); - } + if (lastmod == string::npos) { + button_number = PBD::atoi (str); + } else { + button_number = PBD::atoi (str.substr (lastmod+1)); + } - b = MouseButton (s, button_number); - return true; + b = MouseButton (s, button_number); + return true; } string MouseButton::name () const { - int s = state(); + int s = state(); - string str; + string str; - if (s & Keyboard::PrimaryModifier) { - str += "Primary"; - } - if (s & Keyboard::SecondaryModifier) { - if (!str.empty()) { - str += '-'; - } - str += "Secondary"; - } - if (s & Keyboard::TertiaryModifier) { - if (!str.empty()) { - str += '-'; - } - str += "Tertiary"; - } - if (s & Keyboard::Level4Modifier) { - if (!str.empty()) { - str += '-'; - } - str += "Level4"; - } + if (s & Keyboard::PrimaryModifier) { + str += "Primary"; + } + if (s & Keyboard::SecondaryModifier) { + if (!str.empty()) { + str += '-'; + } + str += "Secondary"; + } + if (s & Keyboard::TertiaryModifier) { + if (!str.empty()) { + str += '-'; + } + str += "Tertiary"; + } + if (s & Keyboard::Level4Modifier) { + if (!str.empty()) { + str += '-'; + } + str += "Level4"; + } - if (!str.empty()) { - str += '-'; - } + if (!str.empty()) { + str += '-'; + } - char buf[16]; - snprintf (buf, sizeof (buf), "%u", button()); - str += buf; + char buf[16]; + snprintf (buf, sizeof (buf), "%u", button()); + str += buf; - return str; + return str; } /*================================ KeyboardKey ================================*/ KeyboardKey::KeyboardKey (uint32_t state, uint32_t keycode) { - uint32_t ignore = ~Keyboard::RelevantModifierKeyMask; + uint32_t ignore = ~Keyboard::RelevantModifierKeyMask; - _val = (state & ~ignore); - _val <<= 32; - _val |= keycode; + _val = (state & ~ignore); + _val <<= 32; + _val |= keycode; } string @@ -177,16 +177,16 @@ KeyboardKey::display_label () const * on all platforms, notably the command key on OS X. */ - uint32_t mod = state(); + uint32_t mod = state(); #ifdef __APPLE__ - /* We use both bits (MOD2|META) for Primary on OS X, - * but we don't want MOD2 showing up in listings. - */ + /* We use both bits (MOD2|META) for Primary on OS X, + * but we don't want MOD2 showing up in listings. + */ - if (mod & GDK_MOD2_MASK) { - mod &= ~GDK_MOD2_MASK; - } + if (mod & GDK_MOD2_MASK) { + mod &= ~GDK_MOD2_MASK; + } #endif return gtk_accelerator_get_label (key(), (GdkModifierType) mod); @@ -195,100 +195,100 @@ KeyboardKey::display_label () const string KeyboardKey::name () const { - int s = state(); + int s = state(); - string str; + string str; - if (s & Keyboard::PrimaryModifier) { - str += "Primary"; - } - if (s & Keyboard::SecondaryModifier) { - if (!str.empty()) { - str += '-'; - } - str += "Secondary"; - } - if (s & Keyboard::TertiaryModifier) { - if (!str.empty()) { - str += '-'; - } - str += "Tertiary"; - } - if (s & Keyboard::Level4Modifier) { - if (!str.empty()) { - str += '-'; - } - str += "Level4"; - } + if (s & Keyboard::PrimaryModifier) { + str += "Primary"; + } + if (s & Keyboard::SecondaryModifier) { + if (!str.empty()) { + str += '-'; + } + str += "Secondary"; + } + if (s & Keyboard::TertiaryModifier) { + if (!str.empty()) { + str += '-'; + } + str += "Tertiary"; + } + if (s & Keyboard::Level4Modifier) { + if (!str.empty()) { + str += '-'; + } + str += "Level4"; + } - if (!str.empty()) { - str += '-'; - } + if (!str.empty()) { + str += '-'; + } - char const *gdk_name = gdk_keyval_name (key()); + char const *gdk_name = gdk_keyval_name (key()); - if (gdk_name) { - str += gdk_name; - } else { - /* fail! */ - return string(); - } + if (gdk_name) { + str += gdk_name; + } else { + /* fail! */ + return string(); + } - return str; + return str; } bool KeyboardKey::make_key (const string& str, KeyboardKey& k) { - int s = 0; + int s = 0; - if (str.find ("Primary") != string::npos) { - s |= Keyboard::PrimaryModifier; - } + if (str.find ("Primary") != string::npos) { + s |= Keyboard::PrimaryModifier; + } - if (str.find ("Secondary") != string::npos) { - s |= Keyboard::SecondaryModifier; - } + if (str.find ("Secondary") != string::npos) { + s |= Keyboard::SecondaryModifier; + } - if (str.find ("Tertiary") != string::npos) { - s |= Keyboard::TertiaryModifier; - } + if (str.find ("Tertiary") != string::npos) { + s |= Keyboard::TertiaryModifier; + } - if (str.find ("Level4") != string::npos) { - s |= Keyboard::Level4Modifier; - } + if (str.find ("Level4") != string::npos) { + s |= Keyboard::Level4Modifier; + } - /* since all SINGLE key events keycodes are changed to lower case - * before looking them up, make sure we only store lower case here. The - * Shift part will be stored in the modifier part of the KeyboardKey. - * - * And yes Mildred, this doesn't cover CapsLock cases. Oh well. - */ + /* since all SINGLE key events keycodes are changed to lower case + * before looking them up, make sure we only store lower case here. The + * Shift part will be stored in the modifier part of the KeyboardKey. + * + * And yes Mildred, this doesn't cover CapsLock cases. Oh well. + */ - string actual; + string actual; - if (str.size() == 1) { - actual = PBD::downcase (str); - } else { - actual = str; - } + if (str.size() == 1) { + actual = PBD::downcase (str); + } else { + actual = str; + } - string::size_type lastmod = actual.find_last_of ('-'); - guint keyval; + string::size_type lastmod = actual.find_last_of ('-'); + guint keyval; - if (lastmod != string::npos) { - actual = PBD::downcase (str.substr (lastmod+1)); - } + if (lastmod != string::npos) { + actual = PBD::downcase (str.substr (lastmod+1)); + } - keyval = gdk_keyval_from_name (actual.c_str()); + keyval = gdk_keyval_from_name (actual.c_str()); - if (keyval == GDK_VoidSymbol || keyval == 0) { - return false; - } + if (keyval == GDK_VoidSymbol || keyval == 0) { + return false; + } - k = KeyboardKey (s, keyval); + k = KeyboardKey (s, keyval); - return true; + return true; } /*================================= Bindings =================================*/ @@ -316,49 +316,49 @@ Bindings::get_binding_for_action (RefPtr action, Operation& op) { const string action_name = ardour_action_name (action); - for (KeybindingMap::iterator k = press_bindings.begin(); k != press_bindings.end(); ++k) { + for (KeybindingMap::iterator k = press_bindings.begin(); k != press_bindings.end(); ++k) { - /* option one: action has already been associated with the - * binding - */ + /* option one: action has already been associated with the + * binding + */ - if (k->second.action == action) { - return k->first; - } + if (k->second.action == action) { + return k->first; + } - /* option two: action name matches, so lookup the action, - * setup the association while we're here, and return the binding. - */ + /* option two: action name matches, so lookup the action, + * setup the association while we're here, and return the binding. + */ - if (_action_map && k->second.action_name == action_name) { - k->second.action = _action_map->find_action (action_name); - return k->first; - } + if (_action_map && k->second.action_name == action_name) { + k->second.action = _action_map->find_action (action_name); + return k->first; + } - } + } - for (KeybindingMap::iterator k = release_bindings.begin(); k != release_bindings.end(); ++k) { + for (KeybindingMap::iterator k = release_bindings.begin(); k != release_bindings.end(); ++k) { - /* option one: action has already been associated with the - * binding - */ + /* option one: action has already been associated with the + * binding + */ - if (k->second.action == action) { - return k->first; - } + if (k->second.action == action) { + return k->first; + } - /* option two: action name matches, so lookup the action, - * setup the association while we're here, and return the binding. - */ + /* option two: action name matches, so lookup the action, + * setup the association while we're here, and return the binding. + */ - if (_action_map && k->second.action_name == action_name) { - k->second.action = _action_map->find_action (action_name); - return k->first; - } + if (_action_map && k->second.action_name == action_name) { + k->second.action = _action_map->find_action (action_name); + return k->first; + } - } + } - return KeyboardKey::null_key(); + return KeyboardKey::null_key(); } void @@ -398,40 +398,40 @@ Bindings::activate (KeyboardKey kb, Operation op) { KeybindingMap& kbm = get_keymap (op); - /* if shift was pressed, GDK will send us (e.g) 'E' rather than 'e'. - Our bindings all use the lower case character/keyname, so switch - to the lower case before doing the lookup. - */ + /* if shift was pressed, GDK will send us (e.g) 'E' rather than 'e'. + Our bindings all use the lower case character/keyname, so switch + to the lower case before doing the lookup. + */ - KeyboardKey unshifted (kb.state(), gdk_keyval_to_lower (kb.key())); + KeyboardKey unshifted (kb.state(), gdk_keyval_to_lower (kb.key())); - KeybindingMap::iterator k = kbm.find (unshifted); + KeybindingMap::iterator k = kbm.find (unshifted); - if (k == kbm.end()) { - /* no entry for this key in the state map */ - DEBUG_TRACE (DEBUG::Bindings, string_compose ("no binding for %1\n", unshifted)); - return false; - } + if (k == kbm.end()) { + /* no entry for this key in the state map */ + DEBUG_TRACE (DEBUG::Bindings, string_compose ("no binding for %1\n", unshifted)); + return false; + } - RefPtr action; + RefPtr action; - if (k->second.action) { - action = k->second.action; - } else { - if (_action_map) { - action = _action_map->find_action (k->second.action_name); - } - } + if (k->second.action) { + action = k->second.action; + } else { + if (_action_map) { + action = _action_map->find_action (k->second.action_name); + } + } - if (action) { - /* lets do it ... */ - DEBUG_TRACE (DEBUG::Bindings, string_compose ("binding for %1: %2\n", unshifted, k->second.action_name)); - action->activate (); - } + if (action) { + /* lets do it ... */ + DEBUG_TRACE (DEBUG::Bindings, string_compose ("binding for %1: %2\n", unshifted, k->second.action_name)); + action->activate (); + } - /* return true even if the action could not be found */ + /* return true even if the action could not be found */ - return true; + return true; } void @@ -484,32 +484,32 @@ Bindings::dissociate () void Bindings::push_to_gtk (KeyboardKey kb, RefPtr what) { - /* GTK has the useful feature of showing key bindings for actions in - * menus. As of August 2015, we have no interest in trying to - * reimplement this functionality, so we will use it even though we no - * longer use GTK accelerators for handling key events. To do this, we - * need to make sure that there is a fully populated GTK AccelMap set - * up with all bindings/actions. - */ + /* GTK has the useful feature of showing key bindings for actions in + * menus. As of August 2015, we have no interest in trying to + * reimplement this functionality, so we will use it even though we no + * longer use GTK accelerators for handling key events. To do this, we + * need to make sure that there is a fully populated GTK AccelMap set + * up with all bindings/actions. + */ Gtk::AccelKey gtk_key; bool entry_exists = Gtk::AccelMap::lookup_entry (what->get_accel_path(), gtk_key); - if (!entry_exists) { + if (!entry_exists) { - /* there is a trick happening here. It turns out that - * gtk_accel_map_add_entry() performs no validation checks on - * the accelerator keyval. This means we can use it to define - * ANY accelerator, even if they violate GTK's rules - * (e.g. about not using navigation keys). This works ONLY when - * the entry in the GTK accelerator map has not already been - * added. The entries will be added by the GTK UIManager when - * building menus, so this code must be called before that - * happens. - */ + /* there is a trick happening here. It turns out that + * gtk_accel_map_add_entry() performs no validation checks on + * the accelerator keyval. This means we can use it to define + * ANY accelerator, even if they violate GTK's rules + * (e.g. about not using navigation keys). This works ONLY when + * the entry in the GTK accelerator map has not already been + * added. The entries will be added by the GTK UIManager when + * building menus, so this code must be called before that + * happens. + */ - Gtk::AccelMap::add_entry (what->get_accel_path(), kb.key(), (Gdk::ModifierType) kb.state()); - } + Gtk::AccelMap::add_entry (what->get_accel_path(), kb.key(), (Gdk::ModifierType) kb.state()); + } } bool @@ -577,32 +577,32 @@ Bindings::activate (MouseButton bb, Operation op) { MouseButtonBindingMap& bbm = get_mousemap(op); - MouseButtonBindingMap::iterator b = bbm.find (bb); + MouseButtonBindingMap::iterator b = bbm.find (bb); - if (b == bbm.end()) { - /* no entry for this key in the state map */ - return false; - } + if (b == bbm.end()) { + /* no entry for this key in the state map */ + return false; + } - RefPtr action; + RefPtr action; - if (b->second.action) { - action = b->second.action; - } else { - if (_action_map) { - action = _action_map->find_action (b->second.action_name); - } - } + if (b->second.action) { + action = b->second.action; + } else { + if (_action_map) { + action = _action_map->find_action (b->second.action_name); + } + } - if (action) { - /* lets do it ... */ - DEBUG_TRACE (DEBUG::Bindings, string_compose ("activating action %1\n", ardour_action_name (action))); - action->activate (); - } + if (action) { + /* lets do it ... */ + DEBUG_TRACE (DEBUG::Bindings, string_compose ("activating action %1\n", ardour_action_name (action))); + action->activate (); + } - /* return true even if the action could not be found */ + /* return true even if the action could not be found */ - return true; + return true; } void @@ -610,134 +610,134 @@ Bindings::add (MouseButton bb, Operation op, string const& action_name) { MouseButtonBindingMap& bbm = get_mousemap(op); - MouseButtonBindingMap::value_type newpair (bb, ActionInfo (action_name)); - bbm.insert (newpair); + MouseButtonBindingMap::value_type newpair (bb, ActionInfo (action_name)); + bbm.insert (newpair); } void Bindings::remove (MouseButton bb, Operation op) { MouseButtonBindingMap& bbm = get_mousemap(op); - MouseButtonBindingMap::iterator b = bbm.find (bb); + MouseButtonBindingMap::iterator b = bbm.find (bb); - if (b != bbm.end()) { - bbm.erase (b); - } + if (b != bbm.end()) { + bbm.erase (b); + } } void Bindings::save (XMLNode& root) { - XMLNode* presses = new XMLNode (X_("Press")); + XMLNode* presses = new XMLNode (X_("Press")); - for (KeybindingMap::iterator k = press_bindings.begin(); k != press_bindings.end(); ++k) { - XMLNode* child; + for (KeybindingMap::iterator k = press_bindings.begin(); k != press_bindings.end(); ++k) { + XMLNode* child; - if (k->first.name().empty()) { - continue; - } + if (k->first.name().empty()) { + continue; + } - child = new XMLNode (X_("Binding")); - child->add_property (X_("key"), k->first.name()); - child->add_property (X_("action"), k->second.action_name); - presses->add_child_nocopy (*child); - } + child = new XMLNode (X_("Binding")); + child->add_property (X_("key"), k->first.name()); + child->add_property (X_("action"), k->second.action_name); + presses->add_child_nocopy (*child); + } - for (MouseButtonBindingMap::iterator k = button_press_bindings.begin(); k != button_press_bindings.end(); ++k) { - XMLNode* child; - child = new XMLNode (X_("Binding")); - child->add_property (X_("button"), k->first.name()); - child->add_property (X_("action"), k->second.action_name); - presses->add_child_nocopy (*child); - } + for (MouseButtonBindingMap::iterator k = button_press_bindings.begin(); k != button_press_bindings.end(); ++k) { + XMLNode* child; + child = new XMLNode (X_("Binding")); + child->add_property (X_("button"), k->first.name()); + child->add_property (X_("action"), k->second.action_name); + presses->add_child_nocopy (*child); + } - XMLNode* releases = new XMLNode (X_("Release")); + XMLNode* releases = new XMLNode (X_("Release")); - for (KeybindingMap::iterator k = release_bindings.begin(); k != release_bindings.end(); ++k) { - XMLNode* child; + for (KeybindingMap::iterator k = release_bindings.begin(); k != release_bindings.end(); ++k) { + XMLNode* child; - if (k->first.name().empty()) { - continue; - } + if (k->first.name().empty()) { + continue; + } - child = new XMLNode (X_("Binding")); - child->add_property (X_("key"), k->first.name()); - child->add_property (X_("action"), k->second.action_name); - releases->add_child_nocopy (*child); - } + child = new XMLNode (X_("Binding")); + child->add_property (X_("key"), k->first.name()); + child->add_property (X_("action"), k->second.action_name); + releases->add_child_nocopy (*child); + } - for (MouseButtonBindingMap::iterator k = button_release_bindings.begin(); k != button_release_bindings.end(); ++k) { - XMLNode* child; - child = new XMLNode (X_("Binding")); - child->add_property (X_("button"), k->first.name()); - child->add_property (X_("action"), k->second.action_name); - releases->add_child_nocopy (*child); - } + for (MouseButtonBindingMap::iterator k = button_release_bindings.begin(); k != button_release_bindings.end(); ++k) { + XMLNode* child; + child = new XMLNode (X_("Binding")); + child->add_property (X_("button"), k->first.name()); + child->add_property (X_("action"), k->second.action_name); + releases->add_child_nocopy (*child); + } - root.add_child_nocopy (*presses); - root.add_child_nocopy (*releases); + root.add_child_nocopy (*presses); + root.add_child_nocopy (*releases); } bool Bindings::load (XMLNode const& node) { - const XMLNodeList& children (node.children()); + const XMLNodeList& children (node.children()); - press_bindings.clear (); - release_bindings.clear (); + press_bindings.clear (); + release_bindings.clear (); - for (XMLNodeList::const_iterator i = children.begin(); i != children.end(); ++i) { - /* each node could be Press or Release */ - load_operation (**i); - } + for (XMLNodeList::const_iterator i = children.begin(); i != children.end(); ++i) { + /* each node could be Press or Release */ + load_operation (**i); + } - return true; + return true; } void Bindings::load_operation (XMLNode const& node) { - if (node.name() == X_("Press") || node.name() == X_("Release")) { + if (node.name() == X_("Press") || node.name() == X_("Release")) { - Operation op; + Operation op; - if (node.name() == X_("Press")) { - op = Press; - } else { - op = Release; - } + if (node.name() == X_("Press")) { + op = Press; + } else { + op = Release; + } - const XMLNodeList& children (node.children()); + const XMLNodeList& children (node.children()); - for (XMLNodeList::const_iterator p = children.begin(); p != children.end(); ++p) { + for (XMLNodeList::const_iterator p = children.begin(); p != children.end(); ++p) { - XMLProperty* ap; - XMLProperty* kp; - XMLProperty* bp; + XMLProperty* ap; + XMLProperty* kp; + XMLProperty* bp; - ap = (*p)->property ("action"); - kp = (*p)->property ("key"); - bp = (*p)->property ("button"); + ap = (*p)->property ("action"); + kp = (*p)->property ("key"); + bp = (*p)->property ("button"); - if (!ap || (!kp && !bp)) { - continue; - } + if (!ap || (!kp && !bp)) { + continue; + } - if (kp) { - KeyboardKey k; - if (!KeyboardKey::make_key (kp->value(), k)) { - continue; - } - add (k, op, ap->value()); - } else { - MouseButton b; - if (!MouseButton::make_button (bp->value(), b)) { - continue; - } - add (b, op, ap->value()); - } - } - } + if (kp) { + KeyboardKey k; + if (!KeyboardKey::make_key (kp->value(), k)) { + continue; + } + add (k, op, ap->value()); + } else { + MouseButton b; + if (!MouseButton::make_button (bp->value(), b)) { + continue; + } + add (b, op, ap->value()); + } + } + } } void @@ -822,11 +822,11 @@ Bindings::KeybindingMap& Bindings::get_keymap (Operation op) { switch (op) { - case Press: - return press_bindings; - case Release: - default: - return release_bindings; + case Press: + return press_bindings; + case Release: + default: + return release_bindings; } } @@ -834,11 +834,11 @@ const Bindings::KeybindingMap& Bindings::get_keymap (Operation op) const { switch (op) { - case Press: - return press_bindings; - case Release: - default: - return release_bindings; + case Press: + return press_bindings; + case Release: + default: + return release_bindings; } } @@ -846,11 +846,11 @@ Bindings::MouseButtonBindingMap& Bindings::get_mousemap (Operation op) { switch (op) { - case Press: - return button_press_bindings; - case Release: - default: - return button_release_bindings; + case Press: + return button_press_bindings; + case Release: + default: + return button_release_bindings; } } @@ -885,13 +885,13 @@ ActionMap::get_actions (ActionMap::Actions& acts) RefPtr ActionMap::find_action (const string& name) { - _ActionMap::iterator a = _actions.find (name); + _ActionMap::iterator a = _actions.find (name); - if (a != _actions.end()) { - return a->second; - } + if (a != _actions.end()) { + return a->second; + } - return RefPtr(); + return RefPtr(); } RefPtr @@ -916,42 +916,42 @@ ActionMap::create_action_group (const string& name) RefPtr ActionMap::register_action (RefPtr group, const char* name, const char* label) { - string fullpath; + string fullpath; - RefPtr act = Action::create (name, label); + RefPtr act = Action::create (name, label); - fullpath = group->get_name(); - fullpath += '/'; - fullpath += name; + fullpath = group->get_name(); + fullpath += '/'; + fullpath += name; - if (_actions.insert (_ActionMap::value_type (fullpath, act)).second) { - group->add (act); - return act; - } + if (_actions.insert (_ActionMap::value_type (fullpath, act)).second) { + group->add (act); + return act; + } - /* already registered */ - return RefPtr (); + /* already registered */ + return RefPtr (); } RefPtr ActionMap::register_action (RefPtr group, const char* name, const char* label, sigc::slot sl) { - string fullpath; + string fullpath; - RefPtr act = Action::create (name, label); + RefPtr act = Action::create (name, label); - fullpath = group->get_name(); - fullpath += '/'; - fullpath += name; + fullpath = group->get_name(); + fullpath += '/'; + fullpath += name; - if (_actions.insert (_ActionMap::value_type (fullpath, act)).second) { - group->add (act, sl); - return act; - } + if (_actions.insert (_ActionMap::value_type (fullpath, act)).second) { + group->add (act, sl); + return act; + } - /* already registered */ - return RefPtr(); + /* already registered */ + return RefPtr(); } RefPtr @@ -960,22 +960,22 @@ ActionMap::register_radio_action (RefPtr group, const char* name, const char* label, sigc::slot sl) { - string fullpath; + string fullpath; - RefPtr act = RadioAction::create (rgroup, name, label); - RefPtr ract = RefPtr::cast_dynamic(act); + RefPtr act = RadioAction::create (rgroup, name, label); + RefPtr ract = RefPtr::cast_dynamic(act); - fullpath = group->get_name(); - fullpath += '/'; - fullpath += name; + fullpath = group->get_name(); + fullpath += '/'; + fullpath += name; - if (_actions.insert (_ActionMap::value_type (fullpath, act)).second) { - group->add (act, sl); - return act; - } + if (_actions.insert (_ActionMap::value_type (fullpath, act)).second) { + group->add (act, sl); + return act; + } - /* already registered */ - return RefPtr(); + /* already registered */ + return RefPtr(); } RefPtr @@ -985,53 +985,53 @@ ActionMap::register_radio_action (RefPtr group, sigc::slot sl, int value) { - string fullpath; + string fullpath; - RefPtr act = RadioAction::create (rgroup, name, label); - RefPtr ract = RefPtr::cast_dynamic(act); - ract->property_value() = value; + RefPtr act = RadioAction::create (rgroup, name, label); + RefPtr ract = RefPtr::cast_dynamic(act); + ract->property_value() = value; - fullpath = group->get_name(); - fullpath += '/'; - fullpath += name; + fullpath = group->get_name(); + fullpath += '/'; + fullpath += name; - if (_actions.insert (_ActionMap::value_type (fullpath, act)).second) { - group->add (act, sigc::bind (sl, act->gobj())); - return act; - } + if (_actions.insert (_ActionMap::value_type (fullpath, act)).second) { + group->add (act, sigc::bind (sl, act->gobj())); + return act; + } - /* already registered */ + /* already registered */ - return RefPtr(); + return RefPtr(); } RefPtr ActionMap::register_toggle_action (RefPtr group, const char* name, const char* label, sigc::slot sl) { - string fullpath; + string fullpath; - fullpath = group->get_name(); - fullpath += '/'; - fullpath += name; + fullpath = group->get_name(); + fullpath += '/'; + fullpath += name; - RefPtr act = ToggleAction::create (name, label); + RefPtr act = ToggleAction::create (name, label); - if (_actions.insert (_ActionMap::value_type (fullpath, act)).second) { - group->add (act, sl); - return act; - } + if (_actions.insert (_ActionMap::value_type (fullpath, act)).second) { + group->add (act, sl); + return act; + } - /* already registered */ - return RefPtr(); + /* already registered */ + return RefPtr(); } void ActionMap::get_all_actions (std::vector& paths, - std::vector& labels, - std::vector& tooltips, - std::vector& keys, - std::vector >& actions) + std::vector& labels, + std::vector& tooltips, + std::vector& keys, + std::vector >& actions) { for (list::const_iterator map = action_maps.begin(); map != action_maps.end(); ++map) { diff --git a/libs/gtkmm2ext/gtkmm2ext/bindings.h b/libs/gtkmm2ext/gtkmm2ext/bindings.h index 45c030b4c6..f7437fa67b 100644 --- a/libs/gtkmm2ext/gtkmm2ext/bindings.h +++ b/libs/gtkmm2ext/gtkmm2ext/bindings.h @@ -23,57 +23,57 @@ namespace Gtkmm2ext { class LIBGTKMM2EXT_API KeyboardKey { public: - KeyboardKey () { - _val = GDK_VoidSymbol; - } + KeyboardKey () { + _val = GDK_VoidSymbol; + } - KeyboardKey (uint32_t state, uint32_t keycode); + KeyboardKey (uint32_t state, uint32_t keycode); - static KeyboardKey null_key() { return KeyboardKey (0, 0); } + static KeyboardKey null_key() { return KeyboardKey (0, 0); } - uint32_t state() const { return _val >> 32; } - uint32_t key() const { return _val & 0xffff; } + uint32_t state() const { return _val >> 32; } + uint32_t key() const { return _val & 0xffff; } - bool operator<(const KeyboardKey& other) const { - return _val < other._val; - } + bool operator<(const KeyboardKey& other) const { + return _val < other._val; + } - bool operator==(const KeyboardKey& other) const { - return _val == other._val; - } + bool operator==(const KeyboardKey& other) const { + return _val == other._val; + } - std::string name() const; - static bool make_key (const std::string&, KeyboardKey&); + std::string name() const; + static bool make_key (const std::string&, KeyboardKey&); - std::string display_label() const; + std::string display_label() const; private: - uint64_t _val; + uint64_t _val; }; class LIBGTKMM2EXT_API MouseButton { public: - MouseButton () { - _val = ~0ULL; - } + MouseButton () { + _val = ~0ULL; + } - MouseButton (uint32_t state, uint32_t button_number); - uint32_t state() const { return _val >> 32; } - uint32_t button() const { return _val & 0xffff; } + MouseButton (uint32_t state, uint32_t button_number); + uint32_t state() const { return _val >> 32; } + uint32_t button() const { return _val & 0xffff; } - bool operator<(const MouseButton& other) const { - return _val < other._val; - } + bool operator<(const MouseButton& other) const { + return _val < other._val; + } - bool operator==(const MouseButton& other) const { - return _val == other._val; - } + bool operator==(const MouseButton& other) const { + return _val == other._val; + } - std::string name() const; - static bool make_button (const std::string&, MouseButton&); + std::string name() const; + static bool make_button (const std::string&, MouseButton&); private: - uint64_t _val; + uint64_t _val; }; class LIBGTKMM2EXT_API Bindings; @@ -85,24 +85,24 @@ class LIBGTKMM2EXT_API ActionMap { std::string name() const { return _name; } - Glib::RefPtr create_action_group (const std::string& group_name); + Glib::RefPtr create_action_group (const std::string& group_name); - Glib::RefPtr register_action (Glib::RefPtr group, const char* name, const char* label); - Glib::RefPtr register_action (Glib::RefPtr group, - const char* name, const char* label, sigc::slot sl); - Glib::RefPtr register_radio_action (Glib::RefPtr group, - Gtk::RadioAction::Group&, - const char* name, const char* label, - sigc::slot sl, - int value); - Glib::RefPtr register_radio_action (Glib::RefPtr group, - Gtk::RadioAction::Group&, - const char* name, const char* label, - sigc::slot sl); + Glib::RefPtr register_action (Glib::RefPtr group, const char* name, const char* label); + Glib::RefPtr register_action (Glib::RefPtr group, + const char* name, const char* label, sigc::slot sl); + Glib::RefPtr register_radio_action (Glib::RefPtr group, + Gtk::RadioAction::Group&, + const char* name, const char* label, + sigc::slot sl, + int value); + Glib::RefPtr register_radio_action (Glib::RefPtr group, + Gtk::RadioAction::Group&, + const char* name, const char* label, + sigc::slot sl); Glib::RefPtr register_toggle_action (Glib::RefPtr group, - const char* name, const char* label, sigc::slot sl); + const char* name, const char* label, sigc::slot sl); - Glib::RefPtr find_action (const std::string& name); + Glib::RefPtr find_action (const std::string& name); void set_bindings (Bindings*); Bindings* bindings() const { return _bindings; } @@ -112,7 +112,7 @@ class LIBGTKMM2EXT_API ActionMap { static std::list action_maps; - /* used by control surface protocols and other UIs */ + /* used by control surface protocols and other UIs */ static void get_all_actions (std::vector& paths, std::vector& labels, std::vector& tooltips, @@ -125,85 +125,85 @@ class LIBGTKMM2EXT_API ActionMap { /* hash for faster lookup of actions by name */ typedef std::map > _ActionMap; - _ActionMap _actions; + _ActionMap _actions; - /* initialized to null; set after a Bindings object has ::associated() - * itself with this action map. - */ + /* initialized to null; set after a Bindings object has ::associated() + * itself with this action map. + */ - Bindings* _bindings; + Bindings* _bindings; }; class LIBGTKMM2EXT_API Bindings { - public: - enum Operation { - Press, - Release - }; + public: + enum Operation { + Press, + Release + }; - struct ActionInfo { - ActionInfo (std::string const& name) : action_name (name) {} + struct ActionInfo { + ActionInfo (std::string const& name) : action_name (name) {} - std::string action_name; - Glib::RefPtr action; - }; - typedef std::map KeybindingMap; + std::string action_name; + Glib::RefPtr action; + }; + typedef std::map KeybindingMap; - Bindings (std::string const& name); - ~Bindings (); + Bindings (std::string const& name); + ~Bindings (); - std::string const& name() const { return _name; } + std::string const& name() const { return _name; } - void associate (); - void dissociate (); + void associate (); + void dissociate (); - bool empty() const; - bool empty_keys () const; - bool empty_mouse () const; + bool empty() const; + bool empty_keys () const; + bool empty_mouse () const; - bool add (KeyboardKey, Operation, std::string 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 add (KeyboardKey, Operation, std::string 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); + bool activate (KeyboardKey, Operation); - void add (MouseButton, Operation, std::string const&); - void remove (MouseButton, Operation); - bool activate (MouseButton, Operation); + void add (MouseButton, Operation, std::string const&); + void remove (MouseButton, Operation); + bool activate (MouseButton, Operation); - bool is_bound (KeyboardKey const&, Operation) const; - bool is_registered (Operation op, std::string const& action_name) const; + bool is_bound (KeyboardKey const&, Operation) const; + bool is_registered (Operation op, std::string const& action_name) const; - KeyboardKey get_binding_for_action (Glib::RefPtr, Operation& op); + KeyboardKey get_binding_for_action (Glib::RefPtr, Operation& op); - bool load (XMLNode const& node); - void load_operation (XMLNode const& node); - void save (XMLNode& root); + bool load (XMLNode const& node); + void load_operation (XMLNode const& node); + void save (XMLNode& root); - /* GTK has the following position a Gtk::Action: - * - * accel_path: /GroupName/ActionName - * name: ActionName - * - * We want proper namespacing and we're not interested in - * the silly "extra" namespace. So in Ardour: - * - * accel_path: /GroupName/ActionName - * name: GroupName/ActionName - * - * This (static) method returns the "ardour" name for the action. - */ - static std::string ardour_action_name (Glib::RefPtr); + /* GTK has the following position a Gtk::Action: + * + * accel_path: /GroupName/ActionName + * name: ActionName + * + * We want proper namespacing and we're not interested in + * the silly "extra" namespace. So in Ardour: + * + * accel_path: /GroupName/ActionName + * name: GroupName/ActionName + * + * This (static) method returns the "ardour" name for the action. + */ + static std::string ardour_action_name (Glib::RefPtr); - void set_action_map (ActionMap&); + void set_action_map (ActionMap&); - /* used for editing bindings */ - void get_all_actions (std::vector& paths, - std::vector& labels, - std::vector& tooltips, - std::vector& keys, - std::vector >& actions); + /* used for editing bindings */ + void get_all_actions (std::vector& paths, + std::vector& labels, + std::vector& tooltips, + std::vector& keys, + std::vector >& actions); /* all bindings currently in existence, as grouped into Bindings */ static std::list bindings; @@ -212,21 +212,21 @@ class LIBGTKMM2EXT_API Bindings { static PBD::Signal1 BindingsChanged; - private: - std::string _name; - ActionMap* _action_map; - KeybindingMap press_bindings; - KeybindingMap release_bindings; + private: + std::string _name; + ActionMap* _action_map; + KeybindingMap press_bindings; + KeybindingMap release_bindings; - typedef std::map MouseButtonBindingMap; - MouseButtonBindingMap button_press_bindings; - MouseButtonBindingMap button_release_bindings; + typedef std::map MouseButtonBindingMap; + MouseButtonBindingMap button_press_bindings; + MouseButtonBindingMap button_release_bindings; - void push_to_gtk (KeyboardKey, Glib::RefPtr); + void push_to_gtk (KeyboardKey, Glib::RefPtr); - KeybindingMap& get_keymap (Operation op); - const KeybindingMap& get_keymap (Operation op) const; - MouseButtonBindingMap& get_mousemap (Operation op); + KeybindingMap& get_keymap (Operation op); + const KeybindingMap& get_keymap (Operation op) const; + MouseButtonBindingMap& get_mousemap (Operation op); }; } // namespace