From fa602c20ececf2ecd9c78f9b44934b5c5b0980ea Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Tue, 9 Oct 2012 18:06:00 +0200 Subject: Show something more helpful on file open error. --- src/ld-window-main.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/ld-window-main.c b/src/ld-window-main.c index da84244..d68a957 100644 --- a/src/ld-window-main.c +++ b/src/ld-window-main.c @@ -694,16 +694,30 @@ diagram_open (LdWindowMain *self, const gchar *filename) GtkWidget *message_dialog; g_warning ("loading failed: %s", error->message); - g_error_free (error); message_dialog = gtk_message_dialog_new (GTK_WINDOW (self), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Failed to open the file")); - gtk_message_dialog_format_secondary_text - (GTK_MESSAGE_DIALOG (message_dialog), - _("The file is probably corrupted.")); + + if (error->domain != G_FILE_ERROR) + { + gchar *display_filename; + + display_filename = g_filename_display_name (filename); + gtk_message_dialog_format_secondary_text + (GTK_MESSAGE_DIALOG (message_dialog), + _("Failed to open file `%s': Invalid contents."), filename); + g_free (display_filename); + } + else + gtk_message_dialog_format_secondary_text + (GTK_MESSAGE_DIALOG (message_dialog), + "%s", error->message); + gtk_dialog_run (GTK_DIALOG (message_dialog)); gtk_widget_destroy (message_dialog); + + g_error_free (error); return FALSE; } -- cgit v1.2.3-70-g09d2