aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
authorChris Toshok <toshok@ximian.com>2002-09-23 05:38:18 +0800
committerChris Toshok <toshok@src.gnome.org>2002-09-23 05:38:18 +0800
commit40dc05f68b7c8c7c813cf17fa5fc02c962183101 (patch)
treedcaa76217a1d70a60c5d96069e9befdc64f931ed /addressbook
parentf09e18ada3cfd6767b6fdbcf8cc9794bfbdcfafe (diff)
downloadgsoc2013-evolution-40dc05f68b7c8c7c813cf17fa5fc02c962183101.tar.gz
gsoc2013-evolution-40dc05f68b7c8c7c813cf17fa5fc02c962183101.tar.zst
gsoc2013-evolution-40dc05f68b7c8c7c813cf17fa5fc02c962183101.zip
[ Fixes #28165, 29171 ] check to see if the value has really changed. the
2002-09-22 Chris Toshok <toshok@ximian.com> [ Fixes #28165, 29171 ] * gui/component/select-names/e-select-names-manager.c (uris_listener): check to see if the value has really changed. the way the preferences dialog works is such that we'll get called when any of the Folder Options are changed (default folders, offline stuff, etc.) we really only want to tear down and build back up the completion books if the autocomplete folder setting changed. (read_completion_books_from_db): cache the folder list, and call load_completion_books. (load_completion_books): new function, loads from the cached_folder_list. (e_select_names_manager_init): init cached_folder_list to NULL. (e_select_names_manager_destroy): g_free (cached_folder_list). svn path=/trunk/; revision=18154
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/ChangeLog17
-rw-r--r--addressbook/gui/component/select-names/e-select-names-manager.c72
2 files changed, 64 insertions, 25 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 07d7a190f6..f9e4f4bcf2 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,20 @@
+2002-09-22 Chris Toshok <toshok@ximian.com>
+
+ [ Fixes #28165, 29171 ]
+ * gui/component/select-names/e-select-names-manager.c
+ (uris_listener): check to see if the value has really changed.
+ the way the preferences dialog works is such that we'll get called
+ when any of the Folder Options are changed (default folders,
+ offline stuff, etc.) we really only want to tear down and build
+ back up the completion books if the autocomplete folder setting
+ changed.
+ (read_completion_books_from_db): cache the folder list, and call
+ load_completion_books.
+ (load_completion_books): new function, loads from the
+ cached_folder_list.
+ (e_select_names_manager_init): init cached_folder_list to NULL.
+ (e_select_names_manager_destroy): g_free (cached_folder_list).
+
2002-09-20 Chris Toshok <toshok@ximian.com>
[ Fixes #30483 ]
diff --git a/addressbook/gui/component/select-names/e-select-names-manager.c b/addressbook/gui/component/select-names/e-select-names-manager.c
index b8b95507b6..5c24e482fa 100644
--- a/addressbook/gui/component/select-names/e-select-names-manager.c
+++ b/addressbook/gui/component/select-names/e-select-names-manager.c
@@ -386,6 +386,26 @@ open_book_cb (EBook *book, EBookStatus status, ESelectNamesManager *manager)
}
static void
+load_completion_books (ESelectNamesManager *manager)
+{
+ EFolderListItem *folders = e_folder_list_parse_xml (manager->cached_folder_list);
+ EFolderListItem *f;
+
+ for (f = folders; f && f->physical_uri; f++) {
+ char *uri;
+ EBook *book = e_book_new ();
+ gtk_object_ref (GTK_OBJECT (manager)); /* ref ourself before our async call */
+
+ if (!strncmp (f->physical_uri, "file:", 5))
+ uri = g_strdup_printf ("%s/addressbook.db", f->physical_uri);
+ else
+ uri = g_strdup (f->physical_uri);
+ addressbook_load_uri (book, uri, (EBookCallback)open_book_cb, manager);
+ }
+ e_folder_list_free_items (folders);
+}
+
+static void
read_completion_books_from_db (ESelectNamesManager *manager)
{
Bonobo_ConfigDatabase db;
@@ -401,23 +421,9 @@ read_completion_books_from_db (ESelectNamesManager *manager)
CORBA_exception_free (&ev);
if (val) {
- EFolderListItem *folders = e_folder_list_parse_xml (val);
- EFolderListItem *f;
-
- for (f = folders; f && f->physical_uri; f++) {
- char *uri;
- EBook *book = e_book_new ();
- gtk_object_ref (GTK_OBJECT (manager)); /* ref ourself before our async call */
-
- if (!strncmp (f->physical_uri, "file:", 5))
- uri = g_strdup_printf ("%s/addressbook.db", f->physical_uri);
- else
- uri = g_strdup (f->physical_uri);
- addressbook_load_uri (book, uri, (EBookCallback)open_book_cb, manager);
- }
- e_folder_list_free_items (folders);
-
- g_free (val);
+ g_free (manager->cached_folder_list);
+ manager->cached_folder_list = val;
+ load_completion_books(manager);
}
}
@@ -428,16 +434,29 @@ uris_listener (BonoboListener *listener, char *event_name,
{
ESelectNamesManager *manager = E_SELECT_NAMES_MANAGER (user_data);
GList *l;
- for (l = manager->entries; l; l = l->next) {
- ESelectNamesManagerEntry *entry = l->data;
- e_select_names_completion_clear_books (E_SELECT_NAMES_COMPLETION (entry->comp));
- }
+ Bonobo_ConfigDatabase db;
+ char *val;
- g_list_foreach (manager->completion_books, (GFunc)gtk_object_unref, NULL);
- g_list_free (manager->completion_books);
- manager->completion_books = NULL;
+ db = addressbook_config_database (NULL);
+
+ val = bonobo_config_get_string (db, "/Addressbook/Completion/uris", NULL);
- read_completion_books_from_db (manager);
+ if (val) {
+ if (!manager->cached_folder_list || strcmp (val, manager->cached_folder_list)) {
+ for (l = manager->entries; l; l = l->next) {
+ ESelectNamesManagerEntry *entry = l->data;
+ e_select_names_completion_clear_books (E_SELECT_NAMES_COMPLETION (entry->comp));
+ }
+
+ g_list_foreach (manager->completion_books, (GFunc)gtk_object_unref, NULL);
+ g_list_free (manager->completion_books);
+ manager->completion_books = NULL;
+
+ g_free (manager->cached_folder_list);
+ manager->cached_folder_list = val;
+ load_completion_books (manager);
+ }
+ }
}
/**
@@ -614,6 +633,7 @@ e_select_names_manager_init (ESelectNamesManager *manager)
manager->sections = NULL;
manager->entries = NULL;
manager->completion_books = NULL;
+ manager->cached_folder_list = NULL;
}
static void
@@ -641,6 +661,8 @@ e_select_names_manager_destroy (GtkObject *object)
manager->completion_books = NULL;
bonobo_event_source_client_remove_listener (addressbook_config_database (NULL), manager->listener_id, NULL);
+
+ g_free (manager->cached_folder_list);
}
static void