[virt-tools-list] [PATCH virt-viewer 18/25] Add VirtViewerDisplay::selectable property
Marc-André Lureau
marcandre.lureau at gmail.com
Tue Jul 17 19:25:00 UTC 2012
This property will be set when the display can be selected to be
"enabled" and shown (this can involve creating/connecting an
additional guest monitor, and may need guest agent cooperation for
example).
---
src/virt-viewer-display-spice.c | 16 ++++++++++++++++
src/virt-viewer-display.c | 23 +++++++++++++++++++++++
src/virt-viewer-display.h | 2 ++
3 files changed, 41 insertions(+)
diff --git a/src/virt-viewer-display-spice.c b/src/virt-viewer-display-spice.c
index d06e5cf..81eb16f 100644
--- a/src/virt-viewer-display-spice.c
+++ b/src/virt-viewer-display-spice.c
@@ -47,6 +47,7 @@ static void virt_viewer_display_spice_send_keys(VirtViewerDisplay *display,
static GdkPixbuf *virt_viewer_display_spice_get_pixbuf(VirtViewerDisplay *display);
static void virt_viewer_display_spice_release_cursor(VirtViewerDisplay *display);
static void virt_viewer_display_spice_close(VirtViewerDisplay *display G_GNUC_UNUSED);
+static gboolean virt_viewer_display_spice_selectable(VirtViewerDisplay *display);
static void
virt_viewer_display_spice_finalize(GObject *obj)
@@ -70,6 +71,7 @@ virt_viewer_display_spice_class_init(VirtViewerDisplaySpiceClass *klass)
dclass->get_pixbuf = virt_viewer_display_spice_get_pixbuf;
dclass->release_cursor = virt_viewer_display_spice_release_cursor;
dclass->close = virt_viewer_display_spice_close;
+ dclass->selectable = virt_viewer_display_spice_selectable;
g_type_class_add_private(klass, sizeof(VirtViewerDisplaySpicePrivate));
}
@@ -279,6 +281,20 @@ virt_viewer_display_spice_close(VirtViewerDisplay *display G_GNUC_UNUSED)
{
}
+static gboolean
+virt_viewer_display_spice_selectable(VirtViewerDisplay *self)
+{
+ gboolean agent_connected;
+ SpiceMainChannel *mainc;
+
+ mainc = get_main(self);
+ g_object_get(mainc,
+ "agent-connected", &agent_connected,
+ NULL);
+
+ return agent_connected;
+}
+
/*
* Local variables:
diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c
index 18fed19..8d13733 100644
--- a/src/virt-viewer-display.c
+++ b/src/virt-viewer-display.c
@@ -80,6 +80,7 @@ enum {
PROP_ZOOM_LEVEL,
PROP_SHOW_HINT,
PROP_SESSION,
+ PROP_SELECTABLE,
};
static void
@@ -167,6 +168,13 @@ virt_viewer_display_class_init(VirtViewerDisplayClass *class)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(object_class,
+ PROP_SELECTABLE,
+ g_param_spec_boolean("selectable",
+ "Selectable",
+ "Selectable",
+ FALSE,
+ G_PARAM_READABLE));
g_signal_new("display-pointer-grab",
G_OBJECT_CLASS_TYPE(object_class),
@@ -302,6 +310,9 @@ virt_viewer_display_get_property(GObject *object,
case PROP_SESSION:
g_value_set_object(value, virt_viewer_display_get_session(display));
break;
+ case PROP_SELECTABLE:
+ g_value_set_boolean(value, virt_viewer_display_get_selectable(display));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -601,6 +612,18 @@ void virt_viewer_display_release_cursor(VirtViewerDisplay *self)
klass->release_cursor(self);
}
+gboolean virt_viewer_display_get_selectable(VirtViewerDisplay *self)
+{
+ VirtViewerDisplayClass *klass;
+
+ g_return_val_if_fail(VIRT_VIEWER_IS_DISPLAY(self), FALSE);
+
+ klass = VIRT_VIEWER_DISPLAY_GET_CLASS(self);
+ if (klass->selectable)
+ return klass->selectable(self);
+
+ return TRUE;
+}
void virt_viewer_display_close(VirtViewerDisplay *self)
{
diff --git a/src/virt-viewer-display.h b/src/virt-viewer-display.h
index 89b4817..4247570 100644
--- a/src/virt-viewer-display.h
+++ b/src/virt-viewer-display.h
@@ -77,6 +77,7 @@ struct _VirtViewerDisplayClass {
void (*release_cursor)(VirtViewerDisplay *display);
void (*close)(VirtViewerDisplay *display);
+ gboolean (*selectable)(VirtViewerDisplay *display);
/* signals */
void (*display_pointer_grab)(VirtViewerDisplay *display);
@@ -118,6 +119,7 @@ void virt_viewer_display_release_cursor(VirtViewerDisplay *display);
void virt_viewer_display_close(VirtViewerDisplay *display);
void virt_viewer_display_set_enabled(VirtViewerDisplay *display, gboolean enabled);
+gboolean virt_viewer_display_get_selectable(VirtViewerDisplay *display);
G_END_DECLS
--
1.7.10.4
More information about the virt-tools-list
mailing list