2009-08-21 [colin] 3.7.2cvs24
authorColin Leroy <colin@colino.net>
Fri, 21 Aug 2009 16:15:13 +0000 (16:15 +0000)
committerColin Leroy <colin@colino.net>
Fri, 21 Aug 2009 16:15:13 +0000 (16:15 +0000)
* src/compose.c
Previous commit: move the function into compose_insert_file
so that it's also used on drag-n-drop

ChangeLog
PATCHSETS
configure.ac
src/compose.c

index 13e6f04..65374c1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+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
+
 2009-08-21 [colin]     3.7.2cvs23
 
        * src/compose.c
index 952e586..fed0e4d 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.100.2.72 -r 1.100.2.73 AUTHORS;  cvs diff -u -r 1.1.2.60 -r 1.1.2.61 src/gtk/authors.h;  cvs diff -u -r 1.36.2.172 -r 1.36.2.173 src/common/utils.c;  ) > 3.7.2cvs21.patchset
 ( cvs diff -u -r 1.382.2.520 -r 1.382.2.521 src/compose.c;  cvs diff -u -r 1.204.2.191 -r 1.204.2.192 src/prefs_common.c;  cvs diff -u -r 1.103.2.124 -r 1.103.2.125 src/prefs_common.h;  cvs diff -u -r 1.1.2.26 -r 1.1.2.27 src/prefs_compose_writing.c;  cvs diff -u -r 1.36.2.173 -r 1.36.2.174 src/common/utils.c;  ) > 3.7.2cvs22.patchset
 ( cvs diff -u -r 1.382.2.521 -r 1.382.2.522 src/compose.c;  ) > 3.7.2cvs23.patchset
+( cvs diff -u -r 1.382.2.522 -r 1.382.2.523 src/compose.c;  ) > 3.7.2cvs24.patchset
index eed608d..681c761 100644 (file)
@@ -12,7 +12,7 @@ MINOR_VERSION=7
 MICRO_VERSION=2
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=23
+EXTRA_VERSION=24
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index ef3a331..dc878e6 100644 (file)
@@ -3330,9 +3330,48 @@ static ComposeInsertResult compose_insert_file(Compose *compose, const gchar *fi
        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 @@ static void compose_insert_file_cb(GtkAction *action, gpointer data)
                        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);