Commit 6f4a2e7e authored by Rodrigo Moya's avatar Rodrigo Moya
Browse files

keyboard: Use GSettings for the settings in g-s-d schemas

parent f80b6b28
......@@ -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");
......
......@@ -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); */
......
......@@ -26,5 +26,5 @@
#include <gtk/gtk.h>
GtkWidget *gnome_keyboard_properties_init (GConfClient * client, GtkBuilder * dialog);
GtkWidget *gnome_keyboard_properties_init (GtkBuilder * dialog);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment