From 917e520bbe50ce58fb69d33438a580be487e96d8 Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Tue, 17 Dec 2002 18:26:52 +0000 Subject: [ Fixes bug #35135 ] don't free the default_book_uri here, it's done in 2002-12-17 Chris Toshok [ Fixes bug #35135 ] * backend/ebook/e-book-util.c (set_default_book_uri_local): don't free the default_book_uri here, it's done in set_default_book_uri. (set_default_book_uri): break some stuff out from set_default_book_uri_from_bonobo_conf to here so it can be used both from that function and the bonobo listener. (default_folder_listener): set the new default book uri. (set_default_book_uri_from_bonobo_conf): install the bonobo conf listener so we'll get updates. svn path=/trunk/; revision=19148 --- addressbook/backend/ebook/e-book-util.c | 45 ++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 9 deletions(-) (limited to 'addressbook/backend') diff --git a/addressbook/backend/ebook/e-book-util.c b/addressbook/backend/ebook/e-book-util.c index e84d0a144d..7852a84675 100644 --- a/addressbook/backend/ebook/e-book-util.c +++ b/addressbook/backend/ebook/e-book-util.c @@ -29,6 +29,7 @@ #include #include +#include #include "e-card-compare.h" typedef struct _CommonBookInfo CommonBookInfo; @@ -191,9 +192,6 @@ set_default_book_uri_local (void) { char *filename; - if (default_book_uri) - g_free (default_book_uri); - filename = g_build_filename (g_get_home_dir(), "evolution/local/Contacts/addressbook.db", NULL); @@ -201,6 +199,35 @@ set_default_book_uri_local (void) g_free (filename); } +static void +set_default_book_uri (char *val) +{ + if (default_book_uri) + g_free (default_book_uri); + + if (val) { + default_book_uri = e_book_expand_uri (val); + g_free (val); + } + else { + set_default_book_uri_local (); + } +} + +#define DEFAULT_CONTACTS_URI_PATH "/apps/evolution/shell/default_folders/contacts_uri" +static void +default_folder_listener (EConfigListener *cl, const char *key, gpointer data) +{ + char *val; + + if (strcmp (key, DEFAULT_CONTACTS_URI_PATH)) + return; + + val = e_config_listener_get_string (cl, DEFAULT_CONTACTS_URI_PATH); + + set_default_book_uri (val); +} + static void set_default_book_uri_from_config_db (void) { @@ -208,13 +235,13 @@ set_default_book_uri_from_config_db (void) EConfigListener* config_db; config_db = e_book_get_config_database (); - val = e_config_listener_get_string_with_default (config_db, "/apps/Evolution/DefaultFolders/contacts_uri", NULL, NULL); + val = e_config_listener_get_string_with_default (config_db, DEFAULT_CONTACTS_URI_PATH, NULL, NULL); - if (val) { - default_book_uri = e_book_expand_uri (val); - g_free (val); - } else - set_default_book_uri_local (); + g_signal_connect (config_db, + "key_changed", + G_CALLBACK (default_folder_listener), NULL); + + set_default_book_uri (val); } typedef struct { -- cgit v1.2.3