[gnome-utils/gsettings-tutorial: 10/22] [gsettings-tutorial] Use g_settings_bind() for the checkbox in the prefs
- From: Vincent Untz <vuntz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-utils/gsettings-tutorial: 10/22] [gsettings-tutorial] Use g_settings_bind() for the checkbox in the prefs
- Date: Sat, 17 Apr 2010 00:07:43 +0000 (UTC)
commit 70d4f444682a8c644a357ccafaeb94bca0760f34
Author: Vincent Untz <vuntz gnome org>
Date: Fri Apr 16 16:11:51 2010 -0400
[gsettings-tutorial] Use g_settings_bind() for the checkbox in the prefs
We use g_settings_bind() to directly link the state of a checkbox to a
setting key.
A few notes:
+ We created a new GSettings to access the key we wanted. But
g_settings_bind() will keep a reference to it, so we can safely
unreference it.
+ The checkbox will be destroyed once the prefs dialog is closed.
But there's no need to call g_settings_unbind(): the binding will
automatically be removed once the object is finalized.
baobab/src/baobab-prefs.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/baobab/src/baobab-prefs.c b/baobab/src/baobab-prefs.c
index 23bfd0a..21d955a 100644
--- a/baobab/src/baobab-prefs.c
+++ b/baobab/src/baobab-prefs.c
@@ -105,6 +105,7 @@ create_props (void)
{
GtkWidget *dlg, *check_enablehome;
GtkBuilder *builder;
+ GSettings *settings_properties;
GError *error = NULL;
props_changed = FALSE;
@@ -132,8 +133,12 @@ create_props (void)
read_gconf ();
check_enablehome = GTK_WIDGET (gtk_builder_get_object (builder, "check_enable_home"));
- gtk_toggle_button_set_active ((GtkToggleButton *) check_enablehome,
- baobab.bbEnableHomeMonitor);
+
+ settings_properties = g_settings_new ("org.gnome.baobab.properties");
+ g_settings_bind (settings_properties, "enable_home_monitor",
+ check_enablehome, "active",
+ G_SETTINGS_BIND_DEFAULT);
+ g_object_unref (settings_properties);
g_signal_connect_after ((GtkToggleButton *) check_enablehome,
"toggled", G_CALLBACK (enable_home_cb),
@@ -410,8 +415,4 @@ void
enable_home_cb (GtkToggleButton *togglebutton, gpointer user_data)
{
baobab.bbEnableHomeMonitor = gtk_toggle_button_get_active (togglebutton);
-
- gconf_client_set_bool (baobab.gconf_client, PROPS_ENABLE_HOME_MONITOR,
- baobab.bbEnableHomeMonitor, NULL);
-
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]