[gnome-control-center] keyboard: Bind scale widgets also via their GtkAdjustment



commit d7b59d3929eb0f2fb7dabb6a47630286831f12b1
Author: Rodrigo Moya <rodrigo gnome-db org>
Date:   Wed Oct 13 13:06:57 2010 +0200

    keyboard: Bind scale widgets also via their GtkAdjustment

 panels/keyboard/gnome-keyboard-properties-xkb.c   |    4 +-
 panels/keyboard/gnome-keyboard-properties-xkb.h   |    7 +--
 panels/keyboard/gnome-keyboard-properties-xkblt.c |    3 +-
 panels/keyboard/gnome-keyboard-properties.c       |   48 +++------------------
 4 files changed, 12 insertions(+), 50 deletions(-)
---
diff --git a/panels/keyboard/gnome-keyboard-properties-xkb.c b/panels/keyboard/gnome-keyboard-properties-xkb.c
index c6b29a4..d5abc37 100644
--- a/panels/keyboard/gnome-keyboard-properties-xkb.c
+++ b/panels/keyboard/gnome-keyboard-properties-xkb.c
@@ -155,7 +155,7 @@ chk_new_windows_inherit_layout_toggled (GtkWidget *
 }
 
 void
-setup_xkb_tabs (GtkBuilder * dialog, GConfChangeSet * changeset)
+setup_xkb_tabs (GtkBuilder * dialog)
 {
 	GtkWidget *chk_new_windows_inherit_layout =
 	    WID ("chk_new_windows_inherit_layout");
@@ -192,7 +192,7 @@ setup_xkb_tabs (GtkBuilder * dialog, GConfChangeSet * changeset)
 #endif
 		gtk_widget_hide (WID ("xkb_layouts_print"));
 
-	xkb_layouts_prepare_selected_tree (dialog, changeset);
+	xkb_layouts_prepare_selected_tree (dialog);
 	xkb_layouts_fill_selected_tree (dialog);
 
 	gtk_widget_set_sensitive (chk_new_windows_inherit_layout,
diff --git a/panels/keyboard/gnome-keyboard-properties-xkb.h b/panels/keyboard/gnome-keyboard-properties-xkb.h
index 4007a92..4d10715 100644
--- a/panels/keyboard/gnome-keyboard-properties-xkb.h
+++ b/panels/keyboard/gnome-keyboard-properties-xkb.h
@@ -24,7 +24,6 @@
 #ifndef __GNOME_KEYBOARD_PROPERTY_XKB_H
 #define __GNOME_KEYBOARD_PROPERTY_XKB_H
 
-#include <gconf/gconf-client.h>
 #include <gtk/gtk.h>
 
 #include "libgnomekbd/gkbd-keyboard-config.h"
@@ -39,8 +38,7 @@ extern GSettings *xkb_keyboard_settings;
 extern GSettings *xkb_desktop_settings;
 extern GkbdKeyboardConfig initial_config;
 
-extern void setup_xkb_tabs (GtkBuilder * dialog,
-			    GConfChangeSet * changeset);
+extern void setup_xkb_tabs (GtkBuilder * dialog);
 
 extern void xkb_layouts_fill_selected_tree (GtkBuilder * dialog);
 
@@ -50,8 +48,7 @@ extern void xkb_layouts_register_conf_listener (GtkBuilder * dialog);
 
 extern void xkb_options_register_conf_listener (GtkBuilder * dialog);
 
-extern void xkb_layouts_prepare_selected_tree (GtkBuilder * dialog,
-					       GConfChangeSet * changeset);
+extern void xkb_layouts_prepare_selected_tree (GtkBuilder * dialog);
 
 extern void xkb_options_load_options (GtkBuilder * dialog);
 
diff --git a/panels/keyboard/gnome-keyboard-properties-xkblt.c b/panels/keyboard/gnome-keyboard-properties-xkblt.c
index dc9baa3..1f02615 100644
--- a/panels/keyboard/gnome-keyboard-properties-xkblt.c
+++ b/panels/keyboard/gnome-keyboard-properties-xkblt.c
@@ -203,8 +203,7 @@ xkb_layouts_dnd_data_received (GtkWidget * widget, GdkDragContext * dc,
 }
 
 void
-xkb_layouts_prepare_selected_tree (GtkBuilder * dialog,
-				   GConfChangeSet * changeset)
+xkb_layouts_prepare_selected_tree (GtkBuilder * dialog)
 {
 	GtkListStore *list_store =
 	    gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING,
diff --git a/panels/keyboard/gnome-keyboard-properties.c b/panels/keyboard/gnome-keyboard-properties.c
index c76cf66..5e41c98 100644
--- a/panels/keyboard/gnome-keyboard-properties.c
+++ b/panels/keyboard/gnome-keyboard-properties.c
@@ -41,8 +41,6 @@ enum {
 	RESPONSE_CLOSE
 };
 
-static void keyboard_settings_changed (GSettings *settings, const gchar *key, GtkBuilder *dialog);
-
 static GSettings *keyboard_settings = NULL;
 
 static void
@@ -120,22 +118,6 @@ dialog_response (GtkWidget * widget,
 }
 
 static void
-repeat_delay_scale_changed (GtkRange *range, GtkBuilder *builder)
-{
-	g_signal_handlers_block_by_func (keyboard_settings, keyboard_settings_changed, builder);
-	g_settings_set_int (keyboard_settings, "delay", (gint) gtk_range_get_value (range));
-	g_signal_handlers_unblock_by_func (keyboard_settings, keyboard_settings_changed, builder);
-}
-
-static void
-repeat_speed_scale_changed (GtkRange *range, GtkBuilder *builder)
-{
-	g_signal_handlers_block_by_func (keyboard_settings, keyboard_settings_changed, builder);
-	g_settings_set_int (keyboard_settings, "rate", (gint) gtk_range_get_value (range));
-	g_signal_handlers_unblock_by_func (keyboard_settings, keyboard_settings_changed, builder);
-}
-
-static void
 setup_dialog (GtkBuilder * dialog)
 {
 	GObject *peditor;
@@ -143,12 +125,12 @@ setup_dialog (GtkBuilder * dialog)
 	g_settings_bind (keyboard_settings, "repeat",
 			 WID ("repeat_toggle"), "active",
 			 G_SETTINGS_BIND_DEFAULT);
-
-	/* For scale widgets, the mapping does not work, so connect to signals */
-	g_signal_connect (WID ("repeat_delay_scale"), "value_changed",
-			  G_CALLBACK (repeat_delay_scale_changed), NULL);
-	g_signal_connect (WID ("repeat_speed_scale"), "value_changed",
-			  G_CALLBACK (repeat_speed_scale_changed), NULL);
+	g_settings_bind (keyboard_settings, "delay",
+			 gtk_range_get_adjustment (GTK_RANGE (WID ("repeat_delay_scale"))), "value",
+			 G_SETTINGS_BIND_DEFAULT);
+	g_settings_bind (keyboard_settings, "rate",
+			 gtk_range_get_adjustment (GTK_RANGE (WID ("repeat_speed_scale"))), "value",
+			 G_SETTINGS_BIND_DEFAULT);
 
 	/* FIXME: GConf stuff that needs to be solved */
 	peditor = gconf_peditor_new_boolean
@@ -167,24 +149,10 @@ setup_dialog (GtkBuilder * dialog)
 	g_signal_connect (WID ("keyboard_dialog"), "response",
 			  (GCallback) dialog_response, NULL);
 
-	setup_xkb_tabs (dialog, NULL);
+	setup_xkb_tabs (dialog);
 	setup_a11y_tabs (dialog, NULL);
 }
 
-static void
-keyboard_settings_changed (GSettings *settings, const gchar *key, GtkBuilder *dialog)
-{
-	if (g_str_equal (key, "delay")) {
-		g_signal_handlers_block_by_func (WID ("repeat_delay_scale"), repeat_delay_scale_changed, dialog);
-		gtk_range_set_value (GTK_RANGE (WID ("repeat_delay_scale")), (gdouble) g_settings_get_int (settings, "delay"));
-		g_signal_handlers_unblock_by_func (WID ("repeat_delay_scale"), repeat_delay_scale_changed, dialog);
-	} else if (g_str_equal (key, "rate")) {
-		g_signal_handlers_block_by_func (WID ("repeat_speed_scale"), repeat_speed_scale_changed, dialog);
-		gtk_range_set_value (GTK_RANGE (WID ("repeat_speed_scale")), (gdouble) g_settings_get_int (settings, "rate"));
-		g_signal_handlers_unblock_by_func (WID ("repeat_speed_scale"), repeat_speed_scale_changed, dialog);
-	}
-}
-
 GtkWidget *
 gnome_keyboard_properties_init (GtkBuilder * dialog)
 {
@@ -192,8 +160,6 @@ gnome_keyboard_properties_init (GtkBuilder * dialog)
 
 	if (keyboard_settings == NULL) {
 		keyboard_settings = g_settings_new ("org.gnome.settings-daemon.peripherals.keyboard");
-		g_signal_connect (keyboard_settings, "changed",
-				  G_CALLBACK (keyboard_settings_changed), dialog);
 	}
 
 	create_dialog (dialog);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]