Re: [evolution-patches] Overwriting files warnings in save-attachments and save-calendar plugins



On Tue, 2005-01-04 at 11:28 +0800, Not Zed wrote:
> 
> Except it should be using e-error for all of these windows.  We
> do/should not use gtk message dialogues at all.  We also include no
> markup in error message strings to simplify translation.
> 
> Infact we already have a 'system' e-error for this purpose.
> 
> You simply need to do:
> 
> #include "widgets/misc/e-error.h"
> 
> if (e_error_run(parent, E_ERROR_ASK_FILE_EXISTS_OVERWRITE, path, NULL)
> == GTK_RESPONSE_OK)
>    .. overwrite is ok ...
> else
>    .. cancelled ...
> 
> where:
> parent == the parent window, NULL if not known (it will use a system
> wide one if this is the case)
> path == the filename

Altered and patch attached. Should I commit this?

Else please review ;-)




-- 
Philip Van Hoof, Software Developer @ Cronos
home: me at freax dot org
gnome: pvanhoof at gnome dot org
work: philip dot vanhoof at cronos dot be
junk: philip dot vanhoof at gmail dot com
http://www.freax.be, http://www.freax.eu.org
? groupwise-account-setup/Makefile
? groupwise-account-setup/Makefile.in
? groupwise-account-setup/org-gnome-gw-account-setup.eplug
Index: save-attachments/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/plugins/save-attachments/ChangeLog,v
retrieving revision 1.4
diff -u -r1.4 ChangeLog
--- save-attachments/ChangeLog	3 Jan 2005 12:37:03 -0000	1.4
+++ save-attachments/ChangeLog	4 Jan 2005 09:23:36 -0000
@@ -1,3 +1,7 @@
+2005-01-04  Philip Van Hoof  <pvanhoof gnome org>
+
+	* save-attachments.c: Use standard error messages
+
 2004-12-27  Philip Van Hoof  <pvanhoof gnome org>
 
 	* save-attachments.c: Warning when overwriting file
Index: save-attachments/save-attachments.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/save-attachments/save-attachments.c,v
retrieving revision 1.2
diff -u -r1.2 save-attachments.c
--- save-attachments/save-attachments.c	3 Jan 2005 12:37:03 -0000	1.2
+++ save-attachments/save-attachments.c	4 Jan 2005 09:23:36 -0000
@@ -53,6 +53,8 @@
 #include <camel/camel-multipart.h>
 #include <camel/camel-utf8.h>
 
+#include "widgets/misc/e-error.h"
+
 #include "mail/em-menu.h"
 #include "mail/em-utils.h"
 
@@ -218,23 +220,8 @@
 	 * the POSIX access-call should suffice for checking the file existence.
 	 */
 
-	if (access (save, F_OK)) {
-		GtkWidget *warning = 
-			gtk_message_dialog_new_with_markup (NULL,
-				GTK_DIALOG_DESTROY_WITH_PARENT,
-				GTK_MESSAGE_WARNING,
-				GTK_BUTTONS_NONE,
-				_("File exists \"%s\".\n"
-				  "Do you wish to overwrite it?"), save);
-
-			gtk_dialog_add_button (GTK_DIALOG (warning), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
-			gtk_dialog_add_button (GTK_DIALOG (warning), _("_Overwrite"), GTK_RESPONSE_YES);
-
-			doit = FALSE;
-			if (gtk_dialog_run (GTK_DIALOG (warning)) == GTK_RESPONSE_YES)
-				doit = TRUE;
-			gtk_widget_destroy (warning);
-	}
+	if (access (save, F_OK))
+		doit = e_error_run(NULL, E_ERROR_ASK_FILE_EXISTS_OVERWRITE, save, NULL) == GTK_RESPONSE_OK;
 
 	if (doit)
 		em_utils_save_part_to_file(NULL, save, part);
Index: save-calendar/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/plugins/save-calendar/ChangeLog,v
retrieving revision 1.9
diff -u -r1.9 ChangeLog
--- save-calendar/ChangeLog	3 Jan 2005 12:39:33 -0000	1.9
+++ save-calendar/ChangeLog	4 Jan 2005 09:23:36 -0000
@@ -1,3 +1,7 @@
+2005-01-04  Philip Van Hoof  <pvanhoof gnome org>
+
+	* csv-format.c, rdf-format.c: Use standard error messages
+
 2004-12-27  Philip Van Hoof  <pvanhoof gnome org>
 
 	* csv-format.c, rdf-format.c: Warning when overwriting file
Index: save-calendar/csv-format.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/save-calendar/csv-format.c,v
retrieving revision 1.2
diff -u -r1.2 csv-format.c
--- save-calendar/csv-format.c	3 Jan 2005 12:39:33 -0000	1.2
+++ save-calendar/csv-format.c	4 Jan 2005 09:23:36 -0000
@@ -40,6 +40,8 @@
 #include <libgnomevfs/gnome-vfs.h>
 #include <string.h>
 
+#include "widgets/misc/e-error.h"
+
 #include "format-handler.h"
 
 typedef struct _CsvConfig CsvConfig;
@@ -349,23 +351,9 @@
 	uri = gnome_vfs_uri_new (dest_uri);
 
 	result = gnome_vfs_open_uri (&handle, uri, GNOME_VFS_OPEN_READ);
-	if (result == GNOME_VFS_OK) {
-		GtkWidget *warning = 
-		  gtk_message_dialog_new_with_markup (NULL,
-				GTK_DIALOG_DESTROY_WITH_PARENT,
-				GTK_MESSAGE_WARNING,
-				GTK_BUTTONS_NONE,
-				_("File exists \"%s\".\n"
-				  "Do you wish to overwrite it?"), dest_uri);
-
-		gtk_dialog_add_button (GTK_DIALOG (warning), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
-		gtk_dialog_add_button (GTK_DIALOG (warning), _("_Overwrite"), GTK_RESPONSE_YES);
-
-		doit = FALSE;
-		if (gtk_dialog_run (GTK_DIALOG (warning)) == GTK_RESPONSE_YES)
-			doit = TRUE;
-		gtk_widget_destroy (warning);
-	} 
+	if (result == GNOME_VFS_OK)
+		doit = e_error_run(gtk_widget_get_toplevel (GTK_WIDGET (target->selector)),
+			 E_ERROR_ASK_FILE_EXISTS_OVERWRITE, dest_uri, NULL) == GTK_RESPONSE_OK;
 
 	if (doit) {
 		result = gnome_vfs_open_uri (&handle, uri, GNOME_VFS_OPEN_WRITE);
Index: save-calendar/rdf-format.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/save-calendar/rdf-format.c,v
retrieving revision 1.2
diff -u -r1.2 rdf-format.c
--- save-calendar/rdf-format.c	3 Jan 2005 12:39:33 -0000	1.2
+++ save-calendar/rdf-format.c	4 Jan 2005 09:23:37 -0000
@@ -45,6 +45,8 @@
 #include <libxml/xpath.h>
 #include <string.h>
 
+#include "widgets/misc/e-error.h"
+
 #include "format-handler.h"
 
 static void 
@@ -214,23 +216,9 @@
 	uri = gnome_vfs_uri_new (dest_uri);
 
 	result = gnome_vfs_open_uri (&handle, uri, GNOME_VFS_OPEN_READ);
-	if (result == GNOME_VFS_OK) {
-		GtkWidget *warning = 
-		  gtk_message_dialog_new_with_markup (NULL,
-				GTK_DIALOG_DESTROY_WITH_PARENT,
-				GTK_MESSAGE_WARNING,
-				GTK_BUTTONS_NONE,
-				_("<b>File exists \"%s\".\n"
-				  "Do you wish to overwrite it?"), dest_uri);
-
-		gtk_dialog_add_button (GTK_DIALOG (warning), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
-		gtk_dialog_add_button (GTK_DIALOG (warning), _("_Overwrite"), GTK_RESPONSE_YES);
-
-		doit = FALSE;
-		if (gtk_dialog_run (GTK_DIALOG (warning)) == GTK_RESPONSE_YES)
-			doit = TRUE;
-		gtk_widget_destroy (warning);
-	} 
+	if (result == GNOME_VFS_OK) 
+		doit = e_error_run(gtk_widget_get_toplevel (GTK_WIDGET (target->selector)),
+			 E_ERROR_ASK_FILE_EXISTS_OVERWRITE, dest_uri, NULL) == GTK_RESPONSE_OK;
 
 	if (doit) {
 		result = gnome_vfs_open_uri (&handle, uri, GNOME_VFS_OPEN_WRITE);


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