Your message dated Sat, 25 Nov 2017 07:13:48 +0100
with message-id <[email protected]>
and subject line 
has caused the Debian Bug report #548949,
regarding Warn if file already exist at "Save raw file"
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
548949: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=548949
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: gtkterm
Version: 0.99.5-1
Priority: wishlist
Tags: patch
--- gtkterm-0.99.5/src/fichier.c	2005-09-22 23:49:23.000000000 +0400
+++ gtkterm-0.99.5.mod/src/fichier.c	2009-08-21 16:26:00.000000000 +0400
@@ -32,6 +32,7 @@
 #include <string.h>
 
 #include "gettext.h"
+#include "i18n.h"
 #include "config.h"
 #include "widgets.h"
 #include "serie.h"
@@ -282,9 +283,36 @@
   fwrite(data, size, 1, Fic);
 }
 
+void really_save_file(GtkDialog *dialog, gint id, gpointer data)
+{
+  char *file_name = (char *)data;
+
+  if (id != GTK_RESPONSE_ACCEPT)
+    return;
+
+  Fic = fopen(file_name, "w");
+
+  if (Fic == NULL)
+    {
+      g_free(str);
+      str = g_strdup_printf(_("Cannot open file %s : %s\n"), file_name, strerror_utf8(errno));
+      show_message(str, MSG_ERR);
+    }
+  else
+    {
+      fic_defaut = g_strdup(file_name);
+
+      write_buffer_with_func(write_file);
+
+      fclose(Fic);
+    }
+}
+
 gint Sauve_fichier(GtkFileSelection *FS)
 {
   gchar *NomFichier;
+  GtkWidget *dialog, *label;
+  struct stat st;
 
   NomFichier = g_strdup(gtk_file_selection_get_filename(FS));
   if ((!NomFichier || (strcmp(NomFichier, ""))) == 0)
@@ -294,20 +322,32 @@
       show_message(str, MSG_ERR);
       return FALSE;
     }
-  Fic = fopen(NomFichier, "w");
-  if(Fic == NULL)
+
+  if (stat (NomFichier, &st) != 0)
     {
-      g_free(str);
-      str = g_strdup_printf(_("Cannot open file %s : %s\n"), NomFichier, strerror_utf8(errno));
-      show_message(str, MSG_ERR);
+      really_save_file (NULL, GTK_RESPONSE_ACCEPT, (gpointer) NomFichier);
+
+      return FALSE;
     }
-  else
-    {
-      fic_defaut = g_strdup(NomFichier);
 
-      write_buffer_with_func(write_file);
+  /* File already exists */
+  dialog = gtk_dialog_new_with_buttons (_("Warning !"),
+                NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
+                GTK_STOCK_CANCEL, GTK_RESPONSE_NONE,
+                GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
+
+  g_free(str);
+  str = g_strdup_printf (_("\nFile \"%s\" already exists.\n"
+			  "Do you want to overwrite it ?\n"), NomFichier);
+  label = gtk_label_new (str);
+  g_signal_connect (GTK_OBJECT (dialog), "response",
+                  G_CALLBACK (really_save_file), (gpointer) NomFichier);
+  g_signal_connect_swapped (GTK_OBJECT(dialog), "response",
+                  G_CALLBACK (gtk_widget_destroy), GTK_WIDGET (dialog));
+
+  gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), label);
+
+  gtk_widget_show_all (dialog);
 
-      fclose(Fic);
-    }
   return FALSE;
 }

--- End Message ---
--- Begin Message ---
version 0.99.7+git9d63182-1 

--- End Message ---

Reply via email to