[virt-tools-list] [PATCH virt-viewer 06/25] Turn display:show-hint into flags type
Marc-André Lureau
marcandre.lureau at gmail.com
Tue Jul 17 19:24:48 UTC 2012
---
src/virt-viewer-app.c | 5 +++--
src/virt-viewer-display.c | 26 ++++++++++++++++----------
src/virt-viewer-display.h | 11 ++++++-----
src/virt-viewer-window.c | 5 ++++-
4 files changed, 29 insertions(+), 18 deletions(-)
diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 1447ce7..5588c6a 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -609,7 +609,8 @@ display_show_hint(VirtViewerDisplay *display,
{
VirtViewerApp *self;
VirtViewerNotebook *nb = virt_viewer_window_get_notebook(win);
- gint nth, hint;
+ gint nth;
+ guint hint;
g_object_get(win,
"app", &self,
@@ -619,7 +620,7 @@ display_show_hint(VirtViewerDisplay *display,
"show-hint", &hint,
NULL);
- if (hint == VIRT_VIEWER_DISPLAY_SHOW_HINT_HIDE) {
+ if (hint == 0) {
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
More information about the virt-tools-list
mailing list