overwrite confirmation - gtk file chooser
Mark Doliner
mark at kingant.net
Sun Aug 12 19:38:07 EDT 2007
On Sun, 12 Aug 2007 23:35:04 +0300, Gabriel Schulhof wrote
> 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);
I don't know what this code will be used for... but gtk_dialog_run() shouldn't
be used in Pidgin because it is application modal, and application modal
dialogs should only be used when absolutely necessary.
See
http://developer.gnome.org/projects/gup/hig/2.0/windows.html#window-props-modality
for a little more explanation
-Mark
More information about the Devel
mailing list