[libgnomekbd] fixed default switched function, new api style
- From: Sergey V. Udaltsov <svu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgnomekbd] fixed default switched function, new api style
- Date: Sun, 3 Oct 2010 22:24:45 +0000 (UTC)
commit 12b3a7ae18b8bb84f21ba30255ba3add41806ade
Author: Sergey V. Udaltsov <svu gnome org>
Date: Sun Oct 3 23:22:12 2010 +0100
fixed default switched function, new api style
libgnomekbd/gkbd-keyboard-config.c | 40 +++++++++++++++++++++--------------
libgnomekbd/gkbd-keyboard-config.h | 6 ++--
2 files changed, 27 insertions(+), 19 deletions(-)
---
diff --git a/libgnomekbd/gkbd-keyboard-config.c b/libgnomekbd/gkbd-keyboard-config.c
index fdeb6f7..2ec754f 100644
--- a/libgnomekbd/gkbd-keyboard-config.c
+++ b/libgnomekbd/gkbd-keyboard-config.c
@@ -659,37 +659,45 @@ gkbd_keyboard_config_to_string (const GkbdKeyboardConfig * config)
return result;
}
-GSList *
-gkbd_keyboard_config_add_default_switch_option_if_necessary (GSList *
+gchar **
+gkbd_keyboard_config_add_default_switch_option_if_necessary (gchar **
layouts_list,
- GSList *
+ gchar **
options_list,
gboolean *
was_appended)
{
*was_appended = FALSE;
- if (g_slist_length (layouts_list) >= 2) {
+ if (g_strv_length (layouts_list) >= 2) {
gboolean any_switcher = False;
- GSList *option = options_list;
- while (option != NULL) {
- char *g, *o;
- if (gkbd_keyboard_config_split_items
- (option->data, &g, &o)) {
- if (!g_ascii_strcasecmp
- (g, GROUP_SWITCHERS_GROUP)) {
- any_switcher = True;
- break;
+ if (*options_list != NULL) {
+ gchar **option = options_list;
+ while (*option != NULL) {
+ char *g, *o;
+ if (gkbd_keyboard_config_split_items
+ (*option, &g, &o)) {
+ if (!g_ascii_strcasecmp
+ (g, GROUP_SWITCHERS_GROUP)) {
+ any_switcher = True;
+ break;
+ }
}
+ option++;
}
- option = option->next;
}
if (!any_switcher) {
const gchar *id =
gkbd_keyboard_config_merge_items
(GROUP_SWITCHERS_GROUP,
DEFAULT_GROUP_SWITCH);
- options_list =
- g_slist_append (options_list, g_strdup (id));
+ gint old_size = g_strv_length (options_list);
+ gchar **new_options_list =
+ g_new0 (gchar *, old_size + 2);
+ memcpy (new_options_list, options_list,
+ old_size * sizeof (gchar *));
+ new_options_list[old_size] = g_strdup (id);
+ g_free (options_list);
+ options_list = new_options_list;
*was_appended = TRUE;
}
}
diff --git a/libgnomekbd/gkbd-keyboard-config.h b/libgnomekbd/gkbd-keyboard-config.h
index 20f454b..a1a9168 100644
--- a/libgnomekbd/gkbd-keyboard-config.h
+++ b/libgnomekbd/gkbd-keyboard-config.h
@@ -110,10 +110,10 @@ extern const gchar *gkbd_keyboard_config_format_full_layout (const gchar
extern gchar *gkbd_keyboard_config_to_string (const GkbdKeyboardConfig *
config);
-extern GSList
- * gkbd_keyboard_config_add_default_switch_option_if_necessary (GSList *
+extern gchar
+ **gkbd_keyboard_config_add_default_switch_option_if_necessary (gchar **
layouts_list,
- GSList *
+ gchar **
options_list,
gboolean
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]