[evolution-patches] [Contacts] Patch for 62142



The EABEditor/EContactEditor save/close logic isn't all that hot on the
whole, but for now I'm keeping the changes minimal to reduce the risk of
new bugs.

I was unable to test moving between a mix of read-only and writable
books, since apparently the file backend thinks everything is writable
regardless of file system permissions (it didn't use to be like that),
and I had to hardwire read-onlyness into the code to test.

Anyway, this fixes bug 62142 in a narrow sense, meaning it will no
longer prompt to save if no changes were made. I replaced the old dialog
code used in delete_event_cb() with a shorter bit using existing utility
functions.

-- 
Hans Petter

? 57795.patch
? 58921.patch
? 60529.patch
? 62085.patch
? 62142.patch
? birthdate.patch
? log.diff
? out.diff
? gui/component/ldap-config.gladep
? gui/component/old
? gui/component/out
? gui/component/select-names/crap
? gui/contact-editor/hpj-contact-editor.glade
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/ChangeLog,v
retrieving revision 1.1805
diff -u -p -r1.1805 ChangeLog
--- ChangeLog	4 Aug 2004 15:23:13 -0000	1.1805
+++ ChangeLog	11 Aug 2004 05:08:54 -0000
@@ -1,3 +1,10 @@
+2004-08-11  Hans Petter Jansson  <hpj ximian com>
+
+	* gui/contact-editor/e-contact-editor.c (app_delete_event_cb):
+	Remove the custom prompt-to-save dialogs from here - use
+	eab_prompt_save_dialog (), and then only if the contact actually
+	changed.
+
 2004-08-04  Rodney Dawes  <dobey novell com>
 
 	* gui/widgets/eab-popup-control.c: #include <gtk/gtkvbox.h>
Index: gui/component/addressbook.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/component/addressbook.c,v
retrieving revision 1.238
diff -u -p -r1.238 addressbook.c
--- gui/component/addressbook.c	12 Jul 2004 18:28:08 -0000	1.238
+++ gui/component/addressbook.c	11 Aug 2004 05:08:55 -0000
@@ -232,6 +232,14 @@ load_source_cb (EBook *book, EBookStatus
 	free_load_source_data (load_source_data);
 }
 
+static gboolean
+load_source_early_error_cb (LoadSourceData *load_source_data)
+{
+	load_source_data->cb (NULL, E_BOOK_ERROR_NO_SUCH_BOOK, load_source_data->closure);
+	free_load_source_data (load_source_data);
+	return FALSE;
+}
+
 guint
 addressbook_load (EBook *book,
 		  EBookCallback cb, gpointer closure)
@@ -243,7 +251,8 @@ addressbook_load (EBook *book,
 	load_source_data->source = g_object_ref (g_object_ref (e_book_get_source (book)));
 	load_source_data->cancelled = FALSE;
 
-	e_book_async_open (book, FALSE, load_source_cb, load_source_data);
+	if (e_book_async_open (book, FALSE, load_source_cb, load_source_data))
+		g_idle_add ((GSourceFunc) load_source_early_error_cb, load_source_data);
 
 	return GPOINTER_TO_UINT (load_source_data);
 }
Index: gui/contact-editor/e-contact-editor.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/contact-editor/e-contact-editor.c,v
retrieving revision 1.213
diff -u -p -r1.213 e-contact-editor.c
--- gui/contact-editor/e-contact-editor.c	21 Jul 2004 19:34:50 -0000	1.213
+++ gui/contact-editor/e-contact-editor.c	11 Aug 2004 05:08:55 -0000
@@ -2788,62 +2788,24 @@ app_delete_event_cb (GtkWidget *widget, 
 	if (ce->in_async_call)
 		return TRUE;
 
-	if (!ce->target_editable) {
-		GtkWidget *dialog;
-		gint       response;
+	if (ce->changed) {
+		switch (eab_prompt_save_dialog (GTK_WINDOW (ce->app))) {
+			case GTK_RESPONSE_YES:
+				if (!eab_editor_is_valid (EAB_EDITOR (ce)))
+					return TRUE;
 
-		dialog = gtk_message_dialog_new (GTK_WINDOW (widget),
-						 (GtkDialogFlags) 0,
-						 GTK_MESSAGE_QUESTION,
-						 GTK_BUTTONS_NONE,
-						 _("The contact cannot be saved to the "
-						   "selected address book. Do you want to "
-						   "discard changes?"));
-		gtk_dialog_add_buttons (GTK_DIALOG (dialog),
-					_("_Discard"), GTK_RESPONSE_YES,
-					GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-					NULL);
-
-		gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
-		response = gtk_dialog_run (GTK_DIALOG (dialog));
-		gtk_widget_destroy (dialog);
-
-		if (response != GTK_RESPONSE_YES)
-			return TRUE;
-	}
-	else if (!e_book_is_writable (ce->source_book)) {
-		GtkWidget *dialog;
-		gint       response;
-
-		dialog = gtk_message_dialog_new (GTK_WINDOW (widget),
-						 (GtkDialogFlags) 0,
-						 GTK_MESSAGE_QUESTION,
-						 GTK_BUTTONS_NONE,
-						 _("You are moving the contact from one "
-						   "address book to another, but it cannot "
-						   "be removed from the source. Do you want "
-						   "to save a copy instead?"));
-		gtk_dialog_add_buttons (GTK_DIALOG (dialog),
-					_("_Discard"), GTK_RESPONSE_NO,
-					GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-					GTK_STOCK_SAVE, GTK_RESPONSE_YES,
-					NULL);
+				eab_editor_save_contact (EAB_EDITOR (ce), TRUE);
+				return TRUE;
 
-		gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
-		response = gtk_dialog_run (GTK_DIALOG (dialog));
-		gtk_widget_destroy (dialog);
+			case GTK_RESPONSE_NO:
+				break;
 
-		if (response == GTK_RESPONSE_YES) {
-			if (e_contact_editor_is_valid (EAB_EDITOR (ce)))
-				real_save_contact (ce, FALSE);
-			else
+			case GTK_RESPONSE_CANCEL:
+			default:
 				return TRUE;
+
 		}
-		else if (response == GTK_RESPONSE_CANCEL)
-			return TRUE;
 	}
-	else if (!eab_editor_prompt_to_save_changes (EAB_EDITOR (ce), GTK_WINDOW (ce->app)))
-		return TRUE;
 
 	eab_editor_close (EAB_EDITOR (ce));
 	return TRUE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]