aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/ChangeLog36
-rw-r--r--addressbook/gui/component/select-names/e-select-names-completion.c211
-rw-r--r--addressbook/gui/component/select-names/e-select-names-completion.h2
-rw-r--r--addressbook/gui/component/select-names/e-select-names-manager.c11
4 files changed, 170 insertions, 90 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 38402519e6..339178451f 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,5 +1,41 @@
2001-10-27 Chris Toshok <toshok@ximian.com>
+ * gui/component/select-names/e-select-names-completion.c
+ (e_select_names_completion_destroy): free up all the book_data
+ list stuff.
+ (e_select_names_completion_got_book_view_cb): deal with book_data
+ being passed as the closure, and increment the
+ pending_completion_seq counter.
+ (e_select_names_completion_card_added_cb): deal with book_data
+ being passwd as the closure.
+ (e_select_names_completion_seq_complete_cb): same, and decrement
+ the pending_completion_seq if we haven't gotten one for this book
+ view before.
+ (e_select_names_completion_stop_query): cancel all the
+ book_data's.
+ (e_select_names_completion_start_query): use the books_not_ready
+ counter instead of book_ready. also, do e_book_get_book_view on
+ each of the book's in our list.
+ (e_select_names_completion_do_query): change to deal with our
+ list.
+ (e_select_names_completion_book_ready): decrement the
+ book_not_ready counter.
+ (e_select_names_completion_new): add the book we're created with
+ to our list.
+ (e_select_names_completion_add_book): implement.
+
+ * gui/component/select-names/e-select-names-completion.h: add
+ prototype for e_select_names_completion_add_book.
+
+ * gui/component/select-names/e-select-names-manager.c
+ (e_select_names_manager_new): use addressbook_config_data, and
+ don't unref the db.
+ (e_select_names_manager_create_entry): always add NULL for a book
+ (which corresponds to the local book), and if the completion_book
+ is present, add it to the list of books to complete again.
+
+2001-10-27 Chris Toshok <toshok@ximian.com>
+
* gui/contact-editor/e-contact-quick-add.c (merge_cb): change to
EBookCallback signature, and unref the book.
(quick_add_merge_card): use addressbook_load_default_book.
diff --git a/addressbook/gui/component/select-names/e-select-names-completion.c b/addressbook/gui/component/select-names/e-select-names-completion.c
index 2e2cd03be1..1899662dda 100644
--- a/addressbook/gui/component/select-names/e-select-names-completion.c
+++ b/addressbook/gui/component/select-names/e-select-names-completion.c
@@ -43,18 +43,23 @@
#include <addressbook/backend/ebook/e-card-simple.h>
#include <addressbook/backend/ebook/e-card-compare.h>
-
-struct _ESelectNamesCompletionPrivate {
-
- ESelectNamesModel *model;
-
+typedef struct {
EBook *book;
- gboolean book_ready;
-
guint book_view_tag;
EBookView *book_view;
+ ESelectNamesCompletion *comp;
guint card_added_tag;
guint seq_complete_tag;
+ gboolean sequence_complete_received;
+} ESelectNamesCompletionBookData;
+
+struct _ESelectNamesCompletionPrivate {
+
+ ESelectNamesModel *model;
+
+ GList *book_data;
+ gint books_not_ready;
+ gint pending_completion_seq;
gchar *waiting_query;
gint waiting_pos, waiting_limit;
@@ -725,26 +730,28 @@ static void
e_select_names_completion_destroy (GtkObject *object)
{
ESelectNamesCompletion *comp = E_SELECT_NAMES_COMPLETION (object);
+ GList *l;
if (comp->priv->model)
gtk_object_unref (GTK_OBJECT (comp->priv->model));
- if (comp->priv->book)
- gtk_object_unref (GTK_OBJECT (comp->priv->book));
-
- if (comp->priv->card_added_tag) {
- gtk_signal_disconnect (GTK_OBJECT (comp->priv->book_view), comp->priv->card_added_tag);
- comp->priv->card_added_tag = 0;
- }
-
- if (comp->priv->seq_complete_tag) {
- gtk_signal_disconnect (GTK_OBJECT (comp->priv->book_view), comp->priv->seq_complete_tag);
- comp->priv->seq_complete_tag = 0;
+ for (l = comp->priv->book_data; l; l = l->next) {
+ ESelectNamesCompletionBookData *book_data = l->data;
+ gtk_object_unref (GTK_OBJECT (book_data->book));
+ if (book_data->book_view)
+ gtk_object_unref (GTK_OBJECT (book_data->book_view));
+ if (book_data->card_added_tag) {
+ gtk_signal_disconnect (GTK_OBJECT (book_data->book_view), book_data->card_added_tag);
+ book_data->card_added_tag = 0;
+ }
+ if (book_data->seq_complete_tag) {
+ gtk_signal_disconnect (GTK_OBJECT (book_data->book_view), book_data->seq_complete_tag);
+ book_data->seq_complete_tag = 0;
+ }
+ g_free (book_data);
}
+ g_list_free (comp->priv->book_data);
- if (comp->priv->book_view)
- gtk_object_unref (GTK_OBJECT (comp->priv->book_view));
-
g_free (comp->priv->waiting_query);
g_free (comp->priv->query_text);
@@ -800,46 +807,50 @@ static void
e_select_names_completion_got_book_view_cb (EBook *book, EBookStatus status, EBookView *view, gpointer user_data)
{
ESelectNamesCompletion *comp;
+ ESelectNamesCompletionBookData *book_data;
if (status != E_BOOK_STATUS_SUCCESS)
return;
- comp = E_SELECT_NAMES_COMPLETION (user_data);
+ book_data = (ESelectNamesCompletionBookData*)user_data;
+ comp = book_data->comp;
- comp->priv->book_view_tag = 0;
+ book_data->book_view_tag = 0;
- if (comp->priv->card_added_tag) {
- gtk_signal_disconnect (GTK_OBJECT (comp->priv->book_view), comp->priv->card_added_tag);
- comp->priv->card_added_tag = 0;
+ if (book_data->card_added_tag) {
+ gtk_signal_disconnect (GTK_OBJECT (book_data->book_view), book_data->card_added_tag);
+ book_data->card_added_tag = 0;
}
- if (comp->priv->seq_complete_tag) {
- gtk_signal_disconnect (GTK_OBJECT (comp->priv->book_view), comp->priv->seq_complete_tag);
- comp->priv->seq_complete_tag = 0;
+ if (book_data->seq_complete_tag) {
+ gtk_signal_disconnect (GTK_OBJECT (book_data->book_view), book_data->seq_complete_tag);
+ book_data->seq_complete_tag = 0;
}
gtk_object_ref (GTK_OBJECT (view));
- if (comp->priv->book_view)
- gtk_object_unref (GTK_OBJECT (comp->priv->book_view));
- comp->priv->book_view = view;
+ if (book_data->book_view)
+ gtk_object_unref (GTK_OBJECT (book_data->book_view));
+ book_data->book_view = view;
- comp->priv->card_added_tag =
+ book_data->card_added_tag =
gtk_signal_connect (GTK_OBJECT (view),
"card_added",
GTK_SIGNAL_FUNC (e_select_names_completion_card_added_cb),
- comp);
+ book_data);
- comp->priv->seq_complete_tag =
+ book_data->seq_complete_tag =
gtk_signal_connect (GTK_OBJECT (view),
"sequence_complete",
GTK_SIGNAL_FUNC (e_select_names_completion_seq_complete_cb),
- comp);
+ book_data);
+ book_data->sequence_complete_received = FALSE;
+ comp->priv->pending_completion_seq++;
}
static void
e_select_names_completion_card_added_cb (EBookView *book_view, const GList *cards, gpointer user_data)
{
- ESelectNamesCompletion *comp = E_SELECT_NAMES_COMPLETION (user_data);
-
+ ESelectNamesCompletionBookData *book_data = user_data;
+ ESelectNamesCompletion *comp = book_data->comp;
if (e_completion_searching (E_COMPLETION (comp))) {
book_query_process_card_list (comp, cards);
@@ -856,7 +867,8 @@ e_select_names_completion_card_added_cb (EBookView *book_view, const GList *card
static void
e_select_names_completion_seq_complete_cb (EBookView *book_view, gpointer user_data)
{
- ESelectNamesCompletion *comp = E_SELECT_NAMES_COMPLETION (user_data);
+ ESelectNamesCompletionBookData *book_data = user_data;
+ ESelectNamesCompletion *comp = E_SELECT_NAMES_COMPLETION(book_data->comp);
/*
* We aren't searching, but the addressbook has changed -- clear our card cache so that
@@ -867,6 +879,13 @@ e_select_names_completion_seq_complete_cb (EBookView *book_view, gpointer user_d
return;
}
+ if (!book_data->sequence_complete_received) {
+ book_data->sequence_complete_received = TRUE;
+ comp->priv->pending_completion_seq --;
+ if (comp->priv->pending_completion_seq > 0)
+ return;
+ }
+
g_free (comp->priv->query_text);
comp->priv->query_text = NULL;
@@ -887,6 +906,8 @@ e_select_names_completion_seq_complete_cb (EBookView *book_view, gpointer user_d
static void
e_select_names_completion_stop_query (ESelectNamesCompletion *comp)
{
+ GList *l;
+
g_return_if_fail (comp && E_IS_SELECT_NAMES_COMPLETION (comp));
if (out)
@@ -902,31 +923,32 @@ e_select_names_completion_stop_query (ESelectNamesCompletion *comp)
g_free (comp->priv->query_text);
comp->priv->query_text = NULL;
- if (comp->priv->book_view_tag) {
- if (out)
- fprintf (out, "cancelled book view creation\n");
- e_book_cancel (comp->priv->book, comp->priv->book_view_tag);
- comp->priv->book_view_tag = 0;
- }
-
- if (comp->priv->book_view) {
-
- if (out)
- fprintf (out, "disconnecting book view signals\n");
-
- if (comp->priv->card_added_tag) {
- gtk_signal_disconnect (GTK_OBJECT (comp->priv->book_view), comp->priv->card_added_tag);
- comp->priv->card_added_tag = 0;
- }
- if (comp->priv->seq_complete_tag) {
- gtk_signal_disconnect (GTK_OBJECT (comp->priv->book_view), comp->priv->seq_complete_tag);
- comp->priv->seq_complete_tag = 0;
+ for (l = comp->priv->book_data; l; l = l->next) {
+ ESelectNamesCompletionBookData *book_data = l->data;
+ if (book_data->book_view_tag) {
+ if (out)
+ fprintf (out, "cancelled book view creation\n");
+ e_book_cancel (book_data->book, book_data->book_view_tag);
+ book_data->book_view_tag = 0;
}
+ if (book_data->book_view) {
+ if (out)
+ fprintf (out, "disconnecting book view signals\n");
+
+ if (book_data->card_added_tag) {
+ gtk_signal_disconnect (GTK_OBJECT (book_data->book_view), book_data->card_added_tag);
+ book_data->card_added_tag = 0;
+ }
+ if (book_data->seq_complete_tag) {
+ gtk_signal_disconnect (GTK_OBJECT (book_data->book_view), book_data->seq_complete_tag);
+ book_data->seq_complete_tag = 0;
+ }
- if (out)
- fprintf (out, "unrefed book view\n");
- gtk_object_unref (GTK_OBJECT (comp->priv->book_view));
- comp->priv->book_view = NULL;
+ if (out)
+ fprintf (out, "unrefed book view\n");
+ gtk_object_unref (GTK_OBJECT (book_data->book_view));
+ book_data->book_view = NULL;
+ }
}
/* Clear the cache, which may contain partial results. */
@@ -942,7 +964,7 @@ e_select_names_completion_start_query (ESelectNamesCompletion *comp, const gchar
e_select_names_completion_stop_query (comp); /* Stop any prior queries. */
- if (comp->priv->book_ready) {
+ if (comp->priv->books_not_ready == 0) {
gchar *sexp;
g_free (comp->priv->query_text);
@@ -953,15 +975,18 @@ e_select_names_completion_start_query (ESelectNamesCompletion *comp, const gchar
sexp = book_query_sexp (comp);
if (sexp && *sexp) {
+ GList *l;
if (out)
fprintf (out, "\n\n**** starting query: \"%s\"\n", comp->priv->query_text);
- comp->priv->book_view_tag = e_book_get_book_view (comp->priv->book, sexp,
- e_select_names_completion_got_book_view_cb, comp);
-
- if (! comp->priv->book_view_tag)
- g_warning ("Exception calling e_book_get_book_view");
+ for (l = comp->priv->book_data; l; l = l->next) {
+ ESelectNamesCompletionBookData *book_data = l->data;
+ book_data->book_view_tag = e_book_get_book_view (book_data->book, sexp,
+ e_select_names_completion_got_book_view_cb, book_data);
+ if (! book_data->book_view_tag)
+ g_warning ("Exception calling e_book_get_book_view");
+ }
} else {
g_free (comp->priv->query_text);
@@ -981,6 +1006,7 @@ e_select_names_completion_do_query (ESelectNamesCompletion *comp, const gchar *q
{
gchar *clean;
gboolean query_is_still_running, can_reuse_cached_cards;
+ GList *l;
g_return_if_fail (comp != NULL);
g_return_if_fail (E_IS_SELECT_NAMES_COMPLETION (comp));
@@ -992,7 +1018,13 @@ e_select_names_completion_do_query (ESelectNamesCompletion *comp, const gchar *q
return;
}
- query_is_still_running = comp->priv->book_view_tag;
+ query_is_still_running = FALSE;
+ for (l = comp->priv->book_data; l; l = l->next) {
+ ESelectNamesCompletionBookData *book_data = l->data;
+ query_is_still_running = book_data->book_view_tag;
+ if (query_is_still_running)
+ break;
+ }
if (out) {
fprintf (out, "do_query: %s => %s\n", query_text, clean);
@@ -1148,7 +1180,7 @@ check_capabilities (ESelectNamesCompletion *comp, EBook *book)
static void
e_select_names_completion_book_ready (EBook *book, EBookStatus status, ESelectNamesCompletion *comp)
{
- comp->priv->book_ready = TRUE;
+ comp->priv->books_not_ready--;
g_return_if_fail (E_IS_BOOK (book));
g_return_if_fail (E_IS_SELECT_NAMES_COMPLETION (comp));
@@ -1157,7 +1189,7 @@ e_select_names_completion_book_ready (EBook *book, EBookStatus status, ESelectNa
/* If waiting_query is non-NULL, someone tried to start a query before the book was ready.
Now that it is, get started. */
- if (comp->priv->waiting_query) {
+ if (comp->priv->books_not_ready == 0 && comp->priv->waiting_query) {
e_select_names_completion_start_query (comp, comp->priv->waiting_query);
g_free (comp->priv->waiting_query);
comp->priv->waiting_query = NULL;
@@ -1185,23 +1217,21 @@ e_select_names_completion_new (EBook *book, ESelectNamesModel *model)
comp = (ESelectNamesCompletion *) gtk_type_new (e_select_names_completion_get_type ());
if (book == NULL) {
+ ESelectNamesCompletionBookData *book_data = g_new0 (ESelectNamesCompletionBookData, 1);
- comp->priv->book = e_book_new ();
- gtk_object_ref (GTK_OBJECT (comp->priv->book));
- gtk_object_sink (GTK_OBJECT (comp->priv->book));
+ book_data->book = e_book_new ();
+ book_data->comp = comp;
+ gtk_object_ref (GTK_OBJECT (book_data->book));
+ gtk_object_sink (GTK_OBJECT (book_data->book));
+
+ comp->priv->book_data = g_list_append (comp->priv->book_data, book_data);
+ comp->priv->books_not_ready++;
- comp->priv->book_ready = FALSE;
gtk_object_ref (GTK_OBJECT (comp)); /* ref ourself before our async call */
- e_book_load_local_address_book (comp->priv->book, (EBookCallback) e_select_names_completion_book_ready, comp);
+ e_book_load_local_address_book (book_data->book, (EBookCallback) e_select_names_completion_book_ready, comp);
} else {
-
- comp->priv->book = book;
- gtk_object_ref (GTK_OBJECT (comp->priv->book));
- comp->priv->book_ready = TRUE;
-
- check_capabilities (comp, book);
-
+ e_select_names_completion_add_book (comp, book);
}
comp->priv->model = model;
@@ -1210,6 +1240,21 @@ e_select_names_completion_new (EBook *book, ESelectNamesModel *model)
return E_COMPLETION (comp);
}
+void
+e_select_names_completion_add_book (ESelectNamesCompletion *comp, EBook *book)
+{
+ ESelectNamesCompletionBookData *book_data;
+
+ g_return_if_fail (book != NULL);
+
+ book_data = g_new0 (ESelectNamesCompletionBookData, 1);
+ book_data->book = book;
+ book_data->comp = comp;
+ check_capabilities (comp, book);
+ gtk_object_ref (GTK_OBJECT (book_data->book));
+ comp->priv->book_data = g_list_append (comp->priv->book_data, book_data);
+}
+
gboolean
e_select_names_completion_get_match_contact_lists (ESelectNamesCompletion *comp)
{
diff --git a/addressbook/gui/component/select-names/e-select-names-completion.h b/addressbook/gui/component/select-names/e-select-names-completion.h
index 8b79112569..03a30c3cc2 100644
--- a/addressbook/gui/component/select-names/e-select-names-completion.h
+++ b/addressbook/gui/component/select-names/e-select-names-completion.h
@@ -57,7 +57,7 @@ struct _ESelectNamesCompletionClass {
GtkType e_select_names_completion_get_type (void);
ECompletion *e_select_names_completion_new (EBook *, ESelectNamesModel *);
-
+void e_select_names_completion_add_book (ESelectNamesCompletion *, EBook *);
gboolean e_select_names_completion_get_match_contact_lists (ESelectNamesCompletion *);
void e_select_names_completion_set_match_contact_lists (ESelectNamesCompletion *, gboolean);
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 d422265c02..10b7662b31 100644
--- a/addressbook/gui/component/select-names/e-select-names-manager.c
+++ b/addressbook/gui/component/select-names/e-select-names-manager.c
@@ -120,7 +120,7 @@ e_select_names_manager_new (void)
CORBA_exception_init (&ev);
- db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", &ev);
+ db = addressbook_config_database (&ev);
val = bonobo_config_get_string (db, "/Addressbook/Completion/uri", &ev);
@@ -135,10 +135,6 @@ e_select_names_manager_new (void)
else
manager->completion_book = NULL;
- CORBA_exception_init (&ev);
- bonobo_object_release_unref (db, &ev);
- CORBA_exception_free (&ev);
-
return manager;
}
@@ -500,7 +496,10 @@ e_select_names_manager_create_entry (ESelectNamesManager *manager, const char *i
e_list_append (manager->entries, entry);
g_free(entry);
- comp = e_select_names_completion_new (manager->completion_book, section->model);
+ comp = e_select_names_completion_new (NULL, section->model);
+ if (manager->completion_book)
+ e_select_names_completion_add_book (E_SELECT_NAMES_COMPLETION (comp),
+ manager->completion_book);
e_entry_enable_completion_full (eentry, comp, 50, completion_handler);
gtk_object_set_data (GTK_OBJECT (eentry), "completion_handler", comp);