[evolution-patches] Bug #57001
- From: Nirnimesh <nirnimesh students iiit net>
- To: evolution-patches lists ximian com
- Subject: [evolution-patches] Bug #57001
- Date: Mon, 31 May 2004 20:23:21 +0530
Bug #57001: Fixed.
Actually, one could get cleaner with this code (could incorporate for
'cut' and 'delete' prompts separately) and this made me do a lot deal
more work for this than actually expected. :-)
But the good thing is that it works!
Nirnimesh <nirnimesh students iiit net>
IIIT-Hyderabad.
Index: eab-editor.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/contact-editor/eab-editor.c,v
retrieving revision 1.2
diff -u -r1.2 eab-editor.c
--- a/eab-editor.c 26 Mar 2004 04:09:18 -0000 1.2
+++ b/eab-editor.c 31 May 2004 14:36:25 -0000
@@ -301,10 +301,12 @@
}
gboolean
-eab_editor_confirm_delete (GtkWindow *parent)
+eab_editor_confirm_delete (GtkWindow *parent, const char* name)
{
GtkWidget *dialog;
gint result;
+ char* message=(char*) malloc(sizeof(char)*100+strlen(name));
+ sprintf(message, "Are you sure you want\nto delete the contact (%s)?", name);
dialog = gtk_message_dialog_new (parent,
0,
@@ -316,8 +318,7 @@
? _("Are you sure you want\n"
"to delete these contacts?"))
#endif
- _("Are you sure you want\n"
- "to delete this contact?"));
+ _(message));
gtk_dialog_add_buttons (GTK_DIALOG (dialog),
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
@@ -331,6 +332,38 @@
return (result == GTK_RESPONSE_ACCEPT);
}
+/* Prompt for 'cut the contact' instead of 'delete the contact' while actually deleting */
+gboolean
+eab_editor_confirm_delete_after_cutting (GtkWindow *parent, const char* name)
+{
+ GtkWidget *dialog;
+ gint result;
+ char* message=(char*) malloc(sizeof(char)*100+strlen(name));
+ sprintf(message, "Are you sure you want\nto cut the contact (%s)?", name);
+
+ dialog = gtk_message_dialog_new (parent,
+ 0,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE,
+#if notyet
+ /* XXX we really need to handle the plural case here.. */
+ (plural
+ ? _("Are you sure you want\n"
+ "to delete these contacts?"))
+#endif
+ _(message));
+
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT,
+ NULL);
+
+ result = gtk_dialog_run(GTK_DIALOG (dialog));
+
+ gtk_widget_destroy (dialog);
+
+ return (result == GTK_RESPONSE_ACCEPT);
+}
void
eab_editor_contact_added (EABEditor *editor, EBookStatus status, EContact *contact)
Index: eab-editor.h
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/contact-editor/eab-editor.h,v
retrieving revision 1.1
diff -u -r1.1 eab-editor.h
--- a/eab-editor.h 24 Mar 2004 19:58:15 -0000 1.1
+++ b/eab-editor.h 31 May 2004 14:36:26 -0000
@@ -90,7 +90,8 @@
GtkWindow* eab_editor_get_window (EABEditor *editor);
gboolean eab_editor_prompt_to_save_changes (EABEditor *editor, GtkWindow *window);
-gboolean eab_editor_confirm_delete (GtkWindow *parent);
+gboolean eab_editor_confirm_delete (GtkWindow *parent, const char* name);
+gboolean eab_editor_confirm_delete_after_cutting (GtkWindow *parent, const char* name);
/* these four generate EABEditor signals */
void eab_editor_contact_added (EABEditor *editor, EBookStatus status, EContact *contact);
Index: e-addressbook-view.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/widgets/e-addressbook-view.c,v
retrieving revision 1.139
diff -u -r1.139 e-addressbook-view.c
--- e-addressbook-view.c 11 May 2004 00:42:19 -0000 1.139
+++ e-addressbook-view.c 31 May 2004 14:39:14 -0000
@@ -920,7 +920,64 @@
static void
delete (GtkWidget *widget, ContactAndBook *contact_and_book)
{
- if (eab_editor_confirm_delete(GTK_WINDOW(gtk_widget_get_toplevel(contact_and_book->view->widget)))) {
+ /* XXX get the file as name .. not handled multiple selections :( */
+ EContact *contact_pre = get_contact_list(contact_and_book)->data;
+ gpointer contact_file_as = e_contact_get_const (contact_pre, E_CONTACT_FILE_AS);
+
+ if (eab_editor_confirm_delete(GTK_WINDOW(gtk_widget_get_toplevel(contact_and_book->view->widget)), contact_file_as)) {
+ EBook *book;
+ GList *list = get_contact_list(contact_and_book);
+ GList *iterator;
+ gboolean bulk_remove = FALSE;
+
+ bulk_remove = e_book_check_static_capability (contact_and_book->view->model->book,
+ "bulk-remove");
+
+ g_object_get(contact_and_book->view->model,
+ "book", &book,
+ NULL);
+
+ if (bulk_remove) {
+ GList *ids = NULL;
+
+ for (iterator = list; iterator; iterator = iterator->next) {
+ EContact *contact = iterator->data;
+ ids = g_list_prepend (ids, (char*)e_contact_get_const (contact, E_CONTACT_UID));
+ }
+
+ /* Remove the cards all at once. */
+ /* XXX no callback specified... ugh */
+ e_book_async_remove_contacts (book,
+ ids,
+ NULL,
+ NULL);
+
+ g_list_free (ids);
+ }
+ else {
+ for (iterator = list; iterator; iterator = iterator->next) {
+ EContact *contact = iterator->data;
+ /* Remove the card. */
+ /* XXX no callback specified... ugh */
+ e_book_async_remove_contact (book,
+ contact,
+ NULL,
+ NULL);
+ }
+ }
+ e_free_object_list(list);
+ g_object_unref(book);
+ }
+}
+
+static void
+delete_after_cutting (GtkWidget *widget, ContactAndBook *contact_and_book)
+{
+ /* XXX get the file as name .. not handled multiple selections :( */
+ EContact *contact_pre = get_contact_list(contact_and_book)->data;
+ gpointer contact_file_as = e_contact_get_const (contact_pre, E_CONTACT_FILE_AS);
+
+ if (eab_editor_confirm_delete_after_cutting (GTK_WINDOW(gtk_widget_get_toplevel(contact_and_book->view->widget)), contact_file_as)) {
EBook *book;
GList *list = get_contact_list(contact_and_book);
GList *iterator;
@@ -1976,6 +2033,16 @@
delete (GTK_WIDGET (view), &contact_and_book);
}
+void
+eab_view_delete_selection_after_cutting(EABView *view)
+{
+ ContactAndBook contact_and_book;
+
+ memset (&contact_and_book, 0, sizeof (contact_and_book));
+ contact_and_book.view = view;
+
+ delete_after_cutting (GTK_WIDGET (view), &contact_and_book);
+}
static void
invisible_destroyed (gpointer data, GObject *where_object_was)
{
@@ -2107,7 +2174,7 @@
eab_view_cut (EABView *view)
{
eab_view_copy (view);
- eab_view_delete_selection (view);
+ eab_view_delete_selection_after_cutting (view);
}
void
Index: e-addressbook-view.h
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/widgets/e-addressbook-view.h,v
retrieving revision 1.31
diff -u -r1.31 e-addressbook-view.h
--- e-addressbook-view.h 2 Feb 2004 22:20:41 -0000 1.31
+++ e-addressbook-view.h 31 May 2004 14:39:14 -0000
@@ -126,6 +126,7 @@
void eab_view_print (EABView *view);
void eab_view_print_preview (EABView *view);
void eab_view_delete_selection (EABView *view);
+void eab_view_delete_selection_after_cutting (EABView *view);
void eab_view_cut (EABView *view);
void eab_view_copy (EABView *view);
void eab_view_paste (EABView *view);
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/ChangeLog,v
retrieving revision 1.1704
diff -u -r1.1704 ChangeLog
--- ChangeLog 12 May 2004 17:22:22 -0000 1.1704
+++ ChangeLog 31 May 2004 14:41:52 -0000
@@ -1,3 +1,10 @@
+2004-05-31 Nirnimesh <nirnimesh students iiit net>
+ * Bug #57001: Alert message is not proper when we are cutting a contact from the address book.
+ The code can get cleaner, still.
+
+2004-05-28 Nirnimesh <nirnimesh students iiit net>
+ * Fixed Bug #22599: Deleting contacts&lists should display contact name, plurals & type (list)
+
2004-05-12 Hans Petter Jansson <hpj ximian com>
* gui/contact-editor/contact-editor.glade: Add PO box entries.
[
Date Prev][
Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]