[Spice-commits] 3 commits - gtk/channel-smartcard.c gtk/controller gtk/Makefile.am gtk/spice-audio.c gtk/spice-audio.h gtk/spice-audio-priv.h gtk/spice-gstaudio.c gtk/spice-pulse.c gtk/usb-device-manager.c
Marc-André Lureau
elmarco at kemper.freedesktop.org
Fri Dec 2 04:20:05 PST 2011
gtk/Makefile.am | 1
gtk/channel-smartcard.c | 2
gtk/controller/test.c | 4 -
gtk/spice-audio-priv.h | 35 +++++++++++
gtk/spice-audio.c | 144 +++++++++++++++++++++++++++++++++++++++++++++--
gtk/spice-audio.h | 6 +
gtk/spice-gstaudio.c | 89 ++++++++++++++---------------
gtk/spice-pulse.c | 44 ++++++--------
gtk/usb-device-manager.c | 18 +++--
9 files changed, 260 insertions(+), 83 deletions(-)
New commits:
commit e83f5a7c2c98aae96bee57bda9590e70dbbcb62e
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Fri Dec 2 13:19:30 2011 +0100
string formatting fixes
Patch based on Mageia, provided by Olav Vitters.
https://bugs.freedesktop.org/show_bug.cgi?id=43456
diff --git a/gtk/channel-smartcard.c b/gtk/channel-smartcard.c
index c5aa17b..f376e53 100644
--- a/gtk/channel-smartcard.c
+++ b/gtk/channel-smartcard.c
@@ -430,7 +430,7 @@ static void spice_smartcard_channel_up_cb(GObject *source_object,
spice_smartcard_manager_init_finish(SPICE_SESSION(source_object),
res, &error);
if (error)
- g_warning(error->message);
+ g_warning("%s", error->message);
g_clear_error(&error);
}
diff --git a/gtk/controller/test.c b/gtk/controller/test.c
index 5b2f5a3..e43d299 100644
--- a/gtk/controller/test.c
+++ b/gtk/controller/test.c
@@ -173,10 +173,10 @@ void notified (GObject *gobject, GParamSpec *pspec,
gchar** p = (gchar **)g_value_get_boxed (&value);
g_message ("notify::%s == ", pspec->name);
while (*p)
- g_message (*p++);
+ g_message ("%s", *p++);
} else if (pspec->value_type == G_TYPE_OBJECT) {
GObject *o = g_value_get_object (&value);
- g_message ("notify::%s == %s", G_OBJECT_TYPE_NAME (o));
+ g_message ("notify::%s == %s", pspec->name, G_OBJECT_TYPE_NAME (o));
} else {
g_value_transform (&value, &strvalue);
g_message ("notify::%s = %s", pspec->name, g_value_get_string (&strvalue));
commit a57faa03ade857ce28befa8989799a7480b92fd5
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Fri Nov 25 20:01:40 2011 +0100
Move auto-connect logic in Audio base class
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index ebf908d..491eff8 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -203,6 +203,7 @@ endif
libspice_client_glib_2_0_la_SOURCES = \
glib-compat.h \
spice-audio.c \
+ spice-audio-priv.h \
spice-common.h \
spice-util.c \
spice-util-priv.h \
diff --git a/gtk/spice-audio-priv.h b/gtk/spice-audio-priv.h
new file mode 100644
index 0000000..71cc8ed
--- /dev/null
+++ b/gtk/spice-audio-priv.h
@@ -0,0 +1,35 @@
+/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ Copyright (C) 2010 Red Hat, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef __SPICE_AUDIO_PRIVATE_H__
+#define __SPICE_AUDIO_PRIVATE_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+#include "spice-session.h"
+
+G_BEGIN_DECLS
+
+struct _SpiceAudioPrivate {
+ SpiceSession *session;
+ GMainContext *main_context;
+};
+
+G_END_DECLS
+
+#endif /* __SPICE_AUDIO_PRIVATE_H__ */
+
diff --git a/gtk/spice-audio.c b/gtk/spice-audio.c
index b1741e5..b9d1011 100644
--- a/gtk/spice-audio.c
+++ b/gtk/spice-audio.c
@@ -41,6 +41,8 @@
#include "spice-audio.h"
#include "spice-session-priv.h"
+#include "spice-channel-priv.h"
+#include "spice-audio-priv.h"
#ifdef WITH_PULSE
#include "spice-pulse.h"
@@ -49,17 +51,144 @@
#include "spice-gstaudio.h"
#endif
+#define SPICE_AUDIO_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((obj), SPICE_TYPE_AUDIO, SpiceAudioPrivate))
+
G_DEFINE_ABSTRACT_TYPE(SpiceAudio, spice_audio, G_TYPE_OBJECT)
+enum {
+ PROP_0,
+ PROP_SESSION,
+ PROP_MAIN_CONTEXT,
+};
+
+static void spice_audio_finalize(GObject *gobject)
+{
+ SpiceAudio *self = SPICE_AUDIO(gobject);
+ SpiceAudioPrivate *priv = SPICE_AUDIO_GET_PRIVATE(self);
+
+ if (priv->main_context) {
+ g_main_context_unref(priv->main_context);
+ priv->main_context = NULL;
+ }
+
+ if (G_OBJECT_CLASS(spice_audio_parent_class)->finalize)
+ G_OBJECT_CLASS(spice_audio_parent_class)->finalize(gobject);
+}
-static void spice_audio_class_init(SpiceAudioClass *klass G_GNUC_UNUSED)
+static void spice_audio_get_property(GObject *gobject,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
+ SpiceAudio *self = SPICE_AUDIO(gobject);
+ SpiceAudioPrivate *priv = SPICE_AUDIO_GET_PRIVATE(self);
+
+ switch (prop_id) {
+ case PROP_SESSION:
+ g_value_set_object(value, priv->session);
+ break;
+ case PROP_MAIN_CONTEXT:
+ g_value_set_boxed(value, priv->main_context);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
+ break;
+ }
+}
+
+static void spice_audio_set_property(GObject *gobject,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ SpiceAudio *self = SPICE_AUDIO(gobject);
+ SpiceAudioPrivate *priv = SPICE_AUDIO_GET_PRIVATE(self);
+
+ switch (prop_id) {
+ case PROP_SESSION:
+ priv->session = g_value_get_object(value);
+ break;
+ case PROP_MAIN_CONTEXT:
+ priv->main_context = g_value_dup_boxed(value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
+ break;
+ }
+}
+
+static void spice_audio_class_init(SpiceAudioClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GParamSpec *pspec;
+
+ gobject_class->finalize = spice_audio_finalize;
+ gobject_class->get_property = spice_audio_get_property;
+ gobject_class->set_property = spice_audio_set_property;
+
+ /**
+ * SpiceAudio:session:
+ *
+ * #SpiceSession this #SpiceAudio is associated with
+ *
+ **/
+ pspec = g_param_spec_object("session", "Session", "SpiceSession",
+ SPICE_TYPE_SESSION,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property(gobject_class, PROP_SESSION, pspec);
+
+ /**
+ * SpiceAudio:main-context:
+ */
+ pspec = g_param_spec_boxed("main-context", "Main Context",
+ "GMainContext to use for the event source",
+ G_TYPE_MAIN_CONTEXT,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property(gobject_class, PROP_MAIN_CONTEXT, pspec);
+
+ g_type_class_add_private(klass, sizeof(SpiceAudioPrivate));
}
static void spice_audio_init(SpiceAudio *self G_GNUC_UNUSED)
{
+ /* FIXME: self->priv = SPICE_AUDIO_GET_PRIVATE(audio) when ABI break */
+}
+
+static void connect_channel(SpiceAudio *self, SpiceChannel *channel)
+{
+ if (channel->priv->state != SPICE_CHANNEL_STATE_UNCONNECTED)
+ return;
+
+ if (SPICE_AUDIO_GET_CLASS(self)->connect_channel(self, channel))
+ spice_channel_connect(channel);
}
+static void update_audio_channels(SpiceAudio *self, SpiceSession *session)
+{
+ if (session->priv->audio) {
+ GList *list, *tmp;
+
+ list = spice_session_get_channels(session);
+ for (tmp = g_list_first(list); tmp != NULL; tmp = g_list_next(tmp)) {
+ connect_channel(self, tmp->data);
+ }
+ g_list_free(list);
+ } else {
+ g_debug("FIXME: disconnect audio channels");
+ }
+}
+
+static void channel_new(SpiceSession *session, SpiceChannel *channel, SpiceAudio *self)
+{
+ connect_channel(self, channel);
+}
+
+static void session_enable_audio(GObject *gobject, GParamSpec *pspec,
+ gpointer user_data)
+{
+ update_audio_channels(SPICE_AUDIO(user_data), SPICE_SESSION(gobject));
+}
/**
* spice_audio_new:
@@ -77,7 +206,7 @@ G_GNUC_DEPRECATED_FOR(spice_audio_get)
SpiceAudio *spice_audio_new(SpiceSession *session, GMainContext *context,
const char *name)
{
- SpiceAudio *audio = NULL;
+ SpiceAudio *self = NULL;
if (context == NULL)
context = g_main_context_default();
@@ -85,12 +214,17 @@ SpiceAudio *spice_audio_new(SpiceSession *session, GMainContext *context,
name = g_get_application_name();
#ifdef WITH_PULSE
- audio = SPICE_AUDIO(spice_pulse_new(session, context, name));
+ self = SPICE_AUDIO(spice_pulse_new(session, context, name));
#endif
#ifdef WITH_GSTAUDIO
- audio = SPICE_AUDIO(spice_gstaudio_new(session, context, name));
+ self = SPICE_AUDIO(spice_gstaudio_new(session, context, name));
#endif
- return audio;
+
+ spice_g_signal_connect_object(session, "notify::enable-audio", G_CALLBACK(session_enable_audio), self, 0);
+ spice_g_signal_connect_object(session, "channel-new", G_CALLBACK(channel_new), self, 0);
+ update_audio_channels(self, session);
+
+ return self;
}
/**
diff --git a/gtk/spice-audio.h b/gtk/spice-audio.h
index dc66e88..1709227 100644
--- a/gtk/spice-audio.h
+++ b/gtk/spice-audio.h
@@ -43,6 +43,7 @@ G_BEGIN_DECLS
typedef struct _SpiceAudio SpiceAudio;
typedef struct _SpiceAudioClass SpiceAudioClass;
+typedef struct _SpiceAudioPrivate SpiceAudioPrivate;
/**
* SpiceAudio:
@@ -52,6 +53,7 @@ typedef struct _SpiceAudioClass SpiceAudioClass;
*/
struct _SpiceAudio {
GObject parent;
+ /* FIXME: break ABI!! SpiceAudioPrivate *priv; */
};
/**
@@ -64,7 +66,9 @@ struct _SpiceAudioClass {
GObjectClass parent_class;
/*< private >*/
- gchar _spice_reserved[SPICE_RESERVED_PADDING];
+ gboolean (*connect_channel)(SpiceAudio *audio, SpiceChannel *channel);
+
+ gchar _spice_reserved[SPICE_RESERVED_PADDING - sizeof(void*)];
};
GType spice_audio_get_type(void);
diff --git a/gtk/spice-gstaudio.c b/gtk/spice-gstaudio.c
index 559da8c..080169b 100644
--- a/gtk/spice-gstaudio.c
+++ b/gtk/spice-gstaudio.c
@@ -28,6 +28,7 @@
#include "spice-gstaudio.h"
#include "spice-common.h"
#include "spice-session.h"
+#include "spice-util.h"
#define SPICE_GSTAUDIO_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), SPICE_TYPE_GSTAUDIO, SpiceGstaudioPrivate))
@@ -43,7 +44,6 @@ struct stream {
};
struct _SpiceGstaudioPrivate {
- SpiceSession *session;
SpiceChannel *pchannel;
SpiceChannel *rchannel;
struct stream playback;
@@ -53,6 +53,7 @@ struct _SpiceGstaudioPrivate {
static void channel_event(SpiceChannel *channel, SpiceChannelEvent event,
gpointer data);
+static gboolean connect_channel(SpiceAudio *audio, SpiceChannel *channel);
static void spice_gstaudio_finalize(GObject *obj)
{
@@ -110,6 +111,9 @@ static void spice_gstaudio_init(SpiceGstaudio *pulse)
static void spice_gstaudio_class_init(SpiceGstaudioClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
+ SpiceAudioClass *audio_class = SPICE_AUDIO_CLASS(klass);
+
+ audio_class->connect_channel = connect_channel;
gobject_class->finalize = spice_gstaudio_finalize;
gobject_class->dispose = spice_gstaudio_dispose;
@@ -213,8 +217,8 @@ static void record_start(SpiceRecordChannel *channel, gint format, gint channels
p->record.channels = channels;
gst_app_sink_set_emit_signals(GST_APP_SINK(p->record.sink), TRUE);
- g_signal_connect(p->record.sink, "new-buffer",
- G_CALLBACK(record_new_buffer), data);
+ spice_g_signal_connect_object(p->record.sink, "new-buffer",
+ G_CALLBACK(record_new_buffer), gstaudio, 0);
lerr:
g_clear_error(&error);
@@ -471,65 +475,62 @@ static void record_mute_changed(GObject *object, GParamSpec *pspec, gpointer dat
g_object_unref(e);
}
-static void channel_new(SpiceSession *s, SpiceChannel *channel, gpointer data)
+static gboolean connect_channel(SpiceAudio *audio, SpiceChannel *channel)
{
- SpiceGstaudio *gstaudio = data;
+ SpiceGstaudio *gstaudio = SPICE_GSTAUDIO(audio);
SpiceGstaudioPrivate *p = gstaudio->priv;
if (SPICE_IS_PLAYBACK_CHANNEL(channel)) {
- g_return_if_fail(p->pchannel == NULL);
+ g_return_val_if_fail(p->pchannel == NULL, FALSE);
+
p->pchannel = g_object_ref(channel);
- g_signal_connect(channel, "playback-start",
- G_CALLBACK(playback_start), gstaudio);
- g_signal_connect(channel, "playback-data",
- G_CALLBACK(playback_data), gstaudio);
- g_signal_connect(channel, "playback-stop",
- G_CALLBACK(playback_stop), gstaudio);
- g_signal_connect(channel, "channel-event",
- G_CALLBACK(channel_event), gstaudio);
- g_signal_connect(channel, "notify::volume",
- G_CALLBACK(playback_volume_changed), gstaudio);
- g_signal_connect(channel, "notify::mute",
- G_CALLBACK(playback_mute_changed), gstaudio);
- spice_channel_connect(channel);
+ spice_g_signal_connect_object(channel, "playback-start",
+ G_CALLBACK(playback_start), gstaudio, 0);
+ spice_g_signal_connect_object(channel, "playback-data",
+ G_CALLBACK(playback_data), gstaudio, 0);
+ spice_g_signal_connect_object(channel, "playback-stop",
+ G_CALLBACK(playback_stop), gstaudio, 0);
+ spice_g_signal_connect_object(channel, "channel-event",
+ G_CALLBACK(channel_event), gstaudio, 0);
+ spice_g_signal_connect_object(channel, "notify::volume",
+ G_CALLBACK(playback_volume_changed), gstaudio, 0);
+ spice_g_signal_connect_object(channel, "notify::mute",
+ G_CALLBACK(playback_mute_changed), gstaudio, 0);
+
+ return TRUE;
}
if (SPICE_IS_RECORD_CHANNEL(channel)) {
- g_return_if_fail(p->rchannel == NULL);
+ g_return_val_if_fail(p->rchannel == NULL, FALSE);
+
p->rchannel = g_object_ref(channel);
- g_signal_connect(channel, "record-start",
- G_CALLBACK(record_start), gstaudio);
- g_signal_connect(channel, "record-stop",
- G_CALLBACK(record_stop), gstaudio);
- g_signal_connect(channel, "channel-event",
- G_CALLBACK(channel_event), gstaudio);
- g_signal_connect(channel, "notify::volume",
- G_CALLBACK(record_volume_changed), gstaudio);
- g_signal_connect(channel, "notify::mute",
- G_CALLBACK(record_mute_changed), gstaudio);
- spice_channel_connect(channel);
+ spice_g_signal_connect_object(channel, "record-start",
+ G_CALLBACK(record_start), gstaudio, 0);
+ spice_g_signal_connect_object(channel, "record-stop",
+ G_CALLBACK(record_stop), gstaudio, 0);
+ spice_g_signal_connect_object(channel, "channel-event",
+ G_CALLBACK(channel_event), gstaudio, 0);
+ spice_g_signal_connect_object(channel, "notify::volume",
+ G_CALLBACK(record_volume_changed), gstaudio, 0);
+ spice_g_signal_connect_object(channel, "notify::mute",
+ G_CALLBACK(record_mute_changed), gstaudio, 0);
+
+ return TRUE;
}
+
+ return FALSE;
}
SpiceGstaudio *spice_gstaudio_new(SpiceSession *session, GMainContext *context,
const char *name)
{
SpiceGstaudio *gstaudio;
- SpiceGstaudioPrivate *p;
- GList *list;
gst_init(NULL, NULL);
- gstaudio = g_object_new(SPICE_TYPE_GSTAUDIO, NULL);
- p = SPICE_GSTAUDIO_GET_PRIVATE(gstaudio);
- p->session = g_object_ref(session);
-
- g_signal_connect(session, "channel-new",
- G_CALLBACK(channel_new), gstaudio);
- list = spice_session_get_channels(session);
- for (list = g_list_first(list); list != NULL; list = g_list_next(list)) {
- channel_new(session, list->data, (gpointer)gstaudio);
- }
- g_list_free(list);
+ gstaudio = g_object_new(SPICE_TYPE_GSTAUDIO,
+ "session", session,
+ "main-context", context,
+ NULL);
return gstaudio;
}
diff --git a/gtk/spice-pulse.c b/gtk/spice-pulse.c
index 83f7cb9..6a977c4 100644
--- a/gtk/spice-pulse.c
+++ b/gtk/spice-pulse.c
@@ -37,7 +37,6 @@ struct stream {
};
struct _SpicePulsePrivate {
- SpiceSession *session;
SpiceChannel *pchannel;
SpiceChannel *rchannel;
@@ -73,8 +72,7 @@ static const char *context_state_names[] = {
static void channel_event(SpiceChannel *channel, SpiceChannelEvent event,
gpointer data);
static void stream_stop(SpicePulse *pulse, struct stream *s);
-static void channel_new(SpiceSession *s, SpiceChannel *channel,
- gpointer data);
+static gboolean connect_channel(SpiceAudio *audio, SpiceChannel *channel);
static void spice_pulse_finalize(GObject *obj)
{
@@ -122,10 +120,6 @@ static void spice_pulse_dispose(GObject *obj)
g_object_unref(p->rchannel);
p->rchannel = NULL;
- if (p->session)
- g_object_unref(p->session);
- p->session = NULL;
-
G_OBJECT_CLASS(spice_pulse_parent_class)->dispose(obj);
}
@@ -137,6 +131,9 @@ static void spice_pulse_init(SpicePulse *pulse)
static void spice_pulse_class_init(SpicePulseClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
+ SpiceAudioClass *audio_class = SPICE_AUDIO_CLASS(klass);
+
+ audio_class->connect_channel = connect_channel;
gobject_class->finalize = spice_pulse_finalize;
gobject_class->dispose = spice_pulse_dispose;
@@ -701,13 +698,14 @@ static void record_volume_changed(GObject *object, GParamSpec *pspec, gpointer d
pa_operation_unref(op);
}
-static void channel_new(SpiceSession *s, SpiceChannel *channel, gpointer data)
+static gboolean connect_channel(SpiceAudio *audio, SpiceChannel *channel)
{
- SpicePulse *pulse = data;
+ SpicePulse *pulse = SPICE_PULSE(audio);
SpicePulsePrivate *p = pulse->priv;
if (SPICE_IS_PLAYBACK_CHANNEL(channel)) {
- g_return_if_fail(p->pchannel == NULL);
+ g_return_val_if_fail(p->pchannel == NULL, FALSE);
+
p->pchannel = g_object_ref(channel);
spice_g_signal_connect_object(channel, "playback-start",
G_CALLBACK(playback_start), pulse, 0);
@@ -723,11 +721,13 @@ static void channel_new(SpiceSession *s, SpiceChannel *channel, gpointer data)
G_CALLBACK(playback_volume_changed), pulse, 0);
spice_g_signal_connect_object(channel, "notify::mute",
G_CALLBACK(playback_mute_changed), pulse, 0);
- spice_channel_connect(channel);
+
+ return TRUE;
}
if (SPICE_IS_RECORD_CHANNEL(channel)) {
- g_return_if_fail(p->rchannel == NULL);
+ g_return_val_if_fail(p->rchannel == NULL, FALSE);
+
p->rchannel = g_object_ref(channel);
spice_g_signal_connect_object(channel, "record-start",
G_CALLBACK(record_start), pulse, 0);
@@ -739,8 +739,11 @@ static void channel_new(SpiceSession *s, SpiceChannel *channel, gpointer data)
G_CALLBACK(record_volume_changed), pulse, 0);
spice_g_signal_connect_object(channel, "notify::mute",
G_CALLBACK(record_mute_changed), pulse, 0);
- spice_channel_connect(channel);
+
+ return TRUE;
}
+
+ return FALSE;
}
static void context_state_callback(pa_context *c, void *userdata)
@@ -783,19 +786,12 @@ SpicePulse *spice_pulse_new(SpiceSession *session, GMainContext *context,
{
SpicePulse *pulse;
SpicePulsePrivate *p;
- GList *list, *tmp;
- pulse = g_object_new(SPICE_TYPE_PULSE, NULL);
+ pulse = g_object_new(SPICE_TYPE_PULSE,
+ "session", session,
+ "main-context", context,
+ NULL);
p = SPICE_PULSE_GET_PRIVATE(pulse);
- p->session = g_object_ref(session);
-
- spice_g_signal_connect_object(session, "channel-new",
- G_CALLBACK(channel_new), pulse, 0);
- list = spice_session_get_channels(session);
- for (tmp = g_list_first(list); tmp != NULL; tmp = g_list_next(tmp)) {
- channel_new(session, tmp->data, (gpointer)pulse);
- }
- g_list_free(list);
p->mainloop = pa_glib_mainloop_new(context);
p->state = PA_CONTEXT_READY;
commit b8cc5053ca11dc8036f3e26f62f6e8ffde5d4a08
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Thu Nov 24 19:28:59 2011 +0100
Make UsbDeviceManager main-context a boxed property
diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
index b1d6c95..db16971 100644
--- a/gtk/usb-device-manager.c
+++ b/gtk/usb-device-manager.c
@@ -216,6 +216,11 @@ static void spice_usb_device_manager_finalize(GObject *gobject)
}
#endif
+ if (priv->main_context) {
+ g_main_context_unref(priv->main_context);
+ priv->main_context = NULL;
+ }
+
g_ptr_array_unref(priv->channels);
g_ptr_array_unref(priv->devices);
@@ -242,7 +247,7 @@ static void spice_usb_device_manager_get_property(GObject *gobject,
g_value_set_object(value, priv->session);
break;
case PROP_MAIN_CONTEXT:
- g_value_set_pointer(value, priv->main_context);
+ g_value_set_boxed(value, priv->main_context);
break;
case PROP_AUTO_CONNECT:
g_value_set_boolean(value, priv->auto_connect);
@@ -266,7 +271,7 @@ static void spice_usb_device_manager_set_property(GObject *gobject,
priv->session = g_value_get_object(value);
break;
case PROP_MAIN_CONTEXT:
- priv->main_context = g_value_get_pointer(value);
+ priv->main_context = g_value_dup_boxed(value);
break;
case PROP_AUTO_CONNECT:
priv->auto_connect = g_value_get_boolean(value);
@@ -304,10 +309,11 @@ static void spice_usb_device_manager_class_init(SpiceUsbDeviceManagerClass *klas
/**
* SpiceUsbDeviceManager:main-context:
*/
- pspec = g_param_spec_pointer("main-context", "Main Context",
- "GMainContext to use for the event source",
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS);
+ pspec = g_param_spec_boxed("main-context", "Main Context",
+ "GMainContext to use for the event source",
+ G_TYPE_MAIN_CONTEXT,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS);
g_object_class_install_property(gobject_class, PROP_MAIN_CONTEXT, pspec);
/**
More information about the Spice-commits
mailing list