[gnome-control-center] Updated for the latest libgnomekbd API
- From: Sergey V. Udaltsov <svu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] Updated for the latest libgnomekbd API
- Date: Sun, 3 Oct 2010 22:53:00 +0000 (UTC)
commit 3e27315e0db9c4e6fff16ed22768404435243a5b
Author: Sergey V. Udaltsov <svu gnome org>
Date: Sun Oct 3 23:52:32 2010 +0100
Updated for the latest libgnomekbd API
panels/keyboard/gnome-keyboard-properties-xkb.c | 86 +++++-----
panels/keyboard/gnome-keyboard-properties-xkb.h | 21 +--
panels/keyboard/gnome-keyboard-properties-xkblt.c | 181 ++++++++------------
.../keyboard/gnome-keyboard-properties-xkbltadd.c | 24 ++-
panels/keyboard/gnome-keyboard-properties-xkbmc.c | 10 +-
panels/keyboard/gnome-keyboard-properties-xkbot.c | 179 ++++++++++----------
6 files changed, 232 insertions(+), 269 deletions(-)
---
diff --git a/panels/keyboard/gnome-keyboard-properties-xkb.c b/panels/keyboard/gnome-keyboard-properties-xkb.c
index 7e083fa..774668f 100644
--- a/panels/keyboard/gnome-keyboard-properties-xkb.c
+++ b/panels/keyboard/gnome-keyboard-properties-xkb.c
@@ -27,7 +27,6 @@
#include <string.h>
#include <gdk/gdkx.h>
-#include <gconf/gconf-client.h>
#include <glib/gi18n.h>
#include "gconf-property-editor.h"
@@ -42,7 +41,8 @@ XklConfigRegistry *config_registry;
GkbdKeyboardConfig initial_config;
GkbdDesktopConfig desktop_config;
-GConfClient *xkb_gconf_client;
+GSettings *xkb_keyboard_settings;
+GSettings *xkb_desktop_settings;
char *
xci_desc_to_utf8 (XklConfigItem * ci)
@@ -52,16 +52,9 @@ xci_desc_to_utf8 (XklConfigItem * ci)
}
static void
-set_model_text (GtkWidget * picker, GConfValue * value)
+set_model_text (GtkWidget * picker, gchar * model)
{
XklConfigItem *ci = xkl_config_item_new ();
- const char *model = NULL;
-
- if (value != NULL && value->type == GCONF_VALUE_STRING) {
- model = gconf_value_get_string (value);
- if (model != NULL && model[0] == '\0')
- model = NULL;
- }
if (model == NULL) {
model = initial_config.model;
@@ -84,30 +77,29 @@ set_model_text (GtkWidget * picker, GConfValue * value)
}
static void
-model_key_changed (GConfClient * client,
- guint cnxn_id, GConfEntry * entry, GtkBuilder * dialog)
+model_key_changed (GSettings * settings, const gchar * key,
+ GtkBuilder * dialog)
{
- set_model_text (WID ("xkb_model_pick"),
- gconf_entry_get_value (entry));
-
- enable_disable_restoring (dialog);
+ if (!strcmp (key, GKBD_KEYBOARD_CONFIG_KEY_MODEL)) {
+ gchar *value =
+ g_settings_get_string (xkb_keyboard_settings,
+ GKBD_KEYBOARD_CONFIG_KEY_MODEL);
+ set_model_text (WID ("xkb_model_pick"), value);
+ if (value != NULL)
+ g_free (value);
+
+ enable_disable_restoring (dialog);
+ }
}
static void
setup_model_entry (GtkBuilder * dialog)
{
- GConfValue *value;
-
- value = gconf_client_get (xkb_gconf_client,
- GKBD_KEYBOARD_CONFIG_KEY_MODEL, NULL);
- set_model_text (WID ("xkb_model_pick"), value);
- if (value != NULL)
- gconf_value_free (value);
-
- gconf_client_notify_add (xkb_gconf_client,
- GKBD_KEYBOARD_CONFIG_KEY_MODEL,
- (GConfClientNotifyFunc) model_key_changed,
- dialog, NULL, NULL);
+ model_key_changed (xkb_keyboard_settings,
+ GKBD_KEYBOARD_CONFIG_KEY_MODEL, dialog);
+
+ g_signal_connect (xkb_keyboard_settings, "changed",
+ (GCallback) model_key_changed, dialog);
}
static void
@@ -119,8 +111,10 @@ cleanup_xkb_tabs (GtkBuilder * dialog)
config_registry = NULL;
g_object_unref (G_OBJECT (engine));
engine = NULL;
- g_object_unref (G_OBJECT (xkb_gconf_client));
- xkb_gconf_client = NULL;
+ g_object_unref (G_OBJECT (xkb_keyboard_settings));
+ g_object_unref (G_OBJECT (xkb_desktop_settings));
+ xkb_keyboard_settings = NULL;
+ xkb_desktop_settings = NULL;
}
static void
@@ -128,13 +122,12 @@ reset_to_defaults (GtkWidget * button, GtkBuilder * dialog)
{
GkbdKeyboardConfig empty_kbd_config;
- gkbd_keyboard_config_init (&empty_kbd_config, xkb_gconf_client,
- engine);
- gkbd_keyboard_config_save_to_gconf (&empty_kbd_config);
+ gkbd_keyboard_config_init (&empty_kbd_config, engine);
+ gkbd_keyboard_config_save (&empty_kbd_config);
gkbd_keyboard_config_term (&empty_kbd_config);
- gconf_client_unset (xkb_gconf_client,
- GKBD_DESKTOP_CONFIG_KEY_DEFAULT_GROUP, NULL);
+ g_settings_reset (xkb_desktop_settings,
+ GKBD_DESKTOP_CONFIG_KEY_DEFAULT_GROUP);
/* all the rest is g-s-d's business */
}
@@ -167,20 +160,21 @@ setup_xkb_tabs (GtkBuilder * dialog, GConfChangeSet * changeset)
GtkWidget *chk_new_windows_inherit_layout =
WID ("chk_new_windows_inherit_layout");
- xkb_gconf_client = gconf_client_get_default ();
+ xkb_desktop_settings = g_settings_new (GKBD_DESKTOP_SCHEMA);
+ xkb_keyboard_settings = g_settings_new (GKBD_KEYBOARD_SCHEMA);
- engine = xkl_engine_get_instance (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
+ engine =
+ xkl_engine_get_instance (GDK_DISPLAY_XDISPLAY
+ (gdk_display_get_default ()));
config_registry = xkl_config_registry_get_instance (engine);
- gkbd_desktop_config_init (&desktop_config, xkb_gconf_client,
- engine);
- gkbd_desktop_config_load_from_gconf (&desktop_config);
+ gkbd_desktop_config_init (&desktop_config, engine);
+ gkbd_desktop_config_load (&desktop_config);
xkl_config_registry_load (config_registry,
desktop_config.load_extra_items);
- gkbd_keyboard_config_init (&initial_config, xkb_gconf_client,
- engine);
+ gkbd_keyboard_config_init (&initial_config, engine);
gkbd_keyboard_config_load_from_x_initial (&initial_config, NULL);
setup_model_entry (dialog);
@@ -227,8 +221,8 @@ setup_xkb_tabs (GtkBuilder * dialog, GConfChangeSet * changeset)
"clicked", G_CALLBACK (choose_model),
dialog);
- xkb_layouts_register_gconf_listener (dialog);
- xkb_options_register_gconf_listener (dialog);
+ xkb_layouts_register_conf_listener (dialog);
+ xkb_options_register_conf_listener (dialog);
g_signal_connect (G_OBJECT (WID ("keyboard_dialog")),
"destroy", G_CALLBACK (cleanup_xkb_tabs),
@@ -243,8 +237,8 @@ enable_disable_restoring (GtkBuilder * dialog)
GkbdKeyboardConfig gswic;
gboolean enable;
- gkbd_keyboard_config_init (&gswic, xkb_gconf_client, engine);
- gkbd_keyboard_config_load_from_gconf (&gswic, NULL);
+ gkbd_keyboard_config_init (&gswic, engine);
+ gkbd_keyboard_config_load (&gswic, NULL);
enable = !gkbd_keyboard_config_equals (&gswic, &initial_config);
diff --git a/panels/keyboard/gnome-keyboard-properties-xkb.h b/panels/keyboard/gnome-keyboard-properties-xkb.h
index 340525d..bd42b87 100644
--- a/panels/keyboard/gnome-keyboard-properties-xkb.h
+++ b/panels/keyboard/gnome-keyboard-properties-xkb.h
@@ -34,7 +34,8 @@ G_BEGIN_DECLS
#define WID(s) GTK_WIDGET (gtk_builder_get_object (dialog, s))
extern XklEngine *engine;
extern XklConfigRegistry *config_registry;
-extern GConfClient *xkb_gconf_client;
+extern GSettings *xkb_keyboard_settings;
+extern GSettings *xkb_desktop_settings;
extern GkbdKeyboardConfig initial_config;
extern void setup_xkb_tabs (GtkBuilder * dialog,
@@ -44,9 +45,9 @@ extern void xkb_layouts_fill_selected_tree (GtkBuilder * dialog);
extern void xkb_layouts_register_buttons_handlers (GtkBuilder * dialog);
-extern void xkb_layouts_register_gconf_listener (GtkBuilder * dialog);
+extern void xkb_layouts_register_conf_listener (GtkBuilder * dialog);
-extern void xkb_options_register_gconf_listener (GtkBuilder * dialog);
+extern void xkb_options_register_conf_listener (GtkBuilder * dialog);
extern void xkb_layouts_prepare_selected_tree (GtkBuilder * dialog,
GConfChangeSet * changeset);
@@ -55,8 +56,6 @@ extern void xkb_options_load_options (GtkBuilder * dialog);
extern void xkb_options_popup_dialog (GtkBuilder * dialog);
-extern void clear_xkb_elements_list (GSList * list);
-
extern char *xci_desc_to_utf8 (XklConfigItem * ci);
extern gchar *xkb_layout_description_utf8 (const gchar * visible);
@@ -69,19 +68,19 @@ extern void choose_model (GtkBuilder * dialog);
extern void xkb_layout_choose (GtkBuilder * dialog);
-extern GSList *xkb_layouts_get_selected_list (void);
+extern gchar **xkb_layouts_get_selected_list (void);
-extern GSList *xkb_options_get_selected_list (void);
+extern gchar **xkb_options_get_selected_list (void);
#define xkb_layouts_set_selected_list(list) \
- gconf_client_set_list (gconf_client_get_default (), \
+ g_settings_set_strv (xkb_keyboard_settings, \
GKBD_KEYBOARD_CONFIG_KEY_LAYOUTS, \
- GCONF_VALUE_STRING, (list), NULL)
+ (const gchar *const*)(list))
#define xkb_options_set_selected_list(list) \
- gconf_client_set_list (gconf_client_get_default (), \
+ g_settings_set_strv (xkb_keyboard_settings, \
GKBD_KEYBOARD_CONFIG_KEY_OPTIONS, \
- GCONF_VALUE_STRING, (list), NULL)
+ (const gchar *const*)(list))
extern GtkWidget *xkb_layout_preview_create_widget (GtkBuilder *
chooser_dialog);
diff --git a/panels/keyboard/gnome-keyboard-properties-xkblt.c b/panels/keyboard/gnome-keyboard-properties-xkblt.c
index 92a7c16..c8fdccd 100644
--- a/panels/keyboard/gnome-keyboard-properties-xkblt.c
+++ b/panels/keyboard/gnome-keyboard-properties-xkblt.c
@@ -26,7 +26,6 @@
#endif
#include <gdk/gdkx.h>
-#include <gconf/gconf-client.h>
#include <glib/gi18n.h>
#include <libgnomekbd/gkbd-desktop-config.h>
@@ -47,17 +46,6 @@ static GtkCellRenderer *text_renderer;
static gboolean disable_buttons_sensibility_update = FALSE;
-void
-clear_xkb_elements_list (GSList * list)
-{
- while (list != NULL) {
- GSList *p = list;
- list = list->next;
- g_free (p->data);
- g_slist_free_1 (p);
- }
-}
-
static gint
find_selected_layout_idx (GtkBuilder * dialog)
{
@@ -84,24 +72,15 @@ find_selected_layout_idx (GtkBuilder * dialog)
return rv;
}
-GSList *
+gchar **
xkb_layouts_get_selected_list (void)
{
- GSList *retval;
+ gchar **retval;
- retval = gconf_client_get_list (xkb_gconf_client,
- GKBD_KEYBOARD_CONFIG_KEY_LAYOUTS,
- GCONF_VALUE_STRING, NULL);
+ retval = g_settings_get_strv (xkb_keyboard_settings,
+ GKBD_KEYBOARD_CONFIG_KEY_LAYOUTS);
if (retval == NULL) {
- GSList *cur_layout;
-
- for (cur_layout = initial_config.layouts_variants;
- cur_layout != NULL; cur_layout = cur_layout->next)
- retval =
- g_slist_prepend (retval,
- g_strdup (cur_layout->data));
-
- retval = g_slist_reverse (retval);
+ retval = g_strdupv (initial_config.layouts_variants);
}
return retval;
@@ -110,18 +89,17 @@ xkb_layouts_get_selected_list (void)
gint
xkb_get_default_group ()
{
- return gconf_client_get_int (xkb_gconf_client,
- GKBD_DESKTOP_CONFIG_KEY_DEFAULT_GROUP,
- NULL);
+ return g_settings_get_int (xkb_desktop_settings,
+ GKBD_DESKTOP_CONFIG_KEY_DEFAULT_GROUP);
}
void
xkb_save_default_group (gint default_group)
{
if (default_group != xkb_get_default_group ())
- gconf_client_set_int (xkb_gconf_client,
- GKBD_DESKTOP_CONFIG_KEY_DEFAULT_GROUP,
- default_group, NULL);
+ g_settings_set_int (xkb_desktop_settings,
+ GKBD_DESKTOP_CONFIG_KEY_DEFAULT_GROUP,
+ default_group);
}
static void
@@ -188,23 +166,24 @@ xkb_layouts_dnd_data_received (GtkWidget * widget, GdkDragContext * dc,
GtkTreeViewDropPosition pos;
gint didx;
gchar *id;
- GSList *layouts_list;
- GSList *node2Remove;
+ gchar **layouts_list;
if (sidx == -1)
return;
layouts_list = xkb_layouts_get_selected_list ();
- node2Remove = g_slist_nth (layouts_list, sidx);
+ id = layouts_list[sidx];
- id = (gchar *) node2Remove->data;
- layouts_list = g_slist_delete_link (layouts_list, node2Remove);
+ /* Remove the element at position sidx */
+ memmove (layouts_list + sidx, layouts_list + sidx + 1,
+ sizeof (gchar *) * g_strv_length (layouts_list + sidx));
if (!gtk_tree_view_get_dest_row_at_pos
(GTK_TREE_VIEW (tree_view), x, y, &path, &pos)) {
/* Move to the very end */
- layouts_list =
- g_slist_append (layouts_list, g_strdup (id));
+ int old_length = g_strv_length (layouts_list);
+ layouts_list[old_length] = id;
+ /* NULL was there before deletion, no need to re-assign */
xkb_layouts_set_selected_list (layouts_list);
} else if (path != NULL) {
gint *indices = gtk_tree_path_get_indices (path);
@@ -212,14 +191,13 @@ xkb_layouts_dnd_data_received (GtkWidget * widget, GdkDragContext * dc,
gtk_tree_path_free (path);
/* Move to the new position */
if (sidx != didx) {
- layouts_list =
- g_slist_insert (layouts_list, g_strdup (id),
- didx);
+ memmove (layouts_list + didx,
+ layouts_list + didx + 1,
+ g_strv_length (layouts_list + didx));
xkb_layouts_set_selected_list (layouts_list);
}
}
- g_free (id);
- clear_xkb_elements_list (layouts_list);
+ g_strfreev (layouts_list);
}
void
@@ -292,8 +270,8 @@ xkb_layout_description_utf8 (const gchar * visible)
void
xkb_layouts_fill_selected_tree (GtkBuilder * dialog)
{
- GSList *layouts = xkb_layouts_get_selected_list ();
- GSList *cur_layout;
+ gchar **layouts = xkb_layouts_get_selected_list ();
+ gchar **cur_layout;
GtkListStore *list_store =
GTK_LIST_STORE (gtk_tree_view_get_model
(GTK_TREE_VIEW
@@ -305,23 +283,29 @@ xkb_layouts_fill_selected_tree (GtkBuilder * dialog)
gtk_list_store_clear (list_store);
- for (cur_layout = layouts; cur_layout != NULL;
- cur_layout = cur_layout->next, counter++) {
- GtkTreeIter iter;
- const char *visible = (char *) cur_layout->data;
- gchar *utf_visible = xkb_layout_description_utf8 (visible);
- gtk_list_store_append (list_store, &iter);
- gtk_list_store_set (list_store, &iter,
- SEL_LAYOUT_TREE_COL_DESCRIPTION,
- utf_visible,
- SEL_LAYOUT_TREE_COL_ID,
- cur_layout->data,
- SEL_LAYOUT_TREE_COL_ENABLED,
- counter < max_selected_layouts, -1);
- g_free (utf_visible);
+ cur_layout = layouts;
+ if (layouts != NULL) {
+ while (*cur_layout != NULL) {
+ GtkTreeIter iter;
+ const char *visible = *cur_layout;
+ gchar *utf_visible =
+ xkb_layout_description_utf8 (visible);
+ gtk_list_store_append (list_store, &iter);
+ gtk_list_store_set (list_store, &iter,
+ SEL_LAYOUT_TREE_COL_DESCRIPTION,
+ utf_visible,
+ SEL_LAYOUT_TREE_COL_ID,
+ *cur_layout,
+ SEL_LAYOUT_TREE_COL_ENABLED,
+ counter < max_selected_layouts,
+ -1);
+ g_free (utf_visible);
+ cur_layout++;
+ counter++;
+ }
}
- clear_xkb_elements_list (layouts);
+ g_strfreev (layouts);
/* enable the buttons' status update */
disable_buttons_sensibility_update = FALSE;
@@ -355,13 +339,14 @@ show_selected_layout (GtkWidget * button, GtkBuilder * dialog)
gint idx = find_selected_layout_idx (dialog);
if (idx != -1) {
- GSList *layouts_list = xkb_layouts_get_selected_list ();
- const gchar *id = g_slist_nth_data (layouts_list, idx);
+ gchar **layouts_list = xkb_layouts_get_selected_list ();
+ const gchar *id = layouts_list[idx];
char *descr = xkb_layout_description_utf8 (id);
GtkWidget *parent = WID ("keyboard_dialog");
- GtkWidget *popup = gkbd_keyboard_drawing_new_dialog (idx, descr);
+ GtkWidget *popup =
+ gkbd_keyboard_drawing_new_dialog (idx, descr);
gtk_widget_set_parent (popup, parent);
- clear_xkb_elements_list (layouts_list);
+ g_strfreev (layouts_list);
g_free (descr);
}
}
@@ -372,16 +357,10 @@ remove_selected_layout (GtkWidget * button, GtkBuilder * dialog)
gint idx = find_selected_layout_idx (dialog);
if (idx != -1) {
- GSList *layouts_list = xkb_layouts_get_selected_list ();
- char *id = NULL;
- GSList *node2Remove = g_slist_nth (layouts_list, idx);
-
- layouts_list =
- g_slist_remove_link (layouts_list, node2Remove);
-
- id = (char *) node2Remove->data;
- g_slist_free_1 (node2Remove);
- g_free (id);
+ gchar **layouts_list = xkb_layouts_get_selected_list ();
+ g_free (layouts_list[idx]);
+ memmove (layouts_list + idx, layouts_list + idx + 1,
+ g_strv_length (layouts_list + idx));
if (default_group > idx)
xkb_save_default_group (default_group - 1);
@@ -389,7 +368,7 @@ remove_selected_layout (GtkWidget * button, GtkBuilder * dialog)
xkb_save_default_group (-1);
xkb_layouts_set_selected_list (layouts_list);
- clear_xkb_elements_list (layouts_list);
+ g_strfreev (layouts_list);
}
}
@@ -399,19 +378,14 @@ move_up_selected_layout (GtkWidget * button, GtkBuilder * dialog)
gint idx = find_selected_layout_idx (dialog);
if (idx != -1) {
- GSList *layouts_list = xkb_layouts_get_selected_list ();
- GSList *node2Remove = g_slist_nth (layouts_list, idx);
-
- layouts_list =
- g_slist_remove_link (layouts_list, node2Remove);
- layouts_list =
- g_slist_insert (layouts_list, node2Remove->data,
- idx - 1);
- g_slist_free_1 (node2Remove);
+ gchar **layouts_list = xkb_layouts_get_selected_list ();
+ gchar *tmp = layouts_list[idx - 1];
+ layouts_list[idx - 1] = layouts_list[idx];
+ layouts_list[idx] = tmp;
idx2select = idx - 1;
xkb_layouts_set_selected_list (layouts_list);
- clear_xkb_elements_list (layouts_list);
+ g_strfreev (layouts_list);
}
}
@@ -421,19 +395,14 @@ move_down_selected_layout (GtkWidget * button, GtkBuilder * dialog)
gint idx = find_selected_layout_idx (dialog);
if (idx != -1) {
- GSList *layouts_list = xkb_layouts_get_selected_list ();
- GSList *node2Remove = g_slist_nth (layouts_list, idx);
-
- layouts_list =
- g_slist_remove_link (layouts_list, node2Remove);
- layouts_list =
- g_slist_insert (layouts_list, node2Remove->data,
- idx + 1);
- g_slist_free_1 (node2Remove);
+ gchar **layouts_list = xkb_layouts_get_selected_list ();
+ gchar *tmp = layouts_list[idx + 1];
+ layouts_list[idx + 1] = layouts_list[idx];
+ layouts_list[idx] = tmp;
idx2select = idx + 1;
xkb_layouts_set_selected_list (layouts_list);
- clear_xkb_elements_list (layouts_list);
+ g_strfreev (layouts_list);
}
}
@@ -455,20 +424,18 @@ xkb_layouts_register_buttons_handlers (GtkBuilder * dialog)
}
static void
-xkb_layouts_update_list (GConfClient * client,
- guint cnxn_id, GConfEntry * entry,
- GtkBuilder * dialog)
+xkb_layouts_update_list (GSettings * settings,
+ gchar * key, GtkBuilder * dialog)
{
- xkb_layouts_fill_selected_tree (dialog);
- enable_disable_restoring (dialog);
+ if (!strcmp (key, GKBD_KEYBOARD_CONFIG_KEY_LAYOUTS)) {
+ xkb_layouts_fill_selected_tree (dialog);
+ enable_disable_restoring (dialog);
+ }
}
void
-xkb_layouts_register_gconf_listener (GtkBuilder * dialog)
+xkb_layouts_register_conf_listener (GtkBuilder * dialog)
{
- gconf_client_notify_add (xkb_gconf_client,
- GKBD_KEYBOARD_CONFIG_KEY_LAYOUTS,
- (GConfClientNotifyFunc)
- xkb_layouts_update_list, dialog, NULL,
- NULL);
+ g_signal_connect (xkb_keyboard_settings, "changed",
+ (GCallback)xkb_layouts_update_list, dialog);
}
diff --git a/panels/keyboard/gnome-keyboard-properties-xkbltadd.c b/panels/keyboard/gnome-keyboard-properties-xkbltadd.c
index 44d28df..fee0d15 100644
--- a/panels/keyboard/gnome-keyboard-properties-xkbltadd.c
+++ b/panels/keyboard/gnome-keyboard-properties-xkbltadd.c
@@ -365,11 +365,11 @@ xkb_layout_chooser_available_layouts_fill (GtkBuilder *
chooser_dialog);
}
-void
-xkl_layout_chooser_add_default_switcher_if_necessary (GSList *
+static void
+xkl_layout_chooser_add_default_switcher_if_necessary (gchar **
layouts_list)
{
- GSList *options_list = xkb_options_get_selected_list ();
+ gchar **options_list = xkb_options_get_selected_list ();
gboolean was_appended;
options_list =
@@ -377,7 +377,7 @@ xkl_layout_chooser_add_default_switcher_if_necessary (GSList *
(layouts_list, options_list, &was_appended);
if (was_appended)
xkb_options_set_selected_list (options_list);
- clear_xkb_elements_list (options_list);
+ g_strfreev (options_list);
}
static void
@@ -408,19 +408,23 @@ xkb_layout_chooser_response (GtkDialog * dialog,
xkb_layout_chooser_get_selected_id (chooser_dialog);
if (selected_id != NULL) {
- GSList *layouts_list =
+ gchar **layouts_list =
xkb_layouts_get_selected_list ();
+ gint len = g_strv_length(layouts_list);
+ gchar **new_layouts_list = g_new0(gchar*, len + 2);
selected_id = g_strdup (selected_id);
- layouts_list =
- g_slist_append (layouts_list, selected_id);
- xkb_layouts_set_selected_list (layouts_list);
+ memcpy(new_layouts_list, layouts_list, sizeof (gchar*) * len);
+ new_layouts_list[len] = selected_id;
+ g_free(layouts_list);
+
+ xkb_layouts_set_selected_list (new_layouts_list);
xkl_layout_chooser_add_default_switcher_if_necessary
- (layouts_list);
+ (new_layouts_list);
- clear_xkb_elements_list (layouts_list);
+ g_strfreev (new_layouts_list);
}
} else if (response == gtk_dialog_get_response_for_widget
(dialog, CWID ("btnPrint"))) {
diff --git a/panels/keyboard/gnome-keyboard-properties-xkbmc.c b/panels/keyboard/gnome-keyboard-properties-xkbmc.c
index 4a21728..4a70b09 100644
--- a/panels/keyboard/gnome-keyboard-properties-xkbmc.c
+++ b/panels/keyboard/gnome-keyboard-properties-xkbmc.c
@@ -26,7 +26,6 @@
#endif
#include <gdk/gdkx.h>
-#include <gconf/gconf-client.h>
#include <glib/gi18n.h>
#include "gnome-keyboard-properties-xkb.h"
@@ -298,9 +297,7 @@ xkb_model_chooser_response (GtkDialog * dialog,
gtk_tree_model_get (list_store, &iter,
1, &model_name, -1);
- gconf_client_set_string (xkb_gconf_client,
- GKBD_KEYBOARD_CONFIG_KEY_MODEL,
- model_name, NULL);
+ g_settings_set_string (xkb_keyboard_settings, GKBD_KEYBOARD_CONFIG_KEY_MODEL, model_name);
g_free (model_name);
}
}
@@ -320,10 +317,7 @@ choose_model (GtkBuilder * dialog)
gtk_window_set_transient_for (GTK_WINDOW (chooser),
GTK_WINDOW (WID
("keyboard_dialog")));
- current_model_name =
- gconf_client_get_string (xkb_gconf_client,
- GKBD_KEYBOARD_CONFIG_KEY_MODEL, NULL);
-
+ current_model_name = g_settings_get_string (xkb_keyboard_settings, GKBD_KEYBOARD_CONFIG_KEY_MODEL);
prepare_vendors_list (chooser_dialog);
prepare_models_list (chooser_dialog);
diff --git a/panels/keyboard/gnome-keyboard-properties-xkbot.c b/panels/keyboard/gnome-keyboard-properties-xkbot.c
index abe6a5f..6e07d62 100644
--- a/panels/keyboard/gnome-keyboard-properties-xkbot.c
+++ b/panels/keyboard/gnome-keyboard-properties-xkbot.c
@@ -28,7 +28,6 @@
#include <glib/gi18n.h>
#include <string.h>
-#include <gconf/gconf-client.h>
#include "gnome-keyboard-properties-xkb.h"
@@ -45,24 +44,16 @@ static GSList *current_radio_group = NULL;
#define GCONFSTATE_PROP "gconfState"
#define EXPANDERS_PROP "expandersList"
-GSList *
+gchar **
xkb_options_get_selected_list (void)
{
- GSList *retval;
+ gchar **retval;
- retval = gconf_client_get_list (xkb_gconf_client,
- GKBD_KEYBOARD_CONFIG_KEY_OPTIONS,
- GCONF_VALUE_STRING, NULL);
+ retval =
+ g_settings_get_strv (xkb_keyboard_settings,
+ GKBD_KEYBOARD_CONFIG_KEY_OPTIONS);
if (retval == NULL) {
- GSList *cur_option;
-
- for (cur_option = initial_config.options;
- cur_option != NULL; cur_option = cur_option->next)
- retval =
- g_slist_prepend (retval,
- g_strdup (cur_option->data));
-
- retval = g_slist_reverse (retval);
+ retval = g_strdupv (initial_config.options);
}
return retval;
@@ -122,41 +113,50 @@ static void
xkb_options_select (gchar * optionname)
{
gboolean already_selected = FALSE;
- GSList *options_list = xkb_options_get_selected_list ();
- GSList *option;
- for (option = options_list; option != NULL; option = option->next)
- if (!strcmp ((gchar *) option->data, optionname))
- already_selected = TRUE;
-
- if (!already_selected)
- options_list =
- g_slist_append (options_list, g_strdup (optionname));
- xkb_options_set_selected_list (options_list);
-
- clear_xkb_elements_list (options_list);
+ gchar **options_list = xkb_options_get_selected_list ();
+ if (options_list != NULL) {
+ gchar **option = options_list;
+ while (*option != NULL)
+ if (!strcmp (*option, optionname)) {
+ already_selected = TRUE;
+ break;
+ }
+ }
+
+ if (!already_selected) {
+ gint old_length = g_strv_length (options_list);
+ gchar **new_options_list =
+ g_new0 (gchar *, old_length + 2);
+ memcpy (new_options_list, options_list,
+ sizeof (gchar *) * old_length);
+ new_options_list[old_length] = g_strdup (optionname);
+ xkb_options_set_selected_list (new_options_list);
+ g_free (new_options_list);
+ }
+
+ g_strfreev (options_list);
}
/* Remove all occurences of optionname from the backend's selection list */
static void
xkb_options_deselect (gchar * optionname)
{
- GSList *options_list = xkb_options_get_selected_list ();
- GSList *nodetmp;
- GSList *option = options_list;
- while (option != NULL) {
- gchar *id = (char *) option->data;
- if (!strcmp (id, optionname)) {
- nodetmp = option->next;
- g_free (id);
- options_list =
- g_slist_remove_link (options_list, option);
- g_slist_free_1 (option);
- option = nodetmp;
- } else
- option = option->next;
+ gchar **options_list = xkb_options_get_selected_list ();
+ if (options_list != NULL) {
+ gchar **option = options_list;
+ while (*option != NULL) {
+ gchar *id = *option;
+ if (!strcmp (id, optionname)) {
+ g_free (*option);
+ memmove (option, option + 1,
+ g_strv_length (option) *
+ sizeof (gchar *));
+ } else
+ option++;
+ }
+ xkb_options_set_selected_list (options_list);
}
- xkb_options_set_selected_list (options_list);
- clear_xkb_elements_list (options_list);
+ g_strfreev (options_list);
}
/* Return true if optionname describes a string already in the backend's
@@ -165,13 +165,18 @@ static gboolean
xkb_options_is_selected (gchar * optionname)
{
gboolean retval = FALSE;
- GSList *options_list = xkb_options_get_selected_list ();
- GSList *option;
- for (option = options_list; option != NULL; option = option->next) {
- if (!strcmp ((gchar *) option->data, optionname))
- retval = TRUE;
+ gchar **options_list = xkb_options_get_selected_list ();
+ if (options_list != NULL) {
+ gchar **option = options_list;
+ while (*option != NULL) {
+ if (!strcmp (*option, optionname)) {
+ retval = TRUE;
+ break;
+ }
+ option++;
+ }
}
- clear_xkb_elements_list (options_list);
+ g_strfreev (options_list);
return retval;
}
@@ -186,8 +191,7 @@ option_focused_cb (GtkWidget * widget, GdkEventFocus * event,
gtk_widget_get_allocation (widget, &alloc);
adj = gtk_scrolled_window_get_vadjustment (win);
- gtk_adjustment_clamp_page (adj, alloc.y,
- alloc.y + alloc.height);
+ gtk_adjustment_clamp_page (adj, alloc.y, alloc.y + alloc.height);
return FALSE;
}
@@ -346,7 +350,8 @@ xkb_options_add_group (XklConfigRegistry * config_registry,
(GCompareFunc) xkb_option_checks_compare);
while (option_checks_list) {
option_check = GTK_WIDGET (option_checks_list->data);
- gtk_box_pack_start (GTK_BOX (vbox), option_check, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), option_check, TRUE,
+ TRUE, 0);
option_checks_list = option_checks_list->next;
}
/* free it */
@@ -417,7 +422,7 @@ chooser_response_cb (GtkDialog * dialog, gint response, gpointer data)
switch (response) {
case GTK_RESPONSE_HELP:
/* capplet_help (GTK_WINDOW (dialog),
- "prefs-keyboard-layoutoptions"); */
+ "prefs-keyboard-layoutoptions"); */
break;
case GTK_RESPONSE_CLOSE:{
/* just cleanup */
@@ -442,9 +447,9 @@ xkb_options_popup_dialog (GtkBuilder * dialog)
GtkWidget *chooser;
chooser_dialog = gtk_builder_new ();
- gtk_builder_add_from_file (chooser_dialog, GNOMECC_UI_DIR
- "/gnome-keyboard-properties-options-dialog.ui",
- NULL);
+ gtk_builder_add_from_file (chooser_dialog, GNOMECC_UI_DIR
+ "/gnome-keyboard-properties-options-dialog.ui",
+ NULL);
chooser = CWID ("xkb_options_dialog");
gtk_window_set_transient_for (GTK_WINDOW (chooser),
@@ -473,42 +478,42 @@ xkb_options_update_option_counters (XklConfigRegistry * config_registry,
/* Respond to a change in the xkb gconf settings */
static void
-xkb_options_update (GConfClient * client,
- guint cnxn_id, GConfEntry * entry, GtkBuilder * dialog)
+xkb_options_update (GSettings * settings, gchar * key, GtkBuilder * dialog)
{
- /* Updating options is handled by gconf notifies for each widget
- This is here to avoid calling it N_OPTIONS times for each gconf
- change. */
- enable_disable_restoring (dialog);
-
- if (chooser_dialog != NULL) {
- GSList *expanders_list =
- g_object_get_data (G_OBJECT (chooser_dialog),
- EXPANDERS_PROP);
- while (expanders_list) {
- current_expander =
- GTK_WIDGET (expanders_list->data);
- gchar *group_id =
- g_object_get_data (G_OBJECT (current_expander),
- "groupId");
- current1st_level_id = group_id;
- xkb_options_expander_selcounter_reset ();
- xkl_config_registry_foreach_option
- (config_registry, group_id,
- (ConfigItemProcessFunc)
- xkb_options_update_option_counters,
- current_expander);
- xkb_options_expander_highlight ();
- expanders_list = expanders_list->next;
+ if (!strcmp (key, GKBD_KEYBOARD_CONFIG_KEY_OPTIONS)) {
+ /* Updating options is handled by gconf notifies for each widget
+ This is here to avoid calling it N_OPTIONS times for each gconf
+ change. */
+ enable_disable_restoring (dialog);
+
+ if (chooser_dialog != NULL) {
+ GSList *expanders_list =
+ g_object_get_data (G_OBJECT (chooser_dialog),
+ EXPANDERS_PROP);
+ while (expanders_list) {
+ current_expander =
+ GTK_WIDGET (expanders_list->data);
+ gchar *group_id =
+ g_object_get_data (G_OBJECT
+ (current_expander),
+ "groupId");
+ current1st_level_id = group_id;
+ xkb_options_expander_selcounter_reset ();
+ xkl_config_registry_foreach_option
+ (config_registry, group_id,
+ (ConfigItemProcessFunc)
+ xkb_options_update_option_counters,
+ current_expander);
+ xkb_options_expander_highlight ();
+ expanders_list = expanders_list->next;
+ }
}
}
}
void
-xkb_options_register_gconf_listener (GtkBuilder * dialog)
+xkb_options_register_conf_listener (GtkBuilder * dialog)
{
- gconf_client_notify_add (xkb_gconf_client,
- GKBD_KEYBOARD_CONFIG_KEY_OPTIONS,
- (GConfClientNotifyFunc)
- xkb_options_update, dialog, NULL, NULL);
+ g_signal_connect (xkb_keyboard_settings, "changed",
+ (GCallback) xkb_options_update, dialog);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]