2013-01-16 13:27:41 -05:00
|
|
|
/*
|
|
|
|
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 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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2010-08-06 14:44:55 -04:00
|
|
|
#include <iostream>
|
2011-03-03 22:10:17 -05:00
|
|
|
|
2010-08-06 14:44:55 -04:00
|
|
|
#include "pbd/xml++.h"
|
2011-03-03 22:10:17 -05:00
|
|
|
#include "pbd/convert.h"
|
|
|
|
|
|
|
|
#include "gtkmm2ext/actions.h"
|
2010-08-06 14:44:55 -04:00
|
|
|
#include "gtkmm2ext/bindings.h"
|
|
|
|
#include "gtkmm2ext/keyboard.h"
|
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace Glib;
|
|
|
|
using namespace Gtk;
|
|
|
|
using namespace Gtkmm2ext;
|
|
|
|
|
2011-03-03 22:10:17 -05:00
|
|
|
uint32_t Bindings::_ignored_state = 0;
|
|
|
|
|
|
|
|
MouseButton::MouseButton (uint32_t state, uint32_t keycode)
|
|
|
|
{
|
|
|
|
uint32_t ignore = Bindings::ignored_state();
|
|
|
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool
|
|
|
|
MouseButton::make_button (const string& str, MouseButton& b)
|
|
|
|
{
|
|
|
|
int s = 0;
|
|
|
|
|
|
|
|
if (str.find ("Primary") != string::npos) {
|
|
|
|
s |= Keyboard::PrimaryModifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (str.find ("Secondary") != string::npos) {
|
|
|
|
s |= Keyboard::SecondaryModifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (str.find ("Tertiary") != string::npos) {
|
|
|
|
s |= Keyboard::TertiaryModifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (str.find ("Level4") != string::npos) {
|
|
|
|
s |= Keyboard::Level4Modifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
|
|
|
b = MouseButton (s, button_number);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
string
|
|
|
|
MouseButton::name () const
|
|
|
|
{
|
|
|
|
int s = state();
|
|
|
|
|
|
|
|
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 (!str.empty()) {
|
|
|
|
str += '-';
|
|
|
|
}
|
|
|
|
|
|
|
|
char buf[16];
|
|
|
|
snprintf (buf, sizeof (buf), "%u", button());
|
|
|
|
str += buf;
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
2010-08-12 17:02:01 -04:00
|
|
|
|
|
|
|
KeyboardKey::KeyboardKey (uint32_t state, uint32_t keycode)
|
|
|
|
{
|
2011-03-03 22:10:17 -05:00
|
|
|
uint32_t ignore = Bindings::ignored_state();
|
2010-08-12 17:02:01 -04:00
|
|
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-08-06 14:44:55 -04:00
|
|
|
string
|
|
|
|
KeyboardKey::name () const
|
|
|
|
{
|
|
|
|
int s = state();
|
|
|
|
|
|
|
|
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 (!str.empty()) {
|
|
|
|
str += '-';
|
|
|
|
}
|
|
|
|
|
|
|
|
str += gdk_keyval_name (key());
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
KeyboardKey::make_key (const string& str, KeyboardKey& k)
|
|
|
|
{
|
|
|
|
int s = 0;
|
|
|
|
|
|
|
|
if (str.find ("Primary") != string::npos) {
|
|
|
|
s |= Keyboard::PrimaryModifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (str.find ("Secondary") != string::npos) {
|
|
|
|
s |= Keyboard::SecondaryModifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (str.find ("Tertiary") != string::npos) {
|
|
|
|
s |= Keyboard::TertiaryModifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (str.find ("Level4") != string::npos) {
|
|
|
|
s |= Keyboard::Level4Modifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
string::size_type lastmod = str.find_last_of ('-');
|
|
|
|
guint keyval;
|
|
|
|
|
|
|
|
if (lastmod == string::npos) {
|
|
|
|
keyval = gdk_keyval_from_name (str.c_str());
|
|
|
|
} else {
|
|
|
|
keyval = gdk_keyval_from_name (str.substr (lastmod+1).c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (keyval == GDK_VoidSymbol) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
k = KeyboardKey (s, keyval);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Bindings::Bindings ()
|
|
|
|
: action_map (0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Bindings::~Bindings()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Bindings::set_action_map (ActionMap& am)
|
|
|
|
{
|
|
|
|
action_map = &am;
|
|
|
|
press_bindings.clear ();
|
|
|
|
release_bindings.clear ();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2011-03-03 22:10:17 -05:00
|
|
|
Bindings::activate (KeyboardKey kb, Operation op)
|
2010-08-06 14:44:55 -04:00
|
|
|
{
|
2011-09-30 13:55:14 -04:00
|
|
|
KeybindingMap* kbm = 0;
|
2010-08-06 14:44:55 -04:00
|
|
|
|
|
|
|
switch (op) {
|
2011-03-03 22:10:17 -05:00
|
|
|
case Press:
|
2010-08-06 14:44:55 -04:00
|
|
|
kbm = &press_bindings;
|
|
|
|
break;
|
2011-03-03 22:10:17 -05:00
|
|
|
case Release:
|
2010-08-06 14:44:55 -04:00
|
|
|
kbm = &release_bindings;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
KeybindingMap::iterator k = kbm->find (kb);
|
|
|
|
|
|
|
|
if (k == kbm->end()) {
|
|
|
|
/* no entry for this key in the state map */
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* lets do it ... */
|
|
|
|
|
|
|
|
k->second->activate ();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-03-03 22:10:17 -05:00
|
|
|
Bindings::add (KeyboardKey kb, Operation op, RefPtr<Action> what)
|
2010-08-06 14:44:55 -04:00
|
|
|
{
|
2011-09-30 13:55:14 -04:00
|
|
|
KeybindingMap* kbm = 0;
|
2010-08-06 14:44:55 -04:00
|
|
|
|
|
|
|
switch (op) {
|
2011-03-03 22:10:17 -05:00
|
|
|
case Press:
|
2010-08-06 14:44:55 -04:00
|
|
|
kbm = &press_bindings;
|
|
|
|
break;
|
2011-03-03 22:10:17 -05:00
|
|
|
case Release:
|
2010-08-06 14:44:55 -04:00
|
|
|
kbm = &release_bindings;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
KeybindingMap::iterator k = kbm->find (kb);
|
|
|
|
|
|
|
|
if (k == kbm->end()) {
|
|
|
|
pair<KeyboardKey,RefPtr<Action> > newpair (kb, what);
|
|
|
|
kbm->insert (newpair);
|
2011-11-04 13:51:34 -04:00
|
|
|
// cerr << "Bindings added " << kb.key() << " w/ " << kb.state() << " => " << what->get_name() << endl;
|
2010-08-06 14:44:55 -04:00
|
|
|
} else {
|
|
|
|
k->second = what;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-03-03 22:10:17 -05:00
|
|
|
Bindings::remove (KeyboardKey kb, Operation op)
|
2010-08-06 14:44:55 -04:00
|
|
|
{
|
2011-09-30 13:55:14 -04:00
|
|
|
KeybindingMap* kbm = 0;
|
2010-08-06 14:44:55 -04:00
|
|
|
|
|
|
|
switch (op) {
|
2011-03-03 22:10:17 -05:00
|
|
|
case Press:
|
2010-08-06 14:44:55 -04:00
|
|
|
kbm = &press_bindings;
|
|
|
|
break;
|
2011-03-03 22:10:17 -05:00
|
|
|
case Release:
|
2010-08-06 14:44:55 -04:00
|
|
|
kbm = &release_bindings;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
KeybindingMap::iterator k = kbm->find (kb);
|
|
|
|
|
|
|
|
if (k != kbm->end()) {
|
|
|
|
kbm->erase (k);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-03 22:10:17 -05:00
|
|
|
bool
|
|
|
|
Bindings::activate (MouseButton bb, Operation op)
|
|
|
|
{
|
2011-09-30 13:55:14 -04:00
|
|
|
MouseButtonBindingMap* bbm = 0;
|
2011-03-03 22:10:17 -05:00
|
|
|
|
|
|
|
switch (op) {
|
|
|
|
case Press:
|
|
|
|
bbm = &button_press_bindings;
|
|
|
|
break;
|
|
|
|
case Release:
|
|
|
|
bbm = &button_release_bindings;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseButtonBindingMap::iterator b = bbm->find (bb);
|
|
|
|
|
|
|
|
if (b == bbm->end()) {
|
|
|
|
/* no entry for this key in the state map */
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* lets do it ... */
|
|
|
|
|
|
|
|
b->second->activate ();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Bindings::add (MouseButton bb, Operation op, RefPtr<Action> what)
|
|
|
|
{
|
2011-09-30 13:55:14 -04:00
|
|
|
MouseButtonBindingMap* bbm = 0;
|
2011-03-03 22:10:17 -05:00
|
|
|
|
|
|
|
switch (op) {
|
|
|
|
case Press:
|
|
|
|
bbm = &button_press_bindings;
|
|
|
|
break;
|
|
|
|
case Release:
|
|
|
|
bbm = &button_release_bindings;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseButtonBindingMap::iterator b = bbm->find (bb);
|
|
|
|
|
|
|
|
if (b == bbm->end()) {
|
|
|
|
pair<MouseButton,RefPtr<Action> > newpair (bb, what);
|
|
|
|
bbm->insert (newpair);
|
2011-11-04 13:51:34 -04:00
|
|
|
// cerr << "Bindings added mouse button " << bb.button() << " w/ " << bb.state() << " => " << what->get_name() << endl;
|
2011-03-03 22:10:17 -05:00
|
|
|
} else {
|
|
|
|
b->second = what;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Bindings::remove (MouseButton bb, Operation op)
|
|
|
|
{
|
2011-09-30 13:55:14 -04:00
|
|
|
MouseButtonBindingMap* bbm = 0;
|
2011-03-03 22:10:17 -05:00
|
|
|
|
|
|
|
switch (op) {
|
|
|
|
case Press:
|
|
|
|
bbm = &button_press_bindings;
|
|
|
|
break;
|
|
|
|
case Release:
|
|
|
|
bbm = &button_release_bindings;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseButtonBindingMap::iterator b = bbm->find (bb);
|
|
|
|
|
|
|
|
if (b != bbm->end()) {
|
|
|
|
bbm->erase (b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-06 14:44:55 -04:00
|
|
|
bool
|
|
|
|
Bindings::save (const string& path)
|
|
|
|
{
|
|
|
|
XMLTree tree;
|
|
|
|
XMLNode* root = new XMLNode (X_("Bindings"));
|
|
|
|
tree.set_root (root);
|
2011-03-03 22:10:17 -05:00
|
|
|
|
|
|
|
save (*root);
|
|
|
|
|
|
|
|
if (!tree.write (path)) {
|
|
|
|
::unlink (path.c_str());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2010-08-06 14:44:55 -04:00
|
|
|
|
2011-03-03 22:10:17 -05:00
|
|
|
void
|
|
|
|
Bindings::save (XMLNode& root)
|
|
|
|
{
|
2010-08-06 14:44:55 -04:00
|
|
|
XMLNode* presses = new XMLNode (X_("Press"));
|
2011-03-03 22:10:17 -05:00
|
|
|
root.add_child_nocopy (*presses);
|
2010-08-06 14:44:55 -04:00
|
|
|
|
|
|
|
for (KeybindingMap::iterator k = press_bindings.begin(); k != press_bindings.end(); ++k) {
|
|
|
|
XMLNode* child;
|
|
|
|
child = new XMLNode (X_("Binding"));
|
|
|
|
child->add_property (X_("key"), k->first.name());
|
2011-03-03 22:10:17 -05:00
|
|
|
string ap = k->second->get_accel_path();
|
|
|
|
child->add_property (X_("action"), ap.substr (ap.find ('/') + 1));
|
|
|
|
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());
|
|
|
|
string ap = k->second->get_accel_path();
|
|
|
|
child->add_property (X_("action"), ap.substr (ap.find ('/') + 1));
|
2010-08-06 14:44:55 -04:00
|
|
|
presses->add_child_nocopy (*child);
|
2010-08-13 17:48:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
XMLNode* releases = new XMLNode (X_("Release"));
|
2011-03-03 22:10:17 -05:00
|
|
|
root.add_child_nocopy (*releases);
|
2010-08-13 17:48:09 -04:00
|
|
|
|
|
|
|
for (KeybindingMap::iterator k = release_bindings.begin(); k != release_bindings.end(); ++k) {
|
|
|
|
XMLNode* child;
|
|
|
|
child = new XMLNode (X_("Binding"));
|
|
|
|
child->add_property (X_("key"), k->first.name());
|
2011-03-03 22:10:17 -05:00
|
|
|
string ap = k->second->get_accel_path();
|
|
|
|
child->add_property (X_("action"), ap.substr (ap.find ('/') + 1));
|
2010-08-13 17:48:09 -04:00
|
|
|
releases->add_child_nocopy (*child);
|
2010-08-06 14:44:55 -04:00
|
|
|
}
|
|
|
|
|
2011-03-03 22:10:17 -05:00
|
|
|
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());
|
|
|
|
string ap = k->second->get_accel_path();
|
|
|
|
child->add_property (X_("action"), ap.substr (ap.find ('/') + 1));
|
|
|
|
releases->add_child_nocopy (*child);
|
2010-08-06 14:44:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Bindings::load (const string& path)
|
|
|
|
{
|
|
|
|
XMLTree tree;
|
|
|
|
|
|
|
|
if (!action_map) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!tree.read (path)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
press_bindings.clear ();
|
|
|
|
release_bindings.clear ();
|
|
|
|
|
|
|
|
XMLNode& root (*tree.root());
|
|
|
|
const XMLNodeList& children (root.children());
|
|
|
|
|
|
|
|
for (XMLNodeList::const_iterator i = children.begin(); i != children.end(); ++i) {
|
2011-03-03 22:10:17 -05:00
|
|
|
load (**i);
|
|
|
|
}
|
2010-08-06 14:44:55 -04:00
|
|
|
|
2011-03-03 22:10:17 -05:00
|
|
|
return true;
|
|
|
|
}
|
2010-08-06 14:44:55 -04:00
|
|
|
|
2011-03-03 22:10:17 -05:00
|
|
|
void
|
|
|
|
Bindings::load (const XMLNode& node)
|
|
|
|
{
|
|
|
|
if (node.name() == X_("Press") || node.name() == X_("Release")) {
|
|
|
|
|
|
|
|
Operation op;
|
|
|
|
|
|
|
|
if (node.name() == X_("Press")) {
|
|
|
|
op = Press;
|
|
|
|
} else {
|
|
|
|
op = Release;
|
|
|
|
}
|
|
|
|
|
|
|
|
const XMLNodeList& children (node.children());
|
|
|
|
|
|
|
|
for (XMLNodeList::const_iterator p = children.begin(); p != children.end(); ++p) {
|
2010-08-06 14:44:55 -04:00
|
|
|
|
2011-03-03 22:10:17 -05:00
|
|
|
XMLProperty* ap;
|
|
|
|
XMLProperty* kp;
|
|
|
|
XMLProperty* bp;
|
|
|
|
|
|
|
|
ap = (*p)->property ("action");
|
|
|
|
kp = (*p)->property ("key");
|
|
|
|
bp = (*p)->property ("button");
|
|
|
|
|
|
|
|
if (!ap || (!kp && !bp)) {
|
|
|
|
continue;
|
|
|
|
}
|
2010-08-06 14:44:55 -04:00
|
|
|
|
2011-03-03 22:10:17 -05:00
|
|
|
RefPtr<Action> act;
|
2010-08-06 14:44:55 -04:00
|
|
|
|
2011-03-03 22:10:17 -05:00
|
|
|
if (action_map) {
|
|
|
|
act = action_map->find_action (ap->value());
|
|
|
|
}
|
2010-08-06 14:44:55 -04:00
|
|
|
|
2011-03-03 22:10:17 -05:00
|
|
|
if (!act) {
|
|
|
|
string::size_type slash = ap->value().find ('/');
|
|
|
|
if (slash != string::npos) {
|
|
|
|
string group = ap->value().substr (0, slash);
|
|
|
|
string action = ap->value().substr (slash+1);
|
|
|
|
act = ActionManager::get_action (group.c_str(), action.c_str());
|
2010-08-06 14:44:55 -04:00
|
|
|
}
|
2011-03-03 22:10:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!act) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (kp) {
|
2010-08-06 14:44:55 -04:00
|
|
|
KeyboardKey k;
|
|
|
|
if (!KeyboardKey::make_key (kp->value(), k)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
add (k, op, act);
|
2011-03-03 22:10:17 -05:00
|
|
|
} else {
|
|
|
|
MouseButton b;
|
|
|
|
if (!MouseButton::make_button (bp->value(), b)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
add (b, op, act);
|
2010-08-06 14:44:55 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-03-03 22:10:17 -05:00
|
|
|
}
|
2010-08-06 14:44:55 -04:00
|
|
|
|
|
|
|
RefPtr<Action>
|
|
|
|
ActionMap::find_action (const string& name)
|
|
|
|
{
|
|
|
|
_ActionMap::iterator a = actions.find (name);
|
|
|
|
|
|
|
|
if (a != actions.end()) {
|
|
|
|
return a->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
return RefPtr<Action>();
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<Action>
|
|
|
|
ActionMap::register_action (const char* path,
|
|
|
|
const char* name, const char* label, sigc::slot<void> sl)
|
|
|
|
{
|
|
|
|
string fullpath;
|
|
|
|
|
|
|
|
RefPtr<Action> act = Action::create (name, label);
|
|
|
|
|
|
|
|
act->signal_activate().connect (sl);
|
|
|
|
|
|
|
|
fullpath = path;
|
|
|
|
fullpath += '/';
|
|
|
|
fullpath += name;
|
|
|
|
|
|
|
|
actions.insert (_ActionMap::value_type (fullpath, act));
|
|
|
|
return act;
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<Action>
|
|
|
|
ActionMap::register_radio_action (const char* path, Gtk::RadioAction::Group& rgroup,
|
2010-08-10 17:27:19 -04:00
|
|
|
const char* name, const char* label,
|
|
|
|
sigc::slot<void,GtkAction*> sl,
|
|
|
|
int value)
|
2010-08-06 14:44:55 -04:00
|
|
|
{
|
|
|
|
string fullpath;
|
|
|
|
|
|
|
|
RefPtr<Action> act = RadioAction::create (rgroup, name, label);
|
2010-08-10 17:27:19 -04:00
|
|
|
RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
|
|
|
|
ract->property_value() = value;
|
2010-08-06 14:44:55 -04:00
|
|
|
|
2010-08-10 17:27:19 -04:00
|
|
|
act->signal_activate().connect (sigc::bind (sl, act->gobj()));
|
2010-08-06 14:44:55 -04:00
|
|
|
|
|
|
|
fullpath = path;
|
|
|
|
fullpath += '/';
|
|
|
|
fullpath += name;
|
|
|
|
|
|
|
|
actions.insert (_ActionMap::value_type (fullpath, act));
|
|
|
|
return act;
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<Action>
|
2010-08-06 15:02:21 -04:00
|
|
|
ActionMap::register_toggle_action (const char* path,
|
2010-08-06 14:44:55 -04:00
|
|
|
const char* name, const char* label, sigc::slot<void> sl)
|
|
|
|
{
|
|
|
|
string fullpath;
|
|
|
|
|
|
|
|
RefPtr<Action> act = ToggleAction::create (name, label);
|
|
|
|
|
|
|
|
act->signal_activate().connect (sl);
|
|
|
|
|
|
|
|
fullpath = path;
|
|
|
|
fullpath += '/';
|
|
|
|
fullpath += name;
|
|
|
|
|
|
|
|
actions.insert (_ActionMap::value_type (fullpath, act));
|
|
|
|
return act;
|
|
|
|
}
|