[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [PATCH virt-viewer 07/17] Add a few property getters, used by controller



- virt_viewer_app_get_windows()
- virt_viewer_window_get_builder()
- "VirtViewerSessionSpice:spice-session" property
---
 src/virt-viewer-app.c           |    7 +++++
 src/virt-viewer-app.h           |    1 +
 src/virt-viewer-session-spice.c |   47 +++++++++++++++++++++++++++++++++++++-
 src/virt-viewer-window.c        |    9 +++++++
 src/virt-viewer-window.h        |    1 +
 5 files changed, 63 insertions(+), 2 deletions(-)

diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 97b53c2..352f206 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -1528,6 +1528,13 @@ virt_viewer_app_show_display(VirtViewerApp *self)
 	g_hash_table_foreach(self->priv->windows, show_display_cb, self);
 }
 
+GHashTable*
+virt_viewer_app_get_windows(VirtViewerApp *self)
+{
+	g_return_val_if_fail(VIRT_VIEWER_IS_APP(self), NULL);
+	return self->priv->windows;
+}
+
 /*
  * Local variables:
  *  c-indent-level: 8
diff --git a/src/virt-viewer-app.h b/src/virt-viewer-app.h
index 7c3f0a7..320e75c 100644
--- a/src/virt-viewer-app.h
+++ b/src/virt-viewer-app.h
@@ -86,6 +86,7 @@ void virt_viewer_app_set_connect_info(VirtViewerApp *self,
 gboolean virt_viewer_app_window_set_visible(VirtViewerApp *self, VirtViewerWindow *window, gboolean visible);
 void virt_viewer_app_show_status(VirtViewerApp *self, const gchar *fmt, ...);
 void virt_viewer_app_show_display(VirtViewerApp *self);
+GHashTable* virt_viewer_app_get_windows(VirtViewerApp *self);
 
 G_END_DECLS
 
diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
index 066f922..f89d042 100644
--- a/src/virt-viewer-session-spice.c
+++ b/src/virt-viewer-session-spice.c
@@ -41,6 +41,12 @@ struct _VirtViewerSessionSpicePrivate {
 
 #define VIRT_VIEWER_SESSION_SPICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), VIRT_VIEWER_TYPE_SESSION_SPICE, VirtViewerSessionSpicePrivate))
 
+enum {
+	PROP_0,
+	PROP_SPICE_SESSION,
+};
+
+
 static void virt_viewer_session_spice_close(VirtViewerSession *session);
 static gboolean virt_viewer_session_spice_open_fd(VirtViewerSession *session, int fd);
 static gboolean virt_viewer_session_spice_open_host(VirtViewerSession *session, char *host, char *port);
@@ -55,7 +61,33 @@ static void virt_viewer_session_spice_channel_destroy(SpiceSession *s,
 
 
 static void
-virt_viewer_session_spice_finalize(GObject *obj)
+virt_viewer_session_spice_get_property(GObject *object, guint property_id,
+				       GValue *value, GParamSpec *pspec)
+{
+	VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(object);
+	VirtViewerSessionSpicePrivate *priv = self->priv;
+
+	switch (property_id) {
+	case PROP_SPICE_SESSION:
+		g_value_set_object(value, priv->session);
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+	}
+}
+
+static void
+virt_viewer_session_spice_set_property(GObject *object, guint property_id,
+				       const GValue *value G_GNUC_UNUSED, GParamSpec *pspec)
+{
+	switch (property_id) {
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+	}
+}
+
+static void
+virt_viewer_session_spice_dispose(GObject *obj)
 {
 	VirtViewerSessionSpice *spice = VIRT_VIEWER_SESSION_SPICE(obj);
 
@@ -76,7 +108,9 @@ virt_viewer_session_spice_class_init(VirtViewerSessionSpiceClass *klass)
 	VirtViewerSessionClass *dclass = VIRT_VIEWER_SESSION_CLASS(klass);
 	GObjectClass *oclass = G_OBJECT_CLASS(klass);
 
-	oclass->finalize = virt_viewer_session_spice_finalize;
+	oclass->get_property = virt_viewer_session_spice_get_property;
+	oclass->set_property = virt_viewer_session_spice_set_property;
+	oclass->dispose = virt_viewer_session_spice_dispose;
 
 	dclass->close = virt_viewer_session_spice_close;
 	dclass->open_fd = virt_viewer_session_spice_open_fd;
@@ -85,6 +119,15 @@ virt_viewer_session_spice_class_init(VirtViewerSessionSpiceClass *klass)
 	dclass->channel_open_fd = virt_viewer_session_spice_channel_open_fd;
 
 	g_type_class_add_private(oclass, sizeof(VirtViewerSessionSpicePrivate));
+
+	g_object_class_install_property(oclass,
+					PROP_SPICE_SESSION,
+					g_param_spec_object("spice-session",
+							    "Spice session",
+							    "Spice session",
+							    SPICE_TYPE_SESSION,
+							    G_PARAM_READABLE |
+							    G_PARAM_STATIC_STRINGS));
 }
 
 static void
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 324e37f..d80b456 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -912,9 +912,18 @@ GtkMenuItem*
 virt_viewer_window_get_menu_displays(VirtViewerWindow *self)
 {
 	g_return_val_if_fail(VIRT_VIEWER_IS_WINDOW(self), NULL);
+
 	return GTK_MENU_ITEM(gtk_builder_get_object(self->priv->builder, "menu-displays"));
 }
 
+GtkBuilder*
+virt_viewer_window_get_builder(VirtViewerWindow *self)
+{
+	g_return_val_if_fail(VIRT_VIEWER_IS_WINDOW(self), NULL);
+
+	return self->priv->builder;
+}
+
 /*
  * Local variables:
  *  c-indent-level: 8
diff --git a/src/virt-viewer-window.h b/src/virt-viewer-window.h
index 9baab76..cf66f5e 100644
--- a/src/virt-viewer-window.h
+++ b/src/virt-viewer-window.h
@@ -69,6 +69,7 @@ gint virt_viewer_window_get_zoom_level(VirtViewerWindow *self);
 void virt_viewer_window_leave_fullscreen(VirtViewerWindow *self);
 void virt_viewer_window_enter_fullscreen(VirtViewerWindow *self, gboolean move, gint x, gint y);
 GtkMenuItem *virt_viewer_window_get_menu_displays(VirtViewerWindow *self);
+GtkBuilder* virt_viewer_window_get_builder(VirtViewerWindow *window);
 
 G_END_DECLS
 
-- 
1.7.7.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]