[virt-tools-list] [PATCH virt-viewer 06/19] Turn display:show-hint into flags type

Christophe Fergeau cfergeau at redhat.com
Tue Jul 17 08:59:12 UTC 2012


On Mon, Jul 16, 2012 at 06:57:41PM +0200, Marc-André Lureau wrote:
> ---
>  src/virt-viewer-app.c     |    2 +-
>  src/virt-viewer-display.c |   26 ++++++++++++++++----------
>  src/virt-viewer-display.h |   11 ++++++-----
>  src/virt-viewer-window.c  |    5 ++++-
>  4 files changed, 27 insertions(+), 17 deletions(-)
> 
> diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
> index 1447ce7..b93a978 100644
> --- a/src/virt-viewer-app.c
> +++ b/src/virt-viewer-app.c
> @@ -619,7 +619,7 @@ display_show_hint(VirtViewerDisplay *display,
>                   "show-hint", &hint,
>                   NULL);
>  
> -    if (hint == VIRT_VIEWER_DISPLAY_SHOW_HINT_HIDE) {
> +    if (hint == 0) {

On second thought, shouldn't this be if (!(hint & _HINT_READY)) { } ? I'm
not sure which flags you are going to add.

Christophe

>          if (win != self->priv->main_window &&
>              g_getenv("VIRT_VIEWER_HIDE"))
>              virt_viewer_window_hide(win);
> diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c
> index 6d6052b..43ec45e 100644
> --- a/src/virt-viewer-display.c
> +++ b/src/virt-viewer-display.c
> @@ -41,7 +41,7 @@ struct _VirtViewerDisplayPrivate
>      guint zoom_level;
>      gboolean zoom;
>      gint nth_display;
> -    gint show_hint;
> +    guint show_hint;
>      VirtViewerSession *session;
>      gboolean auto_resize;
>  };
> @@ -151,13 +151,12 @@ virt_viewer_display_class_init(VirtViewerDisplayClass *class)
>  
>      g_object_class_install_property(object_class,
>                                      PROP_SHOW_HINT,
> -                                    g_param_spec_int("show-hint",
> -                                                     "Show hint",
> -                                                     "Show state hint",
> -                                                     0,
> -                                                     G_MAXINT32,
> -                                                     0,
> -                                                     G_PARAM_READABLE));
> +                                    g_param_spec_flags("show-hint",
> +                                                       "Show hint",
> +                                                       "Show state hint",
> +                                                       VIRT_VIEWER_TYPE_DISPLAY_SHOW_HINT_FLAGS,
> +                                                       0,
> +                                                       G_PARAM_READABLE));
>  
>      g_object_class_install_property(object_class,
>                                      PROP_SESSION,
> @@ -298,7 +297,7 @@ virt_viewer_display_get_property(GObject *object,
>          g_value_set_int(value, priv->nth_display);
>          break;
>      case PROP_SHOW_HINT:
> -        g_value_set_int(value, priv->show_hint);
> +        g_value_set_flags(value, priv->show_hint);
>          break;
>      case PROP_SESSION:
>          g_value_set_object(value, virt_viewer_display_get_session(display));
> @@ -530,7 +529,14 @@ GdkPixbuf* virt_viewer_display_get_pixbuf(VirtViewerDisplay *display)
>      return VIRT_VIEWER_DISPLAY_GET_CLASS(display)->get_pixbuf(display);
>  }
>  
> -void virt_viewer_display_set_show_hint(VirtViewerDisplay *self, gint hint)
> +guint virt_viewer_display_get_show_hint(VirtViewerDisplay *self)
> +{
> +    g_return_val_if_fail(VIRT_VIEWER_IS_DISPLAY(self), 0);
> +
> +    return self->priv->show_hint;
> +}
> +
> +void virt_viewer_display_set_show_hint(VirtViewerDisplay *self, guint hint)
>  {
>      VirtViewerDisplayPrivate *priv;
>      g_return_if_fail(VIRT_VIEWER_IS_DISPLAY(self));
> diff --git a/src/virt-viewer-display.h b/src/virt-viewer-display.h
> index ffbaf0e..225080d 100644
> --- a/src/virt-viewer-display.h
> +++ b/src/virt-viewer-display.h
> @@ -25,6 +25,7 @@
>  #define _VIRT_VIEWER_DISPLAY_H
>  
>  #include <gtk/gtk.h>
> +#include "virt-viewer-enums.h"
>  
>  G_BEGIN_DECLS
>  
> @@ -54,10 +55,9 @@ typedef struct _VirtViewerDisplayPrivate VirtViewerDisplayPrivate;
>  
>  typedef struct _VirtViewerDisplayChannel VirtViewerDisplayChannel;
>  
> -enum {
> -    VIRT_VIEWER_DISPLAY_SHOW_HINT_HIDE = 0,
> -    VIRT_VIEWER_DISPLAY_SHOW_HINT_READY,
> -};
> +typedef enum {
> +    VIRT_VIEWER_DISPLAY_SHOW_HINT_READY            = 1 << 0,
> +} VirtViewerDisplayShowHintFlags;
>  
>  /* perhaps this become an interface, and be pushed in gtkvnc and spice? */
>  struct _VirtViewerDisplay {
> @@ -108,7 +108,8 @@ gboolean virt_viewer_display_get_zoom(VirtViewerDisplay *display);
>  void virt_viewer_display_send_keys(VirtViewerDisplay *display,
>                                     const guint *keyvals, int nkeyvals);
>  GdkPixbuf* virt_viewer_display_get_pixbuf(VirtViewerDisplay *display);
> -void virt_viewer_display_set_show_hint(VirtViewerDisplay *display, gint hint);
> +void virt_viewer_display_set_show_hint(VirtViewerDisplay *display, guint hint);
> +guint virt_viewer_display_get_show_hint(VirtViewerDisplay *display);
>  VirtViewerSession* virt_viewer_display_get_session(VirtViewerDisplay *display);
>  void virt_viewer_display_set_auto_resize(VirtViewerDisplay *display, gboolean auto_resize);
>  gboolean virt_viewer_display_get_auto_resize(VirtViewerDisplay *display);
> diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
> index 7b582a0..c873ebc 100644
> --- a/src/virt-viewer-window.c
> +++ b/src/virt-viewer-window.c
> @@ -1002,9 +1002,12 @@ display_show_hint(VirtViewerDisplay *display,
>                    GParamSpec *pspec G_GNUC_UNUSED,
>                    VirtViewerWindow *self)
>  {
> -    gboolean hint;
> +    guint hint;
>  
>      g_object_get(display, "show-hint", &hint, NULL);
> +
> +    hint = (hint & VIRT_VIEWER_DISPLAY_SHOW_HINT_READY);
> +
>      gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder, "menu-send")), hint);
>      gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder, "menu-file-screenshot")), hint);
>      gtk_widget_set_sensitive(self->priv->toolbar_send_key, hint);
> -- 
> 1.7.10.4
> 
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20120717/6ebdf88d/attachment.sig>


More information about the virt-tools-list mailing list