[virt-tools-list] [PATCH virt-viewer 02/12] kiosk: add app kiosk option, pass it down to window

Marc-André Lureau marcandre.lureau at gmail.com
Mon Jul 15 19:36:09 UTC 2013


---
 src/remote-viewer-main.c |  7 +++++--
 src/remote-viewer.c      |  9 +++++++--
 src/remote-viewer.h      |  5 +++--
 src/virt-viewer-app.c    | 21 +++++++++++++++++++++
 src/virt-viewer-main.c   |  5 ++++-
 src/virt-viewer-window.c |  7 +++++++
 src/virt-viewer-window.h |  1 +
 src/virt-viewer.c        |  4 +++-
 src/virt-viewer.h        |  3 ++-
 9 files changed, 53 insertions(+), 9 deletions(-)

diff --git a/src/remote-viewer-main.c b/src/remote-viewer-main.c
index 820a676..b752da8 100644
--- a/src/remote-viewer-main.c
+++ b/src/remote-viewer-main.c
@@ -110,6 +110,7 @@ main(int argc, char **argv)
     gchar *uri = NULL;
     char *title = NULL;
     char *hotkeys = NULL;
+    gboolean kiosk = FALSE;
     gboolean verbose = FALSE;
     gboolean debug = FALSE;
     gboolean direct = FALSE;
@@ -139,6 +140,8 @@ main(int argc, char **argv)
 #endif
         { "hotkeys", 'H', 0, G_OPTION_ARG_STRING, &hotkeys,
           N_("Customise hotkeys"), NULL },
+        { "kiosk", 'k', 0, G_OPTION_ARG_NONE, &kiosk,
+          N_("Enable kiosk mode"), NULL },
         { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &args,
           NULL, "-- URI" },
         { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
@@ -197,11 +200,11 @@ main(int argc, char **argv)
 
 #ifdef HAVE_SPICE_GTK
     if (controller) {
-        viewer = remote_viewer_new_with_controller(verbose);
+        viewer = remote_viewer_new_with_controller(kiosk, verbose);
         g_object_set(viewer, "guest-name", "defined by Spice controller", NULL);
     } else {
 #endif
-        viewer = remote_viewer_new(uri, title, verbose);
+        viewer = remote_viewer_new(kiosk, uri, title, verbose);
         g_object_set(viewer, "guest-name", uri, NULL);
 #ifdef HAVE_SPICE_GTK
     }
diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index b656175..ac2c19f 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -220,9 +220,13 @@ remote_viewer_init(RemoteViewer *self)
 }
 
 RemoteViewer *
-remote_viewer_new(const gchar *uri, const gchar *title, gboolean verbose)
+remote_viewer_new(gboolean kiosk,
+                  const gchar *uri,
+                  const gchar *title,
+                  gboolean verbose)
 {
     return g_object_new(REMOTE_VIEWER_TYPE,
+                        "kiosk", kiosk,
                         "guri", uri,
                         "verbose", verbose,
                         "title", title,
@@ -250,13 +254,14 @@ foreign_menu_title_changed(SpiceCtrlForeignMenu *menu G_GNUC_UNUSED,
 }
 
 RemoteViewer *
-remote_viewer_new_with_controller(gboolean verbose)
+remote_viewer_new_with_controller(gboolean kiosk, gboolean verbose)
 {
     RemoteViewer *self;
     SpiceCtrlController *ctrl = spice_ctrl_controller_new();
     SpiceCtrlForeignMenu *menu = spice_ctrl_foreign_menu_new();
 
     self =  g_object_new(REMOTE_VIEWER_TYPE,
+                         "kiosk", kiosk,
                          "controller", ctrl,
                          "foreign-menu", menu,
                          "verbose", verbose,
diff --git a/src/remote-viewer.h b/src/remote-viewer.h
index de701e0..dfc0f9d 100644
--- a/src/remote-viewer.h
+++ b/src/remote-viewer.h
@@ -48,10 +48,11 @@ typedef struct {
 
 GType remote_viewer_get_type (void);
 
-RemoteViewer* remote_viewer_new(const gchar *uri,
+RemoteViewer* remote_viewer_new(gboolean kiosk,
+                                const gchar *uri,
                                 const gchar *title,
                                 gboolean verbose);
-RemoteViewer* remote_viewer_new_with_controller(gboolean verbose);
+RemoteViewer* remote_viewer_new_with_controller(gboolean kiosk, gboolean verbose);
 
 G_END_DECLS
 
diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index f0f75e7..794dddd 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -118,6 +118,7 @@ struct _VirtViewerAppPrivate {
     gboolean fullscreen_auto_conf;
     gboolean attach;
     gboolean quiting;
+    gboolean kiosk;
 
     VirtViewerSession *session;
     gboolean active;
@@ -159,6 +160,7 @@ enum {
     PROP_ENABLE_ACCEL,
     PROP_HAS_FOCUS,
     PROP_FULLSCREEN_AUTO_CONF,
+    PROP_KIOSK,
 };
 
 enum {
@@ -651,6 +653,7 @@ virt_viewer_app_window_new(VirtViewerApp *self, gint nth)
     GtkWindow *w;
 
     window = g_object_new(VIRT_VIEWER_TYPE_WINDOW, "app", self, NULL);
+    virt_viewer_window_set_kiosk(window, self->priv->kiosk);
     if (self->priv->main_window)
         virt_viewer_window_set_zoom_level(window, virt_viewer_window_get_zoom_level(self->priv->main_window));
     virt_viewer_app_set_nth_window(self, nth, window);
@@ -1276,6 +1279,10 @@ virt_viewer_app_get_property (GObject *object, guint property_id,
         g_value_set_boolean(value, virt_viewer_app_get_fullscreen_auto_conf(self));
         break;
 
+    case PROP_KIOSK:
+        g_value_set_boolean(value, priv->kiosk);
+        break;
+
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
     }
@@ -1321,6 +1328,10 @@ virt_viewer_app_set_property (GObject *object, guint property_id,
         priv->fullscreen_auto_conf = g_value_get_boolean(value);
         break;
 
+    case PROP_KIOSK:
+        priv->kiosk = g_value_get_boolean(value);
+        break;
+
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
     }
@@ -1528,6 +1539,16 @@ virt_viewer_app_class_init (VirtViewerAppClass *klass)
                                                          G_PARAM_READABLE |
                                                          G_PARAM_STATIC_STRINGS));
 
+    g_object_class_install_property(object_class,
+                                    PROP_KIOSK,
+                                    g_param_spec_boolean("kiosk",
+                                                         "Kiosk",
+                                                         "Kiosk mode",
+                                                         FALSE,
+                                                         G_PARAM_CONSTRUCT |
+                                                         G_PARAM_READWRITE |
+                                                         G_PARAM_STATIC_STRINGS));
+
     signals[SIGNAL_WINDOW_ADDED] =
         g_signal_new("window-added",
                      G_OBJECT_CLASS_TYPE(object_class),
diff --git a/src/virt-viewer-main.c b/src/virt-viewer-main.c
index 96e2e00..6d38711 100644
--- a/src/virt-viewer-main.c
+++ b/src/virt-viewer-main.c
@@ -57,6 +57,7 @@ int main(int argc, char **argv)
     gboolean waitvm = FALSE;
     gboolean reconnect = FALSE;
     gboolean fullscreen = FALSE;
+    gboolean kiosk = FALSE;
     VirtViewer *viewer = NULL;
     char *base_name;
     char *help_msg = NULL;
@@ -83,6 +84,8 @@ int main(int argc, char **argv)
           N_("Open in full screen mode"), NULL },
         { "hotkeys", 'H', 0, G_OPTION_ARG_STRING, &hotkeys,
           N_("Customise hotkeys"), NULL },
+        { "kiosk", 'k', 0, G_OPTION_ARG_NONE, &kiosk,
+          N_("Enable kiosk mode"), NULL },
         { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &args,
           NULL, "-- DOMAIN-NAME|ID|UUID" },
         { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
@@ -129,7 +132,7 @@ int main(int argc, char **argv)
 
     virt_viewer_app_set_debug(debug);
 
-    viewer = virt_viewer_new(uri, args[0], zoom, direct, attach, waitvm, reconnect, verbose);
+    viewer = virt_viewer_new(uri, args[0], zoom, direct, attach, waitvm, reconnect, verbose, kiosk);
     if (viewer == NULL)
         goto cleanup;
 
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 5d646ac..d0e6357 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -99,6 +99,7 @@ struct _VirtViewerWindowPrivate {
     GdkRectangle before_fullscreen;
     gint fullscreen_monitor;
     gboolean desktop_resize_pending;
+    gboolean kiosk;
 
     gint zoomlevel;
     gboolean auto_resize;
@@ -1233,6 +1234,12 @@ virt_viewer_window_get_display(VirtViewerWindow *self)
     return self->priv->display;
 }
 
+void
+virt_viewer_window_set_kiosk(VirtViewerWindow *self, gboolean enabled)
+{
+    self->priv->kiosk = enabled;
+}
+
 /*
  * Local variables:
  *  c-indent-level: 4
diff --git a/src/virt-viewer-window.h b/src/virt-viewer-window.h
index 41ac5e2..33cf8f4 100644
--- a/src/virt-viewer-window.h
+++ b/src/virt-viewer-window.h
@@ -74,6 +74,7 @@ void virt_viewer_window_leave_fullscreen(VirtViewerWindow *self);
 void virt_viewer_window_enter_fullscreen(VirtViewerWindow *self, gint monitor);
 GtkMenuItem *virt_viewer_window_get_menu_displays(VirtViewerWindow *self);
 GtkBuilder* virt_viewer_window_get_builder(VirtViewerWindow *window);
+void virt_viewer_window_set_kiosk(VirtViewerWindow *self, gboolean enabled);
 
 G_END_DECLS
 
diff --git a/src/virt-viewer.c b/src/virt-viewer.c
index 207c9ca..152f248 100644
--- a/src/virt-viewer.c
+++ b/src/virt-viewer.c
@@ -733,13 +733,15 @@ virt_viewer_new(const char *uri,
                 gboolean attach,
                 gboolean waitvm,
                 gboolean reconnect,
-                gboolean verbose)
+                gboolean verbose,
+                gboolean kiosk)
 {
     VirtViewer *self;
     VirtViewerApp *app;
     VirtViewerPrivate *priv;
 
     self = g_object_new(VIRT_VIEWER_TYPE,
+                        "kiosk", kiosk,
                         "verbose", verbose,
                         "guest-name", name,
                         NULL);
diff --git a/src/virt-viewer.h b/src/virt-viewer.h
index 73d9170..185534b 100644
--- a/src/virt-viewer.h
+++ b/src/virt-viewer.h
@@ -56,7 +56,8 @@ virt_viewer_new(const char *uri,
                 gboolean attach,
                 gboolean waitvm,
                 gboolean reconnect,
-                gboolean verbose);
+                gboolean verbose,
+                gboolean kiosk);
 
 G_END_DECLS
 
-- 
1.8.3.rc1.49.g8d97506




More information about the virt-tools-list mailing list