diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2012-10-09 18:06:00 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2012-10-09 18:06:00 +0200 |
commit | fa602c20ececf2ecd9c78f9b44934b5c5b0980ea (patch) | |
tree | 24d3a8ebff19555b1b295afc564d3f0942c95dda | |
parent | 0066917014d32f80b70982b927ee5a6859b0cbd5 (diff) | |
download | logdiag-fa602c20ececf2ecd9c78f9b44934b5c5b0980ea.tar.gz logdiag-fa602c20ececf2ecd9c78f9b44934b5c5b0980ea.tar.xz logdiag-fa602c20ececf2ecd9c78f9b44934b5c5b0980ea.zip |
Show something more helpful on file open error.
-rw-r--r-- | src/ld-window-main.c | 22 |
1 files 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; } |