Mercurial > pidgin.yaz
comparison src/gtkconv.c @ 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 | 22923270493f |
children | 0c4d0c93c8c5 |
comparison
equal
deleted
inserted
replaced
6037:4543f56f6fc3 | 6038:78c8b0f636f4 |
---|---|
35 #include "log.h" | 35 #include "log.h" |
36 #include "multi.h" | 36 #include "multi.h" |
37 #include "notify.h" | 37 #include "notify.h" |
38 #include "prefs.h" | 38 #include "prefs.h" |
39 #include "prpl.h" | 39 #include "prpl.h" |
40 #include "request.h" | |
40 #include "sound.h" | 41 #include "sound.h" |
41 #include "util.h" | 42 #include "util.h" |
42 | 43 |
43 #include "dnd-hints.h" | 44 #include "dnd-hints.h" |
44 #include "gtkblist.h" | 45 #include "gtkblist.h" |
139 | 140 |
140 /************************************************************************** | 141 /************************************************************************** |
141 * Callbacks | 142 * Callbacks |
142 **************************************************************************/ | 143 **************************************************************************/ |
143 static void | 144 static void |
144 do_save_convo(GObject *obj, GtkWidget *wid) | 145 do_save_convo(GtkWidget *wid) |
145 { | 146 { |
146 GaimConversation *c = g_object_get_data(obj, "gaim_conversation"); | 147 GaimConversation *c = g_object_get_data(GTK_FILE_SELECTION(wid)->ok_button, |
148 "gaim_conversation"); | |
147 const char *filename; | 149 const char *filename; |
148 FILE *fp; | 150 FILE *fp; |
149 | 151 |
150 filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(wid)); | 152 filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(wid)); |
151 | |
152 if (gaim_gtk_check_if_dir(filename, GTK_FILE_SELECTION(wid))) | |
153 return; | |
154 | 153 |
155 if (!((gaim_conversation_get_type(c) != GAIM_CONV_CHAT && | 154 if (!((gaim_conversation_get_type(c) != GAIM_CONV_CHAT && |
156 g_list_find(gaim_get_ims(), c)) || | 155 g_list_find(gaim_get_ims(), c)) || |
157 (gaim_conversation_get_type(c) == GAIM_CONV_CHAT && | 156 (gaim_conversation_get_type(c) == GAIM_CONV_CHAT && |
158 g_list_find(gaim_get_chats(), c)))) | 157 g_list_find(gaim_get_chats(), c)))) |
169 fprintf(fp, "%s", c->history->str); | 168 fprintf(fp, "%s", c->history->str); |
170 | 169 |
171 fclose(fp); | 170 fclose(fp); |
172 } | 171 } |
173 | 172 |
173 static void | |
174 do_check_save_convo(GObject *obj, GtkWidget *wid) | |
175 { | |
176 const char *filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION(wid)); | |
177 | |
178 if (gaim_gtk_check_if_dir(filename, GTK_FILE_SELECTION(wid))) | |
179 return; | |
180 | |
181 if(g_file_test(filename, G_FILE_TEST_EXISTS)){ | |
182 gaim_request_yes_no(NULL, NULL, _("That file already exists"), | |
183 _("Would you like to overwrite it?"), 1, wid, | |
184 G_CALLBACK(do_save_convo), NULL); | |
185 } | |
186 else | |
187 do_save_convo(wid); | |
188 } | |
189 | |
174 static void | 190 static void |
175 do_insert_image_cb(GObject *obj, GtkWidget *wid) | 191 do_insert_image_cb(GObject *obj, GtkWidget *wid) |
176 { | 192 { |
177 GaimConversation *conv; | 193 GaimConversation *conv; |
178 GaimGtkConversation *gtkconv; | 194 GaimGtkConversation *gtkconv; |
2744 gaim_home_dir(), normalize(c->name)); | 2760 gaim_home_dir(), normalize(c->name)); |
2745 gtk_file_selection_set_filename(GTK_FILE_SELECTION(window), buf); | 2761 gtk_file_selection_set_filename(GTK_FILE_SELECTION(window), buf); |
2746 g_object_set_data(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button), | 2762 g_object_set_data(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button), |
2747 "gaim_conversation", c); | 2763 "gaim_conversation", c); |
2748 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button), | 2764 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button), |
2749 "clicked", G_CALLBACK(do_save_convo), window); | 2765 "clicked", G_CALLBACK(do_check_save_convo), window); |
2750 g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(window)->cancel_button), | 2766 g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(window)->cancel_button), |
2751 "clicked", G_CALLBACK(gtk_widget_destroy), (gpointer)window); | 2767 "clicked", G_CALLBACK(gtk_widget_destroy), (gpointer)window); |
2752 gtk_widget_show(window); | 2768 gtk_widget_show(window); |
2753 } | 2769 } |
2754 | 2770 |