[gnome-initial-setup] keyboard: pre-select input source from X Window or gnome-desktop
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup] keyboard: pre-select input source from X Window or gnome-desktop
- Date: Wed, 11 Apr 2018 18:16:18 +0000 (UTC)
commit 07e24d6f2ac4d340e72e839e23e8d54a0395685b
Author: Peng Wu <alexepico gmail com>
Date: Tue Apr 3 13:30:26 2018 +0800
keyboard: pre-select input source from X Window or gnome-desktop
For keyboard layout, we pre-select it from X Window.
For other input source, we pre-select it from gnome-desktop.
https://bugzilla.gnome.org/show_bug.cgi?id=776189
.../pages/keyboard/gis-keyboard-page.c | 38 +++++++++++++++----
1 files changed, 30 insertions(+), 8 deletions(-)
---
diff --git a/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c
b/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c
index d75a7d0..237c528 100644
--- a/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c
+++ b/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c
@@ -37,6 +37,8 @@
#include "keyboard-resources.h"
#include "cc-input-chooser.h"
+#include "cc-common-language.h"
+
#define GNOME_DESKTOP_INPUT_SOURCES_DIR "org.gnome.desktop.input-sources"
#define KEY_CURRENT_INPUT_SOURCE "current"
#define KEY_INPUT_SOURCES "sources"
@@ -278,8 +280,7 @@ add_default_input_sources (GisKeyboardPage *self,
{
const gchar *type;
const gchar *id;
- const gchar * const *locales;
- const gchar *language;
+ gchar *language;
GVariantBuilder builder;
GSettings *input_settings;
@@ -289,12 +290,12 @@ add_default_input_sources (GisKeyboardPage *self,
add_default_keyboard_layout (proxy, &builder);
/* add other input sources */
- locales = g_get_language_names ();
- language = locales[0];
+ language = cc_common_language_get_current_language ();
if (gnome_get_input_source_from_locale (language, &type, &id)) {
if (!g_str_equal (type, "xkb"))
g_variant_builder_add (&builder, "(ss)", type, id);
}
+ g_free (language);
g_settings_delay (input_settings);
g_settings_set_value (input_settings, KEY_INPUT_SOURCES, g_variant_builder_end (&builder));
@@ -346,8 +347,12 @@ gis_keyboard_page_skip (GisPage *page)
}
static void
-load_localed_input (GisKeyboardPage *self)
+preselect_input_source (GisKeyboardPage *self)
{
+ const gchar *type;
+ const gchar *id;
+ gchar *language;
+
GisKeyboardPagePrivate *priv = gis_keyboard_page_get_instance_private (self);
GSList *sources = get_localed_input (priv->localed);
@@ -356,11 +361,28 @@ load_localed_input (GisKeyboardPage *self)
g_slist_free_full (priv->system_sources, g_free);
priv->system_sources = g_slist_reverse (sources);
- /* We only pre-select the first system layout. */
- if (priv->system_sources)
+ /* For languages that use an input method, we will add both
+ * system keyboard layout and the ibus input method. For
+ * languages that use keyboard layout only, we will add only
+ * system keyboard layout. Because the keyboard layout
+ * information from gnome-desktop is not as accurate as system
+ * keyboard layout, if gnome-desktop returns keyboard layout,
+ * we ignore it and use system keyboard layout instead. If
+ * gnome-desktop instead returns an ibus input method, we will
+ * add both system keyboard layout and the ibus input method. */
+ language = cc_common_language_get_current_language ();
+
+ if (!priv->system_sources ||
+ (gnome_get_input_source_from_locale (language, &type, &id) && g_strcmp0 (type, "xkb") != 0)) {
+ cc_input_chooser_set_input (CC_INPUT_CHOOSER (priv->input_chooser),
+ id, type);
+ } else {
cc_input_chooser_set_input (CC_INPUT_CHOOSER (priv->input_chooser),
(const gchar *) priv->system_sources->data,
"xkb");
+ }
+
+ g_free (language);
}
static void
@@ -395,7 +417,7 @@ localed_proxy_ready (GObject *source,
priv->localed = proxy;
- load_localed_input (self);
+ preselect_input_source (self);
update_page_complete (self);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]