diff options
author | Sergey V. Udaltsov <svu@src.gnome.org> | 2006-10-18 22:37:40 +0000 |
---|---|---|
committer | Sergey V. Udaltsov <svu@src.gnome.org> | 2006-10-18 22:37:40 +0000 |
commit | ada87a95f23d27ecaa466a15759a10fffd26aa77 (patch) | |
tree | 9895b0f9e9cf8e1c29292b88ae2215107d0ceeea | |
parent | 0caebda160b773e09b744e665e4d6c242315a5c9 (diff) | |
download | gnome-control-center-ada87a95f23d27ecaa466a15759a10fffd26aa77.tar.gz |
Changing library dependency from virtual libgswitchit/libkbdraw to normal libgnomekbd
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | capplets/keyboard/Makefile.am | 6 | ||||
-rw-r--r-- | capplets/keyboard/gnome-keyboard-properties-xkb.c | 236 | ||||
-rw-r--r-- | capplets/keyboard/gnome-keyboard-properties-xkb.h | 27 | ||||
-rw-r--r-- | capplets/keyboard/gnome-keyboard-properties-xkblt.c | 979 | ||||
-rw-r--r-- | capplets/keyboard/gnome-keyboard-properties-xkbmc.c | 220 | ||||
-rw-r--r-- | capplets/keyboard/gnome-keyboard-properties-xkbot.c | 482 | ||||
-rw-r--r-- | capplets/keyboard/gnome-keyboard-properties-xkbpv.c | 134 | ||||
-rw-r--r-- | configure.in | 24 | ||||
-rw-r--r-- | gnome-settings-daemon/Makefile.am | 6 | ||||
-rw-r--r-- | gnome-settings-daemon/gnome-settings-keyboard-xkb.c | 68 | ||||
-rw-r--r-- | gnome-settings-daemon/gnome-settings-keyboard-xkb.h | 10 | ||||
-rw-r--r-- | schemas/Makefile.am | 1 | ||||
-rw-r--r-- | schemas/desktop_gnome_peripherals_keyboard_xkb.schemas.in | 193 |
15 files changed, 1172 insertions, 1231 deletions
@@ -1,3 +1,18 @@ +2006-10-18 Sergey Udaltsov <svu@gnome.org> + + * Makefile.am, configure.in, capplets/keyboard/Makefile.am, + capplets/keyboard/gnome-keyboard-properties-xkb.c, + capplets/keyboard/gnome-keyboard-properties-xkb.h, + capplets/keyboard/gnome-keyboard-properties-xkblt.c, + capplets/keyboard/gnome-keyboard-properties-xkbmc.c, + capplets/keyboard/gnome-keyboard-properties-xkbot.c, + capplets/keyboard/gnome-keyboard-properties-xkbpv.c, + gnome-settings-daemon/Makefile.am, + gnome-settings-daemon/gnome-settings-keyboard-xkb.c, + gnome-settings-daemon/gnome-settings-keyboard-xkb.h, + schemas/Makefile.am: changing things from libgswitchit/libkbdraw to + libgnomekbd + 2006-10-16 Rodrigo Moya <rodrigo@novell.com> * configure.in: diff --git a/Makefile.am b/Makefile.am index 45fbbf5b6..1578f4ae5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = po libsounds libbackground libwindow-settings libgswitchit libkbdraw gnome-settings-daemon capplets control-center help vfs-methods idl schemas $(TYPING_BREAK) +SUBDIRS = po libsounds libbackground libwindow-settings gnome-settings-daemon capplets control-center help vfs-methods idl schemas $(TYPING_BREAK) ACLOCAL_AMFLAGS = -I m4 diff --git a/capplets/keyboard/Makefile.am b/capplets/keyboard/Makefile.am index 56ad9f2d2..61fba6b37 100644 --- a/capplets/keyboard/Makefile.am +++ b/capplets/keyboard/Makefile.am @@ -9,9 +9,7 @@ gnome_keyboard_properties_SOURCES = gnome-keyboard-properties.c \ gnome-keyboard-properties-xkb.h gnome_keyboard_properties_LDADD = \ ../accessibility/keyboard/libaccessibility-keyboard.a \ - $(GNOMECC_CAPPLETS_LIBS) $(LIBXKLAVIER_LIBS) \ - ../../libgswitchit/libgswitchit.a \ - ../../libkbdraw/libkbdraw.a + $(GNOMECC_CAPPLETS_LIBS) $(LIBGNOMEKBDUI_LIBS) @INTLTOOL_DESKTOP_RULE@ @@ -29,6 +27,6 @@ desktopdir = $(datadir)/applications Desktop_in_files = keyboard.desktop.in desktop_DATA = $(Desktop_in_files:.desktop.in=.desktop) -INCLUDES = $(GNOMECC_CAPPLETS_CFLAGS) $(LIBXKLAVIER_CFLAGS) +INCLUDES = $(GNOMECC_CAPPLETS_CFLAGS) $(LIBGNOMEKBDUI_CFLAGS) CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES) $(Desktop_in_files) $(desktop_DATA) EXTRA_DIST = $(Glade_DATA) $(pixmaps_DATA) diff --git a/capplets/keyboard/gnome-keyboard-properties-xkb.c b/capplets/keyboard/gnome-keyboard-properties-xkb.c index 3b2040075..c6126d004 100644 --- a/capplets/keyboard/gnome-keyboard-properties-xkb.c +++ b/capplets/keyboard/gnome-keyboard-properties-xkb.c @@ -30,192 +30,192 @@ #include <gconf/gconf-client.h> #include <glade/glade.h> -#include "libgswitchit/gswitchit-config.h" - #include "capplet-util.h" #include "gconf-property-editor.h" #include "activate-settings-daemon.h" #include "capplet-stock-icons.h" #include <../accessibility/keyboard/accessibility-keyboard.h> +#include <libgnomekbd/gkbd-desktop-config.h> + #include "gnome-keyboard-properties-xkb.h" XklEngine *engine; XklConfigRegistry *config_registry; -GSwitchItKbdConfig initial_config; +GkbdKeyboardConfig initial_config; GConfClient *xkb_gconf_client; char * xci_desc_to_utf8 (XklConfigItem * ci) { - char *sd = g_strstrip (ci->description); - return sd[0] == 0 ? g_strdup (ci->name) : - g_locale_to_utf8 (sd, -1, NULL, NULL, NULL); + char *sd = g_strstrip (ci->description); + return sd[0] == 0 ? g_strdup (ci->name) : + g_locale_to_utf8 (sd, -1, NULL, NULL, NULL); } static void -set_model_text (GtkWidget * entry, - GConfValue * value) +set_model_text (GtkWidget * entry, GConfValue * value) { - XklConfigItem ci; - 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; - if (model == NULL) - model = ""; - } - - g_snprintf (ci.name, sizeof (ci.name), "%s", model); - - if (xkl_config_registry_find_model (config_registry, &ci)) - { - char * d; - - d = xci_desc_to_utf8 (&ci); - gtk_entry_set_text (GTK_ENTRY (entry), d); - g_free (d); - } - else - { - gtk_entry_set_text (GTK_ENTRY (entry), _("Unknown")); - } + XklConfigItem ci; + 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; + if (model == NULL) + model = ""; + } + + g_snprintf (ci.name, sizeof (ci.name), "%s", model); + + if (xkl_config_registry_find_model (config_registry, &ci)) { + char *d; + + d = xci_desc_to_utf8 (&ci); + gtk_entry_set_text (GTK_ENTRY (entry), d); + g_free (d); + } else { + gtk_entry_set_text (GTK_ENTRY (entry), _("Unknown")); + } } static void model_key_changed (GConfClient * client, - guint cnxn_id, - GConfEntry * entry, - GladeXML * dialog) + guint cnxn_id, GConfEntry * entry, GladeXML * dialog) { - set_model_text (WID ("xkb_model"), - gconf_entry_get_value (entry)); + set_model_text (WID ("xkb_model"), gconf_entry_get_value (entry)); - enable_disable_restoring (dialog); + enable_disable_restoring (dialog); } static void setup_model_entry (GladeXML * dialog) { - GConfValue * value; - - value = gconf_client_get (xkb_gconf_client, - GSWITCHIT_KBD_CONFIG_KEY_MODEL, - NULL); - set_model_text (WID ("xkb_model"), value); - if (value != NULL) - gconf_value_free (value); - - gconf_client_notify_add (xkb_gconf_client, - GSWITCHIT_KBD_CONFIG_KEY_MODEL, - (GConfClientNotifyFunc) model_key_changed, - dialog, NULL, NULL); + GConfValue *value; + + value = gconf_client_get (xkb_gconf_client, + GKBD_KEYBOARD_CONFIG_KEY_MODEL, NULL); + set_model_text (WID ("xkb_model"), 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); } static void cleanup_xkb_tabs (GladeXML * dialog) { - gswitchit_kbd_config_term (&initial_config); - g_object_unref (G_OBJECT (config_registry)); - config_registry = NULL; - g_object_unref (G_OBJECT (engine)); - engine = NULL; - g_object_unref (G_OBJECT (xkb_gconf_client)); - xkb_gconf_client = NULL; + gkbd_keyboard_config_term (&initial_config); + g_object_unref (G_OBJECT (config_registry)); + config_registry = NULL; + g_object_unref (G_OBJECT (engine)); + engine = NULL; + g_object_unref (G_OBJECT (xkb_gconf_client)); + xkb_gconf_client = NULL; } static void reset_to_defaults (GtkWidget * button, GladeXML * dialog) { - GSwitchItKbdConfig empty_kbd_config; + GkbdKeyboardConfig empty_kbd_config; - gswitchit_kbd_config_init (&empty_kbd_config, xkb_gconf_client, engine); - gswitchit_kbd_config_save_to_gconf_backup (&empty_kbd_config); - gswitchit_kbd_config_save_to_gconf (&empty_kbd_config); - gswitchit_kbd_config_term (&empty_kbd_config); + gkbd_keyboard_config_init (&empty_kbd_config, xkb_gconf_client, + engine); + gkbd_keyboard_config_save_to_gconf_backup (&empty_kbd_config); + gkbd_keyboard_config_save_to_gconf (&empty_kbd_config); + gkbd_keyboard_config_term (&empty_kbd_config); - /* all the rest is g-s-d's business */ + /* all the rest is g-s-d's business */ } static void -chk_separate_group_per_window_toggled (GConfPropertyEditor *peditor, - const gchar *key, - const GConfValue *value, - GladeXML* dialog) +chk_separate_group_per_window_toggled (GConfPropertyEditor * peditor, + const gchar * key, + const GConfValue * value, + GladeXML * dialog) { - xkb_layouts_enable_disable_default (dialog, value && gconf_value_get_bool (value)); + xkb_layouts_enable_disable_default (dialog, value + && + gconf_value_get_bool (value)); } void setup_xkb_tabs (GladeXML * dialog, GConfChangeSet * changeset) { - GObject * peditor; - xkb_gconf_client = gconf_client_get_default (); + GObject *peditor; + xkb_gconf_client = gconf_client_get_default (); - engine = xkl_engine_get_instance (GDK_DISPLAY ()); - config_registry = xkl_config_registry_get_instance (engine); - xkl_config_registry_load (config_registry); + engine = xkl_engine_get_instance (GDK_DISPLAY ()); + config_registry = xkl_config_registry_get_instance (engine); + xkl_config_registry_load (config_registry); - gswitchit_kbd_config_init (&initial_config, xkb_gconf_client, engine); - gswitchit_kbd_config_load_from_x_initial (&initial_config); + gkbd_keyboard_config_init (&initial_config, xkb_gconf_client, + engine); + gkbd_keyboard_config_load_from_x_initial (&initial_config, NULL); - setup_model_entry (dialog); + setup_model_entry (dialog); - peditor = gconf_peditor_new_boolean - (changeset, (gchar *) GSWITCHIT_CONFIG_KEY_GROUP_PER_WINDOW, - WID ("chk_separate_group_per_window"), NULL); + peditor = gconf_peditor_new_boolean + (changeset, (gchar *) GKBD_DESKTOP_CONFIG_KEY_GROUP_PER_WINDOW, + WID ("chk_separate_group_per_window"), NULL); - g_signal_connect (peditor, "value-changed", (GCallback)chk_separate_group_per_window_toggled , dialog); + g_signal_connect (peditor, "value-changed", + (GCallback) + chk_separate_group_per_window_toggled, dialog); /* tab 2 */ - /*fill_available_layouts_tree (dialog);*/ - xkb_layouts_prepare_selected_tree (dialog, changeset); - xkb_layouts_fill_selected_tree (dialog); + /*fill_available_layouts_tree (dialog); */ + xkb_layouts_prepare_selected_tree (dialog, changeset); + xkb_layouts_fill_selected_tree (dialog); /* tab 3 */ - xkb_options_load_options (dialog); - - xkb_layouts_register_buttons_handlers (dialog); - g_signal_connect (G_OBJECT (WID ("xkb_reset_to_defaults")), "clicked", - G_CALLBACK (reset_to_defaults), dialog); - - g_signal_connect_swapped (G_OBJECT (WID ("xkb_model_pick")), "clicked", - G_CALLBACK (choose_model), dialog); - - xkb_layouts_register_gconf_listener (dialog); - xkb_options_register_gconf_listener (dialog); - - g_signal_connect (G_OBJECT (WID ("keyboard_dialog")), - "destroy", G_CALLBACK (cleanup_xkb_tabs), dialog); - - enable_disable_restoring (dialog); - xkb_layouts_enable_disable_default (dialog, - gconf_client_get_bool (xkb_gconf_client, - GSWITCHIT_CONFIG_KEY_GROUP_PER_WINDOW, - NULL)); + xkb_options_load_options (dialog); + + xkb_layouts_register_buttons_handlers (dialog); + g_signal_connect (G_OBJECT (WID ("xkb_reset_to_defaults")), + "clicked", G_CALLBACK (reset_to_defaults), + dialog); + + g_signal_connect_swapped (G_OBJECT (WID ("xkb_model_pick")), + "clicked", G_CALLBACK (choose_model), + dialog); + + xkb_layouts_register_gconf_listener (dialog); + xkb_options_register_gconf_listener (dialog); + + g_signal_connect (G_OBJECT (WID ("keyboard_dialog")), + "destroy", G_CALLBACK (cleanup_xkb_tabs), + dialog); + + enable_disable_restoring (dialog); + xkb_layouts_enable_disable_default (dialog, + gconf_client_get_bool + (xkb_gconf_client, + GKBD_DESKTOP_CONFIG_KEY_GROUP_PER_WINDOW, + NULL)); } void enable_disable_restoring (GladeXML * dialog) { - GSwitchItKbdConfig gswic; - gboolean enable; + GkbdKeyboardConfig gswic; + gboolean enable; - gswitchit_kbd_config_init (&gswic, xkb_gconf_client, engine); - gswitchit_kbd_config_load_from_gconf (&gswic, NULL); + gkbd_keyboard_config_init (&gswic, xkb_gconf_client, engine); + gkbd_keyboard_config_load_from_gconf (&gswic, NULL); - enable = !gswitchit_kbd_config_equals (&gswic, &initial_config); + enable = !gkbd_keyboard_config_equals (&gswic, &initial_config); - gswitchit_kbd_config_term (&gswic); - gtk_widget_set_sensitive (WID ("xkb_reset_to_defaults"), enable); + gkbd_keyboard_config_term (&gswic); + gtk_widget_set_sensitive (WID ("xkb_reset_to_defaults"), enable); } diff --git a/capplets/keyboard/gnome-keyboard-properties-xkb.h b/capplets/keyboard/gnome-keyboard-properties-xkb.h index 2ec104d3e..052cb0135 100644 --- a/capplets/keyboard/gnome-keyboard-properties-xkb.h +++ b/capplets/keyboard/gnome-keyboard-properties-xkb.h @@ -24,29 +24,23 @@ #ifndef __GNOME_KEYBOARD_PROPERTY_XKB_H #define __GNOME_KEYBOARD_PROPERTY_XKB_H -#include <libxklavier/xklavier.h> #include <gconf/gconf-client.h> -#include "libgswitchit/gswitchit-config.h" +#include "libgnomekbd/gkbd-keyboard-config.h" G_BEGIN_DECLS - #define SEL_LAYOUT_TREE_COL_DESCRIPTION 0 #define SEL_LAYOUT_TREE_COL_DEFAULT 1 #define SEL_LAYOUT_TREE_COL_ID 2 - #define AVAIL_LAYOUT_TREE_COL_DESCRIPTION 0 #define AVAIL_LAYOUT_TREE_COL_ID 1 - #define CWID(s) glade_xml_get_widget (chooser_dialog, s) - extern XklEngine *engine; extern XklConfigRegistry *config_registry; extern GConfClient *xkb_gconf_client; -extern GSwitchItKbdConfig initial_config; +extern GkbdKeyboardConfig initial_config; -extern void setup_xkb_tabs (GladeXML * dialog, - GConfChangeSet * changeset); +extern void setup_xkb_tabs (GladeXML * dialog, GConfChangeSet * changeset); extern void xkb_layouts_fill_available_tree (GladeXML * dialog); @@ -64,8 +58,8 @@ extern void xkb_layouts_register_gconf_listener (GladeXML * dialog); extern void xkb_options_register_gconf_listener (GladeXML * dialog); -extern void xkb_layouts_prepare_selected_tree (GladeXML * dialog, - GConfChangeSet * changeset); +extern void xkb_layouts_prepare_selected_tree (GladeXML * dialog, + GConfChangeSet * changeset); extern void xkb_options_prepare_selected_tree (GladeXML * dialog); @@ -85,23 +79,24 @@ extern void choose_model (GladeXML * dialog); extern void xkb_layout_choose (GladeXML * dialog); -extern void xkb_layouts_enable_disable_default (GladeXML * dialog, - gboolean enable); +extern void xkb_layouts_enable_disable_default (GladeXML * dialog, + gboolean enable); extern GSList *xkb_layouts_get_selected_list (void); extern GSList *xkb_options_get_selected_list (void); #define xkb_layouts_set_selected_list(list) \ gconf_client_set_list (gconf_client_get_default (), \ - GSWITCHIT_KBD_CONFIG_KEY_LAYOUTS, \ + GKBD_KEYBOARD_CONFIG_KEY_LAYOUTS, \ GCONF_VALUE_STRING, (list), NULL) #define xkb_options_set_selected_list(list) \ gconf_client_set_list (gconf_client_get_default (), \ - GSWITCHIT_KBD_CONFIG_KEY_OPTIONS, \ + GKBD_KEYBOARD_CONFIG_KEY_OPTIONS, \ GCONF_VALUE_STRING, (list), NULL) -extern GtkWidget * xkb_layout_preview_create_widget (GladeXML * chooser_dialog); +extern GtkWidget *xkb_layout_preview_create_widget (GladeXML * + chooser_dialog); extern void xkb_layout_preview_update (GladeXML * chooser_dialog); diff --git a/capplets/keyboard/gnome-keyboard-properties-xkblt.c b/capplets/keyboard/gnome-keyboard-properties-xkblt.c index e7599b4b6..714691bc3 100644 --- a/capplets/keyboard/gnome-keyboard-properties-xkblt.c +++ b/capplets/keyboard/gnome-keyboard-properties-xkblt.c @@ -29,17 +29,16 @@ #include <gconf/gconf-client.h> #include <glade/glade.h> -#include "libgswitchit/gswitchit-config.h" -#include "libgswitchit/gswitchit-util.h" - #include "capplet-util.h" #include "gconf-property-editor.h" #include "activate-settings-daemon.h" #include "capplet-stock-icons.h" #include <../accessibility/keyboard/accessibility-keyboard.h> +#include <libgnomekbd/gkbd-desktop-config.h> +#include <libgnomekbd/gkbd-util.h> + #include "gnome-keyboard-properties-xkb.h" -#include "libkbdraw/keyboard-drawing.h" #define GROUP_SWITCHERS_GROUP "grp" #define DEFAULT_GROUP_SWITCH "grp:alts_toggle" @@ -59,587 +58,643 @@ 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); - } + while (list != NULL) { + GSList *p = list; + list = list->next; + g_free (p->data); + g_slist_free_1 (p); + } } GSList * xkb_layouts_get_selected_list (void) { - GSList *retval; + GSList *retval; - retval = gconf_client_get_list (xkb_gconf_client, - GSWITCHIT_KBD_CONFIG_KEY_LAYOUTS, - GCONF_VALUE_STRING, - NULL); - if (retval == NULL) - { - GSList *cur_layout; + retval = gconf_client_get_list (xkb_gconf_client, + GKBD_KEYBOARD_CONFIG_KEY_LAYOUTS, + GCONF_VALUE_STRING, NULL); + if (retval == NULL) { + GSList *cur_layout; - for (cur_layout = initial_config.layouts; cur_layout != NULL; cur_layout = cur_layout->next) - retval = g_slist_prepend (retval, g_strdup (cur_layout->data)); + 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_slist_reverse (retval); + } - return retval; + return retval; } static void save_default_group (int default_group) { - if (default_group != gconf_client_get_int (xkb_gconf_client, - GSWITCHIT_CONFIG_KEY_DEFAULT_GROUP, - NULL)) - gconf_client_set_int (xkb_gconf_client, - GSWITCHIT_CONFIG_KEY_DEFAULT_GROUP, - default_group, - NULL); + if (default_group != gconf_client_get_int (xkb_gconf_client, + GKBD_DESKTOP_CONFIG_KEY_DEFAULT_GROUP, + NULL)) + gconf_client_set_int (xkb_gconf_client, + GKBD_DESKTOP_CONFIG_KEY_DEFAULT_GROUP, + default_group, NULL); } static void -def_group_in_ui_changed (GtkCellRendererToggle *cell_renderer, - gchar *path, - GladeXML * dialog) +def_group_in_ui_changed (GtkCellRendererToggle * cell_renderer, + gchar * path, GladeXML * dialog) { - GtkTreePath *chpath = gtk_tree_path_new_from_string (path); - int new_default_group = -1; - gboolean previously_selected = gtk_cell_renderer_toggle_get_active (cell_renderer); - - if (!previously_selected) /* prev state - non-selected! */ - { - int *indices = gtk_tree_path_get_indices (chpath); - new_default_group = indices[0]; - } - - save_default_group (new_default_group); - gtk_tree_path_free (chpath); + GtkTreePath *chpath = gtk_tree_path_new_from_string (path); + int new_default_group = -1; + gboolean previously_selected = + gtk_cell_renderer_toggle_get_active (cell_renderer); + + if (!previously_selected) { /* prev state - non-selected! */ + int *indices = gtk_tree_path_get_indices (chpath); + new_default_group = indices[0]; + } + + save_default_group (new_default_group); + gtk_tree_path_free (chpath); } static void def_group_in_gconf_changed (GConfClient * client, - guint cnxn_id, - GConfEntry * entry, GladeXML* dialog) + guint cnxn_id, + GConfEntry * entry, GladeXML * dialog) { - GConfValue *value = gconf_entry_get_value (entry); - - if (value->type == GCONF_VALUE_INT) - { - GtkWidget* tree_view = WID ("xkb_layouts_selected"); - GtkTreeModel *model = GTK_TREE_MODEL (gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view))); - GtkTreeIter iter; - int counter = 0; - default_group = gconf_value_get_int (value); - if (gtk_tree_model_get_iter_first (model, &iter)) - { - do - { - gboolean cur_val; - gtk_tree_model_get (model, &iter, - SEL_LAYOUT_TREE_COL_DEFAULT, &cur_val, - -1); - if (cur_val != ( counter == default_group)) - gtk_list_store_set (GTK_LIST_STORE (model), &iter, - SEL_LAYOUT_TREE_COL_DEFAULT, counter == default_group, - -1); - counter++; - } - while (gtk_tree_model_iter_next (model, &iter)); - } - } + GConfValue *value = gconf_entry_get_value (entry); + + if (value->type == GCONF_VALUE_INT) { + GtkWidget *tree_view = WID ("xkb_layouts_selected"); + GtkTreeModel *model = + GTK_TREE_MODEL (gtk_tree_view_get_model + (GTK_TREE_VIEW (tree_view))); + GtkTreeIter iter; + int counter = 0; + default_group = gconf_value_get_int (value); + if (gtk_tree_model_get_iter_first (model, &iter)) { + do { + gboolean cur_val; + gtk_tree_model_get (model, &iter, + SEL_LAYOUT_TREE_COL_DEFAULT, + &cur_val, -1); + if (cur_val != (counter == default_group)) + gtk_list_store_set (GTK_LIST_STORE + (model), &iter, + SEL_LAYOUT_TREE_COL_DEFAULT, + counter == + default_group, + -1); + counter++; + } + while (gtk_tree_model_iter_next (model, &iter)); + } + } } static void add_variant_to_available_layouts_tree (XklConfigRegistry * config_registry, - XklConfigItem * config_item, - GladeXML * chooser_dialog) + XklConfigItem * config_item, + GladeXML * chooser_dialog) { - GtkWidget *layouts_tree = CWID ("xkb_layouts_available"); - GtkTreeIter iter; - GtkTreeStore *tree_store = - GTK_TREE_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (layouts_tree))); - const gchar *full_layout_name = gswitchit_kbd_config_merge_items (current1st_level_id, - config_item->name); - char *utf_variant_name = xci_desc_to_utf8 (config_item); - - gtk_tree_store_append (tree_store, &iter, ¤t1st_level_iter); - gtk_tree_store_set (tree_store, &iter, - AVAIL_LAYOUT_TREE_COL_DESCRIPTION, utf_variant_name, - AVAIL_LAYOUT_TREE_COL_ID, full_layout_name, -1); - g_free (utf_variant_name); + GtkWidget *layouts_tree = CWID ("xkb_layouts_available"); + GtkTreeIter iter; + GtkTreeStore *tree_store = + GTK_TREE_STORE (gtk_tree_view_get_model + (GTK_TREE_VIEW (layouts_tree))); + const gchar *full_layout_name = + gkbd_keyboard_config_merge_items (current1st_level_id, + config_item->name); + char *utf_variant_name = xci_desc_to_utf8 (config_item); + + gtk_tree_store_append (tree_store, &iter, ¤t1st_level_iter); + gtk_tree_store_set (tree_store, &iter, + AVAIL_LAYOUT_TREE_COL_DESCRIPTION, + utf_variant_name, AVAIL_LAYOUT_TREE_COL_ID, + full_layout_name, -1); + g_free (utf_variant_name); } static void add_layout_to_available_layouts_tree (XklConfigRegistry * config_registry, - XklConfigItem * config_item, - GladeXML * chooser_dialog) + XklConfigItem * config_item, + GladeXML * chooser_dialog) { - GtkWidget *layouts_tree = CWID ("xkb_layouts_available"); - GtkTreeStore *tree_store = - GTK_TREE_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (layouts_tree))); - char *utf_layout_name = xci_desc_to_utf8 (config_item); - - gtk_tree_store_append (tree_store, ¤t1st_level_iter, NULL); - gtk_tree_store_set (tree_store, ¤t1st_level_iter, - AVAIL_LAYOUT_TREE_COL_DESCRIPTION, utf_layout_name, - AVAIL_LAYOUT_TREE_COL_ID, config_item->name, -1); - g_free (utf_layout_name); - - current1st_level_id = config_item->name; - - xkl_config_registry_foreach_layout_variant (config_registry, config_item->name, - (ConfigItemProcessFunc)add_variant_to_available_layouts_tree, - chooser_dialog); + GtkWidget *layouts_tree = CWID ("xkb_layouts_available"); + GtkTreeStore *tree_store = + GTK_TREE_STORE (gtk_tree_view_get_model + (GTK_TREE_VIEW (layouts_tree))); + char *utf_layout_name = xci_desc_to_utf8 (config_item); + + gtk_tree_store_append (tree_store, ¤t1st_level_iter, NULL); + gtk_tree_store_set (tree_store, ¤t1st_level_iter, + AVAIL_LAYOUT_TREE_COL_DESCRIPTION, + utf_layout_name, AVAIL_LAYOUT_TREE_COL_ID, + config_item->name, -1); + g_free (utf_layout_name); + + current1st_level_id = config_item->name; + + xkl_config_registry_foreach_layout_variant (config_registry, + config_item->name, + (ConfigItemProcessFunc) + add_variant_to_available_layouts_tree, + chooser_dialog); } static void xkb_layouts_enable_disable_buttons (GladeXML * dialog) { - GtkWidget *add_layout_btn = WID ("xkb_layouts_add"); - GtkWidget *del_layout_btn = WID ("xkb_layouts_remove"); - GtkWidget *up_layout_btn = WID ("xkb_layouts_up"); - GtkWidget *dn_layout_btn = WID ("xkb_layouts_down"); - GtkWidget *selected_layouts_tree = WID ("xkb_layouts_selected"); - - GtkTreeSelection *s_selection = - gtk_tree_view_get_selection (GTK_TREE_VIEW (selected_layouts_tree)); - const int n_selected_selected_layouts = - gtk_tree_selection_count_selected_rows (s_selection); - gboolean can_move_up = FALSE; - gboolean can_move_dn = FALSE; - GtkTreeIter iter; - GtkTreeModel *selected_layouts_model = gtk_tree_view_get_model - (GTK_TREE_VIEW (selected_layouts_tree)); - const int n_selected_layouts = - gtk_tree_model_iter_n_children (selected_layouts_model, - NULL); - - if (disable_buttons_sensibility_update) - return; - - gtk_widget_set_sensitive (add_layout_btn, - (n_selected_layouts < max_selected_layouts || - max_selected_layouts == 0)); - gtk_widget_set_sensitive (del_layout_btn, n_selected_selected_layouts > 0); - - if (gtk_tree_selection_get_selected (s_selection, NULL, &iter)) - { - GtkTreePath *path = gtk_tree_model_get_path (selected_layouts_model, - &iter); - if (path != NULL) - { - int *indices = gtk_tree_path_get_indices (path); - int idx = indices[0]; - can_move_up = idx > 0; - can_move_dn = idx < (n_selected_layouts - 1); - gtk_tree_path_free (path); + GtkWidget *add_layout_btn = WID ("xkb_layouts_add"); + GtkWidget *del_layout_btn = WID ("xkb_layouts_remove"); + GtkWidget *up_layout_btn = WID ("xkb_layouts_up"); + GtkWidget *dn_layout_btn = WID ("xkb_layouts_down"); + GtkWidget *selected_layouts_tree = WID ("xkb_layouts_selected"); + + GtkTreeSelection *s_selection = + gtk_tree_view_get_selection (GTK_TREE_VIEW + (selected_layouts_tree)); + const int n_selected_selected_layouts = + gtk_tree_selection_count_selected_rows (s_selection); + gboolean can_move_up = FALSE; + gboolean can_move_dn = FALSE; + GtkTreeIter iter; + GtkTreeModel *selected_layouts_model = gtk_tree_view_get_model + (GTK_TREE_VIEW (selected_layouts_tree)); + const int n_selected_layouts = + gtk_tree_model_iter_n_children (selected_layouts_model, + NULL); + + if (disable_buttons_sensibility_update) + return; + + gtk_widget_set_sensitive (add_layout_btn, + (n_selected_layouts < + max_selected_layouts + || max_selected_layouts == 0)); + gtk_widget_set_sensitive (del_layout_btn, + n_selected_selected_layouts > 0); + + if (gtk_tree_selection_get_selected (s_selection, NULL, &iter)) { + GtkTreePath *path = + gtk_tree_model_get_path (selected_layouts_model, + &iter); + if (path != NULL) { + int *indices = gtk_tree_path_get_indices (path); + int idx = indices[0]; + can_move_up = idx > 0; + can_move_dn = idx < (n_selected_layouts - 1); + gtk_tree_path_free (path); + } } - } - gtk_widget_set_sensitive (up_layout_btn, can_move_up); - gtk_widget_set_sensitive (dn_layout_btn, can_move_dn); + gtk_widget_set_sensitive (up_layout_btn, can_move_up); + gtk_widget_set_sensitive (dn_layout_btn, can_move_dn); } static void xkb_layout_chooser_enable_disable_buttons (GladeXML * chooser_dialog) { - GtkWidget *available_layouts_tree = CWID ("xkb_layouts_available"); - GtkTreeSelection *selection = - gtk_tree_view_get_selection (GTK_TREE_VIEW (available_layouts_tree)); - const int n_selected_available_layouts = - gtk_tree_selection_count_selected_rows (selection); - - gtk_dialog_set_response_sensitive (GTK_DIALOG (CWID ("xkb_layout_chooser")), - GTK_RESPONSE_OK, n_selected_available_layouts > 0); + GtkWidget *available_layouts_tree = CWID ("xkb_layouts_available"); + GtkTreeSelection *selection = + gtk_tree_view_get_selection (GTK_TREE_VIEW + (available_layouts_tree)); + const int n_selected_available_layouts = + gtk_tree_selection_count_selected_rows (selection); + + gtk_dialog_set_response_sensitive (GTK_DIALOG + (CWID ("xkb_layout_chooser")), + GTK_RESPONSE_OK, + n_selected_available_layouts > + 0); } -void xkb_layouts_enable_disable_default (GladeXML * dialog, - gboolean enable) +void +xkb_layouts_enable_disable_default (GladeXML * dialog, gboolean enable) { - GValue val = {0}; - g_value_init (&val, G_TYPE_BOOLEAN); - g_value_set_boolean (&val, enable); - g_object_set_property (G_OBJECT (toggle_renderer), "activatable", &val); + GValue val = { 0 }; + g_value_init (&val, G_TYPE_BOOLEAN); + g_value_set_boolean (&val, enable); + g_object_set_property (G_OBJECT (toggle_renderer), "activatable", + &val); } void -xkb_layouts_prepare_selected_tree (GladeXML * dialog, GConfChangeSet * changeset) +xkb_layouts_prepare_selected_tree (GladeXML * dialog, + GConfChangeSet * changeset) { - GtkListStore *list_store = - gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING); - GtkWidget *tree_view = WID ("xkb_layouts_selected"); - GtkTreeViewColumn * desc_column, * def_column; - GtkTreeSelection *selection; - - text_renderer = GTK_CELL_RENDERER (gtk_cell_renderer_text_new ()); - toggle_renderer = GTK_CELL_RENDERER (gtk_cell_renderer_toggle_new ()); - - desc_column = gtk_tree_view_column_new_with_attributes (_("Layout"), - text_renderer, - "text", SEL_LAYOUT_TREE_COL_DESCRIPTION, - NULL); - def_column = gtk_tree_view_column_new_with_attributes (_("Default"), - toggle_renderer, - "active", SEL_LAYOUT_TREE_COL_DEFAULT, - NULL); - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); - - gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), - GTK_TREE_MODEL (list_store)); - - gtk_tree_view_column_set_sizing (desc_column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); - gtk_tree_view_column_set_sizing (def_column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); - gtk_tree_view_column_set_resizable (desc_column, TRUE); - gtk_tree_view_column_set_resizable (def_column, TRUE); - - gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), desc_column); - gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), def_column); - - g_signal_connect_swapped (G_OBJECT (selection), "changed", - G_CALLBACK - (xkb_layouts_enable_disable_buttons), dialog); - max_selected_layouts = xkl_engine_get_max_num_groups (engine); - - gconf_client_notify_add (xkb_gconf_client, - GSWITCHIT_CONFIG_KEY_DEFAULT_GROUP, - (GConfClientNotifyFunc)def_group_in_gconf_changed, - dialog, - NULL, - NULL); - g_signal_connect (G_OBJECT (toggle_renderer), "toggled", - G_CALLBACK (def_group_in_ui_changed), dialog); + GtkListStore *list_store = + gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_BOOLEAN, + G_TYPE_STRING); + GtkWidget *tree_view = WID ("xkb_layouts_selected"); + GtkTreeViewColumn *desc_column, *def_column; + GtkTreeSelection *selection; + + text_renderer = GTK_CELL_RENDERER (gtk_cell_renderer_text_new ()); + toggle_renderer = + GTK_CELL_RENDERER (gtk_cell_renderer_toggle_new ()); + + desc_column = + gtk_tree_view_column_new_with_attributes (_("Layout"), + text_renderer, + "text", + SEL_LAYOUT_TREE_COL_DESCRIPTION, + NULL); + def_column = + gtk_tree_view_column_new_with_attributes (_("Default"), + toggle_renderer, + "active", + SEL_LAYOUT_TREE_COL_DEFAULT, + NULL); + selection = + gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); + + gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), + GTK_TREE_MODEL (list_store)); + + gtk_tree_view_column_set_sizing (desc_column, + GTK_TREE_VIEW_COLUMN_AUTOSIZE); + gtk_tree_view_column_set_sizing (def_column, + GTK_TREE_VIEW_COLUMN_AUTOSIZE); + gtk_tree_view_column_set_resizable (desc_column, TRUE); + gtk_tree_view_column_set_resizable (def_column, TRUE); + + gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), + desc_column); + gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), + def_column); + + g_signal_connect_swapped (G_OBJECT (selection), "changed", + G_CALLBACK + (xkb_layouts_enable_disable_buttons), + dialog); + max_selected_layouts = xkl_engine_get_max_num_groups (engine); + + gconf_client_notify_add (xkb_gconf_client, + GKBD_DESKTOP_CONFIG_KEY_DEFAULT_GROUP, + (GConfClientNotifyFunc) + def_group_in_gconf_changed, dialog, NULL, + NULL); + g_signal_connect (G_OBJECT (toggle_renderer), "toggled", + G_CALLBACK (def_group_in_ui_changed), dialog); } static void xkb_layout_chooser_selection_changed (GladeXML * chooser_dialog) { - xkb_layout_preview_update (chooser_dialog); - xkb_layout_chooser_enable_disable_buttons (chooser_dialog); + xkb_layout_preview_update (chooser_dialog); + xkb_layout_chooser_enable_disable_buttons (chooser_dialog); } void xkb_layouts_fill_selected_tree (GladeXML * dialog) { - GConfEntry *gce; - GSList *layouts = xkb_layouts_get_selected_list (); - GSList *cur_layout; - GtkListStore *list_store = - GTK_LIST_STORE (gtk_tree_view_get_model - (GTK_TREE_VIEW (WID ("xkb_layouts_selected")))); - - /* temporarily disable the buttons' status update */ - disable_buttons_sensibility_update = TRUE; - - gtk_list_store_clear (list_store); - - for (cur_layout = layouts; cur_layout != NULL; cur_layout = cur_layout->next) - { - GtkTreeIter iter; - char *l, *sl, *v, *sv; - char *v1, *utf_visible; - const char *visible = (char *) cur_layout->data; - gtk_list_store_append (list_store, &iter); - if (gswitchit_kbd_config_get_descriptions (config_registry, visible, &sl, &l, &sv, &v)) - visible = gswitchit_kbd_config_format_full_layout (l, v); - v1 = g_strdup (visible); - utf_visible = g_locale_to_utf8 (g_strstrip (v1), -1, NULL, NULL, NULL); - gtk_list_store_set (list_store, &iter, - SEL_LAYOUT_TREE_COL_DESCRIPTION, utf_visible, - SEL_LAYOUT_TREE_COL_DEFAULT, FALSE, - SEL_LAYOUT_TREE_COL_ID, cur_layout->data, -1); - g_free (utf_visible); - g_free (v1); - } - - clear_xkb_elements_list (layouts); - - /* enable the buttons' status update */ - disable_buttons_sensibility_update = FALSE; - - if (idx2select != -1) - { - GtkTreeSelection *selection = - gtk_tree_view_get_selection ((GTK_TREE_VIEW - (WID ("xkb_layouts_selected")))); - GtkTreePath *path = gtk_tree_path_new_from_indices (idx2select, -1); - gtk_tree_selection_select_path (selection, path); - gtk_tree_path_free (path); - idx2select = -1; - } - else - { - /* if there is nothing to select - just enable/disable the buttons, - otherwise it would be done by the selection change */ - xkb_layouts_enable_disable_buttons (dialog); - } - - gce = gconf_client_get_entry (xkb_gconf_client, - GSWITCHIT_CONFIG_KEY_DEFAULT_GROUP, - NULL, - TRUE, - NULL); - def_group_in_gconf_changed (xkb_gconf_client, -1, gce, dialog); + GConfEntry *gce; + GSList *layouts = xkb_layouts_get_selected_list (); + GSList *cur_layout; + GtkListStore *list_store = + GTK_LIST_STORE (gtk_tree_view_get_model + (GTK_TREE_VIEW + (WID ("xkb_layouts_selected")))); + + /* temporarily disable the buttons' status update */ + disable_buttons_sensibility_update = TRUE; + + gtk_list_store_clear (list_store); + + for (cur_layout = layouts; cur_layout != NULL; + cur_layout = cur_layout->next) { + GtkTreeIter iter; + char *l, *sl, *v, *sv; + char *v1, *utf_visible; + const char *visible = (char *) cur_layout->data; + gtk_list_store_append (list_store, &iter); + if (gkbd_keyboard_config_get_descriptions + (config_registry, visible, &sl, &l, &sv, &v)) + visible = + gkbd_keyboard_config_format_full_layout (l, v); + v1 = g_strdup (visible); + utf_visible = + g_locale_to_utf8 (g_strstrip (v1), -1, NULL, NULL, + NULL); + gtk_list_store_set (list_store, &iter, + SEL_LAYOUT_TREE_COL_DESCRIPTION, + utf_visible, + SEL_LAYOUT_TREE_COL_DEFAULT, FALSE, + SEL_LAYOUT_TREE_COL_ID, + cur_layout->data, -1); + g_free (utf_visible); + g_free (v1); + } + + clear_xkb_elements_list (layouts); + + /* enable the buttons' status update */ + disable_buttons_sensibility_update = FALSE; + + if (idx2select != -1) { + GtkTreeSelection *selection = + gtk_tree_view_get_selection ((GTK_TREE_VIEW + (WID + ("xkb_layouts_selected")))); + GtkTreePath *path = + gtk_tree_path_new_from_indices (idx2select, -1); + gtk_tree_selection_select_path (selection, path); + gtk_tree_path_free (path); + idx2select = -1; + } else { + /* if there is nothing to select - just enable/disable the buttons, + otherwise it would be done by the selection change */ + xkb_layouts_enable_disable_buttons (dialog); + } + + gce = gconf_client_get_entry (xkb_gconf_client, + GKBD_DESKTOP_CONFIG_KEY_DEFAULT_GROUP, + NULL, TRUE, NULL); + def_group_in_gconf_changed (xkb_gconf_client, -1, gce, dialog); } void sort_tree_content (GtkWidget * tree_view) { - GtkTreeModel *tree_model = - gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)); - GtkTreeModel *sorted_tree_model; - /* replace the store with the sorted version */ - sorted_tree_model = gtk_tree_model_sort_new_with_model (tree_model); - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE - (sorted_tree_model), 0, - GTK_SORT_ASCENDING); - gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), sorted_tree_model); + GtkTreeModel *tree_model = + gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)); + GtkTreeModel *sorted_tree_model; + /* replace the store with the sorted version */ + sorted_tree_model = + gtk_tree_model_sort_new_with_model (tree_model); + gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE + (sorted_tree_model), 0, + GTK_SORT_ASCENDING); + gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), + sorted_tree_model); } void xkb_layouts_fill_available_tree (GladeXML * chooser_dialog) { - GtkTreeStore *tree_store = - gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_STRING); - GtkWidget *tree_view = CWID ("xkb_layouts_available"); - GtkCellRenderer *renderer = - GTK_CELL_RENDERER (gtk_cell_renderer_text_new ()); - GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes (NULL, - renderer, - "text", - AVAIL_LAYOUT_TREE_COL_DESCRIPTION, - NULL); - GtkTreeSelection *selection = - gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); - - gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), - GTK_TREE_MODEL (tree_store)); - gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); - - xkl_config_registry_foreach_layout (config_registry, (ConfigItemProcessFunc) - add_layout_to_available_layouts_tree, chooser_dialog); - - sort_tree_content (tree_view); - g_signal_connect_swapped (G_OBJECT (selection), "changed", - G_CALLBACK - (xkb_layout_chooser_selection_changed), chooser_dialog); + GtkTreeStore *tree_store = + gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_STRING); + GtkWidget *tree_view = CWID ("xkb_layouts_available"); + GtkCellRenderer *renderer = + GTK_CELL_RENDERER (gtk_cell_renderer_text_new ()); + GtkTreeViewColumn *column = + gtk_tree_view_column_new_with_attributes (NULL, + renderer, + "text", + AVAIL_LAYOUT_TREE_COL_DESCRIPTION, + NULL); + GtkTreeSelection *selection = + gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); + + gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), + GTK_TREE_MODEL (tree_store)); + gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); + + xkl_config_registry_foreach_layout (config_registry, + (ConfigItemProcessFunc) + add_layout_to_available_layouts_tree, + chooser_dialog); + + sort_tree_content (tree_view); + g_signal_connect_swapped (G_OBJECT (selection), "changed", + G_CALLBACK + (xkb_layout_chooser_selection_changed), + chooser_dialog); } static void add_selected_layout (GtkWidget * button, GladeXML * dialog) { - xkb_layout_choose (dialog); + xkb_layout_choose (dialog); } static void move_selected_layout (GladeXML * dialog, int offset) { - GtkTreeSelection *selection = - gtk_tree_view_get_selection (GTK_TREE_VIEW - (WID ("xkb_layouts_selected"))); - GtkTreeIter selected_iter; - GtkTreeModel *model; - if (gtk_tree_selection_get_selected (selection, &model, &selected_iter)) - { - GSList *layouts_list = xkb_layouts_get_selected_list (); - GtkTreePath *path = gtk_tree_model_get_path (model, - &selected_iter); - if (path != NULL) - { - int *indices = gtk_tree_path_get_indices (path); - int idx = indices[0]; - 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); - - if (offset == 0) - { - g_free (id); - if (default_group > idx) - save_default_group (default_group - 1); - else if (default_group == idx) - save_default_group (-1); - } - else - { - layouts_list = - g_slist_insert (layouts_list, id, idx + offset); - idx2select = idx + offset; - if (idx == default_group) - save_default_group (idx2select); - else if (idx2select == default_group) - save_default_group (idx); - } - - xkb_layouts_set_selected_list (layouts_list); - gtk_tree_path_free (path); + GtkTreeSelection *selection = + gtk_tree_view_get_selection (GTK_TREE_VIEW + (WID ("xkb_layouts_selected"))); + GtkTreeIter selected_iter; + GtkTreeModel *model; + if (gtk_tree_selection_get_selected + (selection, &model, &selected_iter)) { + GSList *layouts_list = xkb_layouts_get_selected_list (); + GtkTreePath *path = gtk_tree_model_get_path (model, + &selected_iter); + if (path != NULL) { + int *indices = gtk_tree_path_get_indices (path); + int idx = indices[0]; + 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); + + if (offset == 0) { + g_free (id); + if (default_group > idx) + save_default_group (default_group - + 1); + else if (default_group == idx) + save_default_group (-1); + } else { + layouts_list = + g_slist_insert (layouts_list, id, + idx + offset); + idx2select = idx + offset; + if (idx == default_group) + save_default_group (idx2select); + else if (idx2select == default_group) + save_default_group (idx); + } + + xkb_layouts_set_selected_list (layouts_list); + gtk_tree_path_free (path); + } + clear_xkb_elements_list (layouts_list); } - clear_xkb_elements_list (layouts_list); - } } static void remove_selected_layout (GtkWidget * button, GladeXML * dialog) { - move_selected_layout (dialog, 0); + move_selected_layout (dialog, 0); } static void up_selected_layout (GtkWidget * button, GladeXML * dialog) { - move_selected_layout (dialog, -1); + move_selected_layout (dialog, -1); } static void down_selected_layout (GtkWidget * button, GladeXML * dialog) { - move_selected_layout (dialog, +1); + move_selected_layout (dialog, +1); } void xkb_layouts_register_buttons_handlers (GladeXML * dialog) { - g_signal_connect (G_OBJECT (WID ("xkb_layouts_add")), "clicked", - G_CALLBACK (add_selected_layout), dialog); - g_signal_connect (G_OBJECT (WID ("xkb_layouts_remove")), "clicked", - G_CALLBACK (remove_selected_layout), dialog); - g_signal_connect (G_OBJECT (WID ("xkb_layouts_up")), "clicked", - G_CALLBACK (up_selected_layout), dialog); - g_signal_connect (G_OBJECT (WID ("xkb_layouts_down")), "clicked", - G_CALLBACK (down_selected_layout), dialog); + g_signal_connect (G_OBJECT (WID ("xkb_layouts_add")), "clicked", + G_CALLBACK (add_selected_layout), dialog); + g_signal_connect (G_OBJECT (WID ("xkb_layouts_remove")), "clicked", + G_CALLBACK (remove_selected_layout), dialog); + g_signal_connect (G_OBJECT (WID ("xkb_layouts_up")), "clicked", + G_CALLBACK (up_selected_layout), dialog); + g_signal_connect (G_OBJECT (WID ("xkb_layouts_down")), "clicked", + G_CALLBACK (down_selected_layout), dialog); } -static void -xkb_layout_chooser_response(GtkDialog *dialog, - gint response, - GladeXML *chooser_dialog) +static void +xkb_layout_chooser_response (GtkDialog * dialog, + gint response, GladeXML * chooser_dialog) { - GdkRectangle rect; - - if (response == GTK_RESPONSE_OK) - { - GtkTreeSelection *selection = - gtk_tree_view_get_selection (GTK_TREE_VIEW - (CWID ("xkb_layouts_available"))); - GtkTreeIter selected_iter; - GtkTreeModel *model; - if (gtk_tree_selection_get_selected (selection, &model, &selected_iter)) - { - gchar *id; - GSList *layouts_list = xkb_layouts_get_selected_list (); - gtk_tree_model_get (model, &selected_iter, - AVAIL_LAYOUT_TREE_COL_ID, &id, -1); - layouts_list = g_slist_append (layouts_list, id); - xkb_layouts_set_selected_list (layouts_list); - /* process default switcher */ - if (g_slist_length(layouts_list) >= 2) - { - GSList *options_list = xkb_options_get_selected_list (); - gboolean any_switcher = False; - GSList *option = options_list; - while (option != NULL) - { - char *g, *o; - if (gswitchit_kbd_config_split_items (option->data, &g, &o)) - { - if (!g_ascii_strcasecmp (g, GROUP_SWITCHERS_GROUP)) - { - any_switcher = True; - break; - } - } - option = option->next; - } - if (!any_switcher) - { - XklConfigItem ci; - g_snprintf(ci.name, XKL_MAX_CI_NAME_LENGTH, DEFAULT_GROUP_SWITCH ); - if (xkl_config_registry_find_option (config_registry, - GROUP_SWITCHERS_GROUP, - &ci)) - { - const gchar* id = gswitchit_kbd_config_merge_items (GROUP_SWITCHERS_GROUP, DEFAULT_GROUP_SWITCH); - options_list = g_slist_append (options_list, g_strdup (id)); - xkb_options_set_selected_list (options_list); - } - } - clear_xkb_elements_list (options_list); - } - clear_xkb_elements_list (layouts_list); - } - } - - gtk_window_get_position (GTK_WINDOW (dialog), &rect.x, &rect.y); - gtk_window_get_size (GTK_WINDOW (dialog), &rect.width, &rect.height); - gswitchit_preview_save_position (&rect); + GdkRectangle rect; + + if (response == GTK_RESPONSE_OK) { + GtkTreeSelection *selection = + gtk_tree_view_get_selection (GTK_TREE_VIEW + (CWID + ("xkb_layouts_available"))); + GtkTreeIter selected_iter; + GtkTreeModel *model; + if (gtk_tree_selection_get_selected + (selection, &model, &selected_iter)) { + gchar *id; + GSList *layouts_list = + xkb_layouts_get_selected_list (); + gtk_tree_model_get (model, &selected_iter, + AVAIL_LAYOUT_TREE_COL_ID, &id, + -1); + layouts_list = g_slist_append (layouts_list, id); + xkb_layouts_set_selected_list (layouts_list); + /* process default switcher */ + if (g_slist_length (layouts_list) >= 2) { + GSList *options_list = + xkb_options_get_selected_list (); + 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; + } + } + option = option->next; + } + if (!any_switcher) { + XklConfigItem ci; + g_snprintf (ci.name, + XKL_MAX_CI_NAME_LENGTH, + DEFAULT_GROUP_SWITCH); + if (xkl_config_registry_find_option + (config_registry, + GROUP_SWITCHERS_GROUP, &ci)) { + const gchar *id = + gkbd_keyboard_config_merge_items + (GROUP_SWITCHERS_GROUP, + DEFAULT_GROUP_SWITCH); + options_list = + g_slist_append + (options_list, + g_strdup (id)); + xkb_options_set_selected_list + (options_list); + } + } + clear_xkb_elements_list (options_list); + } + clear_xkb_elements_list (layouts_list); + } + } + + gtk_window_get_position (GTK_WINDOW (dialog), &rect.x, &rect.y); + gtk_window_get_size (GTK_WINDOW (dialog), &rect.width, + &rect.height); + gkbd_preview_save_position (&rect); } static void xkb_layouts_update_list (GConfClient * client, - guint cnxn_id, GConfEntry * entry, GladeXML * dialog) + guint cnxn_id, GConfEntry * entry, + GladeXML * dialog) { - xkb_layouts_fill_selected_tree (dialog); - enable_disable_restoring (dialog); + xkb_layouts_fill_selected_tree (dialog); + enable_disable_restoring (dialog); } void xkb_layouts_register_gconf_listener (GladeXML * dialog) { - gconf_client_notify_add (xkb_gconf_client, - GSWITCHIT_KBD_CONFIG_KEY_LAYOUTS, - (GConfClientNotifyFunc) - xkb_layouts_update_list, dialog, NULL, NULL); + gconf_client_notify_add (xkb_gconf_client, + GKBD_KEYBOARD_CONFIG_KEY_LAYOUTS, + (GConfClientNotifyFunc) + xkb_layouts_update_list, dialog, NULL, + NULL); } void xkb_layout_choose (GladeXML * dialog) { - GladeXML* chooser_dialog = glade_xml_new (GNOMECC_DATA_DIR "/interfaces/gnome-keyboard-properties.glade", "xkb_layout_chooser", NULL); - GtkWidget* chooser = CWID ( "xkb_layout_chooser"); - GtkWidget* kbdraw = NULL; - GtkWidget* toplevel = NULL; + GladeXML *chooser_dialog = + glade_xml_new (GNOMECC_DATA_DIR + "/interfaces/gnome-keyboard-properties.glade", + "xkb_layout_chooser", NULL); + GtkWidget *chooser = CWID ("xkb_layout_chooser"); + GtkWidget *kbdraw = NULL; + GtkWidget *toplevel = NULL; + + gtk_window_set_transient_for (GTK_WINDOW (chooser), + GTK_WINDOW (WID + ("keyboard_dialog"))); - gtk_window_set_transient_for (GTK_WINDOW (chooser), GTK_WINDOW (WID ("keyboard_dialog"))); + xkb_layouts_fill_available_tree (chooser_dialog); + xkb_layout_chooser_selection_changed (chooser_dialog); - xkb_layouts_fill_available_tree (chooser_dialog); - xkb_layout_chooser_selection_changed (chooser_dialog); - #ifdef HAVE_X11_EXTENSIONS_XKB_H - if (!strcmp (xkl_engine_get_backend_name (engine), "XKB")) - { - kbdraw = xkb_layout_preview_create_widget (chooser_dialog); - g_object_set_data (G_OBJECT (chooser), "kbdraw", kbdraw); - gtk_container_add (GTK_CONTAINER (CWID ("vboxPreview")), kbdraw); - gtk_widget_show_all (kbdraw); - } else + if (!strcmp (xkl_engine_get_backend_name (engine), "XKB")) { + kbdraw = xkb_layout_preview_create_widget (chooser_dialog); + g_object_set_data (G_OBJECT (chooser), "kbdraw", kbdraw); + gtk_container_add (GTK_CONTAINER (CWID ("vboxPreview")), + kbdraw); + gtk_widget_show_all (kbdraw); + } else #endif - { - gtk_widget_hide_all (CWID ("vboxPreview")); - } - - g_signal_connect (G_OBJECT (chooser), - "response", G_CALLBACK (xkb_layout_chooser_response), chooser_dialog); - - toplevel = gtk_widget_get_toplevel (chooser); - if (GTK_WIDGET_TOPLEVEL (toplevel)) - { - GdkRectangle *rect = gswitchit_preview_load_position (); - if (rect != NULL) - { - gtk_window_move (GTK_WINDOW (toplevel), rect->x, rect->y); - gtk_window_resize (GTK_WINDOW (toplevel), rect->width, rect->height); - g_free (rect); - } - } - - gtk_dialog_run (GTK_DIALOG (chooser)); - gtk_widget_destroy (chooser); + { + gtk_widget_hide_all (CWID ("vboxPreview")); + } + + g_signal_connect (G_OBJECT (chooser), + "response", + G_CALLBACK (xkb_layout_chooser_response), + chooser_dialog); + + toplevel = gtk_widget_get_toplevel (chooser); + if (GTK_WIDGET_TOPLEVEL (toplevel)) { + GdkRectangle *rect = gkbd_preview_load_position (); + if (rect != NULL) { + gtk_window_move (GTK_WINDOW (toplevel), rect->x, + rect->y); + gtk_window_resize (GTK_WINDOW (toplevel), + rect->width, rect->height); + g_free (rect); + } + } + + gtk_dialog_run (GTK_DIALOG (chooser)); + gtk_widget_destroy (chooser); } diff --git a/capplets/keyboard/gnome-keyboard-properties-xkbmc.c b/capplets/keyboard/gnome-keyboard-properties-xkbmc.c index a55c9bfc8..f0a3027fb 100644 --- a/capplets/keyboard/gnome-keyboard-properties-xkbmc.c +++ b/capplets/keyboard/gnome-keyboard-properties-xkbmc.c @@ -30,8 +30,6 @@ #include <gconf/gconf-client.h> #include <glade/glade.h> -#include "libgswitchit/gswitchit-config.h" - #include "capplet-util.h" #include "gconf-property-editor.h" #include "activate-settings-daemon.h" @@ -40,123 +38,145 @@ #include "gnome-keyboard-properties-xkb.h" -static gchar* current_model_name = NULL; +static gchar *current_model_name = NULL; static void add_model_to_list (XklConfigRegistry * config_registry, - XklConfigItem * config_item, - GtkTreeView * models_list) + XklConfigItem * config_item, GtkTreeView * models_list) { - GtkTreeIter iter; - GtkListStore * list_store = GTK_LIST_STORE (gtk_tree_view_get_model (models_list)); - char *utf_model_name = xci_desc_to_utf8 (config_item); - gtk_list_store_append( list_store, &iter ); - gtk_list_store_set( list_store, &iter, - 0, utf_model_name, - 1, config_item->name, -1 ); - - g_free (utf_model_name); + GtkTreeIter iter; + GtkListStore *list_store = + GTK_LIST_STORE (gtk_tree_view_get_model (models_list)); + char *utf_model_name = xci_desc_to_utf8 (config_item); + gtk_list_store_append (list_store, &iter); + gtk_list_store_set (list_store, &iter, + 0, utf_model_name, 1, config_item->name, -1); + + g_free (utf_model_name); } static void -xkb_model_chooser_change_sel (GtkTreeSelection* selection, - GladeXML* chooser_dialog) +xkb_model_chooser_change_sel (GtkTreeSelection * selection, + GladeXML * chooser_dialog) { - gboolean anysel = gtk_tree_selection_get_selected (selection, NULL, NULL); - gtk_dialog_set_response_sensitive (GTK_DIALOG (CWID ("xkb_model_chooser")), - GTK_RESPONSE_OK, anysel); + gboolean anysel = + gtk_tree_selection_get_selected (selection, NULL, NULL); + gtk_dialog_set_response_sensitive (GTK_DIALOG + (CWID ("xkb_model_chooser")), + GTK_RESPONSE_OK, anysel); } static void fill_models_list (GladeXML * chooser_dialog) { - GtkWidget* models_list = CWID( "models_list" ); - GtkTreeIter iter; - GtkTreePath *path; - GtkCellRenderer* renderer = gtk_cell_renderer_text_new (); - GtkTreeViewColumn* description_col = gtk_tree_view_column_new_with_attributes ( _("Models"), - renderer, - "text", 0, - NULL); - GtkListStore *list_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); - char *model_name; - - gtk_tree_view_column_set_visible (description_col, TRUE); - gtk_tree_view_append_column (GTK_TREE_VIEW (models_list), description_col); - - gtk_tree_view_set_model (GTK_TREE_VIEW (models_list), GTK_TREE_MODEL (list_store) ); - - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (list_store), - 0, GTK_SORT_ASCENDING); - - xkl_config_registry_foreach_model (config_registry, - (ConfigItemProcessFunc) add_model_to_list, - models_list); - - if (current_model_name != NULL) - { - if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (list_store), &iter)) - { - do - { - gtk_tree_model_get (GTK_TREE_MODEL (list_store), &iter, - 1, &model_name, -1); - if (!g_ascii_strcasecmp(model_name, current_model_name)) - { - gtk_tree_selection_select_iter (gtk_tree_view_get_selection (GTK_TREE_VIEW (models_list)), &iter); - path = gtk_tree_model_get_path (GTK_TREE_MODEL (list_store), &iter); - gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (models_list), - path, NULL, TRUE, 0.5, 0); - gtk_tree_path_free (path); - } - g_free (model_name); - } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (list_store), &iter)); - } - } - - g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (models_list))), - "changed", - G_CALLBACK (xkb_model_chooser_change_sel), - chooser_dialog); + GtkWidget *models_list = CWID ("models_list"); + GtkTreeIter iter; + GtkTreePath *path; + GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); + GtkTreeViewColumn *description_col = + gtk_tree_view_column_new_with_attributes (_("Models"), + renderer, + "text", 0, + NULL); + GtkListStore *list_store = + gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); + char *model_name; + + gtk_tree_view_column_set_visible (description_col, TRUE); + gtk_tree_view_append_column (GTK_TREE_VIEW (models_list), + description_col); + + gtk_tree_view_set_model (GTK_TREE_VIEW (models_list), + GTK_TREE_MODEL (list_store)); + + gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE + (list_store), 0, + GTK_SORT_ASCENDING); + + xkl_config_registry_foreach_model (config_registry, + (ConfigItemProcessFunc) + add_model_to_list, models_list); + + if (current_model_name != NULL) { + if (gtk_tree_model_get_iter_first + (GTK_TREE_MODEL (list_store), &iter)) { + do { + gtk_tree_model_get (GTK_TREE_MODEL + (list_store), &iter, 1, + &model_name, -1); + if (!g_ascii_strcasecmp + (model_name, current_model_name)) { + gtk_tree_selection_select_iter + (gtk_tree_view_get_selection + (GTK_TREE_VIEW (models_list)), + &iter); + path = + gtk_tree_model_get_path + (GTK_TREE_MODEL (list_store), + &iter); + gtk_tree_view_scroll_to_cell + (GTK_TREE_VIEW (models_list), + path, NULL, TRUE, 0.5, 0); + gtk_tree_path_free (path); + } + g_free (model_name); + } while (gtk_tree_model_iter_next + (GTK_TREE_MODEL (list_store), &iter)); + } + } + + g_signal_connect (G_OBJECT + (gtk_tree_view_get_selection + (GTK_TREE_VIEW (models_list))), "changed", + G_CALLBACK (xkb_model_chooser_change_sel), + chooser_dialog); } static void -xkb_model_chooser_response (GtkDialog *dialog, - gint response, - GladeXML *chooser_dialog) +xkb_model_chooser_response (GtkDialog * dialog, + gint response, GladeXML * chooser_dialog) { - if (response == GTK_RESPONSE_OK) - { - GtkWidget* models_list = CWID( "models_list" ); - GtkTreeSelection* selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (models_list)); - GtkTreeIter iter; - GtkTreeModel* list_store = NULL; - if (gtk_tree_selection_get_selected (selection, &list_store, &iter)) - { - gchar* model_name = NULL; - gtk_tree_model_get (list_store, &iter, - 1, &model_name, -1); - - gconf_client_set_string (xkb_gconf_client, - GSWITCHIT_KBD_CONFIG_KEY_MODEL, - model_name, NULL); - g_free(model_name); - } - } + if (response == GTK_RESPONSE_OK) { + GtkWidget *models_list = CWID ("models_list"); + GtkTreeSelection *selection = + gtk_tree_view_get_selection (GTK_TREE_VIEW + (models_list)); + GtkTreeIter iter; + GtkTreeModel *list_store = NULL; + if (gtk_tree_selection_get_selected + (selection, &list_store, &iter)) { + gchar *model_name = NULL; + 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_free (model_name); + } + } } void -choose_model(GladeXML * dialog) +choose_model (GladeXML * dialog) { - GladeXML* chooser_dialog = glade_xml_new (GNOMECC_DATA_DIR "/interfaces/gnome-keyboard-properties.glade", "xkb_model_chooser", NULL); - GtkWidget* chooser = CWID ( "xkb_model_chooser"); - gtk_window_set_transient_for (GTK_WINDOW (chooser), GTK_WINDOW (WID ("keyboard_dialog"))); - current_model_name = gconf_client_get_string (xkb_gconf_client, - GSWITCHIT_KBD_CONFIG_KEY_MODEL, NULL); - fill_models_list (chooser_dialog); - g_signal_connect (G_OBJECT (chooser), - "response", G_CALLBACK (xkb_model_chooser_response), chooser_dialog); - gtk_dialog_run (GTK_DIALOG (chooser)); - gtk_widget_destroy (chooser); - g_free (current_model_name); + GladeXML *chooser_dialog = + glade_xml_new (GNOMECC_DATA_DIR + "/interfaces/gnome-keyboard-properties.glade", + "xkb_model_chooser", NULL); + GtkWidget *chooser = CWID ("xkb_model_chooser"); + 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); + fill_models_list (chooser_dialog); + g_signal_connect (G_OBJECT (chooser), + "response", + G_CALLBACK (xkb_model_chooser_response), + chooser_dialog); + gtk_dialog_run (GTK_DIALOG (chooser)); + gtk_widget_destroy (chooser); + g_free (current_model_name); } diff --git a/capplets/keyboard/gnome-keyboard-properties-xkbot.c b/capplets/keyboard/gnome-keyboard-properties-xkbot.c index a9a7c3c79..83c6df835 100644 --- a/capplets/keyboard/gnome-keyboard-properties-xkbot.c +++ b/capplets/keyboard/gnome-keyboard-properties-xkbot.c @@ -30,7 +30,7 @@ #include <gconf/gconf-client.h> #include <glade/glade.h> -#include "libgswitchit/gswitchit-config.h" +#include "libgnomekbd/gkbd-keyboard-config.h" #include "capplet-util.h" #include "gconf-property-editor.h" @@ -54,153 +54,170 @@ static GSList *current_radio_group = NULL; GSList * xkb_options_get_selected_list (void) { - GSList *retval; + GSList *retval; - retval = gconf_client_get_list (xkb_gconf_client, - GSWITCHIT_KBD_CONFIG_KEY_OPTIONS, - GCONF_VALUE_STRING, - NULL); - if (retval == NULL) - { - GSList *cur_option; + retval = gconf_client_get_list (xkb_gconf_client, + GKBD_KEYBOARD_CONFIG_KEY_OPTIONS, + GCONF_VALUE_STRING, NULL); + 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)); + 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_slist_reverse (retval); + } - return retval; + return retval; } static GtkWidget * xkb_options_get_expander (GtkWidget * option_button) { - return gtk_widget_get_parent ( - gtk_widget_get_parent ( - gtk_widget_get_parent (option_button))); + return + gtk_widget_get_parent (gtk_widget_get_parent + (gtk_widget_get_parent + (option_button))); } static int xkb_options_expander_selcounter_get (GtkWidget * expander) { - return GPOINTER_TO_INT(g_object_get_data (G_OBJECT (expander), SELCOUNTER_PROP)); + return + GPOINTER_TO_INT (g_object_get_data + (G_OBJECT (expander), SELCOUNTER_PROP)); } static void xkb_options_expander_selcounter_add (GtkWidget * expander, int value) { - g_object_set_data (G_OBJECT (expander), SELCOUNTER_PROP, - GINT_TO_POINTER (xkb_options_expander_selcounter_get (expander) + value)); + g_object_set_data (G_OBJECT (expander), SELCOUNTER_PROP, + GINT_TO_POINTER + (xkb_options_expander_selcounter_get (expander) + + value)); } static void xkb_options_expander_highlight (GtkWidget * expander) { - char * utf_group_name = g_object_get_data (G_OBJECT (expander), "utfGroupName"); - int counter = xkb_options_expander_selcounter_get (expander); - if (utf_group_name != NULL) { - gchar *titlemarkup = g_strconcat (counter > 0 ? "<span weight=\"bold\">" : "<span>", - utf_group_name, "</span>", NULL); - gtk_expander_set_label (GTK_EXPANDER (expander), titlemarkup); - g_free (titlemarkup); - } + char *utf_group_name = + g_object_get_data (G_OBJECT (expander), "utfGroupName"); + int counter = xkb_options_expander_selcounter_get (expander); + if (utf_group_name != NULL) { + gchar *titlemarkup = + g_strconcat (counter > + 0 ? "<span weight=\"bold\">" : "<span>", + utf_group_name, "</span>", NULL); + gtk_expander_set_label (GTK_EXPANDER (expander), + titlemarkup); + g_free (titlemarkup); + } } /* Add optionname from the backend's selection list if it's not already in there. */ static void -xkb_options_select (gchar *optionname) +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); + 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); } /* Remove all occurences of optionname from the backend's selection list */ static void -xkb_options_deselect (gchar *optionname) +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; - } - xkb_options_set_selected_list (options_list); - clear_xkb_elements_list (options_list); + 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; + } + xkb_options_set_selected_list (options_list); + clear_xkb_elements_list (options_list); } /* Return true if optionname describes a string already in the backend's list of selected options */ static gboolean -xkb_options_is_selected (gchar *optionname) +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; - } - clear_xkb_elements_list (options_list); - return retval; + 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; + } + clear_xkb_elements_list (options_list); + return retval; } /* Update xkb backend to reflect the new UI state */ static void -option_toggled_cb (GtkWidget *checkbutton, gpointer data) +option_toggled_cb (GtkWidget * checkbutton, gpointer data) { - gpointer optionID = g_object_get_data (G_OBJECT (checkbutton), OPTION_ID_PROP); - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton))) - xkb_options_select (optionID); - else - xkb_options_deselect (optionID); + gpointer optionID = + g_object_get_data (G_OBJECT (checkbutton), OPTION_ID_PROP); + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton))) + xkb_options_select (optionID); + else + xkb_options_deselect (optionID); } /* Update UI state from xkb backend */ static void option_update_cb (GConfClient * client, - guint cnxn_id, GConfEntry * entry, gpointer data) + guint cnxn_id, GConfEntry * entry, gpointer data) { - GtkToggleButton *toggle = GTK_TOGGLE_BUTTON (data); - GtkWidget *expander = xkb_options_get_expander (GTK_WIDGET (toggle)); - gboolean old_state = gtk_toggle_button_get_active (toggle); - gboolean new_state = xkb_options_is_selected ( - g_object_get_data (G_OBJECT (toggle), OPTION_ID_PROP)); - int old_gstate = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (toggle), GCONFSTATE_PROP)); - int state_diff = new_state - old_gstate; - - if (GTK_WIDGET_TYPE (toggle) == GTK_TYPE_RADIO_BUTTON && - old_state == TRUE && new_state == FALSE) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (g_object_get_data (G_OBJECT (toggle), "NoneRadio")), TRUE); - else - gtk_toggle_button_set_active (toggle, new_state); - - g_object_set_data (G_OBJECT (toggle), GCONFSTATE_PROP, GINT_TO_POINTER (new_state)); - xkb_options_expander_selcounter_add (expander, state_diff); - xkb_options_expander_highlight (expander); + GtkToggleButton *toggle = GTK_TOGGLE_BUTTON (data); + GtkWidget *expander = + xkb_options_get_expander (GTK_WIDGET (toggle)); + gboolean old_state = gtk_toggle_button_get_active (toggle); + gboolean new_state = + xkb_options_is_selected (g_object_get_data + (G_OBJECT (toggle), OPTION_ID_PROP)); + int old_gstate = + GPOINTER_TO_INT (g_object_get_data + (G_OBJECT (toggle), GCONFSTATE_PROP)); + int state_diff = new_state - old_gstate; + + if (GTK_WIDGET_TYPE (toggle) == GTK_TYPE_RADIO_BUTTON && + old_state == TRUE && new_state == FALSE) + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON + (g_object_get_data + (G_OBJECT (toggle), + "NoneRadio")), TRUE); + else + gtk_toggle_button_set_active (toggle, new_state); + + g_object_set_data (G_OBJECT (toggle), GCONFSTATE_PROP, + GINT_TO_POINTER (new_state)); + xkb_options_expander_selcounter_add (expander, state_diff); + xkb_options_expander_highlight (expander); } /* Add a check_button or radio_button to control a particular option @@ -208,153 +225,186 @@ option_update_cb (GConfClient * client, the top of this file. */ static void xkb_options_add_option (XklConfigRegistry * config_registry, - XklConfigItem * config_item, - GladeXML * dialog) + XklConfigItem * config_item, GladeXML * dialog) { - GtkWidget *option_check; - gchar *utf_option_name = xci_desc_to_utf8 (config_item); - /* Copy this out because we'll load it into the widget with set_data */ - gchar *full_option_name = g_strdup( - gswitchit_kbd_config_merge_items (current1st_level_id, config_item->name)); - gboolean initial_state; - - if (current_multi_select) - option_check = gtk_check_button_new_with_label (utf_option_name); - else - { - if (current_radio_group == NULL) - { - /* The first radio in a group is to be "Default", meaning none of - the below options are to be included in the selected list. - This is a HIG-compliant alternative to allowing no - selection in the group. */ - option_check = gtk_radio_button_new_with_label (current_radio_group, _("Default")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (option_check), TRUE); - gtk_box_pack_start_defaults (GTK_BOX (current_vbox), option_check); - current_radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (option_check)); - current_none_radio = option_check; - } - option_check = gtk_radio_button_new_with_label (current_radio_group, utf_option_name); - current_radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (option_check)); - g_object_set_data (G_OBJECT (option_check), "NoneRadio", current_none_radio); - } - g_free (utf_option_name); - - initial_state = xkb_options_is_selected (full_option_name); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (option_check), initial_state); - - g_object_set_data_full (G_OBJECT (option_check), OPTION_ID_PROP, full_option_name, g_free); - - g_signal_connect (G_OBJECT (option_check), "toggled", G_CALLBACK (option_toggled_cb), NULL); - - gconf_client_notify_add (xkb_gconf_client, - GSWITCHIT_KBD_CONFIG_KEY_OPTIONS, - (GConfClientNotifyFunc) - option_update_cb, option_check, NULL, NULL); - - gtk_box_pack_start_defaults (GTK_BOX (current_vbox), option_check); - - xkb_options_expander_selcounter_add (xkb_options_get_expander (option_check), initial_state); - g_object_set_data (G_OBJECT (option_check), GCONFSTATE_PROP, GINT_TO_POINTER (initial_state)); + GtkWidget *option_check; + gchar *utf_option_name = xci_desc_to_utf8 (config_item); + /* Copy this out because we'll load it into the widget with set_data */ + gchar *full_option_name = + g_strdup (gkbd_keyboard_config_merge_items + (current1st_level_id, config_item->name)); + gboolean initial_state; + + if (current_multi_select) + option_check = + gtk_check_button_new_with_label (utf_option_name); + else { + if (current_radio_group == NULL) { + /* The first radio in a group is to be "Default", meaning none of + the below options are to be included in the selected list. + This is a HIG-compliant alternative to allowing no + selection in the group. */ + option_check = + gtk_radio_button_new_with_label + (current_radio_group, _("Default")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON + (option_check), + TRUE); + gtk_box_pack_start_defaults (GTK_BOX + (current_vbox), + option_check); + current_radio_group = + gtk_radio_button_get_group (GTK_RADIO_BUTTON + (option_check)); + current_none_radio = option_check; + } + option_check = + gtk_radio_button_new_with_label (current_radio_group, + utf_option_name); + current_radio_group = + gtk_radio_button_get_group (GTK_RADIO_BUTTON + (option_check)); + g_object_set_data (G_OBJECT (option_check), "NoneRadio", + current_none_radio); + } + g_free (utf_option_name); + + initial_state = xkb_options_is_selected (full_option_name); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (option_check), + initial_state); + + g_object_set_data_full (G_OBJECT (option_check), OPTION_ID_PROP, + full_option_name, g_free); + + g_signal_connect (G_OBJECT (option_check), "toggled", + G_CALLBACK (option_toggled_cb), NULL); + + gconf_client_notify_add (xkb_gconf_client, + GKBD_KEYBOARD_CONFIG_KEY_OPTIONS, + (GConfClientNotifyFunc) + option_update_cb, option_check, NULL, + NULL); + + gtk_box_pack_start_defaults (GTK_BOX (current_vbox), option_check); + + xkb_options_expander_selcounter_add (xkb_options_get_expander + (option_check), + initial_state); + g_object_set_data (G_OBJECT (option_check), GCONFSTATE_PROP, + GINT_TO_POINTER (initial_state)); } /* Add a group of options: create title and layout widgets and then add widgets for all the options in the group. */ static void xkb_options_add_group (XklConfigRegistry * config_registry, - XklConfigItem * config_item, - GladeXML * dialog) + XklConfigItem * config_item, GladeXML * dialog) { - GtkWidget *expander, *align, *vbox; - gboolean allow_multiple_selection = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (config_item), - XCI_PROP_ALLOW_MULTIPLE_SELECTION)); - - GSList * expanders_list = g_object_get_data (G_OBJECT (dialog), EXPANDERS_PROP); - - gchar *utf_group_name = xci_desc_to_utf8 (config_item); - gchar *titlemarkup = g_strconcat ("<span>", utf_group_name, "</span>", NULL); - - expander = gtk_expander_new (titlemarkup); - gtk_expander_set_use_markup (GTK_EXPANDER (expander), TRUE); - g_object_set_data_full (G_OBJECT (expander), "utfGroupName", utf_group_name, g_free); - - g_free (titlemarkup); - align = gtk_alignment_new (0, 0, 1, 1); - gtk_alignment_set_padding (GTK_ALIGNMENT (align), 6, 12, 12, 0); - vbox = gtk_vbox_new (TRUE, 6); - gtk_container_add (GTK_CONTAINER (align), vbox); - gtk_container_add (GTK_CONTAINER (expander), align); - current_vbox = vbox; - - current_multi_select = (gboolean) allow_multiple_selection; - current_radio_group = NULL; - - current1st_level_id = config_item->name; - xkl_config_registry_foreach_option (config_registry, config_item->name, - (ConfigItemProcessFunc)xkb_options_add_option, - dialog); - - xkb_options_expander_highlight (expander); - - expanders_list = g_slist_append (expanders_list, expander); - g_object_set_data (G_OBJECT (dialog), EXPANDERS_PROP, expanders_list); + GtkWidget *expander, *align, *vbox; + gboolean allow_multiple_selection = + GPOINTER_TO_INT (g_object_get_data (G_OBJECT (config_item), + XCI_PROP_ALLOW_MULTIPLE_SELECTION)); + + GSList *expanders_list = + g_object_get_data (G_OBJECT (dialog), EXPANDERS_PROP); + + gchar *utf_group_name = xci_desc_to_utf8 (config_item); + gchar *titlemarkup = + g_strconcat ("<span>", utf_group_name, "</span>", NULL); + + expander = gtk_expander_new (titlemarkup); + gtk_expander_set_use_markup (GTK_EXPANDER (expander), TRUE); + g_object_set_data_full (G_OBJECT (expander), "utfGroupName", + utf_group_name, g_free); + + g_free (titlemarkup); + align = gtk_alignment_new (0, 0, 1, 1); + gtk_alignment_set_padding (GTK_ALIGNMENT (align), 6, 12, 12, 0); + vbox = gtk_vbox_new (TRUE, 6); + gtk_container_add (GTK_CONTAINER (align), vbox); + gtk_container_add (GTK_CONTAINER (expander), align); + current_vbox = vbox; + + current_multi_select = (gboolean) allow_multiple_selection; + current_radio_group = NULL; + + current1st_level_id = config_item->name; + xkl_config_registry_foreach_option (config_registry, + config_item->name, + (ConfigItemProcessFunc) + xkb_options_add_option, + dialog); + + xkb_options_expander_highlight (expander); + + expanders_list = g_slist_append (expanders_list, expander); + g_object_set_data (G_OBJECT (dialog), EXPANDERS_PROP, + expanders_list); } static gint -xkb_options_expanders_compare (GtkWidget * expander1, GtkWidget * expander2) +xkb_options_expanders_compare (GtkWidget * expander1, + GtkWidget * expander2) { - const gchar *t1 = gtk_expander_get_label (GTK_EXPANDER (expander1)); - const gchar *t2 = gtk_expander_get_label (GTK_EXPANDER (expander2)); - return g_utf8_collate (t1, t2); + const gchar *t1 = + gtk_expander_get_label (GTK_EXPANDER (expander1)); + const gchar *t2 = + gtk_expander_get_label (GTK_EXPANDER (expander2)); + return g_utf8_collate (t1, t2); } /* Create widgets to represent the options made available by the backend */ void xkb_options_load_options (GladeXML * dialog) { - GtkWidget *opts_vbox = WID ("options_vbox"); - GSList * expanders_list; - GtkWidget * expander; - - /* fill the list */ - xkl_config_registry_foreach_option_group (config_registry, - (ConfigItemProcessFunc)xkb_options_add_group, - dialog); - /* sort it */ - expanders_list = g_object_get_data (G_OBJECT (dialog), EXPANDERS_PROP); - expanders_list = g_slist_sort (expanders_list, (GCompareFunc)xkb_options_expanders_compare); - while (expanders_list) - { - expander = GTK_WIDGET (expanders_list->data); - gtk_box_pack_start (GTK_BOX (opts_vbox), expander, FALSE, FALSE, 0); - expanders_list = expanders_list->next; - } - - /* just cleanup */ - expanders_list = g_object_get_data (G_OBJECT (dialog), EXPANDERS_PROP); - g_object_set_data (G_OBJECT (dialog), EXPANDERS_PROP, NULL); - g_slist_free (expanders_list); - - gtk_widget_show_all (opts_vbox); + GtkWidget *opts_vbox = WID ("options_vbox"); + GSList *expanders_list; + GtkWidget *expander; + + /* fill the list */ + xkl_config_registry_foreach_option_group (config_registry, + (ConfigItemProcessFunc) + xkb_options_add_group, + dialog); + /* sort it */ + expanders_list = + g_object_get_data (G_OBJECT (dialog), EXPANDERS_PROP); + expanders_list = + g_slist_sort (expanders_list, + (GCompareFunc) xkb_options_expanders_compare); + while (expanders_list) { + expander = GTK_WIDGET (expanders_list->data); + gtk_box_pack_start (GTK_BOX (opts_vbox), expander, FALSE, + FALSE, 0); + expanders_list = expanders_list->next; + } + + /* just cleanup */ + expanders_list = + g_object_get_data (G_OBJECT (dialog), EXPANDERS_PROP); + g_object_set_data (G_OBJECT (dialog), EXPANDERS_PROP, NULL); + g_slist_free (expanders_list); + + gtk_widget_show_all (opts_vbox); } /* Respond to a change in the xkb gconf settings */ static void xkb_options_update (GConfClient * client, - guint cnxn_id, GConfEntry * entry, GladeXML * dialog) + guint cnxn_id, GConfEntry * entry, GladeXML * 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); + /* 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); } void xkb_options_register_gconf_listener (GladeXML * dialog) { - gconf_client_notify_add (xkb_gconf_client, - GSWITCHIT_KBD_CONFIG_KEY_OPTIONS, - (GConfClientNotifyFunc) - xkb_options_update, dialog, NULL, NULL); + gconf_client_notify_add (xkb_gconf_client, + GKBD_KEYBOARD_CONFIG_KEY_OPTIONS, + (GConfClientNotifyFunc) + xkb_options_update, dialog, NULL, NULL); } diff --git a/capplets/keyboard/gnome-keyboard-properties-xkbpv.c b/capplets/keyboard/gnome-keyboard-properties-xkbpv.c index d20c359be..de8ebb5d3 100644 --- a/capplets/keyboard/gnome-keyboard-properties-xkbpv.c +++ b/capplets/keyboard/gnome-keyboard-properties-xkbpv.c @@ -28,12 +28,12 @@ #include <gnome.h> #include <glade/glade.h> -#include "libgswitchit/gswitchit-config.h" +#include <libgnomekbd/gkbd-keyboard-config.h> #include "capplet-util.h" #include "gnome-keyboard-properties-xkb.h" -#include "libkbdraw/keyboard-drawing.h" +#include <libgnomekbd/gkbd-keyboard-drawing.h> #ifdef HAVE_X11_EXTENSIONS_XKB_H #include "X11/XKBlib.h" @@ -42,78 +42,92 @@ * Any ideas on architectural improvements are WELCOME */ extern gboolean xkl_xkb_config_native_prepare (XklEngine * engine, - const XklConfigRec * data, - XkbComponentNamesPtr component_names); + const XklConfigRec * data, + XkbComponentNamesPtr + component_names); extern void xkl_xkb_config_native_cleanup (XklEngine * engine, - XkbComponentNamesPtr component_names); + XkbComponentNamesPtr + component_names); /* */ #endif -static KeyboardDrawingGroupLevel groupsLevels[] = {{0,1},{0,3},{0,0},{0,2}}; -static KeyboardDrawingGroupLevel * pGroupsLevels[] = { -groupsLevels, groupsLevels+1, groupsLevels+2, groupsLevels+3 }; +static GkbdKeyboardDrawingGroupLevel groupsLevels[] = + { {0, 1}, {0, 3}, {0, 0}, {0, 2} }; +static GkbdKeyboardDrawingGroupLevel *pGroupsLevels[] = { + groupsLevels, groupsLevels + 1, groupsLevels + 2, groupsLevels + 3 +}; -GtkWidget* +GtkWidget * xkb_layout_preview_create_widget (GladeXML * chooserDialog) { - GtkWidget *kbdraw = keyboard_drawing_new (); - - keyboard_drawing_set_groups_levels (KEYBOARD_DRAWING (kbdraw), pGroupsLevels); - return kbdraw; + GtkWidget *kbdraw = gkbd_keyboard_drawing_new (); + + gkbd_keyboard_drawing_set_groups_levels (GKBD_KEYBOARD_DRAWING + (kbdraw), pGroupsLevels); + return kbdraw; } void xkb_layout_preview_update (GladeXML * chooser_dialog) { #ifdef HAVE_X11_EXTENSIONS_XKB_H - GtkWidget *chooser = CWID ( "xkb_layout_chooser"); - GtkWidget *available_layouts_tree = CWID ("xkb_layouts_available"); - GtkTreeSelection *selection = - gtk_tree_view_get_selection (GTK_TREE_VIEW (available_layouts_tree)); - GtkTreeIter selected_iter; - GtkTreeModel *model; - GtkWidget *kbdraw = GTK_WIDGET (g_object_get_data (G_OBJECT (chooser), "kbdraw")); - if (kbdraw != NULL && - gtk_tree_selection_get_selected (selection, &model, &selected_iter)) - { - gchar *id; - XklConfigRec *data; - char **p, *layout, *variant; - XkbComponentNamesRec component_names; - - gtk_tree_model_get (model, &selected_iter, AVAIL_LAYOUT_TREE_COL_ID, &id, -1); - data = xkl_config_rec_new (); - if (xkl_config_rec_get_from_server (data, engine)) - { - if( ( p = data->layouts ) != NULL ) - g_strfreev(data->layouts); - - if( ( p = data->variants ) != NULL ) - g_strfreev(data->variants); - - data->layouts = g_new0 (char*, 2); - data->variants = g_new0 (char*, 2); - if (gswitchit_kbd_config_split_items (id, &layout, &variant) - && variant != NULL) - { - data->layouts[0] = (layout == NULL) ? NULL : g_strdup (layout); - data->variants[0] = (variant == NULL) ? NULL : g_strdup (variant); - } else - { - data->layouts[0] = (id == NULL) ? NULL : g_strdup (id); - data->variants[0] = NULL; - } - - if (xkl_xkb_config_native_prepare (engine, data, &component_names)) - { - keyboard_drawing_set_keyboard (KEYBOARD_DRAWING (kbdraw), &component_names); - - xkl_xkb_config_native_cleanup (engine, &component_names); - } - } - g_object_unref (G_OBJECT (data)); - } + GtkWidget *chooser = CWID ("xkb_layout_chooser"); + GtkWidget *available_layouts_tree = CWID ("xkb_layouts_available"); + GtkTreeSelection *selection = + gtk_tree_view_get_selection (GTK_TREE_VIEW + (available_layouts_tree)); + GtkTreeIter selected_iter; + GtkTreeModel *model; + GtkWidget *kbdraw = + GTK_WIDGET (g_object_get_data (G_OBJECT (chooser), "kbdraw")); + if (kbdraw != NULL + && gtk_tree_selection_get_selected (selection, &model, + &selected_iter)) { + gchar *id; + XklConfigRec *data; + char **p, *layout, *variant; + XkbComponentNamesRec component_names; + + gtk_tree_model_get (model, &selected_iter, + AVAIL_LAYOUT_TREE_COL_ID, &id, -1); + data = xkl_config_rec_new (); + if (xkl_config_rec_get_from_server (data, engine)) { + if ((p = data->layouts) != NULL) + g_strfreev (data->layouts); + + if ((p = data->variants) != NULL) + g_strfreev (data->variants); + + data->layouts = g_new0 (char *, 2); + data->variants = g_new0 (char *, 2); + if (gkbd_keyboard_config_split_items + (id, &layout, &variant) + && variant != NULL) { + data->layouts[0] = + (layout == + NULL) ? NULL : g_strdup (layout); + data->variants[0] = + (variant == + NULL) ? NULL : g_strdup (variant); + } else { + data->layouts[0] = + (id == NULL) ? NULL : g_strdup (id); + data->variants[0] = NULL; + } + + if (xkl_xkb_config_native_prepare + (engine, data, &component_names)) { + gkbd_keyboard_drawing_set_keyboard + (GKBD_KEYBOARD_DRAWING (kbdraw), + &component_names); + + xkl_xkb_config_native_cleanup (engine, + &component_names); + } + } + g_object_unref (G_OBJECT (data)); + } #endif } diff --git a/configure.in b/configure.in index 939634e89..39250ef3f 100644 --- a/configure.in +++ b/configure.in @@ -109,9 +109,6 @@ PKG_CHECK_MODULES(GNOME_DESKTOP, gnome-desktop-2.0) PKG_CHECK_MODULES(DEFAULT_APPLICATIONS_CAPPLET, libxml-2.0) PKG_CHECK_MODULES(SOUND_CAPPLET, esound gstreamer-0.10) PKG_CHECK_MODULES(METACITY, libmetacity-private) -PKG_CHECK_MODULES(LIBXKLAVIER, libxklavier >= 2.91,, - AC_MSG_ERROR([gnome-control-center depends on libxklavier >= 2.91. -The latest release is available from http://prdownloads.sourceforge.net/gswitchit], 1)) dnl dnl Check for Xft version 2; we build in extra functionality to the font capplet @@ -195,18 +192,13 @@ fi dnl ============== dnl gswitchit dnl ============== -dnl Make sure the new cvs virtual include has been checked out -AC_MSG_CHECKING([for inclusion of libgswitchit]) -if test ! -d "$srcdir/libgswitchit"; then - AC_MSG_RESULT(no) - AC_MSG_ERROR([Your checkout of gnome-control-center is out of date. - The 'libgswitchit' module has been virtually included into - gnome-control-center by CVS as a subdirectory. Please check - out again (this can be done on top of your existing checkout)]) -else - AC_MSG_RESULT(yes) -fi -AM_CONDITIONAL(INCLUDE_GSWITCHIT_DEVEL, false) dnl pull devel from applet +PKG_CHECK_MODULES(LIBGNOMEKBD, [libgnomekbd >= 0.1]) +AC_SUBST(LIBGNOMEKBD_CFLAGS) +AC_SUBST(LIBGNOMEKBD_LIBS) + +PKG_CHECK_MODULES(LIBGNOMEKBDUI, [libgnomekbdui >= 0.1]) +AC_SUBST(LIBGNOMEKBDUI_CFLAGS) +AC_SUBST(LIBGNOMEKBDUI_LIBS) dnl ============================================== dnl themus and fontilust dependencies @@ -610,8 +602,6 @@ control-center/Makefile libbackground/Makefile libwindow-settings/Makefile libwindow-settings/gnome-window-settings-2.0.pc -libgswitchit/Makefile -libkbdraw/Makefile capplets/Makefile capplets/common/Makefile capplets/default-applications/Makefile diff --git a/gnome-settings-daemon/Makefile.am b/gnome-settings-daemon/Makefile.am index 462ddacfd..42b1991fa 100644 --- a/gnome-settings-daemon/Makefile.am +++ b/gnome-settings-daemon/Makefile.am @@ -1,7 +1,6 @@ SUBDIRS = xrdb actions -INCLUDES=$(DBUS_CFLAGS) $(LIBXKLAVIER_CFLAGS) $(GNOME_SETTINGS_DAEMON_CFLAGS) -I$(top_srcdir)/libbackground -I$(top_srcdir) \ - -DGNOMELOCALEDIR="\"$(datadir)/locale\"" \ +INCLUDES=$(DBUS_CFLAGS) $(LIBGNOMEKBD_CFLAGS) $(GNOME_SETTINGS_DAEMON_CFLAGS) -I$(top_srcdir)/libbackground -I$(top_srcdir) \ -DESD_SERVER="\"$(ESD_SERVER)\"" \ -DDATADIR="\"$(datadir)\"" \ -DPIXMAPSDIR="\"$(GNOMECC_PIXMAPS_DIR)\"" \ @@ -69,10 +68,9 @@ gnome_settings_daemon_SOURCES = \ gnome_settings_daemon_LDADD = \ $(DBUS_LIBS) \ - $(LIBXKLAVIER_LIBS) \ + $(LIBGNOMEKBD_LIBS) \ $(top_builddir)/libbackground/libbackground.la \ $(top_builddir)/libsounds/libsounds.a \ - $(top_builddir)/libgswitchit/libgswitchit.a \ $(top_builddir)/libwindow-settings/libgnome-window-settings.la \ $(top_builddir)/gnome-settings-daemon/actions/libacme.la \ $(GNOME_SETTINGS_DAEMON_LIBS) \ diff --git a/gnome-settings-daemon/gnome-settings-keyboard-xkb.c b/gnome-settings-daemon/gnome-settings-keyboard-xkb.c index 00bc7cf16..2614bd559 100644 --- a/gnome-settings-daemon/gnome-settings-keyboard-xkb.c +++ b/gnome-settings-daemon/gnome-settings-keyboard-xkb.c @@ -35,19 +35,20 @@ #include <string.h> #include <time.h> -#include <libgswitchit/gswitchit-config.h> -#include <libgswitchit/keyboard-config-registry.h> +#include <libgnomekbd/gkbd-config-registry.h> +#include <libgnomekbd/gkbd-desktop-config.h> +#include <libgnomekbd/gkbd-keyboard-config.h> #include "gnome-settings-keyboard-xkb.h" #include "gnome-settings-daemon.h" XklEngine *xkl_engine; -static GSwitchItConfig current_config; -static GSwitchItKbdConfig current_kbd_config; +static GkbdDesktopConfig current_config; +static GkbdKeyboardConfig current_kbd_config; /* never terminated */ -static GSwitchItKbdConfig initial_sys_kbd_config; +static GkbdKeyboardConfig initial_sys_kbd_config; static gboolean inited_ok; @@ -133,34 +134,34 @@ apply_settings (void) if (!inited_ok) return; - gswitchit_config_load_from_gconf (¤t_config); + gkbd_desktop_config_load_from_gconf (¤t_config); /* again, probably it would be nice to compare things before activating them */ - gswitchit_config_activate (¤t_config); + gkbd_desktop_config_activate (¤t_config); } static void apply_xkb_settings (void) { GConfClient *conf_client; - GSwitchItKbdConfig current_sys_kbd_config; + GkbdKeyboardConfig current_sys_kbd_config; if (!inited_ok) return; conf_client = gnome_settings_daemon_get_conf_client (); - gswitchit_kbd_config_init (¤t_sys_kbd_config, conf_client, + gkbd_keyboard_config_init (¤t_sys_kbd_config, conf_client, xkl_engine); - gswitchit_kbd_config_load_from_gconf (¤t_kbd_config, + gkbd_keyboard_config_load_from_gconf (¤t_kbd_config, &initial_sys_kbd_config); - gswitchit_kbd_config_load_from_x_current (¤t_sys_kbd_config); + gkbd_keyboard_config_load_from_x_current (¤t_sys_kbd_config, NULL); /* Activate - only if different! */ - if (!gswitchit_kbd_config_equals + if (!gkbd_keyboard_config_equals (¤t_kbd_config, ¤t_sys_kbd_config)) { - if (gswitchit_kbd_config_activate (¤t_kbd_config)) { - gswitchit_kbd_config_save_to_gconf_backup + if (gkbd_keyboard_config_activate (¤t_kbd_config)) { + gkbd_keyboard_config_save_to_gconf_backup (&initial_sys_kbd_config); if (pa_callback != NULL) { (*pa_callback) (pa_callback_user_data); @@ -174,7 +175,7 @@ apply_xkb_settings (void) xkl_debug (100, "Actual KBD configuration was not changed: redundant notification\n"); - gswitchit_kbd_config_term (¤t_sys_kbd_config); + gkbd_keyboard_config_term (¤t_sys_kbd_config); } static void @@ -183,7 +184,7 @@ gnome_settings_keyboard_xkb_sysconfig_changed_response (GtkDialog * dialog, what2do) { GConfClient *conf_client; - GSwitchItKbdConfig empty_kbd_config; + GkbdKeyboardConfig empty_kbd_config; gboolean dont_show_again = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (g_object_get_data @@ -194,9 +195,9 @@ gnome_settings_keyboard_xkb_sysconfig_changed_response (GtkDialog * dialog, switch (what2do) { case RESPONSE_USE_X: - gswitchit_kbd_config_init (&empty_kbd_config, conf_client, + gkbd_keyboard_config_init (&empty_kbd_config, conf_client, xkl_engine); - gswitchit_kbd_config_save_to_gconf (&empty_kbd_config); + gkbd_keyboard_config_save_to_gconf (&empty_kbd_config); break; case RESPONSE_USE_GNOME: /* Do absolutely nothing - just keep things the way they are */ @@ -215,27 +216,27 @@ static void gnome_settings_keyboard_xkb_analyze_sysconfig (void) { GConfClient *conf_client; - GSwitchItKbdConfig backup_gconf_kbd_config; + GkbdKeyboardConfig backup_gconf_kbd_config; gboolean is_config_changed, dont_show; if (!inited_ok) return; conf_client = gnome_settings_daemon_get_conf_client (); - gswitchit_kbd_config_init (&backup_gconf_kbd_config, conf_client, + gkbd_keyboard_config_init (&backup_gconf_kbd_config, conf_client, xkl_engine); - gswitchit_kbd_config_init (&initial_sys_kbd_config, conf_client, + gkbd_keyboard_config_init (&initial_sys_kbd_config, conf_client, xkl_engine); dont_show = gconf_client_get_bool (conf_client, DISABLE_SYSCONF_CHANGED_WARNING_KEY, NULL); - gswitchit_kbd_config_load_from_gconf_backup + gkbd_keyboard_config_load_from_gconf_backup (&backup_gconf_kbd_config); - gswitchit_kbd_config_load_from_x_initial (&initial_sys_kbd_config); + gkbd_keyboard_config_load_from_x_initial (&initial_sys_kbd_config, NULL); is_config_changed = - g_slist_length (backup_gconf_kbd_config.layouts) - && !gswitchit_kbd_config_equals (&initial_sys_kbd_config, + g_slist_length (backup_gconf_kbd_config.layouts_variants) + && !gkbd_keyboard_config_equals (&initial_sys_kbd_config, &backup_gconf_kbd_config); /* config was changed!!! */ @@ -252,10 +253,10 @@ gnome_settings_keyboard_xkb_analyze_sysconfig (void) GtkWidget *msg; char *gnome_settings = - gswitchit_kbd_config_to_string + gkbd_keyboard_config_to_string (&backup_gconf_kbd_config); char *system_settings = - gswitchit_kbd_config_to_string + gkbd_keyboard_config_to_string (&initial_sys_kbd_config); msg = gtk_message_dialog_new_with_markup (NULL, 0, GTK_MESSAGE_INFO, GTK_BUTTONS_NONE, /* !! temporary one */ @@ -299,7 +300,7 @@ gnome_settings_keyboard_xkb_analyze_sysconfig (void) gtk_widget_show_all (msg); } } - gswitchit_kbd_config_term (&backup_gconf_kbd_config); + gkbd_keyboard_config_term (&backup_gconf_kbd_config); } static gboolean @@ -405,11 +406,11 @@ gnome_settings_keyboard_xkb_init (GConfClient * client) gnome_settings_keyboard_xkb_chk_lcl_xmm (); gnome_settings_daemon_register_callback - (GSWITCHIT_CONFIG_DIR, + (GKBD_DESKTOP_CONFIG_DIR, (KeyCallbackFunc) apply_settings); gnome_settings_daemon_register_callback - (GSWITCHIT_KBD_CONFIG_DIR, + (GKBD_KEYBOARD_CONFIG_DIR, (KeyCallbackFunc) apply_xkb_settings); gdk_window_add_filter (NULL, (GdkFilterFunc) @@ -424,18 +425,17 @@ gnome_settings_keyboard_xkb_init (GConfClient * client) XKLL_MANAGE_WINDOW_STATES); reg = - g_object_new (keyboard_config_registry_get_type (), - NULL); + g_object_new (gkbd_config_registry_get_type (), NULL); } } void gnome_settings_keyboard_xkb_load (GConfClient * client) { - gswitchit_config_init (¤t_config, client, xkl_engine); + gkbd_desktop_config_init (¤t_config, client, xkl_engine); apply_settings (); - gswitchit_kbd_config_init (¤t_kbd_config, client, + gkbd_keyboard_config_init (¤t_kbd_config, client, xkl_engine); apply_xkb_settings (); } diff --git a/gnome-settings-daemon/gnome-settings-keyboard-xkb.h b/gnome-settings-daemon/gnome-settings-keyboard-xkb.h index 4312eaed6..2dc860e24 100644 --- a/gnome-settings-daemon/gnome-settings-keyboard-xkb.h +++ b/gnome-settings-daemon/gnome-settings-keyboard-xkb.h @@ -33,14 +33,14 @@ void gnome_settings_keyboard_xkb_init (GConfClient * client); void gnome_settings_keyboard_xkb_load (GConfClient * client); -typedef void ( *PostActivationCallback ) ( void *userData ); +typedef void (*PostActivationCallback) (void *userData); -void gnome_settings_keyboard_xkb_set_post_activation_callback( - PostActivationCallback fun, - void *userData ); +void +gnome_settings_keyboard_xkb_set_post_activation_callback +(PostActivationCallback fun, void *userData); GType keyboard_config_registry_get_type (void); -extern XklEngine * xkl_engine; +extern XklEngine *xkl_engine; #endif diff --git a/schemas/Makefile.am b/schemas/Makefile.am index 5d1495916..fa8b5371a 100644 --- a/schemas/Makefile.am +++ b/schemas/Makefile.am @@ -3,7 +3,6 @@ schema_in_files= \ apps_gnome_settings_daemon_screensaver.schemas.in \ apps_gnome_settings_daemon_default_editor.schemas.in \ desktop_gnome_font_rendering.schemas.in \ - desktop_gnome_peripherals_keyboard_xkb.schemas.in \ apps_gnome_settings_daemon_keybindings.schemas.in schema_DATA = $(schema_in_files:.schemas.in=.schemas) diff --git a/schemas/desktop_gnome_peripherals_keyboard_xkb.schemas.in b/schemas/desktop_gnome_peripherals_keyboard_xkb.schemas.in deleted file mode 100644 index 1a917e6cb..000000000 --- a/schemas/desktop_gnome_peripherals_keyboard_xkb.schemas.in +++ /dev/null @@ -1,193 +0,0 @@ -<?xml version="1.0"?> -<gconfschemafile> - <schemalist> - <schema> - <key>/schemas/desktop/gnome/peripherals/keyboard/kbd/overrideSettings</key> - <applyto>/desktop/gnome/peripherals/keyboard/kbd/overrideSettings</applyto> - <owner>gnome</owner> - <type>bool</type> - <default>true</default> - <locale name="C"> - <short>Keyboard settings in gconf will be overridden from the system ASAP (deprecated)</short> - <long>Very soon, keyboard settings in gconf will be overridden (from the system configuration) - This key has been deprecated since GNOME 2.12, please unset the model, layouts and - options keys to get the default system configuration.</long> - </locale> - </schema> - - <schema> - <key>/schemas/desktop/gnome/peripherals/keyboard/kbd/model</key> - <applyto>/desktop/gnome/peripherals/keyboard/kbd/model</applyto> - <owner>gnome</owner> - <type>string</type> - <default></default> - <locale name="C"> - <short>Keyboard model</short> - <long>keyboard model</long> - </locale> - </schema> - - <schema> - <key>/schemas/desktop/gnome/peripherals/keyboard/kbd/layouts</key> - <applyto>/desktop/gnome/peripherals/keyboard/kbd/layouts</applyto> - <owner>gnome</owner> - <type>list</type> - <list_type>string</list_type> - <default>[]</default> - <locale name="C"> - <short>Keyboard layout</short> - <long>keyboard layout</long> - </locale> - </schema> - - <schema> - <key>/schemas/desktop/gnome/peripherals/keyboard/kbd/options</key> - <applyto>/desktop/gnome/peripherals/keyboard/kbd/options</applyto> - <owner>gnome</owner> - <type>list</type> - <list_type>string</list_type> - <default>[]</default> - <locale name="C"> - <short>Keyboard options</short> - <long>Keyboard options</long> - </locale> - </schema> - - <schema> - <key>/schemas/desktop/gnome/peripherals/keyboard/general/update_handlers</key> - <applyto>/desktop/gnome/peripherals/keyboard/general/update_handlers</applyto> - <owner>gnome</owner> - <type>list</type> - <list_type>string</list_type> - <default>[]</default> - <locale name="C"> - <short>Keyboard Update Handlers</short> - <long>A collection of scripts to run whenever the keyboard state is - reloaded. Useful for re-applying xmodmap based adjustments</long> - </locale> - </schema> - - <schema> - <key>/schemas/desktop/gnome/peripherals/keyboard/general/known_file_list</key> - <applyto>/desktop/gnome/peripherals/keyboard/general/known_file_list</applyto> - <owner>gnome</owner> - <type>list</type> - <list_type>string</list_type> - <default>[]</default> - <locale name="C"> - <short>modmap file list</short> - <long>A list of modmap files available in the $HOME directory.</long> - </locale> - </schema> - - - <schema> - <key>/schemas/desktop/gnome/peripherals/keyboard/general/defaultGroup</key> - <applyto>/desktop/gnome/peripherals/keyboard/general/defaultGroup</applyto> - <owner>gnome</owner> - <type>int</type> - <default>-1</default> - <locale name="C"> - <short>Default group, assigned on window creation</short> - <long>Default group, assigned on window creation</long> - </locale> - </schema> - - <schema> - <key>/schemas/desktop/gnome/peripherals/keyboard/general/groupPerWindow</key> - <applyto>/desktop/gnome/peripherals/keyboard/general/groupPerWindow</applyto> - <owner>gnome</owner> - <type>bool</type> - <default>true</default> - <locale name="C"> - <short>Keep and manage separate group per window</short> - <long>Keep and manage separate group per window</long> - </locale> - </schema> - - <schema> - <key>/schemas/desktop/gnome/peripherals/keyboard/general/handleIndicators</key> - <applyto>/desktop/gnome/peripherals/keyboard/general/handleIndicators</applyto> - <owner>gnome</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Save/restore indicators together with layout groups</short> - <long>Save/restore indicators together with layout groups</long> - </locale> - </schema> - - <schema> - <key>/schemas/desktop/gnome/peripherals/keyboard/general/layoutNamesAsGroupNames</key> - <applyto>/desktop/gnome/peripherals/keyboard/general/layoutNamesAsGroupNames</applyto> - <owner>gnome</owner> - <type>bool</type> - <default>true</default> - <locale name="C"> - <short>Show layout names instead of group names</short> - <long>Show layout names instead of group names (only for versions of XFree supporting multiple layouts)</long> - </locale> - </schema> - - <schema> - <key>/schemas/desktop/gnome/peripherals/keyboard/general/disable_sysconfig_changed_warning</key> - <applyto>/desktop/gnome/peripherals/keyboard/general/disable_sysconfig_changed_warning</applyto> - <owner>gnome</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Suppress the "X sysconfig changed" warning message</short> - <long>Suppress the "X sysconfig changed" warning message</long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/gswitchit/preview/x</key> - <applyto>/apps/gswitchit/preview/x</applyto> - <owner>gnome</owner> - <type>int</type> - <default>-1</default> - <locale name="C"> - <short>The Keyboard Preview, X offset</short> - <long>The Keyboard Preview, X offset</long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/gswitchit/preview/y</key> - <applyto>/apps/gswitchit/preview/y</applyto> - <owner>gnome</owner> - <type>int</type> - <default>-1</default> - <locale name="C"> - <short>The Keyboard Preview, Y offset</short> - <long>The Keyboard Preview, Y offset</long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/gswitchit/preview/width</key> - <applyto>/apps/gswitchit/preview/width</applyto> - <owner>gnome</owner> - <type>int</type> - <default>-1</default> - <locale name="C"> - <short>The Keyboard Preview, width</short> - <long>The Keyboard Preview, width</long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/gswitchit/preview/height</key> - <applyto>/apps/gswitchit/preview/height</applyto> - <owner>gnome</owner> - <type>int</type> - <default>-1</default> - <locale name="C"> - <short>The Keyboard Preview, height</short> - <long>The Keyboard Preview, height</long> - </locale> - </schema> - - </schemalist> -</gconfschemafile> |