diff --git a/capplets/keyboard/gnome-keyboard-properties-xkb.c b/capplets/keyboard/gnome-keyboard-properties-xkb.c index a6265af69..1426efccb 100644 --- a/capplets/keyboard/gnome-keyboard-properties-xkb.c +++ b/capplets/keyboard/gnome-keyboard-properties-xkb.c @@ -26,6 +26,7 @@ #endif #include +#include #include #include @@ -117,6 +118,7 @@ cleanup_xkb_tabs (GladeXML * dialog) { XklConfigFreeRegistry (); XklConfigTerm (); + XklTerm (); } static void @@ -135,7 +137,7 @@ add_model_to_option_menu (const XklConfigItemPtr configItem, GtkWidget * menu) GtkWidget *menuItem = GTK_WIDGET (existingItemNode->data); GtkWidget *lbl = GTK_BIN (menuItem)->child; const char *txt = gtk_label_get_text (GTK_LABEL (lbl)); - if (g_utf8_collate(txt, utfModelName) > 0) + if (g_utf8_collate (txt, utfModelName) > 0) break; } g_free (utfModelName); @@ -176,9 +178,17 @@ reset_to_defaults (GtkWidget * button, GladeXML * dialog) /* all the rest is g-s-d's business */ } +static void +update_model (GConfClient * client, + guint cnxn_id, GConfEntry * entry, GladeXML * dialog) +{ + enable_disable_restoring (dialog); +} + void setup_xkb_tabs (GladeXML * dialog, GConfChangeSet * changeset) { + XklInit (GDK_DISPLAY ()); XklConfigInit (); XklConfigLoadRegistry (); @@ -207,4 +217,30 @@ setup_xkb_tabs (GladeXML * dialog, GConfChangeSet * changeset) g_signal_connect (G_OBJECT (WID ("keyboard_dialog")), "destroy", G_CALLBACK (cleanup_xkb_tabs), dialog); + + gconf_client_notify_add (gconf_client_get_default (), + GSWITCHIT_CONFIG_XKB_KEY_MODEL, + (GConfClientNotifyFunc) + update_model, dialog, NULL, NULL); + + enable_disable_restoring (dialog); +} + +void +enable_disable_restoring (GladeXML * dialog) +{ + GSwitchItXkbConfig gswic; + GConfClient *confClient = gconf_client_get_default (); + gboolean enable; + + memset (&gswic, 0, sizeof (gswic)); + + GSwitchItXkbConfigInit (&gswic, confClient); + g_object_unref (confClient); + GSwitchItXkbConfigLoad (&gswic); + + enable = !GSwitchItXkbConfigEqualsToInitial (&gswic); + + GSwitchItXkbConfigTerm (&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 27668f09c..8a7a2e843 100644 --- a/capplets/keyboard/gnome-keyboard-properties-xkb.h +++ b/capplets/keyboard/gnome-keyboard-properties-xkb.h @@ -56,5 +56,7 @@ extern char *xci_desc_to_utf8 (XklConfigItem * ci); extern void sort_tree_content (GtkWidget * treeView); +extern void enable_disable_restoring(GladeXML * dialog); + G_END_DECLS #endif /* __GNOME_KEYBOARD_PROPERTY_XKB_H */ diff --git a/capplets/keyboard/gnome-keyboard-properties-xkblt.c b/capplets/keyboard/gnome-keyboard-properties-xkblt.c index 51840e8d8..4c18b260b 100644 --- a/capplets/keyboard/gnome-keyboard-properties-xkblt.c +++ b/capplets/keyboard/gnome-keyboard-properties-xkblt.c @@ -357,6 +357,7 @@ update_layouts_list (GConfClient * client, guint cnxn_id, GConfEntry * entry, GladeXML * dialog) { fill_selected_layouts_tree (dialog); + enable_disable_restoring (dialog); } void diff --git a/capplets/keyboard/gnome-keyboard-properties-xkbot.c b/capplets/keyboard/gnome-keyboard-properties-xkbot.c index 24c3ea2a2..20632d8b3 100644 --- a/capplets/keyboard/gnome-keyboard-properties-xkbot.c +++ b/capplets/keyboard/gnome-keyboard-properties-xkbot.c @@ -375,6 +375,7 @@ update_options_list (GConfClient * client, guint cnxn_id, GConfEntry * entry, GladeXML * dialog) { fill_selected_options_tree (dialog); + enable_disable_restoring (dialog); } void