Commit 76fa379a authored by Alexandre Savard's avatar Alexandre Savard

[#3218] Fix shortcuts

parent 615d73ec
...@@ -2297,6 +2297,7 @@ dbus_get_shortcuts(void) ...@@ -2297,6 +2297,7 @@ dbus_get_shortcuts(void)
{ {
GError *error = NULL; GError *error = NULL;
GHashTable * shortcuts; GHashTable * shortcuts;
if (!org_sflphone_SFLphone_ConfigurationManager_get_shortcuts( if (!org_sflphone_SFLphone_ConfigurationManager_get_shortcuts(
configurationManagerProxy, &shortcuts, &error)) configurationManagerProxy, &shortcuts, &error))
{ {
......
...@@ -387,6 +387,8 @@ shortcuts_initialize_bindings () ...@@ -387,6 +387,8 @@ shortcuts_initialize_bindings ()
gchar* action, *maskAndKey, *token1, *token2 = NULL; gchar* action, *maskAndKey, *token1, *token2 = NULL;
guint mask, key = 0; guint mask, key = 0;
DEBUG("Shortcuts: Initialize bindings");
// get shortcuts stored in config through dbus // get shortcuts stored in config through dbus
shortcutsMap = dbus_get_shortcuts (); shortcutsMap = dbus_get_shortcuts ();
...@@ -402,7 +404,6 @@ shortcuts_initialize_bindings () ...@@ -402,7 +404,6 @@ shortcuts_initialize_bindings ()
action = shortcutsKeysElement->data; action = shortcutsKeysElement->data;
maskAndKey = g_strdup (g_hash_table_lookup (shortcutsMap, action)); maskAndKey = g_strdup (g_hash_table_lookup (shortcutsMap, action));
DEBUG("-------------------- maskAndKey %s", maskAndKey);
token1 = strtok (maskAndKey, "x"); token1 = strtok (maskAndKey, "x");
token2 = strtok (NULL, "x"); token2 = strtok (NULL, "x");
...@@ -411,7 +412,7 @@ shortcuts_initialize_bindings () ...@@ -411,7 +412,7 @@ shortcuts_initialize_bindings ()
// Value not setted // Value not setted
if (token1 && token2){ if (token1 && token2){
DEBUG("token1 %s, token2 %s", token1, token2); DEBUG("Ahortcuts: token1 %s, token2 %s", token1, token2);
mask = atoi (token1); mask = atoi (token1);
key = atoi (token2); key = atoi (token2);
...@@ -465,17 +466,15 @@ filter_keys (const GdkXEvent *xevent, const GdkEvent *event, gpointer data) ...@@ -465,17 +466,15 @@ filter_keys (const GdkXEvent *xevent, const GdkEvent *event, gpointer data)
int i = 0; int i = 0;
xev = (XEvent *) xevent; xev = (XEvent *) xevent;
if (xev->type != KeyPress) if (xev->type != KeyPress) {
{ return GDK_FILTER_CONTINUE;
return GDK_FILTER_CONTINUE; }
}
key = (XKeyEvent *) xevent; key = (XKeyEvent *) xevent;
keystate = key->state & ~(Mod2Mask | Mod5Mask | LockMask); keystate = key->state & ~(Mod2Mask | Mod5Mask | LockMask);
// try to find corresponding action // try to find corresponding action
while (accelerators_list[i].action != NULL) while (accelerators_list[i].action != NULL) {
{
if (accelerators_list[i].key == key->keycode && accelerators_list[i].mask if (accelerators_list[i].key == key->keycode && accelerators_list[i].mask
== keystate) == keystate)
{ {
......
...@@ -733,6 +733,8 @@ std::map<std::string, std::string> ConfigurationManager::getShortcuts() { ...@@ -733,6 +733,8 @@ std::map<std::string, std::string> ConfigurationManager::getShortcuts() {
void ConfigurationManager::setShortcuts( void ConfigurationManager::setShortcuts(
const std::map<std::string, std::string>& shortcutsMap) { const std::map<std::string, std::string>& shortcutsMap) {
std::map<std::string, std::string> map_cpy = shortcutsMap;
/*
std::map<std::string, std::string> map_cpy = shortcutsMap; std::map<std::string, std::string> map_cpy = shortcutsMap;
std::map<std::string, std::string>::iterator it; std::map<std::string, std::string>::iterator it;
...@@ -740,9 +742,12 @@ void ConfigurationManager::setShortcuts( ...@@ -740,9 +742,12 @@ void ConfigurationManager::setShortcuts(
std::string key = shortcutsKeys.at(i); std::string key = shortcutsKeys.at(i);
it = map_cpy.find(key); it = map_cpy.find(key);
if (it != shortcutsMap.end()) { if (it != shortcutsMap.end()) {
Manager::instance().setConfig("Shortcuts", key, it->second); Manager::instance().setConfig("Shortcuts", key, it->second);
} }
} }
*/
Manager::instance().shortcutPreferences.setShortcuts(map_cpy);
Manager::instance().saveConfig(); Manager::instance().saveConfig();
} }
......
...@@ -444,54 +444,49 @@ ShortcutPreferences::ShortcutPreferences() : _hangup("") ...@@ -444,54 +444,49 @@ ShortcutPreferences::ShortcutPreferences() : _hangup("")
ShortcutPreferences::~ShortcutPreferences() {} ShortcutPreferences::~ShortcutPreferences() {}
std::map<std::string, std::string> ShortcutPreferences::getShortcuts() std::map<std::string, std::string> ShortcutPreferences::getShortcuts()
{ {
std::map<std::string, std::string> shortcutsMap; std::map<std::string, std::string> shortcutsMap;
shortcutsMap.insert(std::pair<std::string, std::string>(hangupShortKey, _hangup.data())); shortcutsMap.insert(std::pair<std::string, std::string>(hangupShortKey, _hangup));
shortcutsMap.insert(std::pair<std::string, std::string>(pickupShortKey, _pickup.data())); shortcutsMap.insert(std::pair<std::string, std::string>(pickupShortKey, _pickup));
shortcutsMap.insert(std::pair<std::string, std::string>(popupShortKey, _popup.data())); shortcutsMap.insert(std::pair<std::string, std::string>(popupShortKey, _popup));
shortcutsMap.insert(std::pair<std::string, std::string>(toggleHoldShortKey, _toggleHold.data())); shortcutsMap.insert(std::pair<std::string, std::string>(toggleHoldShortKey, _toggleHold));
shortcutsMap.insert(std::pair<std::string, std::string>(togglePickupHangupShortKey, _togglePickupHangup.data())); shortcutsMap.insert(std::pair<std::string, std::string>(togglePickupHangupShortKey, _togglePickupHangup));
return shortcutsMap; return shortcutsMap;
} }
void ShortcutPreferences::setShortcuts(std::map<std::string, int> shortcut) void ShortcutPreferences::setShortcuts(std::map<std::string, std::string> map_cpy)
{ {
std::map<std::string, int> map_cpy = shortcut; // std::map<std::string, int> map_cpy = shortcut;
std::map<std::string, int>::iterator it; std::map<std::string, std::string>::iterator it;
it = map_cpy.find(hangupShortKey); it = map_cpy.find(hangupShortKey);
if (it != map_cpy.end()) { if (it != map_cpy.end()) {
std::stringstream hangupstr; hangupstr << it->second; _hangup = it->second;
_hangup = hangupstr.str();
} }
it = map_cpy.find(pickupShortKey); it = map_cpy.find(pickupShortKey);
if (it != map_cpy.end()) { if (it != map_cpy.end()) {
std::stringstream pickupstr; pickupstr << it->second; _pickup = it->second;
_pickup = pickupstr.str();
} }
it = map_cpy.find(popupShortKey); it = map_cpy.find(popupShortKey);
if (it != map_cpy.end()) { if (it != map_cpy.end()) {
std::stringstream popupstr; popupstr << it->second; _popup = it->second;
_popup = popupstr.str();
} }
it = map_cpy.find(toggleHoldShortKey); it = map_cpy.find(toggleHoldShortKey);
if(it != map_cpy.end()) { if(it != map_cpy.end()) {
std::stringstream holdstr; holdstr << it->second; _toggleHold = it->second;
_toggleHold = holdstr.str();
} }
it = map_cpy.find(togglePickupHangupShortKey); it = map_cpy.find(togglePickupHangupShortKey);
if(it != map_cpy.end()) { if(it != map_cpy.end()) {
std::stringstream togglestr; togglestr << it->second; _togglePickupHangup = it->second;
_togglePickupHangup = togglestr.str();
} }
/* /*
for (int i = 0; i < (int)shortcutsKeys.size(); i++) { for (int i = 0; i < (int)shortcutsKeys.size(); i++) {
...@@ -537,13 +532,13 @@ void ShortcutPreferences::unserialize(Conf::MappingNode *map) ...@@ -537,13 +532,13 @@ void ShortcutPreferences::unserialize(Conf::MappingNode *map)
Conf::ScalarNode *val = NULL; Conf::ScalarNode *val = NULL;
val = (Conf::ScalarNode *)(map->getValue(hangupShortKey)); val = (Conf::ScalarNode *)(map->getValue(hangupShortKey));
if(val) { _hangup = atoi(val->getValue().data()); val = NULL; } if(val) { _hangup = val->getValue(); val = NULL; }
val = (Conf::ScalarNode *)(map->getValue(pickupShortKey)); val = (Conf::ScalarNode *)(map->getValue(pickupShortKey));
if(val) { _pickup = atoi(val->getValue().data()); val = NULL; } if(val) { _pickup = val->getValue(); val = NULL; }
val = (Conf::ScalarNode *)(map->getValue(popupShortKey)); val = (Conf::ScalarNode *)(map->getValue(popupShortKey));
if(val) { _popup = atoi(val->getValue().data()); val = NULL; } if(val) { _popup = val->getValue(); val = NULL; }
val = (Conf::ScalarNode *)(map->getValue(toggleHoldShortKey)); val = (Conf::ScalarNode *)(map->getValue(toggleHoldShortKey));
if(val) { _toggleHold = atoi(val->getValue().data()); val = NULL; } if(val) { _toggleHold = val->getValue(); val = NULL; }
val = (Conf::ScalarNode *)(map->getValue(togglePickupHangupShortKey)); val = (Conf::ScalarNode *)(map->getValue(togglePickupHangupShortKey));
if(val) { _togglePickupHangup = atoi(val->getValue().data()); val = NULL; } if(val) { _togglePickupHangup = val->getValue(); val = NULL; }
} }
...@@ -375,8 +375,8 @@ class ShortcutPreferences : public Serializable { ...@@ -375,8 +375,8 @@ class ShortcutPreferences : public Serializable {
virtual void unserialize(Conf::MappingNode *map); virtual void unserialize(Conf::MappingNode *map);
void setShortcuts(std::map<std::string, std::string> shortcut);
std::map<std::string, std::string> getShortcuts(void); std::map<std::string, std::string> getShortcuts(void);
void setShortcuts(std::map<std::string, int> shortcut);
std::string getHangup(void) { return _hangup; } std::string getHangup(void) { return _hangup; }
void setHangup(std::string hangup) { _hangup = hangup; } void setHangup(std::string hangup) { _hangup = hangup; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment