[virt-tools-list] [virt-viewer][PATCH v2] virt-viewer: Set toolbar buttons not sensitive when needed
Fabiano Fidencio
ffidenci at redhat.com
Mon Apr 20 08:46:21 UTC 2015
----- Original Message -----
> From: "Lukas Venhoda" <lvenhoda at redhat.com>
> To: virt-tools-list at redhat.com
> Sent: Thursday, April 16, 2015 1:59:51 PM
> Subject: [virt-tools-list] [virt-viewer][PATCH v2] virt-viewer: Set toolbar buttons not sensitive when needed
>
> File->Screenshot, File->Preferences, View->Zoom and Send keys are now
> sensitive only while quest is connected.
>
> Changed behaviour of zoom:
>
> Previously, zoom could be set while quest wasn't connected. The zoom
> would then be set on connection. There was no indication of current zoom
> level while not connected to guest.
>
> Now, the menu is not sensitive while not connected to guest. Zoom can
> now be only modified while connected to guest, or from the command line.
> ---
>
> v2:
> Changed commit message to including the change in zoom menu behaviour.
> Included Preferences menu. Preferences are now also not sensitive
> while not connected to guest.
>
> ---
> src/virt-viewer-app.c | 13 +++++++++++++
> src/virt-viewer-app.h | 1 +
> src/virt-viewer-window.c | 29 ++++++++++++++++++++++++++++-
> src/virt-viewer-window.h | 1 +
> src/virt-viewer.c | 1 +
> 5 files changed, 44 insertions(+), 1 deletion(-)
>
> diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
> index 7cf0c60..cd83fe3 100644
> --- a/src/virt-viewer-app.c
> +++ b/src/virt-viewer-app.c
> @@ -819,6 +819,19 @@ virt_viewer_app_set_usb_options_sensitive(VirtViewerApp
> *self, gboolean sensitiv
> GINT_TO_POINTER(sensitive));
> }
>
> +static void
> +set_menus_sensitive(gpointer value, gpointer user_data)
> +{
> + virt_viewer_window_set_menus_sensitive(VIRT_VIEWER_WINDOW(value),
> + GPOINTER_TO_INT(user_data));
> +}
> +
> +void
> +virt_viewer_app_set_menus_sensitive(VirtViewerApp *self, gboolean sensitive)
> +{
> + g_list_foreach(self->priv->windows, set_menus_sensitive,
> GINT_TO_POINTER(sensitive));
> +}
> +
> static VirtViewerWindow *
> virt_viewer_app_get_nth_window(VirtViewerApp *self, gint nth)
> {
> diff --git a/src/virt-viewer-app.h b/src/virt-viewer-app.h
> index 6af9c01..f53fa73 100644
> --- a/src/virt-viewer-app.h
> +++ b/src/virt-viewer-app.h
> @@ -101,6 +101,7 @@ GList*
> virt_viewer_app_get_initial_displays(VirtViewerApp* self);
> gint virt_viewer_app_get_initial_monitor_for_display(VirtViewerApp* self,
> gint display);
> void virt_viewer_app_set_enable_accel(VirtViewerApp *app, gboolean enable);
> void virt_viewer_app_show_preferences(VirtViewerApp *app, GtkWidget
> *parent);
> +void virt_viewer_app_set_menus_sensitive(VirtViewerApp *self, gboolean
> sensitive);
>
> G_END_DECLS
>
> diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
> index a1eceb5..8d130cf 100644
> --- a/src/virt-viewer-window.c
> +++ b/src/virt-viewer-window.c
> @@ -306,7 +306,9 @@ virt_viewer_window_init (VirtViewerWindow *self)
> priv->builder = virt_viewer_util_load_ui("virt-viewer.xml");
>
> gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder,
> "menu-send")), FALSE);
> +
> gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder,
> "menu-view-zoom")), FALSE);
> gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder,
> "menu-file-screenshot")), FALSE);
> +
> gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder,
> "menu-preferences")), FALSE);
>
> gtk_builder_connect_signals(priv->builder, self);
>
> @@ -1283,6 +1285,29 @@
> virt_viewer_window_set_usb_options_sensitive(VirtViewerWindow *self,
> gboolean se
> gtk_widget_set_visible(priv->toolbar_usb_device_selection, sensitive);
> }
>
> +void
> +virt_viewer_window_set_menus_sensitive(VirtViewerWindow *self, gboolean
> sensitive)
> +{
> + VirtViewerWindowPrivate *priv;
> + GtkWidget *menu;
> +
> + g_return_if_fail(VIRT_VIEWER_IS_WINDOW(self));
> +
> + priv = self->priv;
> +
> + menu = GTK_WIDGET(gtk_builder_get_object(priv->builder,
> "menu-preferences"));
> + gtk_widget_set_sensitive(menu, sensitive);
> +
> + menu = GTK_WIDGET(gtk_builder_get_object(priv->builder,
> "menu-file-screenshot"));
> + gtk_widget_set_sensitive(menu, sensitive);
> +
> + menu = GTK_WIDGET(gtk_builder_get_object(priv->builder,
> "menu-view-zoom"));
> + gtk_widget_set_sensitive(menu, sensitive);
> +
> + menu = GTK_WIDGET(gtk_builder_get_object(priv->builder, "menu-send"));
> + gtk_widget_set_sensitive(menu, sensitive);
> +}
> +
> static void
> display_show_hint(VirtViewerDisplay *display,
> GParamSpec *pspec G_GNUC_UNUSED,
> @@ -1360,6 +1385,8 @@ virt_viewer_window_set_display(VirtViewerWindow *self,
> VirtViewerDisplay *displa
> if (virt_viewer_display_get_enabled(display))
> virt_viewer_window_desktop_resize(display, self);
>
> +
> gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder,
> "menu-preferences")), TRUE);
> +
> gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder,
> "menu-view-zoom")), TRUE);
> gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder,
> "menu-send")), TRUE);
> gtk_widget_set_sensitive(self->priv->toolbar_send_key, TRUE);
> }
> @@ -1446,7 +1473,7 @@ virt_viewer_window_set_zoom_level(VirtViewerWindow
> *self, gint zoom_level)
> g_debug("Zoom level not changed, using: %d", priv->zoomlevel);
> return;
> }
> -
> +
> virt_viewer_display_set_zoom_level(VIRT_VIEWER_DISPLAY(priv->display),
> priv->zoomlevel);
>
> virt_viewer_window_queue_resize(self);
> diff --git a/src/virt-viewer-window.h b/src/virt-viewer-window.h
> index 1f1e130..c25e9c9 100644
> --- a/src/virt-viewer-window.h
> +++ b/src/virt-viewer-window.h
> @@ -71,6 +71,7 @@ void virt_viewer_window_set_display(VirtViewerWindow *self,
> VirtViewerDisplay *d
> VirtViewerDisplay* virt_viewer_window_get_display(VirtViewerWindow *self);
> void virt_viewer_window_set_menu_displays_sensitive(VirtViewerWindow *self,
> gboolean sensitive);
> void virt_viewer_window_set_usb_options_sensitive(VirtViewerWindow *self,
> gboolean sensitive);
> +void virt_viewer_window_set_menus_sensitive(VirtViewerWindow *self, gboolean
> sensitive);
> void virt_viewer_window_update_title(VirtViewerWindow *self);
> void virt_viewer_window_show(VirtViewerWindow *self);
> void virt_viewer_window_hide(VirtViewerWindow *self);
> diff --git a/src/virt-viewer.c b/src/virt-viewer.c
> index 2f047f0..9c3ccc9 100644
> --- a/src/virt-viewer.c
> +++ b/src/virt-viewer.c
> @@ -169,6 +169,7 @@ virt_viewer_deactivated(VirtViewerApp *app, gboolean
> connect_error)
>
> virt_viewer_app_show_status(app, _("Waiting for guest domain to
> re-start"));
> virt_viewer_app_trace(app, "Guest %s display has disconnected,
> waiting to reconnect", priv->domkey);
> + virt_viewer_app_set_menus_sensitive(app, FALSE);
> } else {
> VIRT_VIEWER_APP_CLASS(virt_viewer_parent_class)->deactivated(app,
> connect_error);
> }
> --
> 2.3.5
>
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
>
ACK!
More information about the virt-tools-list
mailing list