diff options
Diffstat (limited to 'addressbook/gui')
-rw-r--r-- | addressbook/gui/component/addressbook.c | 3 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-model.c | 49 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-model.h | 4 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-view.c | 72 |
4 files changed, 69 insertions, 59 deletions
diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c index 5baaa05733..7e43be131c 100644 --- a/addressbook/gui/component/addressbook.c +++ b/addressbook/gui/component/addressbook.c @@ -124,8 +124,7 @@ delete_contact_cb (BonoboUIComponent *uih, void *user_data, const char *path) { AddressbookView *view = (AddressbookView *) user_data; if (view->view) { - if (e_contact_editor_confirm_delete (GTK_WINDOW (view->view))) - e_addressbook_view_delete_selection(view->view); + e_addressbook_view_delete_selection(view->view); } } diff --git a/addressbook/gui/widgets/e-addressbook-model.c b/addressbook/gui/widgets/e-addressbook-model.c index 1d5b228bac..df537cbdf7 100644 --- a/addressbook/gui/widgets/e-addressbook-model.c +++ b/addressbook/gui/widgets/e-addressbook-model.c @@ -197,24 +197,42 @@ create_card(EBookView *book_view, static void remove_card(EBookView *book_view, - const char *id, + GList *ids, EAddressbookModel *model) { - int i; + int i = 0; + int num_deleted = 0; + GList *l; + + /* XXX this is really broken. the CARD_REMOVED signal should + be enough for us, but the !(*@#& EReflow mess can't delete + single objects at a time. In fact it can't remove objects + at all. every deletion = model_changed. */ + for (l = ids; l; l = l->next) { + char *id = l->data; + for ( i = 0; i < model->data_count; i++) { + if ( !strcmp(e_card_get_id(model->data[i]), id) ) { + g_object_unref (model->data[i]); + memmove(model->data + i, model->data + i + 1, (model->data_count - i - 1) * sizeof (ECard *)); + model->data_count--; - for ( i = 0; i < model->data_count; i++) { - if ( !strcmp(e_card_get_id(model->data[i]), id) ) { - g_object_unref (model->data[i]); - memmove(model->data + i, model->data + i + 1, (model->data_count - i - 1) * sizeof (ECard *)); - model->data_count--; - - g_signal_emit (model, - e_addressbook_model_signals [CARD_REMOVED], 0, - i); - update_folder_bar_message (model); - break; + num_deleted++; + break; + } } } + + if (num_deleted == 1) { + g_signal_emit (model, + e_addressbook_model_signals [CARD_REMOVED], 0, + i); + update_folder_bar_message (model); + } + else if (num_deleted > 1) { + g_signal_emit (model, + e_addressbook_model_signals [MODEL_CHANGED], 0); + update_folder_bar_message (model); + } } static void @@ -480,9 +498,7 @@ get_view (EAddressbookModel *model) { if (model->book && model->query) { if (model->first_get_view) { - char *capabilities; - capabilities = e_book_get_static_capabilities (model->book); - if (capabilities && strstr (capabilities, "do-initial-query")) { + if (e_book_check_static_capability (model->book, "do-initial-query")) { e_book_get_book_view (model->book, model->query, book_view_loaded, model); } else { remove_book_view(model); @@ -493,7 +509,6 @@ get_view (EAddressbookModel *model) e_addressbook_model_signals [STOP_STATE_CHANGED], 0); } model->first_get_view = FALSE; - g_free (capabilities); } else e_book_get_book_view (model->book, model->query, book_view_loaded, model); diff --git a/addressbook/gui/widgets/e-addressbook-model.h b/addressbook/gui/widgets/e-addressbook-model.h index 4863c62e07..c5d9e6ca84 100644 --- a/addressbook/gui/widgets/e-addressbook-model.h +++ b/addressbook/gui/widgets/e-addressbook-model.h @@ -31,7 +31,9 @@ struct _EAddressbookModel { int data_count; int allocated_count; - int create_card_id, remove_card_id, modify_card_id, status_message_id, writable_status_id, sequence_complete_id, backend_died_id; + int create_card_id, remove_card_id, modify_card_id; + int status_message_id, writable_status_id, sequence_complete_id; + int backend_died_id; guint search_in_progress : 1; guint editable : 1; diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c index c13baa4a95..db1636693a 100644 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ b/addressbook/gui/widgets/e-addressbook-view.c @@ -746,21 +746,42 @@ delete (GtkWidget *widget, CardAndBook *card_and_book) { if (e_contact_editor_confirm_delete(GTK_WINDOW(gtk_widget_get_toplevel(card_and_book->view->widget)))) { EBook *book; - GList *list = get_card_list(card_and_book); GList *iterator; + gboolean bulk_remove = FALSE; + + bulk_remove = e_book_check_static_capability (card_and_book->view->model->book, + "bulk-remove"); g_object_get(card_and_book->view->model, "book", &book, NULL); - for (iterator = list; iterator; iterator = iterator->next) { - ECard *card = iterator->data; - /* Remove the card. */ - e_book_remove_card (book, - card, - NULL, - NULL); + if (bulk_remove) { + GList *ids = NULL; + + for (iterator = list; iterator; iterator = iterator->next) { + ECard *card = iterator->data; + ids = g_list_prepend (ids, (char*)e_card_get_id (card)); + } + + /* Remove the cards all at once. */ + e_book_remove_cards (book, + ids, + NULL, + NULL); + + g_list_free (ids); + } + else { + for (iterator = list; iterator; iterator = iterator->next) { + ECard *card = iterator->data; + /* Remove the card. */ + e_book_remove_card (book, + card, + NULL, + NULL); + } } e_free_object_list(list); } @@ -1735,42 +1756,15 @@ e_addressbook_view_print_preview(EAddressbookView *view) #endif } -static void -card_deleted_cb (EBook* book, EBookStatus status, gpointer user_data) -{ - if (status != E_BOOK_STATUS_SUCCESS) { - e_addressbook_error_dialog (_("Error removing card"), status); - } -} - -static void -do_remove (int i, gpointer user_data) -{ - EBook *book; - ECard *card; - EAddressbookView *view = user_data; - - g_object_get (view->model, - "book", &book, - NULL); - - card = e_addressbook_model_get_card (view->model, i); - - e_book_remove_card(book, card, card_deleted_cb, view); - - g_object_unref (card); -} - void e_addressbook_view_delete_selection(EAddressbookView *view) { - ESelectionModel *model = get_selection_model (view); + CardAndBook card_and_book; - g_return_if_fail (model); + memset (&card_and_book, 0, sizeof (card_and_book)); + card_and_book.view = view; - e_selection_model_foreach (model, - do_remove, - view); + delete (GTK_WIDGET (view), &card_and_book); } static void |