[virt-tools-list] [virt-viewer v2 4/4] Hide all windows on disconnection
Marc-André Lureau
mlureau at redhat.com
Wed Oct 30 11:53:13 UTC 2013
----- Original Message -----
> When starting remote-viewer without argument, we are showing a
> window where the user can enter connection details. We then
> go on to try and connect to the URI the user specified, and if
> the connection fails, we disconnect from the remote server, and then
> we show again the connection window so that the user can correct the
> URI if he entered it wrong.
> However, when this happens, the window for the previous connection
> will still be visible even if connection failed. To avoid this,
> this commit makes sure we hide all windows when we get a disconnection
> event.
>
> Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1024309
> ---
> src/virt-viewer-app.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
> index 978c322..822ec5c 100644
> --- a/src/virt-viewer-app.c
> +++ b/src/virt-viewer-app.c
> @@ -365,6 +365,19 @@ virt_viewer_app_window_set_visible(VirtViewerApp *self,
> return FALSE;
> }
>
> +static void
> +virt_viewer_app_hide_all_windows(VirtViewerApp *app)
> +{
> + GList *it;
> + GList *windows;
> + virt_viewer_window_hide(app->priv->main_window);
> + windows = g_hash_table_get_values(app->priv->windows);
> + for (it = windows; it != NULL; it = it->next) {
> + virt_viewer_window_hide(VIRT_VIEWER_WINDOW(it->data));
> + }
> + g_list_free(windows);
> +}
Why is app->priv->main_window special cased? It should be already window 0.
tbh, I think g_hash_table_foreach() would be simpler (like done with the rest of the code).
static void hide_each(gpointer key G_GNUC_UNUSED,
gpointer value,
gpointer user_data G_GNUC_UNUSED)
{
virt_viewer_window_hide(VIRT_VIEWER_WINDOW(value));
}
g_hash_table_foreach(priv->windows, hide_each, NULL)
> G_MODULE_EXPORT void
> virt_viewer_app_about_close(GtkWidget *dialog,
> VirtViewerApp *self G_GNUC_UNUSED)
> @@ -1216,6 +1229,7 @@ virt_viewer_app_disconnected(VirtViewerSession *session
> G_GNUC_UNUSED,
> VirtViewerAppPrivate *priv = self->priv;
> gboolean connect_error = !priv->connected && !priv->cancelled;
>
> + virt_viewer_app_hide_all_windows(self);
> if (priv->quitting)
> gtk_main_quit();
>
> --
> 1.8.3.1
>
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
>
More information about the virt-tools-list
mailing list