From 0abbad024a5d29915af4fc61adbd155fc255f3c2 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 20 Feb 2010 01:44:15 +0100 Subject: add minimal error checking --- gnome-speaker-setup.vala | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/gnome-speaker-setup.vala b/gnome-speaker-setup.vala index 936ec43..d9df5f5 100644 --- a/gnome-speaker-setup.vala +++ b/gnome-speaker-setup.vala @@ -311,19 +311,9 @@ public class SpeakerSetupWindow : Window { vbox.pack_start(a, false, false, 0); close_button.clicked += on_close_button_clicked; - destroy += Gtk.main_quit; - - main_loop = new PulseAudio.GLibMainLoop(); - context = new PulseAudio.Context(main_loop.get_api(), "Speaker Test"); - - context.connect(); - - context.set_state_callback(context_state_cb); - context.set_subscribe_callback(context_subscribe_cb); - CellRenderer r = new CellRendererText(); card_combo_box.pack_start(r, true); - card_combo_box.set_attributes(r, "text", 0, null); + card_combo_box.set_attributes(r, "markup", 0, null); r = new CellRendererText(); profile_combo_box.pack_start(r, true); @@ -345,9 +335,28 @@ public class SpeakerSetupWindow : Window { device_combo_box.set_model(unowned_devices); current_devices = unowned_devices; + destroy += main_quit; + TreeIter i; cards.append(out i); - cards.set(i, 0, "Non-Hardware", 1, INVALID_INDEX); + cards.set(i, 0, "Independent Devices", 1, INVALID_INDEX); + + main_loop = new PulseAudio.GLibMainLoop(); + + context = new PulseAudio.Context(main_loop.get_api(), "Speaker Test"); + + if (context == null) { + stderr.printf("Couldn't allocate connection.\n"); + main_quit(); + } else { + context.set_state_callback(context_state_cb); + context.set_subscribe_callback(context_subscribe_cb); + + if (context.connect() < 0) { + stderr.printf("Couldn't initiate connection: %s\n", PulseAudio.strerror(context.errno())); + main_quit(); + } + } } private const int position_table[] = { @@ -634,7 +643,7 @@ public class SpeakerSetupWindow : Window { } void on_close_button_clicked() { - Gtk.main_quit(); + main_quit(); } unowned CardData? get_current_card() { -- cgit