changeset 6038:78c8b0f636f4

[gaim-migrate @ 6488] (23:25:54) javabsp: LSchiere2: fixes 753405, " gaim save conversation wipes out existing file committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Sun, 06 Jul 2003 03:26:20 +0000
parents 4543f56f6fc3
children 0c4d0c93c8c5
files src/gtkconv.c
diffstat 1 files changed, 22 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkconv.c	Sat Jul 05 22:35:01 2003 +0000
+++ b/src/gtkconv.c	Sun Jul 06 03:26:20 2003 +0000
@@ -37,6 +37,7 @@
 #include "notify.h"
 #include "prefs.h"
 #include "prpl.h"
+#include "request.h"
 #include "sound.h"
 #include "util.h"
 
@@ -141,17 +142,15 @@
  * Callbacks
  **************************************************************************/
 static void
-do_save_convo(GObject *obj, GtkWidget *wid)
+do_save_convo(GtkWidget *wid)
 {
-	GaimConversation *c = g_object_get_data(obj, "gaim_conversation");
+	GaimConversation *c = g_object_get_data(GTK_FILE_SELECTION(wid)->ok_button,
+											"gaim_conversation");
 	const char *filename;
 	FILE *fp;
 
 	filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(wid));
 
-	if (gaim_gtk_check_if_dir(filename, GTK_FILE_SELECTION(wid)))
-		return;
-
 	if (!((gaim_conversation_get_type(c) != GAIM_CONV_CHAT &&
 		   g_list_find(gaim_get_ims(), c)) ||
 		  (gaim_conversation_get_type(c) == GAIM_CONV_CHAT &&
@@ -172,6 +171,23 @@
 }
 
 static void
+do_check_save_convo(GObject *obj, GtkWidget *wid)
+{
+	const char *filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(wid));
+
+	if (gaim_gtk_check_if_dir(filename, GTK_FILE_SELECTION(wid)))
+		return;
+
+	if(g_file_test(filename, G_FILE_TEST_EXISTS)){
+		gaim_request_yes_no(NULL, NULL, _("That file already exists"),
+							_("Would you like to overwrite it?"), 1, wid,
+							G_CALLBACK(do_save_convo), NULL);
+	}
+	else
+		do_save_convo(wid);
+}
+	
+static void
 do_insert_image_cb(GObject *obj, GtkWidget *wid)
 {
 	GaimConversation *conv;
@@ -2746,7 +2762,7 @@
 	g_object_set_data(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button),
 			"gaim_conversation", c);
 	g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button),
-			   "clicked", G_CALLBACK(do_save_convo), window);
+			   "clicked", G_CALLBACK(do_check_save_convo), window);
 	g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(window)->cancel_button),
 				  "clicked", G_CALLBACK(gtk_widget_destroy), (gpointer)window);
 	gtk_widget_show(window);