Mercurial > pidgin.yaz
comparison src/gtkaccount.c @ 10605:56d4460bb6bd
[gaim-migrate @ 12037]
This makes us remember the last used folders for saving files, opening files,
and buddy icons (separately).
Also fixes a file transfer crash when you decide not to overwrite an existing
file but then choose a different file to save to.
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Wed, 16 Feb 2005 21:07:10 +0000 |
parents | 0f7452b1f777 |
children | 43ab987a0222 |
comparison
equal
deleted
inserted
replaced
10604:255225f7639e | 10605:56d4460bb6bd |
---|---|
242 | 242 |
243 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ | 243 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ |
244 static void | 244 static void |
245 icon_filesel_choose_cb(GtkWidget *widget, gint response, AccountPrefsDialog *dialog) | 245 icon_filesel_choose_cb(GtkWidget *widget, gint response, AccountPrefsDialog *dialog) |
246 { | 246 { |
247 char *filename; | 247 char *filename, *current_folder; |
248 | 248 |
249 if (response != GTK_RESPONSE_ACCEPT) { | 249 if (response != GTK_RESPONSE_ACCEPT) { |
250 if (response == GTK_RESPONSE_CANCEL) | 250 if (response == GTK_RESPONSE_CANCEL) |
251 gtk_widget_destroy(dialog->icon_filesel); | 251 gtk_widget_destroy(dialog->icon_filesel); |
252 dialog->icon_filesel = NULL; | 252 dialog->icon_filesel = NULL; |
253 return; | 253 return; |
254 } | 254 } |
255 | 255 |
256 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog->icon_filesel)); | 256 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog->icon_filesel)); |
257 current_folder = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(dialog->icon_filesel)); | |
258 if (current_folder != NULL) { | |
259 gaim_prefs_set_string("/gaim/gtk/filelocations/last_icon_folder", current_folder); | |
260 g_free(current_folder); | |
261 } | |
262 | |
257 #else /* FILECHOOSER */ | 263 #else /* FILECHOOSER */ |
258 static void | 264 static void |
259 icon_filesel_choose_cb(GtkWidget *w, AccountPrefsDialog *dialog) | 265 icon_filesel_choose_cb(GtkWidget *w, AccountPrefsDialog *dialog) |
260 { | 266 { |
261 char *filename; | 267 char *filename, *current_folder; |
262 | 268 |
263 filename = g_strdup(gtk_file_selection_get_filename( | 269 filename = g_strdup(gtk_file_selection_get_filename( |
264 GTK_FILE_SELECTION(dialog->icon_filesel))); | 270 GTK_FILE_SELECTION(dialog->icon_filesel))); |
265 | 271 |
266 /* If they typed in a directory, change there */ | 272 /* If they typed in a directory, change there */ |
267 if (gaim_gtk_check_if_dir(filename, | 273 if (gaim_gtk_check_if_dir(filename, |
268 GTK_FILE_SELECTION(dialog->icon_filesel))) | 274 GTK_FILE_SELECTION(dialog->icon_filesel))) |
269 { | 275 { |
270 g_free(filename); | 276 g_free(filename); |
271 return; | 277 return; |
272 } | 278 } |
279 | |
280 current_folder = g_path_get_dirname(filename); | |
281 if (current_folder != NULL) { | |
282 gaim_prefs_set_string("/gaim/gtk/filelocations/last_icon_folder", current_folder); | |
283 g_free(current_folder); | |
284 } | |
285 | |
273 #endif /* FILECHOOSER */ | 286 #endif /* FILECHOOSER */ |
274 | 287 |
275 if (dialog->icon_path) | 288 if (dialog->icon_path) |
276 g_free(dialog->icon_path); | 289 g_free(dialog->icon_path); |
277 dialog->icon_path = convert_buddy_icon(dialog->plugin, filename); | 290 dialog->icon_path = convert_buddy_icon(dialog->plugin, filename); |
365 #if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ | 378 #if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ |
366 GtkWidget *hbox; | 379 GtkWidget *hbox; |
367 GtkWidget *tv; | 380 GtkWidget *tv; |
368 GtkTreeSelection *sel; | 381 GtkTreeSelection *sel; |
369 #endif /* FILECHOOSER */ | 382 #endif /* FILECHOOSER */ |
383 const char *current_folder; | |
370 | 384 |
371 if (dialog->icon_filesel != NULL) { | 385 if (dialog->icon_filesel != NULL) { |
372 gtk_window_present(GTK_WINDOW(dialog->icon_filesel)); | 386 gtk_window_present(GTK_WINDOW(dialog->icon_filesel)); |
373 return; | 387 return; |
374 } | 388 } |
375 | 389 |
390 current_folder = gaim_prefs_get_string("/gaim/gtk/filelocations/last_icon_folder"); | |
376 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ | 391 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ |
377 dialog->icon_filesel = gtk_file_chooser_dialog_new(_("Buddy Icon"), | 392 dialog->icon_filesel = gtk_file_chooser_dialog_new(_("Buddy Icon"), |
378 GTK_WINDOW(dialog->window), | 393 GTK_WINDOW(dialog->window), |
379 GTK_FILE_CHOOSER_ACTION_OPEN, | 394 GTK_FILE_CHOOSER_ACTION_OPEN, |
380 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | 395 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
381 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, | 396 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, |
382 NULL); | 397 NULL); |
383 gtk_dialog_set_default_response(GTK_DIALOG(dialog->icon_filesel), GTK_RESPONSE_ACCEPT); | 398 gtk_dialog_set_default_response(GTK_DIALOG(dialog->icon_filesel), GTK_RESPONSE_ACCEPT); |
384 | 399 if ((current_folder != NULL) && (*current_folder != '\0')) |
385 | 400 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog->icon_filesel), |
386 /* I removed code to set the current path to the current icon in the old file selector so I figure | 401 current_folder); |
387 * it shouldn't be here either. The reason is because the icon will potentially converted and won't | |
388 * be anything near what the user selected last time (which is the advantage to doing it this way. | |
389 * The solution is to create a new pref to specify the last chosen buddy icon. This would also have the | |
390 * advantage (?) of not being account-specific. | |
391 if (dialog->icon_path != NULL) | |
392 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog->icon_filesel), | |
393 dialog->icon_path); | |
394 */ | |
395 | 402 |
396 dialog->icon_preview = gtk_image_new(); | 403 dialog->icon_preview = gtk_image_new(); |
397 dialog->icon_text = gtk_label_new(NULL); | 404 dialog->icon_text = gtk_label_new(NULL); |
398 gtk_widget_set_size_request(GTK_WIDGET(dialog->icon_preview), -1, 50); | 405 gtk_widget_set_size_request(GTK_WIDGET(dialog->icon_preview), -1, 50); |
399 gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog->icon_filesel), | 406 gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog->icon_filesel), |
400 GTK_WIDGET(dialog->icon_preview)); | 407 GTK_WIDGET(dialog->icon_preview)); |
401 g_signal_connect(G_OBJECT(dialog->icon_filesel), "update-preview", | 408 g_signal_connect(G_OBJECT(dialog->icon_filesel), "update-preview", |
402 G_CALLBACK(icon_preview_change_cb), dialog); | 409 G_CALLBACK(icon_preview_change_cb), dialog); |
403 g_signal_connect(G_OBJECT(dialog->icon_filesel), "response", | 410 g_signal_connect(G_OBJECT(dialog->icon_filesel), "response", |
404 G_CALLBACK(icon_filesel_choose_cb), dialog); | 411 G_CALLBACK(icon_filesel_choose_cb), dialog); |
405 icon_preview_change_cb(NULL, dialog); | 412 icon_preview_change_cb(NULL, dialog); |
406 #else /* FILECHOOSER */ | 413 #else /* FILECHOOSER */ |
407 dialog->icon_filesel = gtk_file_selection_new(_("Buddy Icon")); | 414 dialog->icon_filesel = gtk_file_selection_new(_("Buddy Icon")); |
408 dialog->icon_preview = gtk_image_new(); | 415 dialog->icon_preview = gtk_image_new(); |
409 dialog->icon_text = gtk_label_new(NULL); | 416 dialog->icon_text = gtk_label_new(NULL); |
417 if ((current_folder != NULL) && (*current_folder != '\0')) | |
418 gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog->icon_filesel), | |
419 current_folder); | |
410 | 420 |
411 gtk_widget_set_size_request(GTK_WIDGET(dialog->icon_preview), -1, 50); | 421 gtk_widget_set_size_request(GTK_WIDGET(dialog->icon_preview), -1, 50); |
412 hbox = gtk_hbox_new(FALSE, 6); | 422 hbox = gtk_hbox_new(FALSE, 6); |
413 gtk_box_pack_start( | 423 gtk_box_pack_start( |
414 GTK_BOX(GTK_FILE_SELECTION(dialog->icon_filesel)->main_vbox), | 424 GTK_BOX(GTK_FILE_SELECTION(dialog->icon_filesel)->main_vbox), |