[gnome-control-center] keyboard: Use GSettings for the settings in g-s-d schemas
- From: Rodrigo Moya <rodrigo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] keyboard: Use GSettings for the settings in g-s-d schemas
- Date: Wed, 13 Oct 2010 11:07:13 +0000 (UTC)
commit 6f4a2e7e1451c236a39724a309afb55597d768c3
Author: Rodrigo Moya <rodrigo gnome-db org>
Date: Wed Oct 13 12:53:49 2010 +0200
keyboard: Use GSettings for the settings in g-s-d schemas
panels/keyboard/cc-keyboard-panel.c | 12 +---
panels/keyboard/gnome-keyboard-properties.c | 86 ++++++++++++++++++---------
panels/keyboard/gnome-keyboard-properties.h | 2 +-
3 files changed, 61 insertions(+), 39 deletions(-)
---
diff --git a/panels/keyboard/cc-keyboard-panel.c b/panels/keyboard/cc-keyboard-panel.c
index 1616cd8..b0c17de 100644
--- a/panels/keyboard/cc-keyboard-panel.c
+++ b/panels/keyboard/cc-keyboard-panel.c
@@ -20,7 +20,6 @@
*/
#include "cc-keyboard-panel.h"
-#include <gconf/gconf-client.h>
#include <gtk/gtk.h>
G_DEFINE_DYNAMIC_TYPE (CcKeyboardPanel, cc_keyboard_panel, CC_TYPE_PANEL)
@@ -28,7 +27,6 @@ G_DEFINE_DYNAMIC_TYPE (CcKeyboardPanel, cc_keyboard_panel, CC_TYPE_PANEL)
(G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_KEYBOARD_PANEL, CcKeyboardPanelPrivate))
struct _CcKeyboardPanelPrivate {
GtkBuilder *builder;
- GConfClient *client;
};
@@ -60,10 +58,6 @@ static void
cc_keyboard_panel_dispose (GObject * object)
{
CcKeyboardPanelPrivate *priv = CC_KEYBOARD_PANEL (object)->priv;
- if (priv->client) {
- g_object_unref (priv->client);
- priv->client = NULL;
- }
if (priv->builder) {
g_object_unref (priv->builder);
@@ -97,8 +91,7 @@ cc_keyboard_panel_class_finalize (CcKeyboardPanelClass * klass)
{
}
-GtkWidget *gnome_keyboard_properties_init (GConfClient * client,
- GtkBuilder * dialog);
+GtkWidget *gnome_keyboard_properties_init (GtkBuilder * dialog);
static void
cc_keyboard_panel_init (CcKeyboardPanel * self)
@@ -109,7 +102,6 @@ cc_keyboard_panel_init (CcKeyboardPanel * self)
priv = self->priv = KEYBOARD_PANEL_PRIVATE (self);
- priv->client = gconf_client_get_default ();
priv->builder = gtk_builder_new ();
gtk_builder_add_from_file (priv->builder,
@@ -121,7 +113,7 @@ cc_keyboard_panel_init (CcKeyboardPanel * self)
return;
}
- gnome_keyboard_properties_init (priv->client, priv->builder);
+ gnome_keyboard_properties_init (priv->builder);
prefs_widget = (GtkWidget *) gtk_builder_get_object (priv->builder,
"keyboard_notebook");
diff --git a/panels/keyboard/gnome-keyboard-properties.c b/panels/keyboard/gnome-keyboard-properties.c
index 920a5b8..c76cf66 100644
--- a/panels/keyboard/gnome-keyboard-properties.c
+++ b/panels/keyboard/gnome-keyboard-properties.c
@@ -7,6 +7,7 @@
* Written by: Bradford Hovinen <hovinen ximian com>
* Rachel Hestilow <hestilow ximian com>
* Jonathan Blandford <jrb redhat com>
+ * Rodrigo Moya <rodrigo gnome org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -27,8 +28,7 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-
-#include <gconf/gconf-client.h>
+#include <gio/gio.h>
#include "gconf-property-editor.h"
@@ -41,6 +41,10 @@ enum {
RESPONSE_CLOSE
};
+static void keyboard_settings_changed (GSettings *settings, const gchar *key, GtkBuilder *dialog);
+
+static GSettings *keyboard_settings = NULL;
+
static void
create_dialog (GtkBuilder * dialog)
{
@@ -116,31 +120,43 @@ dialog_response (GtkWidget * widget,
}
static void
-setup_dialog (GtkBuilder * dialog, GConfChangeSet * changeset)
+repeat_delay_scale_changed (GtkRange *range, GtkBuilder *builder)
{
- GObject *peditor;
- gchar *monitor;
+ 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);
+}
- peditor = gconf_peditor_new_boolean
- (changeset, "/desktop/gnome/peripherals/keyboard/repeat",
- WID ("repeat_toggle"), NULL);
- gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor),
- WID ("repeat_table"));
+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);
+}
- gconf_peditor_new_numeric_range
- (changeset, "/desktop/gnome/peripherals/keyboard/delay",
- WID ("repeat_delay_scale"), NULL);
+static void
+setup_dialog (GtkBuilder * dialog)
+{
+ GObject *peditor;
- gconf_peditor_new_numeric_range
- (changeset, "/desktop/gnome/peripherals/keyboard/rate",
- WID ("repeat_speed_scale"), NULL);
+ 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);
+
+ /* FIXME: GConf stuff that needs to be solved */
peditor = gconf_peditor_new_boolean
- (changeset, "/desktop/gnome/interface/cursor_blink",
+ (NULL, "/desktop/gnome/interface/cursor_blink",
WID ("cursor_toggle"), NULL);
gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor),
WID ("cursor_hbox"));
- gconf_peditor_new_numeric_range (changeset,
+ gconf_peditor_new_numeric_range (NULL,
"/desktop/gnome/interface/cursor_blink_time",
WID ("cursor_blink_time_scale"),
"conv-to-widget-cb",
@@ -149,26 +165,40 @@ setup_dialog (GtkBuilder * dialog, GConfChangeSet * changeset)
blink_from_widget, NULL);
g_signal_connect (WID ("keyboard_dialog"), "response",
- (GCallback) dialog_response, changeset);
+ (GCallback) dialog_response, NULL);
- setup_xkb_tabs (dialog, changeset);
- setup_a11y_tabs (dialog, changeset);
+ setup_xkb_tabs (dialog, NULL);
+ 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 (GConfClient * client, GtkBuilder * dialog)
+gnome_keyboard_properties_init (GtkBuilder * dialog)
{
GtkWidget *dialog_win = NULL;
- gconf_client_add_dir (client,
- "/desktop/gnome/peripherals/keyboard",
- GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
- gconf_client_add_dir (client, "/desktop/gnome/interface",
- GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+ 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);
if (dialog) {
- setup_dialog (dialog, NULL);
+ setup_dialog (dialog);
dialog_win = WID ("keyboard_dialog");
/* g_signal_connect (dialog_win, "response",
G_CALLBACK (dialog_response_cb), NULL); */
diff --git a/panels/keyboard/gnome-keyboard-properties.h b/panels/keyboard/gnome-keyboard-properties.h
index dc37ced..7b7b0ac 100644
--- a/panels/keyboard/gnome-keyboard-properties.h
+++ b/panels/keyboard/gnome-keyboard-properties.h
@@ -26,5 +26,5 @@
#include <gtk/gtk.h>
-GtkWidget *gnome_keyboard_properties_init (GConfClient * client, GtkBuilder * dialog);
+GtkWidget *gnome_keyboard_properties_init (GtkBuilder * dialog);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]