Commit 9a42aa2e authored by Julien Bonjean's avatar Julien Bonjean

[#3335] Added mask support for shortcuts

parent 1abaefce
......@@ -36,7 +36,6 @@ create_shortcuts_settings()
gnome_main_section_new(_("General"), &result_frame);
label = gtk_label_new(_("Be careful: these shortcuts might override system-wide shortcuts."));
treeview = gtk_tree_view_new();
setup_tree_view(treeview);
......@@ -109,7 +108,7 @@ accel_edited(GtkCellRendererAccel *renderer, gchar *path, guint accel_key,
gtk_tree_model_get_iter_first(model, &iter);
while (list[i].action != NULL)
{
if(list[i].value == code)
if(list[i].value == code && list[i].mask == mask)
{
gtk_list_store_set(GTK_LIST_STORE (model), &iter, MASK, 0, VALUE, 0, -1);
WARN("This key was already affected");
......@@ -124,7 +123,8 @@ accel_edited(GtkCellRendererAccel *renderer, gchar *path, guint accel_key,
accel_key, -1);
// Update GDK bindings
shortcuts_update_bindings(atoi(path), code);
DEBUG("%d %d", hardware_keycode, code);
shortcuts_update_bindings(atoi(path), code, mask);
}
static void
......@@ -141,5 +141,5 @@ accel_cleared(GtkCellRendererAccel *renderer, gchar *path, GtkTreeView *treeview
gtk_list_store_set(GTK_LIST_STORE (model), &iter, MASK, 0, VALUE, 0, -1);
// Update GDK bindings
shortcuts_update_bindings(atoi(path), 0);
shortcuts_update_bindings(atoi(path), 0, 0);
}
......@@ -997,20 +997,20 @@
</method>
<method name="getShortcuts" tp:name-for-bindings="getShortcuts">
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="MapStringInt"/>
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="MapStringString"/>
<tp:docstring>
</tp:docstring>
<arg type="a{si}" name="shortcutsMap" direction="out">
<arg type="a{ss}" name="shortcutsMap" direction="out">
<tp:docstring>
</tp:docstring>
</arg>
</method>
<method name="setShortcuts" tp:name-for-bindings="setShortcuts">
<annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="MapStringInt"/>
<annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="MapStringString"/>
<tp:docstring>
</tp:docstring>
<arg type="a{si}" name="shortcutsMap" direction="in">
<arg type="a{ss}" name="shortcutsMap" direction="in">
<tp:docstring>
</tp:docstring>
</arg>
......
This diff is collapsed.
......@@ -30,10 +30,10 @@ typedef struct
} Accelerator;
static void
grab_key (int key_code, GdkWindow *root);
grab_key (int key_code, GdkModifierType mask, GdkWindow *root);
static void
ungrab_key (int key_code, GdkWindow *root);
ungrab_key (int key_code, GdkModifierType mask, GdkWindow *root);
static GdkFilterReturn
filter_keys (GdkXEvent *xevent, GdkEvent *event, gpointer data);
......@@ -57,7 +57,7 @@ static void
toggle_hold_callback ();
static void
initialize_binding (const gchar* action, const guint code);
initialize_binding (const gchar* action, const guint code, const GdkModifierType mask);
static void
initialize_shortcuts_keys ();
......@@ -66,7 +66,10 @@ static void*
get_action_callback (const gchar* action);
static void
update_bindings_data (const guint index, const guint code);
update_bindings_data (const guint index, const guint code, GdkModifierType mask);
static void
update_shortcuts_map (const gchar* action, guint value, GdkModifierType mask);
/*
* "Public" functions
......@@ -76,7 +79,7 @@ void
shortcuts_initialize_bindings ();
void
shortcuts_update_bindings (const guint index, const guint code);
shortcuts_update_bindings (const guint index, const guint code, GdkModifierType mask);
void
shortcuts_destroy_bindings ();
......
......@@ -816,25 +816,24 @@ void ConfigurationManager::setWindowPositionY(const int32_t& posY) {
Manager::instance().setConfig(PREFERENCES, WINDOW_POSITION_Y, posY);
}
std::map<std::string, int32_t> ConfigurationManager::getShortcuts() {
std::map<std::string, std::string> ConfigurationManager::getShortcuts() {
std::map<std::string, int> shortcutsMap;
int shortcut;
std::map<std::string, std::string> shortcutsMap;
for (int i = 0; i < (int)shortcutsKeys.size(); i++) {
std::string key = shortcutsKeys.at(i);
shortcut = Manager::instance().getConfigInt("Shortcuts", key);
shortcutsMap.insert(std::pair<std::string, int>(key, shortcut));
std::string shortcut = Manager::instance().getConfigString("Shortcuts", key);
shortcutsMap.insert(std::pair<std::string, std::string>(key, shortcut));
}
return shortcutsMap;
}
void ConfigurationManager::setShortcuts(
const std::map<std::string, int32_t>& shortcutsMap) {
const std::map<std::string, std::string>& shortcutsMap) {
std::map<std::string, int> map_cpy = shortcutsMap;
std::map<std::string, int>::iterator it;
std::map<std::string, std::string> map_cpy = shortcutsMap;
std::map<std::string, std::string>::iterator it;
for (int i = 0; i < (int)shortcutsKeys.size(); i++) {
std::string key = shortcutsKeys.at(i);
......
......@@ -150,8 +150,8 @@ public:
std::vector<std::string> getAllIpInterface(void);
std::vector<std::string> getAllIpInterfaceByName(void);
std::map< std::string, int32_t > getShortcuts ();
void setShortcuts (const std::map< std::string, int32_t >& shortcutsMap);
std::map< std::string, std::string > getShortcuts ();
void setShortcuts (const std::map< std::string, std::string >& shortcutsMap);
};
......
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