[virt-tools-list] [PATCH virt-viewer] !fixup Show failed file transfers
Jonathon Jongsma
jjongsma at redhat.com
Thu Oct 27 19:37:15 UTC 2016
---
Here's a possible alternative solution. I chose not to 'continue' in the case
of a NULL filename since you might end up with a message like:
An error caused the following file transfers to fail:
And then no files listed. I think that's a bit odd. So instead I just printed
the file transfer task ID. An alternative might be to just show something like
"(unnamed file)".
src/virt-viewer-file-transfer-dialog.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/virt-viewer-file-transfer-dialog.c b/src/virt-viewer-file-transfer-dialog.c
index 6f28f37..4750441 100644
--- a/src/virt-viewer-file-transfer-dialog.c
+++ b/src/virt-viewer-file-transfer-dialog.c
@@ -178,10 +178,18 @@ static gboolean hide_transfer_dialog(gpointer data)
if (self->priv->failed) {
GSList *sl;
GString *msg = g_string_new("");
+ GtkWidget *dialog;
for (sl = self->priv->failed; sl != NULL; sl = g_slist_next(sl)) {
SpiceFileTransferTask *failed_task = sl->data;
gchar *filename = spice_file_transfer_task_get_filename(failed_task);
+ if (filename == NULL) {
+ guint id;
+
+ g_object_get(failed_task, "id", &id, NULL);
+ g_warning("Unable to get filename of failed transfer");
+ filename = g_strdup_printf("(task #%u)", id);
+ }
g_string_append_printf(msg, "\n%s", filename);
g_free(filename);
@@ -189,10 +197,10 @@ static gboolean hide_transfer_dialog(gpointer data)
g_slist_free_full(self->priv->failed, g_object_unref);
self->priv->failed = NULL;
- GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(self), 0, GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("An error caused following file transfers to fail:\n%s"),
- msg->str);
+ dialog = gtk_message_dialog_new(GTK_WINDOW(self), 0, GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("An error caused the following file transfers to fail:%s"),
+ msg->str);
g_string_free(msg, TRUE);
g_signal_connect(dialog, "response", G_CALLBACK(error_dialog_response), NULL);
gtk_widget_show(dialog);
--
2.7.4
More information about the virt-tools-list
mailing list