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

[#3218] Fix shortcuts

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