overwrite confirmation - gtk file chooser

Gabriel Schulhof nix at go-nix.ca
Sun Aug 12 16:35:04 EDT 2007


On Mon, 2007-08-13 at 00:36 +0530, Prekshu Ajmera wrote:
> How do I take care of overwrite ?

/*
This code is off the top of my head and totally untested.
*/

while (gtk_dialog_run(GTK_DIALOG(the_save_as_dialog))) {
  the_folder = gtk_file_chooser_get_filename(
    GTK_FILE_CHOOSER(the_save_as_dialog));
  if (g_file_test(the_folder, G_FILE_TEST_EXISTS)) {
    GtkWidget *msg = gtk_message_dialog_new(the_save_as_dialog, 
      GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
      "Folder exists. Overwrite?");

    if (GTK_RESPONSE_YES == gtk_dialog_run(GTK_DIALOG(msg))) {
      overwrite_the_folder(the_folder);
      gtk_widget_destroy(msg);
      break;
    }
    gtk_widget_destroy(msg);
  }
  g_free(the_folder);
}

g_free(the_folder);
gtk_widget_destroy(the_save_as_dialog);





More information about the Devel mailing list