diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-02-20 01:44:15 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-02-20 01:44:15 +0100 |
commit | 0abbad024a5d29915af4fc61adbd155fc255f3c2 (patch) | |
tree | 93a1b2d59ad4842f516a55ef66e6309afd188936 | |
parent | 09a2d810e0f13121a26ad79a80517ec2b0adefa6 (diff) |
add minimal error checking
-rw-r--r-- | gnome-speaker-setup.vala | 35 |
1 files 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, "<i>Independent Devices</i>", 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() { |