diff options
Diffstat (limited to 'addressbook')
-rw-r--r-- | addressbook/ChangeLog | 5 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook-component.c | 33 |
2 files changed, 35 insertions, 3 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index a04573ace4..25ff7ee1ee 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,8 @@ +2004-03-03 Hans Petter Jansson <hpj@ximian.com> + + * gui/component/addressbook-component.c (delete_addressbook_cb): + Remove local data, with error reporting on failure. + 2004-03-02 Larry Ewing <lewing@ximian.com> * gui/component/addressbook-component.c: add drop support for diff --git a/addressbook/gui/component/addressbook-component.c b/addressbook/gui/component/addressbook-component.c index 6d84a84747..b9b84e2cf4 100644 --- a/addressbook/gui/component/addressbook-component.c +++ b/addressbook/gui/component/addressbook-component.c @@ -206,6 +206,9 @@ delete_addressbook_cb (GtkWidget *widget, AddressbookComponent *comp) ESource *selected_source; AddressbookComponentPrivate *priv; GtkWidget *dialog; + EBook *book; + gboolean removed = FALSE; + GError *error; priv = comp->priv; @@ -222,7 +225,19 @@ delete_addressbook_cb (GtkWidget *widget, AddressbookComponent *comp) _("Address book '%s' will be removed. Are you sure you want to continue?"), e_source_peek_name (selected_source)); gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); - if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES) { + + if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_YES) { + gtk_widget_destroy (dialog); + return; + } + + /* Remove local data */ + book = e_book_new (); + if (e_book_load_source (book, selected_source, TRUE, &error)) + removed = e_book_remove (book, &error); + + if (removed) { + /* Remove source */ if (e_source_selector_source_is_selected (E_SOURCE_SELECTOR (priv->source_selector), selected_source)) e_source_selector_unselect_source (E_SOURCE_SELECTOR (priv->source_selector), @@ -231,10 +246,22 @@ delete_addressbook_cb (GtkWidget *widget, AddressbookComponent *comp) e_source_group_remove_source (e_source_peek_group (selected_source), selected_source); e_source_list_sync (priv->source_list, NULL); - - /* FIXME: Remove local data */ + } else { + GtkWidget *error_dialog; + + error_dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (widget)), + GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CLOSE, + "Error removing address book: %s", + error->message); + gtk_dialog_run (GTK_DIALOG (error_dialog)); + gtk_widget_destroy (error_dialog); + + g_error_free (error); } + g_object_unref (book); gtk_widget_destroy (dialog); } |