[virt-tools-list] [virt-viewer][PATCH 1/3 v2] virt-viewer-app: Moved reconnect from VV to app

Lukas Venhoda lvenhoda at redhat.com
Tue May 12 15:10:30 UTC 2015


Reconnect field in virt-viewer moved into virt-viewer-app and changed to
property. New getter function implemented for it.
This will be used in virt-viewer-window.c for implementing
a "reconnect" button in the GUI.
---
Changes since v1:
 - Moved the reconnect property from virt-viewer.c into virt-viewer-app.c,
   so it can be moved into preferences.
 - Added a getter function for reconnect to access it from virt-viewer.c
 - Changed g_object_notify to g_object_notify_by_pspec for reconnect
   in virt_viewer_app_set_property.
---
 src/virt-viewer-app.c | 41 ++++++++++++++++++++++++++++++++++++++++-
 src/virt-viewer-app.h |  3 +++
 src/virt-viewer.c     |  5 ++---
 3 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index b22a876..e212831 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -123,7 +123,9 @@ struct _VirtViewerAppPrivate {
     gboolean attach;
     gboolean quitting;
     gboolean kiosk;
-
+#ifdef USING_VIRT_VIEWER
+    gboolean reconnect;
+#endif
     VirtViewerSession *session;
     gboolean active;
     gboolean connected;
@@ -172,6 +174,9 @@ enum {
     PROP_KIOSK,
     PROP_QUIT_ON_DISCONNECT,
     PROP_UUID,
+#ifdef USING_VIRT_VIEWER
+    PROP_RECONNECT,
+#endif
 };

 enum {
@@ -1603,6 +1608,12 @@ virt_viewer_app_get_property (GObject *object, guint property_id,
         g_value_set_string(value, priv->uuid);
         break;

+#ifdef USING_VIRT_VIEWER
+    case PROP_RECONNECT:
+        g_value_set_boolean(value, priv->reconnect);
+        break;
+#endif
+
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
     }
@@ -1653,6 +1664,13 @@ virt_viewer_app_set_property (GObject *object, guint property_id,
         priv->quit_on_disconnect = g_value_get_boolean(value);
         break;

+#ifdef USING_VIRT_VIEWER
+    case PROP_RECONNECT:
+        priv->reconnect = g_value_get_boolean(value);
+        g_object_notify_by_pspec(G_OBJECT(self), pspec);
+        break;
+#endif
+
     case PROP_UUID:
         virt_viewer_app_set_uuid_string(self, g_value_get_string(value));
         break;
@@ -1983,6 +2001,17 @@ virt_viewer_app_class_init (VirtViewerAppClass *klass)
                                                         G_PARAM_WRITABLE |
                                                         G_PARAM_STATIC_STRINGS));

+#ifdef USING_VIRT_VIEWER
+    g_object_class_install_property(object_class,
+                                    PROP_RECONNECT,
+                                    g_param_spec_boolean("reconnect",
+                                                         "Reconnect",
+                                                         "Reconnect",
+                                                         FALSE,
+                                                         G_PARAM_READWRITE |
+                                                         G_PARAM_STATIC_STRINGS));
+#endif
+
     signals[SIGNAL_WINDOW_ADDED] =
         g_signal_new("window-added",
                      G_OBJECT_CLASS_TYPE(object_class),
@@ -2427,6 +2456,16 @@ virt_viewer_app_get_enable_accel(VirtViewerApp *self)
     return self->priv->enable_accel;
 }

+#ifdef USING_VIRT_VIEWER
+gboolean
+virt_viewer_app_get_reconnect(VirtViewerApp *self)
+{
+    g_return_val_if_fail(VIRT_VIEWER_IS_APP(self), FALSE);
+
+    return self->priv->reconnect;
+}
+#endif
+
 VirtViewerSession*
 virt_viewer_app_get_session(VirtViewerApp *self)
 {
diff --git a/src/virt-viewer-app.h b/src/virt-viewer-app.h
index f53fa73..39e4059 100644
--- a/src/virt-viewer-app.h
+++ b/src/virt-viewer-app.h
@@ -103,6 +103,9 @@ 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);

+#ifdef USING_VIRT_VIEWER
+gboolean virt_viewer_app_get_reconnect(VirtViewerApp *self);
+#endif
 G_END_DECLS

 #endif /* VIRT_VIEWER_APP_H */
diff --git a/src/virt-viewer.c b/src/virt-viewer.c
index 9c3ccc9..3d2146a 100644
--- a/src/virt-viewer.c
+++ b/src/virt-viewer.c
@@ -56,7 +56,6 @@ struct _VirtViewerPrivate {
     virDomainPtr dom;
     char *domkey;
     gboolean waitvm;
-    gboolean reconnect;
     gboolean auth_cancelled;
     gint domain_event;
     guint reconnect_poll; /* source id */
@@ -161,7 +160,7 @@ virt_viewer_deactivated(VirtViewerApp *app, gboolean connect_error)
         priv->dom = NULL;
     }

-    if (priv->reconnect) {
+    if (virt_viewer_app_get_reconnect(VIRT_VIEWER_APP(self))) {
         if (priv->domain_event < 0) {
             g_debug("No domain events, falling back to polling");
             virt_viewer_start_reconnect_poll(self);
@@ -990,6 +989,7 @@ virt_viewer_new(const char *uri,

     self = g_object_new(VIRT_VIEWER_TYPE,
                         "guest-name", name,
+                        "reconnect", reconnect,
                         NULL);
     app = VIRT_VIEWER_APP(self);
     priv = self->priv;
@@ -1001,7 +1001,6 @@ virt_viewer_new(const char *uri,
     priv->uri = g_strdup(uri);
     priv->domkey = g_strdup(name);
     priv->waitvm = waitvm;
-    priv->reconnect = reconnect;

     return self;
 }
--
2.4.0




More information about the virt-tools-list mailing list