Remove VIRT_VIEWER_VM_CHOOSE_DIALOG_CANCELLED

This error type isn't really an error, it is used to skip error report
code. The functions can simply return FALSE on failure, without GError
set, to indicate that program should quit normally.
This commit is contained in:
Marc-André Lureau 2014-11-12 12:06:54 +01:00
parent 71f156caf5
commit 15c7d17b96
4 changed files with 5 additions and 18 deletions

View File

@ -1241,15 +1241,9 @@ retry_dialog:
if (g_strcmp0(type, "ovirt") == 0) {
if (!create_ovirt_session(app, guri, &error)) {
if (error) {
if (!g_error_matches(error,
VIRT_VIEWER_ERROR,
VIRT_VIEWER_VM_CHOOSE_DIALOG_CANCELLED)) {
virt_viewer_app_simple_message_dialog(app,
_("Couldn't open oVirt session: %s"),
error->message);
}
} else {
virt_viewer_app_simple_message_dialog(app, _("Couldn't open oVirt session"));
virt_viewer_app_simple_message_dialog(app,
_("Couldn't open oVirt session: %s"),
error->message);
}
g_clear_error(&error);
goto cleanup;

View File

@ -30,7 +30,6 @@ extern gboolean doDebug;
enum {
VIRT_VIEWER_ERROR_FAILED,
VIRT_VIEWER_VM_CHOOSE_DIALOG_CANCELLED,
};
#define VIRT_VIEWER_ERROR virt_viewer_error_quark ()

View File

@ -84,10 +84,6 @@ virt_viewer_vm_connection_choose_name_dialog(GtkTreeModel *model, GError **error
if (dialog_response == GTK_RESPONSE_ACCEPT &&
gtk_tree_selection_get_selected(selection, &model, &iter)) {
gtk_tree_model_get(model, &iter, 0, &vm_name, -1);
} else {
g_set_error_literal(error,
VIRT_VIEWER_ERROR, VIRT_VIEWER_VM_CHOOSE_DIALOG_CANCELLED,
_("No virtual machine was chosen"));
}
gtk_widget_destroy(dialog);

View File

@ -663,8 +663,7 @@ virt_viewer_initial_connect(VirtViewerApp *app, GError **error)
goto done;
} else {
dom = choose_vm(&priv->domkey, priv->conn, &err);
if (dom == NULL &&
!g_error_matches(err, VIRT_VIEWER_ERROR, VIRT_VIEWER_VM_CHOOSE_DIALOG_CANCELLED)) {
if (dom == NULL && err != NULL) {
virt_viewer_app_simple_message_dialog(app, err->message);
goto cleanup;
}
@ -856,8 +855,7 @@ virt_viewer_connect(VirtViewerApp *app)
}
if (!virt_viewer_app_initial_connect(app, &error)) {
if (error &&
!g_error_matches(error, VIRT_VIEWER_ERROR, VIRT_VIEWER_VM_CHOOSE_DIALOG_CANCELLED))
if (error != NULL)
g_warning("%s", error->message);
g_clear_error(&error);
return -1;