diff options
| author | Jon A. Cruz <jon@joncruz.org> | 2007-04-07 08:28:41 +0000 |
|---|---|---|
| committer | joncruz <joncruz@users.sourceforge.net> | 2007-04-07 08:28:41 +0000 |
| commit | 3fbc035c91b527ec2056565c78a1b41cd9517a48 (patch) | |
| tree | 2f5cb8a28136519a8b82b0a427aef5d97990262a /src/interface.cpp | |
| parent | Corrected case where extension would not be added for opened filetypes not in... (diff) | |
| download | inkscape-3fbc035c91b527ec2056565c78a1b41cd9517a48.tar.gz inkscape-3fbc035c91b527ec2056565c78a1b41cd9517a48.zip | |
Updated overwrite confirmation dialog to be similar to the new stock GTK+ one
addresses RFE 1692837
(bzr r2831)
Diffstat (limited to 'src/interface.cpp')
| -rw-r--r-- | src/interface.cpp | 65 |
1 files changed, 26 insertions, 39 deletions
diff --git a/src/interface.cpp b/src/interface.cpp index c6b2aaf86..fa41e5898 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -1254,52 +1254,39 @@ bool sp_ui_overwrite_file(gchar const *filename) { bool return_value = FALSE; - GtkWidget *dialog; - GtkWidget *hbox; - GtkWidget *boxdata; - gchar *title; - gchar *text; if (Inkscape::IO::file_test(filename, G_FILE_TEST_EXISTS)) { - - title = g_strdup_printf(_("Overwrite %s"), filename); - dialog = gtk_dialog_new_with_buttons(title, - NULL, - (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), - GTK_STOCK_NO, - GTK_RESPONSE_NO, - GTK_STOCK_YES, - GTK_RESPONSE_YES, - NULL); - gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_YES); - - sp_transientize(dialog); - gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); - - hbox = gtk_hbox_new(FALSE, 5); - - // TODO - replace with Inkscape-specific call - boxdata = gtk_image_new_from_stock(GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG); - - gtk_widget_show(boxdata); - gtk_box_pack_start(GTK_BOX(hbox), boxdata, TRUE, TRUE, 5); - text = g_strdup_printf(_("The file %s already exists. Do you want to overwrite that file with the current document?"), filename); - boxdata = gtk_label_new(text); - gtk_label_set_line_wrap(GTK_LABEL(boxdata), TRUE); - gtk_widget_show(boxdata); - gtk_box_pack_start(GTK_BOX(hbox), boxdata, FALSE, FALSE, 5); - gtk_widget_show(hbox); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, TRUE, TRUE, 5); - - if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_YES) { + GtkWidget* ancestor = 0; + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + if ( desktop ) { + desktop->getToplevel( ancestor ); + } + GtkWindow *window = GTK_WIDGET_TOPLEVEL(ancestor) ? GTK_WINDOW( ancestor ) : 0; + gchar* baseName = g_path_get_basename( filename ); + gchar* dirName = g_path_get_dirname( filename ); + GtkWidget* dialog = gtk_message_dialog_new_with_markup( window, + (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_NONE, + _( "<span weight=\"bold\" size=\"larger\">A file named \"%s\" already exists. Do you want to replace it?</span>\n\n" + "The file already exists in \"%s\". Replacing it will overwrite its contents." ), + baseName, + dirName + ); + gtk_dialog_add_buttons( GTK_DIALOG(dialog), + GTK_STOCK_CANCEL, GTK_RESPONSE_NO, + _("Replace"), GTK_RESPONSE_YES, + NULL ); + gtk_dialog_set_default_response( GTK_DIALOG(dialog), GTK_RESPONSE_YES ); + + if ( gtk_dialog_run( GTK_DIALOG(dialog) ) == GTK_RESPONSE_YES ) { return_value = TRUE; } else { return_value = FALSE; } - gtk_widget_destroy(dialog); - g_free(title); - g_free(text); + g_free( baseName ); + g_free( dirName ); } else { return_value = TRUE; } |
