diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2010-10-01 12:20:04 +0200 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@gmail.com> | 2010-11-23 17:10:25 +0100 |
commit | 8a09745b8c73a1bc292ebe56b0f1baba5afda5a8 (patch) | |
tree | 577ac8808c46c4c23470292416ae35647086a6b9 /gtk | |
parent | 80817885eb93355ededfceff8fcb8f7f554536fb (diff) |
make spice_session_get_channels return a glist
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/spice-pulse.c | 10 | ||||
-rw-r--r-- | gtk/spice-session.c | 14 | ||||
-rw-r--r-- | gtk/spice-session.h | 2 | ||||
-rw-r--r-- | gtk/spice-widget.c | 10 |
4 files changed, 18 insertions, 18 deletions
diff --git a/gtk/spice-pulse.c b/gtk/spice-pulse.c index 7c363f1..26e7496 100644 --- a/gtk/spice-pulse.c +++ b/gtk/spice-pulse.c @@ -161,8 +161,7 @@ SpicePulse *spice_pulse_new(SpiceSession *session, GMainLoop *mainloop, { SpicePulse *pulse; spice_pulse *p; - SpiceChannel *channels[16]; - int i, n; + GList *list; pulse = g_object_new(SPICE_TYPE_PULSE, NULL); p = SPICE_PULSE_GET_PRIVATE(pulse); @@ -170,10 +169,11 @@ SpicePulse *spice_pulse_new(SpiceSession *session, GMainLoop *mainloop, g_signal_connect(session, "spice-session-channel-new", G_CALLBACK(channel_new), pulse); - n = spice_session_get_channels(session, channels, SPICE_N_ELEMENTS(channels)); - for (i = 0; i < n; i++) { - channel_new(session, channels[i], (gpointer*)pulse); + 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*)pulse); } + g_list_free(list); p->mainloop = pa_glib_mainloop_new(g_main_loop_get_context(mainloop)); p->context = pa_context_new(pa_glib_mainloop_get_api(p->mainloop), name); diff --git a/gtk/spice-session.c b/gtk/spice-session.c index 157a30e..ffb59e2 100644 --- a/gtk/spice-session.c +++ b/gtk/spice-session.c @@ -300,20 +300,20 @@ void spice_session_disconnect(SpiceSession *session) s->cmain = NULL; } -int spice_session_get_channels(SpiceSession *session, SpiceChannel **channels, int max) +GList *spice_session_get_channels(SpiceSession *session) { spice_session *s = SPICE_SESSION_GET_PRIVATE(session); struct channel *item; + GList *list = NULL; RingItem *ring; - int i; - for (i = 0, ring = ring_get_head(&s->channels); - i < max && ring != NULL; - i++, ring = ring_next(&s->channels, ring)) { + for (ring = ring_get_head(&s->channels); + ring != NULL; + ring = ring_next(&s->channels, ring)) { item = SPICE_CONTAINEROF(ring, struct channel, link); - channels[i] = item->channel; + list = g_list_append(list, item->channel); } - return i; + return list; } /* ------------------------------------------------------------------ */ diff --git a/gtk/spice-session.h b/gtk/spice-session.h index 4e1269a..56386b2 100644 --- a/gtk/spice-session.h +++ b/gtk/spice-session.h @@ -39,7 +39,7 @@ GType spice_session_get_type(void) G_GNUC_CONST; SpiceSession *spice_session_new(void); gboolean spice_session_connect(SpiceSession *session); void spice_session_disconnect(SpiceSession *session); -int spice_session_get_channels(SpiceSession *session, SpiceChannel **channels, int max); +GList *spice_session_get_channels(SpiceSession *session); G_END_DECLS diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c index 688e37c..4af1a43 100644 --- a/gtk/spice-widget.c +++ b/gtk/spice-widget.c @@ -1153,8 +1153,7 @@ GtkWidget *spice_display_new(SpiceSession *session, int id) { SpiceDisplay *display; spice_display *d; - SpiceChannel *channels[16]; - int i, n; + GList *list; display = g_object_new(SPICE_TYPE_DISPLAY, NULL); d = SPICE_DISPLAY_GET_PRIVATE(display); @@ -1163,10 +1162,11 @@ GtkWidget *spice_display_new(SpiceSession *session, int id) g_signal_connect(session, "spice-session-channel-new", G_CALLBACK(channel_new), display); - n = spice_session_get_channels(session, channels, SPICE_N_ELEMENTS(channels)); - for (i = 0; i < n; i++) { - channel_new(session, channels[i], (gpointer*)display); + 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*)display); } + g_list_free(list); return GTK_WIDGET(display); } |