[gnome-flashback] input-sources: Assign groups in order while setting user layouts
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] input-sources: Assign groups in order while setting user layouts
- Date: Mon, 21 May 2018 14:36:28 +0000 (UTC)
commit 6ac373a990aa6280f85e6c891cf58a53cc9bc93b
Author: Ignacy Gawędzki <bugs qult net>
Date: Thu Nov 16 00:21:07 2017 +0100
input-sources: Assign groups in order while setting user layouts
When adding layout info to the hash table, directly assign it to a
group, instead of iterating on the layouts afterwards.
Skip layout if it is already contained in the hashmap.
Signed-off-by: Ignacy Gawędzki <bugs qult net>
Signed-off-by: Sebastian Geiger <sbastig gmx net>
.../libinput-sources/gf-keyboard-manager.c | 51 ++++++++-----------
1 files changed, 22 insertions(+), 29 deletions(-)
---
diff --git a/gnome-flashback/libinput-sources/gf-keyboard-manager.c
b/gnome-flashback/libinput-sources/gf-keyboard-manager.c
index b27f05c..4d76308 100644
--- a/gnome-flashback/libinput-sources/gf-keyboard-manager.c
+++ b/gnome-flashback/libinput-sources/gf-keyboard-manager.c
@@ -542,10 +542,9 @@ gf_keyboard_manager_set_user_layouts (GfKeyboardManager *manager,
gchar **ids)
{
gint i;
+ gint j;
const gchar *layout;
const gchar *variant;
- GHashTableIter iter;
- gpointer value;
LayoutInfo **group;
manager->current = NULL;
@@ -556,46 +555,40 @@ gf_keyboard_manager_set_user_layouts (GfKeyboardManager *manager,
manager->layout_infos = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, layout_info_free);
- for (i = 0; ids[i] != NULL; i++)
+ for (i = 0, j = 0; ids[i] != NULL; i++)
{
if (gnome_xkb_info_get_layout_info (manager->xkb_info, ids[i],
NULL, NULL, &layout, &variant))
{
LayoutInfo *info;
+ guint index;
- info = layout_info_new (ids[i], layout, variant);
-
- g_hash_table_insert (manager->layout_infos, g_strdup (ids[i]), info);
- }
- }
+ if (g_hash_table_contains (manager->layout_infos, ids[i]))
+ continue;
- i = 0;
- g_hash_table_iter_init (&iter, manager->layout_infos);
-
- while (g_hash_table_iter_next (&iter, NULL, &value))
- {
- LayoutInfo *info;
- guint index;
+ info = layout_info_new (ids[i], layout, variant);
- info = (LayoutInfo *) value;
+ /*
+ * We need to leave one slot on each group free so that we
+ * can add a layout containing the symbols for the language
+ * used in UI strings to ensure that toolkits can handle
+ * mnemonics like Alt+Ф even if the user is actually typing
+ * in a different layout.
+ */
+ index = j % (MAX_LAYOUTS_PER_GROUP - 1);
- /*
- * We need to leave one slot on each group free so that we can add a
- * layout containing the symbols for the language used in UI strings to
- * ensure that toolkits can handle mnemonics like Alt+Ф even if the user
- * is actually typing in a different layout.
- */
- index = i % (MAX_LAYOUTS_PER_GROUP - 1);
+ if (index == 0)
+ group = g_new0 (LayoutInfo *, (MAX_LAYOUTS_PER_GROUP - 1));
- if (index == 0)
- group = g_new0 (LayoutInfo *, (MAX_LAYOUTS_PER_GROUP - 1));
+ group[index] = info;
- group[index] = info;
+ info->group = group;
+ info->index = index;
- info->group = group;
- info->index = index;
+ g_hash_table_insert (manager->layout_infos, g_strdup (ids[i]), info);
- i++;
+ ++j;
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]