summaryrefslogtreecommitdiff
path: root/libgnomekbd
diff options
context:
space:
mode:
authorSergey V. Udaltsov <svu@gnome.org>2012-04-01 01:37:48 +0100
committerSergey V. Udaltsov <svu@gnome.org>2012-04-05 04:55:25 +0100
commit7e9e60fc6b93cb089c1dcfc8c2a1f078a1babb24 (patch)
treedeba782fffabea088c591ad24c90e21d7e0c4ce8 /libgnomekbd
parent2f18425ccce93f6dd033f35676ab0c59a6d99906 (diff)
downloadlibgnomekbd-7e9e60fc6b93cb089c1dcfc8c2a1f078a1babb24.tar.gz
Separating xmodmap patching into standalone functions
A part of https://bugzilla.gnome.org/show_bug.cgi?id=660000 fix. The xmodmap config patching should happen regardless of the configuration changes (even if from xkb POV there was no change).
Diffstat (limited to 'libgnomekbd')
-rw-r--r--libgnomekbd/gkbd-keyboard-config.c81
-rw-r--r--libgnomekbd/gkbd-keyboard-config.h3
2 files changed, 45 insertions, 39 deletions
diff --git a/libgnomekbd/gkbd-keyboard-config.c b/libgnomekbd/gkbd-keyboard-config.c
index 2f15a42..6fbff37 100644
--- a/libgnomekbd/gkbd-keyboard-config.c
+++ b/libgnomekbd/gkbd-keyboard-config.c
@@ -523,12 +523,16 @@ gkbd_keyboard_config_options_equals (GkbdKeyboardConfig * kbd_config1,
char *group2, *option2;
gboolean are_equal = FALSE;
- if (!gkbd_keyboard_config_split_items (kbd_config1->options[i], &group1, &option1))
+ if (!gkbd_keyboard_config_split_items
+ (kbd_config1->options[i], &group1, &option1))
continue;
for (j = 0; j < num_options && !are_equal; j++) {
- if (gkbd_keyboard_config_split_items (kbd_config2->options[j], &group2, &option2)) {
- are_equal = strcmp (option1, option2) == 0;
+ if (gkbd_keyboard_config_split_items
+ (kbd_config2->options[j], &group2,
+ &option2)) {
+ are_equal =
+ strcmp (option1, option2) == 0;
}
}
@@ -552,10 +556,11 @@ gkbd_keyboard_config_equals (GkbdKeyboardConfig * kbd_config1,
g_ascii_strcasecmp (kbd_config1->model, kbd_config2->model))
return False;
if (!g_strv_equal (kbd_config1->layouts_variants,
- kbd_config2->layouts_variants))
+ kbd_config2->layouts_variants))
return False;
- if (!gkbd_keyboard_config_options_equals (kbd_config1, kbd_config2))
+ if (!gkbd_keyboard_config_options_equals
+ (kbd_config1, kbd_config2))
return False;
return True;
@@ -625,46 +630,44 @@ gkbd_keyboard_config_activate (GkbdKeyboardConfig * kbd_config)
gkbd_keyboard_config_copy_to_xkl_config (kbd_config, data);
rv = xkl_config_rec_activate (data, kbd_config->engine);
g_object_unref (G_OBJECT (data));
+ return rv;
+}
+void
+gkbd_keyboard_config_patch (GkbdKeyboardConfig * kbd_config)
+{
/* Small bit of extensibility by using xmodmap */
- if (rv) {
- int i =
- sizeof (XMODMAP_KNOWN_FILES) /
- sizeof (XMODMAP_KNOWN_FILES[0]);
- while (--i >= 0) {
- gchar *xmodmap_file =
- g_build_filename (g_get_home_dir (),
- XMODMAP_KNOWN_FILES[i],
- NULL);
- if (g_file_test (xmodmap_file, G_FILE_TEST_EXISTS)) {
- GError *error = NULL;
- gchar *command;
- xkl_debug (150,
- "Loading custom xmodmap file %s\n",
- xmodmap_file);
- command =
- g_strconcat (XMODMAP_CMD, " ",
- xmodmap_file,
- NULL);
- /* Fire and forget - do not care about errors */
- if (!g_spawn_command_line_async
- (command, &error)) {
- xkl_debug (0,
- "Error loading custom xmodmap file: [%s]\n",
- error->message);
- g_error_free (error);
- }
- g_free (command);
-
- /* One file is enough */
- i = 0;
+ int i =
+ sizeof (XMODMAP_KNOWN_FILES) / sizeof (XMODMAP_KNOWN_FILES[0]);
+ while (--i >= 0) {
+ gchar *xmodmap_file = g_build_filename (g_get_home_dir (),
+ XMODMAP_KNOWN_FILES
+ [i],
+ NULL);
+ if (g_file_test (xmodmap_file, G_FILE_TEST_EXISTS)) {
+ GError *error = NULL;
+ gchar *command;
+ xkl_debug (150,
+ "Loading custom xmodmap file %s\n",
+ xmodmap_file);
+ command =
+ g_strconcat (XMODMAP_CMD, " ",
+ xmodmap_file, NULL);
+ /* Fire and forget - do not care about errors */
+ if (!g_spawn_command_line_async (command, &error)) {
+ xkl_debug (0,
+ "Error loading custom xmodmap file: [%s]\n",
+ error->message);
+ g_error_free (error);
}
+ g_free (command);
- g_free (xmodmap_file);
+ /* One file is enough */
+ i = 0;
}
- }
- return rv;
+ g_free (xmodmap_file);
+ }
}
/**
diff --git a/libgnomekbd/gkbd-keyboard-config.h b/libgnomekbd/gkbd-keyboard-config.h
index 99ecac6..90f97c6 100644
--- a/libgnomekbd/gkbd-keyboard-config.h
+++ b/libgnomekbd/gkbd-keyboard-config.h
@@ -83,6 +83,9 @@ extern gboolean gkbd_keyboard_config_equals (GkbdKeyboardConfig *
extern gboolean gkbd_keyboard_config_activate (GkbdKeyboardConfig *
kbd_config);
+extern void gkbd_keyboard_config_patch (GkbdKeyboardConfig *
+ kbd_config);
+
extern const gchar *gkbd_keyboard_config_merge_items (const gchar * parent,
const gchar * child);