[gnome-session] capplet: Use g_settings_bind() to simplify code
- From: Vincent Untz <vuntz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-session] capplet: Use g_settings_bind() to simplify code
- Date: Wed, 2 Feb 2011 02:50:01 +0000 (UTC)
commit 11d9ec5976671e54714a4667e5ca45c925c0d762
Author: Vincent Untz <vuntz gnome org>
Date: Wed Feb 2 03:11:09 2011 +0100
capplet: Use g_settings_bind() to simplify code
Also unref the GSettings on dispose().
capplet/gsm-properties-dialog.c | 57 +++++----------------------------------
1 files changed, 7 insertions(+), 50 deletions(-)
---
diff --git a/capplet/gsm-properties-dialog.c b/capplet/gsm-properties-dialog.c
index c3d9a2a..9bec95e 100644
--- a/capplet/gsm-properties-dialog.c
+++ b/capplet/gsm-properties-dialog.c
@@ -61,8 +61,6 @@ struct GsmPropertiesDialogPrivate
GtkWidget *delete_button;
GtkWidget *edit_button;
- GtkWidget *remember_toggle;
-
GSettings *settings;
GspAppManager *manager;
@@ -457,41 +455,6 @@ on_row_activated (GtkTreeView *tree_view,
}
static void
-on_autosave_value_setting_changed (GSettings *settings,
- const gchar *key,
- GsmPropertiesDialog *dialog)
-{
- gboolean gval;
- gboolean bval;
-
- gval = g_settings_get_boolean (dialog->priv->settings, key);
- bval = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->remember_toggle));
-
- if (bval != gval) {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->remember_toggle),
- gval);
- }
-}
-
-static void
-on_autosave_value_toggled (GtkToggleButton *button,
- GsmPropertiesDialog *dialog)
-{
- gboolean gval;
- gboolean bval;
-
- gval = g_settings_get_boolean (dialog->priv->settings,
- SPC_SETTINGS_AUTOSAVE_KEY);
- bval = gtk_toggle_button_get_active (button);
-
- if (gval != bval) {
- g_settings_set_boolean (dialog->priv->settings,
- SPC_SETTINGS_AUTOSAVE_KEY,
- bval);
- }
-}
-
-static void
on_save_session_clicked (GtkWidget *widget,
GsmPropertiesDialog *dialog)
{
@@ -661,19 +624,8 @@ setup_dialog (GsmPropertiesDialog *dialog)
button = GTK_WIDGET (gtk_builder_get_object (dialog->priv->xml,
CAPPLET_REMEMBER_WIDGET_NAME));
- dialog->priv->remember_toggle = button;
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
- g_settings_get_boolean (dialog->priv->settings,
- SPC_SETTINGS_AUTOSAVE_KEY));
- g_signal_connect (dialog->priv->settings,
- "changed::" SPC_SETTINGS_AUTOSAVE_KEY,
- G_CALLBACK (on_autosave_value_setting_changed),
- dialog);
-
- g_signal_connect (button,
- "toggled",
- G_CALLBACK (on_autosave_value_toggled),
- dialog);
+ g_settings_bind (dialog->priv->settings, SPC_SETTINGS_AUTOSAVE_KEY,
+ button, "active", G_SETTINGS_BIND_DEFAULT);
button = GTK_WIDGET (gtk_builder_get_object (dialog->priv->xml,
CAPPLET_SAVE_WIDGET_NAME));
@@ -725,6 +677,11 @@ gsm_properties_dialog_dispose (GObject *object)
dialog->priv->xml = NULL;
}
+ if (dialog->priv->settings != NULL) {
+ g_object_unref (dialog->priv->settings);
+ dialog->priv->settings = NULL;
+ }
+
G_OBJECT_CLASS (gsm_properties_dialog_parent_class)->dispose (object);
/* it's important to do this after chaining to the parent dispose
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]