aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/widgets
diff options
context:
space:
mode:
authorChris Toshok <toshok@ximian.com>2003-02-08 17:06:46 +0800
committerChris Toshok <toshok@src.gnome.org>2003-02-08 17:06:46 +0800
commit0db95c91b293f6b1c87be3c0abdd1fb2b0ac5b42 (patch)
treedd2ae6faaeed6aa9002427a87cc573e4e8e4ef05 /addressbook/gui/widgets
parentaaa6c778e8c8458e107f564d12f1089880810f04 (diff)
downloadgsoc2013-evolution-0db95c91b293f6b1c87be3c0abdd1fb2b0ac5b42.tar
gsoc2013-evolution-0db95c91b293f6b1c87be3c0abdd1fb2b0ac5b42.tar.gz
gsoc2013-evolution-0db95c91b293f6b1c87be3c0abdd1fb2b0ac5b42.tar.bz2
gsoc2013-evolution-0db95c91b293f6b1c87be3c0abdd1fb2b0ac5b42.tar.lz
gsoc2013-evolution-0db95c91b293f6b1c87be3c0abdd1fb2b0ac5b42.tar.xz
gsoc2013-evolution-0db95c91b293f6b1c87be3c0abdd1fb2b0ac5b42.tar.zst
gsoc2013-evolution-0db95c91b293f6b1c87be3c0abdd1fb2b0ac5b42.zip
[ huge change, all for 1 little performance problem :) fixes #18207 ] use
2003-02-08 Chris Toshok <toshok@ximian.com> [ huge change, all for 1 little performance problem :) fixes #18207 ] * gui/widgets/e-addressbook-model.c (get_view): use e_book_check_static_capability here to make things a little prettier. (remove_card): complain about my life, and add code to use one "model_changed" signal if we get back a list of cards instead of multiple "card_removed" signals. * gui/widgets/e-addressbook-model.h: little clean up. * gui/widgets/e-addressbook-view.c (delete): write a bulk-remove case for this. if the backend supports it, send all the ids at once. otherwise loop over the ids. (e_addressbook_view_delete_selection): fake a CardAndBook structure and call delete, instead of duplicating the code in 2 places. * gui/component/addressbook.c (delete_contact_cb): don't call e_contact_editor_confirm_delete here, it's handled by the EAddressbookView. * backend/pas/pas-card-cursor.c (pas_card_cursor_construct): fix a compiler warning about a stupid crash. * backend/pas/pas-book.h (PASOperation): RemoveCard -> RemoveCards. (PASRemoveCardsReques): char *id -> GList *ids. (PASRequest): PASRemoveCardRequest -> PASRemoveCardsRequest. * backend/pas/pas-book.c (pas_book_queue_remove_cards): build up a GList from the id sequence. (pas_book_respond_remove): notifyCardRemoved -> notifyCardsRemoved. (impl_GNOME_Evolution_Addressbook_Book_removeCards): rename. (pas_book_free_request): free the idlist for RemoveCards. (pas_book_class_init): removeCard -> removeCards. * backend/pas/pas-book-view.h: change prototype for pas_book_view_notify_remove, and add prototype for pas_book_view_notify_remove_1. * backend/pas/pas-book-view.c (pas_book_view_notify_remove_1): build up a list and call pas_book_view_notify_remove. (pas_book_view_notify_remove): build up the corba id sequence and call BookViewListener::notifyCardsRemoved. * backend/pas/pas-backend.h: remove_card -> remove_cards. * backend/pas/pas-backend.c (pas_backend_remove_cards): rename from _remove_card. (process_client_requests): RemoveCard -> RemoveCards and _remove_card -> _remove_cards. * backend/pas/pas-backend-ldap.c (check_schema_support): g_strcasecmp -> g_ascii_strcasecmp. (remove_card_handler): _remove => _remove_1. (modify_card_modify_handler): same. (pas_backend_ldap_process_remove_cards): rename from _remove_card. (pas_backend_ldap_class_init): _remove_card -> _remove_cards. * backend/pas/pas-backend-file.c (pas_backend_file_class_init): remove_card -> remove_cards. (pas_backend_file_get_static_capabilities): add "bulk-removes". (pas_backend_file_process_remove_cards): rewrite this function largely, so that it handles lists of ids. first we loop through and for every successful deletion we build a list of deleted ECards. Then for each view we build a list (a subset of the deleted ECard list) and pass back that list to the view. (pas_backend_file_process_modify_card): use _remove_1 instead of _remove. (ecard_matches_search): new function. * backend/pas/pas-backend-card-sexp.c (pas_backend_card_sexp_match_vcard): rewrite in terms of _match_ecard. (pas_backend_card_sexp_match_ecard): new function, the guts from _match_vcard. * backend/pas/pas-backend-card-sexp.h: add prototype for pas_backend_card_sexp_match_ecard. * backend/idl/addressbook.idl: the card removal stuff now takes CardIdList. * backend/ebook/e-book.c (e_book_get_static_capabilities): cache successful capability queries (since they're static). (e_book_check_static_capability): new, convenience function to check if a particular capability is supported. (e_book_remove_card_by_id): build a single element GList and call e_book_remove_cards. (e_book_remove_cards): build up a CORBA sequence from the GList and call Book::removeCards. (e_book_dispose): free the cached capabilities string. * backend/ebook/e-book.h: add new prototypes for e_book_check_static_capability and e_book_remove_cards. * backend/ebook/e-book-view.h (struct _EBookViewClass): rename "card_removed" signal to "cards_removed". * backend/ebook/e-book-view.c (e_book_view_do_removed_event): id -> ids, and free the id list. (e_book_view_check_listener_queue): CardRemovedEvent -> CardsRemovedEvent. * backend/ebook/e-book-view-listener.c (e_book_view_listener_queue_response): free the id list. (e_book_view_listener_queue_idlist_event): new function, used for cards_removed. (e_book_view_listener_queue_status_event): id -> ids. (e_book_view_listener_queue_sequence_event): same. (e_book_view_listener_queue_message_event): same. (impl_BookViewListener_notify_cards_removed): call queue_idlist_event. (e_book_view_listener_dispose): free the id list. (e_book_view_listener_class_init): track change to idl call. * backend/ebook/e-book-view-listener.h (EBookViewListenerOperation): CardRemovedEvent -> CardsRemovedEvent. (EBookViewListenerResponse): char *id -> GList *ids. * backend/ebook/e-book-listener.c (impl_BookListener_respond_r svn path=/trunk/; revision=19854
Diffstat (limited to 'addressbook/gui/widgets')
-rw-r--r--addressbook/gui/widgets/e-addressbook-model.c49
-rw-r--r--addressbook/gui/widgets/e-addressbook-model.h4
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.c72
3 files changed, 68 insertions, 57 deletions
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