Return on cancellation. (simple_query_sequence_complete_cb): Act if not
2001-10-26 Jon Trowbridge <trow@ximian.com> * backend/ebook/e-book-util.c (simple_query_card_added_cb): Return on cancellation. (simple_query_sequence_complete_cb): Act if not cancelled. (simple_query_book_view_cb): Free & return on cancellation. (e_book_simple_query_cancel): Set cancellation flag. * gui/component/e-address-popup.c (e_address_popup_query): Hold a reference to ourselves for the duration of our addressbook fetch. (start_query): Release when we've fetched our addressbook. (e_address_popup_cleanup): Break out most of what we do in _destroy into a separate function. (e_address_popup_destroy): Class cleanup. (contact_editor_cb): Paranoid clean-up. (add_contacts_cb): Paranoid clean-up. (e_address_popup_ambiguous_email_add): Paranoid clean-up. svn path=/trunk/; revision=14199
This commit is contained in:

committed by
Jon Trowbridge

parent
3ba5381842
commit
d08917c280
@ -1,3 +1,21 @@
|
|||||||
|
2001-10-26 Jon Trowbridge <trow@ximian.com>
|
||||||
|
|
||||||
|
* backend/ebook/e-book-util.c (simple_query_card_added_cb): Return
|
||||||
|
on cancellation.
|
||||||
|
(simple_query_sequence_complete_cb): Act if not cancelled.
|
||||||
|
(simple_query_book_view_cb): Free & return on cancellation.
|
||||||
|
(e_book_simple_query_cancel): Set cancellation flag.
|
||||||
|
|
||||||
|
* gui/component/e-address-popup.c (e_address_popup_query): Hold a
|
||||||
|
reference to ourselves for the duration of our addressbook fetch.
|
||||||
|
(start_query): Release when we've fetched our addressbook.
|
||||||
|
(e_address_popup_cleanup): Break out most of what we do in
|
||||||
|
_destroy into a separate function.
|
||||||
|
(e_address_popup_destroy): Class cleanup.
|
||||||
|
(contact_editor_cb): Paranoid clean-up.
|
||||||
|
(add_contacts_cb): Paranoid clean-up.
|
||||||
|
(e_address_popup_ambiguous_email_add): Paranoid clean-up.
|
||||||
|
|
||||||
2001-10-26 JP Rosevear <jpr@ximian.com>
|
2001-10-26 JP Rosevear <jpr@ximian.com>
|
||||||
|
|
||||||
* conduit/e-address.conduit.in: remove the merges as valid sync
|
* conduit/e-address.conduit.in: remove the merges as valid sync
|
||||||
|
@ -138,6 +138,7 @@ struct _SimpleQueryInfo {
|
|||||||
guint add_tag;
|
guint add_tag;
|
||||||
guint seq_complete_tag;
|
guint seq_complete_tag;
|
||||||
GList *cards;
|
GList *cards;
|
||||||
|
gboolean cancelled;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -199,6 +200,7 @@ simple_query_new (EBook *book, const char *query, EBookSimpleQueryCallback cb, g
|
|||||||
sq->query = g_strdup_printf (query);
|
sq->query = g_strdup_printf (query);
|
||||||
sq->cb = cb;
|
sq->cb = cb;
|
||||||
sq->closure = closure;
|
sq->closure = closure;
|
||||||
|
sq->cancelled = FALSE;
|
||||||
|
|
||||||
/* Automatically add ourselves to the EBook's pending list. */
|
/* Automatically add ourselves to the EBook's pending list. */
|
||||||
book_add_simple_query (book, sq);
|
book_add_simple_query (book, sq);
|
||||||
@ -228,13 +230,13 @@ simple_query_disconnect (SimpleQueryInfo *sq)
|
|||||||
static void
|
static void
|
||||||
simple_query_free (SimpleQueryInfo *sq)
|
simple_query_free (SimpleQueryInfo *sq)
|
||||||
{
|
{
|
||||||
|
simple_query_disconnect (sq);
|
||||||
|
|
||||||
/* Remove ourselves from the EBook's pending list. */
|
/* Remove ourselves from the EBook's pending list. */
|
||||||
book_remove_simple_query (sq->book, sq);
|
book_remove_simple_query (sq->book, sq);
|
||||||
|
|
||||||
g_free (sq->query);
|
g_free (sq->query);
|
||||||
|
|
||||||
simple_query_disconnect (sq);
|
|
||||||
|
|
||||||
if (sq->book)
|
if (sq->book)
|
||||||
gtk_object_unref (GTK_OBJECT (sq->book));
|
gtk_object_unref (GTK_OBJECT (sq->book));
|
||||||
|
|
||||||
@ -249,6 +251,9 @@ simple_query_card_added_cb (EBookView *view, const GList *cards, gpointer closur
|
|||||||
{
|
{
|
||||||
SimpleQueryInfo *sq = closure;
|
SimpleQueryInfo *sq = closure;
|
||||||
|
|
||||||
|
if (sq->cancelled)
|
||||||
|
return;
|
||||||
|
|
||||||
sq->cards = g_list_concat (sq->cards, g_list_copy ((GList *) cards));
|
sq->cards = g_list_concat (sq->cards, g_list_copy ((GList *) cards));
|
||||||
g_list_foreach ((GList *) cards, (GFunc) gtk_object_ref, NULL);
|
g_list_foreach ((GList *) cards, (GFunc) gtk_object_ref, NULL);
|
||||||
}
|
}
|
||||||
@ -261,7 +266,8 @@ simple_query_sequence_complete_cb (EBookView *view, gpointer closure)
|
|||||||
/* Disconnect signals, so that we don't pick up any changes to the book that occur
|
/* Disconnect signals, so that we don't pick up any changes to the book that occur
|
||||||
in our callback */
|
in our callback */
|
||||||
simple_query_disconnect (sq);
|
simple_query_disconnect (sq);
|
||||||
sq->cb (sq->book, E_BOOK_SIMPLE_QUERY_STATUS_SUCCESS, sq->cards, sq->closure);
|
if (! sq->cancelled)
|
||||||
|
sq->cb (sq->book, E_BOOK_SIMPLE_QUERY_STATUS_SUCCESS, sq->cards, sq->closure);
|
||||||
simple_query_free (sq);
|
simple_query_free (sq);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,7 +276,13 @@ simple_query_book_view_cb (EBook *book, EBookStatus status, EBookView *book_view
|
|||||||
{
|
{
|
||||||
SimpleQueryInfo *sq = closure;
|
SimpleQueryInfo *sq = closure;
|
||||||
|
|
||||||
|
if (sq->cancelled) {
|
||||||
|
simple_query_free (sq);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (status != E_BOOK_STATUS_SUCCESS) {
|
if (status != E_BOOK_STATUS_SUCCESS) {
|
||||||
|
simple_query_disconnect (sq);
|
||||||
sq->cb (sq->book, E_BOOK_SIMPLE_QUERY_STATUS_OTHER_ERROR, NULL, sq->closure);
|
sq->cb (sq->book, E_BOOK_SIMPLE_QUERY_STATUS_OTHER_ERROR, NULL, sq->closure);
|
||||||
simple_query_free (sq);
|
simple_query_free (sq);
|
||||||
return;
|
return;
|
||||||
@ -314,8 +326,8 @@ e_book_simple_query_cancel (EBook *book, guint tag)
|
|||||||
sq = book_lookup_simple_query (book, tag);
|
sq = book_lookup_simple_query (book, tag);
|
||||||
|
|
||||||
if (sq) {
|
if (sq) {
|
||||||
|
sq->cancelled = TRUE;
|
||||||
sq->cb (sq->book, E_BOOK_SIMPLE_QUERY_STATUS_CANCELLED, NULL, sq->closure);
|
sq->cb (sq->book, E_BOOK_SIMPLE_QUERY_STATUS_CANCELLED, NULL, sq->closure);
|
||||||
simple_query_free (sq);
|
|
||||||
} else {
|
} else {
|
||||||
g_warning ("Simple query tag %d is unknown", tag);
|
g_warning ("Simple query tag %d is unknown", tag);
|
||||||
}
|
}
|
||||||
|
@ -676,25 +676,42 @@ e_address_popup_init (EAddressPopup *pop)
|
|||||||
pop->transitory = TRUE;
|
pop->transitory = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
e_address_popup_cleanup (EAddressPopup *pop)
|
||||||
|
{
|
||||||
|
if (pop->card) {
|
||||||
|
gtk_object_unref (GTK_OBJECT (pop->card));
|
||||||
|
pop = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pop->scheduled_refresh) {
|
||||||
|
gtk_timeout_remove (pop->scheduled_refresh);
|
||||||
|
pop->scheduled_refresh = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pop->query_tag) {
|
||||||
|
e_book_simple_query_cancel (pop->book, pop->query_tag);
|
||||||
|
pop->query_tag = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pop->book) {
|
||||||
|
gtk_object_unref (GTK_OBJECT (pop->book));
|
||||||
|
pop->book = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (pop->name);
|
||||||
|
pop->name = NULL;
|
||||||
|
|
||||||
|
g_free (pop->email);
|
||||||
|
pop->email = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
e_address_popup_destroy (GtkObject *obj)
|
e_address_popup_destroy (GtkObject *obj)
|
||||||
{
|
{
|
||||||
EAddressPopup *pop = E_ADDRESS_POPUP (obj);
|
EAddressPopup *pop = E_ADDRESS_POPUP (obj);
|
||||||
|
|
||||||
if (pop->card)
|
e_address_popup_cleanup (pop);
|
||||||
gtk_object_unref (GTK_OBJECT (pop->card));
|
|
||||||
|
|
||||||
if (pop->scheduled_refresh)
|
|
||||||
gtk_idle_remove (pop->scheduled_refresh);
|
|
||||||
|
|
||||||
if (pop->query_tag)
|
|
||||||
e_book_simple_query_cancel (pop->book, pop->query_tag);
|
|
||||||
|
|
||||||
if (pop->book)
|
|
||||||
gtk_object_unref (GTK_OBJECT (pop->book));
|
|
||||||
|
|
||||||
g_free (pop->name);
|
|
||||||
g_free (pop->email);
|
|
||||||
|
|
||||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||||
GTK_OBJECT_CLASS (parent_class)->destroy (obj);
|
GTK_OBJECT_CLASS (parent_class)->destroy (obj);
|
||||||
@ -751,7 +768,7 @@ e_address_popup_refresh_names (EAddressPopup *pop)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
refresh_idle_cb (gpointer ptr)
|
refresh_timeout_cb (gpointer ptr)
|
||||||
{
|
{
|
||||||
EAddressPopup *pop = E_ADDRESS_POPUP (ptr);
|
EAddressPopup *pop = E_ADDRESS_POPUP (ptr);
|
||||||
e_address_popup_refresh_names (pop);
|
e_address_popup_refresh_names (pop);
|
||||||
@ -763,7 +780,7 @@ static void
|
|||||||
e_address_popup_schedule_refresh (EAddressPopup *pop)
|
e_address_popup_schedule_refresh (EAddressPopup *pop)
|
||||||
{
|
{
|
||||||
if (pop->scheduled_refresh == 0)
|
if (pop->scheduled_refresh == 0)
|
||||||
pop->scheduled_refresh = gtk_idle_add (refresh_idle_cb, pop);
|
pop->scheduled_refresh = gtk_timeout_add (20, refresh_timeout_cb, pop);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we are handed something of the form "Foo <bar@bar.com>",
|
/* If we are handed something of the form "Foo <bar@bar.com>",
|
||||||
@ -911,6 +928,7 @@ contact_editor_cb (EBook *book, gpointer closure)
|
|||||||
{
|
{
|
||||||
EAddressPopup *pop = E_ADDRESS_POPUP (closure);
|
EAddressPopup *pop = E_ADDRESS_POPUP (closure);
|
||||||
EContactEditor *ce = e_addressbook_show_contact_editor (book, pop->card, FALSE, TRUE);
|
EContactEditor *ce = e_addressbook_show_contact_editor (book, pop->card, FALSE, TRUE);
|
||||||
|
e_address_popup_cleanup (pop);
|
||||||
emit_event (pop, "Destroy");
|
emit_event (pop, "Destroy");
|
||||||
e_contact_editor_raise (ce);
|
e_contact_editor_raise (ce);
|
||||||
}
|
}
|
||||||
@ -957,6 +975,7 @@ add_contacts_cb (EAddressPopup *pop)
|
|||||||
e_contact_quick_add_free_form (pop->email, NULL, NULL);
|
e_contact_quick_add_free_form (pop->email, NULL, NULL);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
e_address_popup_cleanup (pop);
|
||||||
emit_event (pop, "Destroy");
|
emit_event (pop, "Destroy");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1021,6 +1040,7 @@ e_address_popup_ambiguous_email_add (EAddressPopup *pop, const GList *cards)
|
|||||||
|
|
||||||
card_picker_init (wiz, cards, pop->name, pop->email);
|
card_picker_init (wiz, cards, pop->name, pop->email);
|
||||||
|
|
||||||
|
e_address_popup_cleanup (pop);
|
||||||
emit_event (pop, "Destroy");
|
emit_event (pop, "Destroy");
|
||||||
|
|
||||||
gtk_container_add (GTK_CONTAINER (win), wiz->body);
|
gtk_container_add (GTK_CONTAINER (win), wiz->body);
|
||||||
@ -1097,17 +1117,20 @@ static void
|
|||||||
start_query (EBook *book, gpointer closure)
|
start_query (EBook *book, gpointer closure)
|
||||||
{
|
{
|
||||||
EAddressPopup *pop = E_ADDRESS_POPUP (closure);
|
EAddressPopup *pop = E_ADDRESS_POPUP (closure);
|
||||||
|
|
||||||
if (pop->query_tag)
|
if (pop->query_tag)
|
||||||
e_book_simple_query_cancel (book, pop->query_tag);
|
e_book_simple_query_cancel (book, pop->query_tag);
|
||||||
|
|
||||||
if (pop->book != book) {
|
if (pop->book != book) {
|
||||||
gtk_object_ref (GTK_OBJECT (book));
|
gtk_object_ref (GTK_OBJECT (book));
|
||||||
gtk_object_unref (GTK_OBJECT (pop->book));
|
if (pop->book)
|
||||||
|
gtk_object_unref (GTK_OBJECT (pop->book));
|
||||||
pop->book = book;
|
pop->book = book;
|
||||||
}
|
}
|
||||||
|
|
||||||
pop->query_tag = e_book_name_and_email_query (book, pop->name, pop->email, query_cb, pop);
|
pop->query_tag = e_book_name_and_email_query (book, pop->name, pop->email, query_cb, pop);
|
||||||
|
|
||||||
|
gtk_object_unref (GTK_OBJECT (pop));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1115,6 +1138,7 @@ e_address_popup_query (EAddressPopup *pop)
|
|||||||
{
|
{
|
||||||
g_return_if_fail (pop && E_IS_ADDRESS_POPUP (pop));
|
g_return_if_fail (pop && E_IS_ADDRESS_POPUP (pop));
|
||||||
|
|
||||||
|
gtk_object_ref (GTK_OBJECT (pop));
|
||||||
e_book_use_local_address_book (start_query, pop);
|
e_book_use_local_address_book (start_query, pop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user