[gnome-settings-daemon] keyboard: Apply XKB options
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] keyboard: Apply XKB options
- Date: Mon, 20 Aug 2012 13:11:18 +0000 (UTC)
commit 8709d69ed21f05f2c013bfa53b240b8cf98d330f
Author: Rui Matos <tiagomatos gmail com>
Date: Tue Jun 26 16:09:20 2012 +0200
keyboard: Apply XKB options
The new 'xkb-options' key contains a list of XKB options to apply
together with XKB layouts and variants.
https://bugzilla.gnome.org/show_bug.cgi?id=679075
configure.ac | 2 +-
plugins/keyboard/gsd-keyboard-manager.c | 48 +++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 10b0bfe..7ae319c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -63,7 +63,7 @@ PKG_CHECK_MODULES(SETTINGS_DAEMON,
gio-2.0 >= $GIO_REQUIRED_VERSION
gmodule-2.0
gthread-2.0
- gsettings-desktop-schemas >= 3.3.0
+ gsettings-desktop-schemas >= 3.5.5
)
PKG_CHECK_MODULES(SETTINGS_PLUGIN,
diff --git a/plugins/keyboard/gsd-keyboard-manager.c b/plugins/keyboard/gsd-keyboard-manager.c
index 975db0d..44ec091 100644
--- a/plugins/keyboard/gsd-keyboard-manager.c
+++ b/plugins/keyboard/gsd-keyboard-manager.c
@@ -80,6 +80,7 @@
#define KEY_CURRENT_INPUT_SOURCE "current"
#define KEY_INPUT_SOURCES "sources"
+#define KEY_KEYBOARD_OPTIONS "xkb-options"
#define INPUT_SOURCE_TYPE_XKB "xkb"
#define INPUT_SOURCE_TYPE_IBUS "ibus"
@@ -484,6 +485,52 @@ replace_layout_and_variant (GsdKeyboardManager *manager,
xkb_var_defs->variant = build_xkb_group_string (variant, locale_variant, latin_variant);
}
+static gchar *
+build_xkb_options_string (gchar **options)
+{
+ gchar *string;
+
+ if (*options) {
+ gint i;
+ gsize len;
+ gchar *ptr;
+
+ /* First part, getting length */
+ len = 1 + strlen (options[0]);
+ for (i = 1; options[i] != NULL; i++)
+ len += strlen (options[i]);
+ len += (i - 1); /* commas */
+
+ /* Second part, building string */
+ string = malloc (len);
+ ptr = g_stpcpy (string, *options);
+ for (i = 1; options[i] != NULL; i++) {
+ ptr = g_stpcpy (ptr, ",");
+ ptr = g_stpcpy (ptr, options[i]);
+ }
+ } else {
+ string = malloc (1);
+ *string = '\0';
+ }
+
+ return string;
+}
+
+static void
+add_xkb_options (GsdKeyboardManager *manager,
+ XkbRF_VarDefsRec *xkb_var_defs)
+{
+ gchar **options;
+
+ options = g_settings_get_strv (manager->priv->input_sources_settings,
+ KEY_KEYBOARD_OPTIONS);
+
+ free (xkb_var_defs->options);
+ xkb_var_defs->options = build_xkb_options_string (options);
+
+ g_strfreev (options);
+}
+
static void
apply_xkb_layout (GsdKeyboardManager *manager,
const gchar *layout,
@@ -495,6 +542,7 @@ apply_xkb_layout (GsdKeyboardManager *manager,
gnome_xkb_info_get_var_defs (&rules_file_path, &xkb_var_defs);
+ add_xkb_options (manager, xkb_var_defs);
replace_layout_and_variant (manager, xkb_var_defs, layout, variant);
gdk_error_trap_push ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]