[almanah] core: Bind the StorageManager's key to GSettings



commit 727d98f1bdf532b7eb7806fb0f752c38c4a74086
Author: Philip Withnall <philip tecnocode co uk>
Date:   Mon Apr 18 17:56:59 2011 +0100

    core: Bind the StorageManager's key to GSettings

 src/application.c     |    9 +++++----
 src/storage-manager.c |    2 +-
 2 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/src/application.c b/src/application.c
index bdc83a8..3220bda 100644
--- a/src/application.c
+++ b/src/application.c
@@ -177,7 +177,7 @@ static void
 startup (GApplication *application)
 {
 	AlmanahApplicationPrivate *priv = ALMANAH_APPLICATION (application)->priv;
-	gchar *db_filename, *encryption_key;
+	gchar *db_filename;
 	GError *error = NULL;
 
 	/* Debug log handling */
@@ -193,11 +193,12 @@ startup (GApplication *application)
 
 	/* Open the DB */
 	db_filename = g_build_filename (g_get_user_data_dir (), "diary.db", NULL);
-	encryption_key = g_settings_get_string (priv->settings, "encryption-key");
-	priv->storage_manager = almanah_storage_manager_new (db_filename, encryption_key);
-	g_free (encryption_key);
+	priv->storage_manager = almanah_storage_manager_new (db_filename, NULL);
 	g_free (db_filename);
 
+	g_settings_bind (priv->settings, "encryption-key", priv->storage_manager, "encryption-key",
+	                 G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_NO_SENSITIVITY);
+
 	if (almanah_storage_manager_connect (priv->storage_manager, &error) == FALSE) {
 		GtkWidget *dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
 		                                            _("Error opening database"));
diff --git a/src/storage-manager.c b/src/storage-manager.c
index 3d19a05..b576621 100644
--- a/src/storage-manager.c
+++ b/src/storage-manager.c
@@ -94,7 +94,7 @@ almanah_storage_manager_class_init (AlmanahStorageManagerClass *klass)
 	                                 g_param_spec_string ("encryption-key",
 	                                                      "Encryption key", "The identifier for the encryption key in the user's keyring.",
 	                                                      NULL,
-	                                                      G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
 	storage_manager_signals[SIGNAL_DISCONNECTED] = g_signal_new ("disconnected",
 	                                                             G_TYPE_FROM_CLASS (klass),



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