summaryrefslogtreecommitdiff
path: root/src/gui.rs
diff options
context:
space:
mode:
authorJustin Worthe <justin.worthe@gmail.com>2016-09-25 16:19:58 +0200
committerJustin Worthe <justin.worthe@gmail.com>2016-09-25 16:19:58 +0200
commit59607a6ba83048d8f92920d974f4ab2c6ecbaae6 (patch)
tree92a92d2e12409700049188414648d796f6757797 /src/gui.rs
GUI, lists PA devices, backend can watch audio stream
Diffstat (limited to 'src/gui.rs')
-rw-r--r--src/gui.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/gui.rs b/src/gui.rs
new file mode 100644
index 0000000..66ae1f7
--- /dev/null
+++ b/src/gui.rs
@@ -0,0 +1,28 @@
+use gtk;
+use gtk::prelude::*;
+
+pub fn start_gui() -> Result<(), String> {
+ try!(gtk::init().map_err(|_| "Failed to initialize GTK."));
+
+ // Create the main window.
+ let window = gtk::Window::new(gtk::WindowType::Toplevel);
+ window.set_title("Musician Training");
+
+ let audio_devices = try!(::audio::get_device_list().map_err(|e| e.to_string()));
+ let dropdown = gtk::ComboBoxText::new();
+ for (index, name) in audio_devices {
+ dropdown.append(Some(format!("{}", index).as_ref()), name.as_ref());
+ }
+ window.add(&dropdown);
+ window.set_default_size(300, 300);
+
+ window.show_all();
+
+ window.connect_delete_event(|_, _| {
+ gtk::main_quit();
+ gtk::prelude::Inhibit(false)
+ });
+
+ gtk::main();
+ Ok(())
+}