[Spice-devel] [PATCH spice-gtk 10/25] widget: add monitor property with ctor

Marc-André Lureau marcandre.lureau at gmail.com
Thu Jul 12 15:29:07 PDT 2012


---
 gtk/map-file            |    1 +
 gtk/spice-widget-priv.h |    1 +
 gtk/spice-widget.c      |   47 +++++++++++++++++++++++++++++++++++++++++++++--
 gtk/spice-widget.h      |    4 +++-
 4 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/gtk/map-file b/gtk/map-file
index c58bab5..0d48bb3 100644
--- a/gtk/map-file
+++ b/gtk/map-file
@@ -25,6 +25,7 @@ spice_display_get_type;
 spice_display_key_event_get_type;
 spice_display_mouse_ungrab;
 spice_display_new;
+spice_display_new_with_monitor;
 spice_display_paste_from_guest;
 spice_display_send_keys;
 spice_display_set_grab_keys;
diff --git a/gtk/spice-widget-priv.h b/gtk/spice-widget-priv.h
index a94db68..a44e5fe 100644
--- a/gtk/spice-widget-priv.h
+++ b/gtk/spice-widget-priv.h
@@ -43,6 +43,7 @@ G_BEGIN_DECLS
 
 struct _SpiceDisplayPrivate {
     gint                    channel_id;
+    gint                    monitor_id;
 
     /* options */
     bool                    keyboard_grab_enable;
diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index 4d0f9be..a24637c 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -101,7 +101,8 @@ enum {
     PROP_AUTO_CLIPBOARD,
     PROP_SCALING,
     PROP_DISABLE_INPUTS,
-    PROP_ZOOM_LEVEL
+    PROP_ZOOM_LEVEL,
+    PROP_MONITOR_ID
 };
 
 /* Signals */
@@ -151,6 +152,9 @@ static void spice_display_get_property(GObject    *object,
     case PROP_CHANNEL_ID:
         g_value_set_int(value, d->channel_id);
         break;
+    case PROP_MONITOR_ID:
+        g_value_set_int(value, d->monitor_id);
+        break;
     case PROP_KEYBOARD_GRAB:
         g_value_set_boolean(value, d->keyboard_grab_enable);
         break;
@@ -242,6 +246,9 @@ static void spice_display_set_property(GObject      *object,
     case PROP_CHANNEL_ID:
         d->channel_id = g_value_get_int(value);
         break;
+    case PROP_MONITOR_ID:
+        d->monitor_id = g_value_get_int(value);
+        break;
     case PROP_KEYBOARD_GRAB:
         d->keyboard_grab_enable = g_value_get_boolean(value);
         update_keyboard_grab(display);
@@ -1492,6 +1499,25 @@ static void spice_display_class_init(SpiceDisplayClass *klass)
                           G_PARAM_STATIC_STRINGS));
 
     /**
+     * SpiceDisplay:monitor-id:
+     *
+     * Select monitor from #SpiceDisplay to show.
+     * The value -1 means the whole display is shown.
+     * By default, the monitor 0 is selected.
+     *
+     * Since: 0.13
+     **/
+    g_object_class_install_property
+        (gobject_class, PROP_MONITOR_ID,
+         g_param_spec_int("monitor-id",
+                          "Monitor ID",
+                          "Select monitor ID",
+                          -1, G_MAXINT, 0,
+                          G_PARAM_READWRITE |
+                          G_PARAM_CONSTRUCT |
+                          G_PARAM_STATIC_STRINGS));
+
+    /**
      * SpiceDisplay::mouse-grab:
      * @display: the #SpiceDisplay that emitted the signal
      * @status: 1 if grabbed, 0 otherwise.
@@ -1969,7 +1995,7 @@ static void channel_destroy(SpiceSession *s, SpiceChannel *channel, gpointer dat
 /**
  * spice_display_new:
  * @session: a #SpiceSession
- * @id: the display channel ID to associate with #SpiceDisplay
+ * @channel_id: the display channel ID to associate with #SpiceDisplay
  *
  * Returns: a new #SpiceDisplay widget.
  **/
@@ -1980,6 +2006,23 @@ SpiceDisplay *spice_display_new(SpiceSession *session, int id)
 }
 
 /**
+ * spice_display_new_with_monitor:
+ * @session: a #SpiceSession
+ * @channel_id: the display channel ID to associate with #SpiceDisplay
+ * @monitor_id: the monitor id within the display channel
+ *
+ * Returns: a new #SpiceDisplay widget.
+ **/
+SpiceDisplay* spice_display_new_with_monitor(SpiceSession *session, gint channel_id, gint monitor_id)
+{
+    return g_object_new(SPICE_TYPE_DISPLAY,
+                        "session", session,
+                        "channel-id", channel_id,
+                        "monitor-id", monitor_id,
+                        NULL);
+}
+
+/**
  * spice_display_mouse_ungrab:
  * @display:
  *
diff --git a/gtk/spice-widget.h b/gtk/spice-widget.h
index 3f6a785..d239ed2 100644
--- a/gtk/spice-widget.h
+++ b/gtk/spice-widget.h
@@ -70,7 +70,9 @@ typedef enum
 
 GType	        spice_display_get_type(void);
 
-SpiceDisplay* spice_display_new(SpiceSession *session, int id);
+SpiceDisplay* spice_display_new(SpiceSession *session, int channel_id);
+SpiceDisplay* spice_display_new_with_monitor(SpiceSession *session, gint channel_id, gint monitor_id);
+
 void spice_display_mouse_ungrab(SpiceDisplay *display);
 void spice_display_set_grab_keys(SpiceDisplay *display, SpiceGrabSequence *seq);
 SpiceGrabSequence *spice_display_get_grab_keys(SpiceDisplay *display);
-- 
1.7.10.4



More information about the Spice-devel mailing list