[claws-mail-cvs-commit] compose.c

Colin Leroy <[email protected]> Fri, 21 Aug 2009 16:15:14 +0000
Newsgroups gmane.mail.sylpheed.claws.cvs
Message-ID <[email protected]>
Update of /srv/cvs/claws-mail/claws/src
In directory ran:/tmp/cvs-serv25926/src

Modified Files:
      Tag: gtk2
	compose.c 
Log Message:
2009-08-21 [colin]	3.7.2cvs24

	* src/compose.c
		Previous commit: move the function into compose_insert_file
		so that it's also used on drag-n-drop

Index: compose.c
===================================================================
RCS file: /srv/cvs/claws-mail/claws/src/compose.c,v
retrieving revision 1.382.2.522
retrieving revision 1.382.2.523
diff -u -d -r1.382.2.522 -r1.382.2.523
--- compose.c	21 Aug 2009 15:58:30 -0000	1.382.2.522
+++ compose.c	21 Aug 2009 16:15:11 -0000	1.382.2.523
@@ -3330,9 +3330,48 @@
 	FILE *fp;
 	gboolean prev_autowrap;
 	gboolean badtxt = FALSE;
+	struct stat file_stat;
+	int ret;
 
 	cm_return_val_if_fail(file != NULL, COMPOSE_INSERT_NO_FILE);
 
+	/* get the size of the file we are about to insert */
+	ret = g_stat(file, &file_stat);
+	if (ret != 0) {
+		gchar *shortfile = g_path_get_basename(file);
+		alertpanel_error(_("Could not get size of file '%s'."), shortfile);
+		g_free(shortfile);
+		return COMPOSE_INSERT_NO_FILE;
+	} else if (prefs_common.warn_large_insert == TRUE) {
+
+		/* ask user for confirmation if the file is large */
+		if (prefs_common.warn_large_insert_size < 0 ||
+		    file_stat.st_size > (prefs_common.warn_large_insert_size * 1024)) {
+			AlertValue aval;
+			gchar *msg;
+
+			msg = g_strdup_printf(_("You are about to insert a file of %s "
+						"in the message body. Are you sure you want to do that?"),
+						to_human_readable(file_stat.st_size));
+			aval = alertpanel_full(_("Are you sure?"), msg, GTK_STOCK_CANCEL,
+					_("+_Insert"), NULL, TRUE, NULL, ALERT_QUESTION, G_ALERTDEFAULT);
+			g_free(msg);
+
+			/* do we ask for confirmation next time? */
+			if (aval & G_ALERTDISABLE) {
+				/* no confirmation next time, disable feature in preferences */
+				aval &= ~G_ALERTDISABLE;
+				prefs_common.warn_large_insert = FALSE;
+			}
+
+			/* abort file insertion if user canceled action */
+			if (aval != G_ALERTALTERNATE) {
+				return COMPOSE_INSERT_NO_FILE;
+			}
+		}
+	}
+
+
 	if ((fp = g_fopen(file, "rb")) == NULL) {
 		FILE_OP_ERROR(file, "fopen");
 		return COMPOSE_INSERT_READ_ERROR;
@@ -9379,58 +9418,16 @@
 			gchar *file = (gchar *) tmp->data;
 			gchar *filedup = g_strdup(file);
 			gchar *shortfile = g_path_get_basename(filedup);
-			struct stat file_stat;
-			gboolean do_insert;
 			ComposeInsertResult res;
-			int ret;
-
-			do_insert = TRUE;
-
-			/* get the size of the file we are about to insert */
-			ret = g_stat(file, &file_stat);
-			if (ret != 0) {
-				alertpanel_error(_("Could not get size of file '%s'."), shortfile);
-				do_insert = FALSE;
-			} else if (prefs_common.warn_large_insert == TRUE) {
-
-				/* ask user for confirmation if the file is large */
-				if (prefs_common.warn_large_insert_size < 0 ||
-				    file_stat.st_size > (prefs_common.warn_large_insert_size * 1024)) {
-					AlertValue aval;
-					gchar *msg;
-					
-					msg = g_strdup_printf(_("You are about to insert a file of %s "
-								"in the message body. Are your sure to do that?"),
-								to_human_readable(file_stat.st_size));
-					aval = alertpanel_full(_("Are you sure?"), msg, GTK_STOCK_CANCEL,
-							_("+_Insert"), NULL, TRUE, NULL, ALERT_QUESTION, G_ALERTDEFAULT);
-					g_free(msg);
-
-					/* do we ask for confirmation next time? */
-					if (aval & G_ALERTDISABLE) {
-						/* no confirmation next time, disable feature in preferences */
-						aval &= ~G_ALERTDISABLE;
-						prefs_common.warn_large_insert = FALSE;
-					}
-
-					/* abort file insertion if user canceled action */
-					if (aval != G_ALERTALTERNATE) {
-						do_insert = FALSE;
-					}
-				}
-			}
-
 			/* insert the file if the file is short or if the user confirmed that
 			   he/she wants to insert the large file */
-			if (do_insert) {
-				res = compose_insert_file(compose, file);
-				if (res == COMPOSE_INSERT_READ_ERROR) {
-					alertpanel_error(_("File '%s' could not be read."), shortfile);
-				} else if (res == COMPOSE_INSERT_INVALID_CHARACTER) {
-					alertpanel_error(_("File '%s' contained invalid characters\n"
-								"for the current encoding, insertion may be incorrect."),
-								shortfile);
-				}
+			res = compose_insert_file(compose, file);
+			if (res == COMPOSE_INSERT_READ_ERROR) {
+				alertpanel_error(_("File '%s' could not be read."), shortfile);
+			} else if (res == COMPOSE_INSERT_INVALID_CHARACTER) {
+				alertpanel_error(_("File '%s' contained invalid characters\n"
+							"for the current encoding, insertion may be incorrect."),
+							shortfile);
 			}
 
 			g_free(shortfile);