From 3845a729a2f2ca27f79a7891311ebadb276e25ad Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Tue, 22 Sep 2020 17:46:27 +0100 Subject: [PATCH] initial --- .gitignore | 2 ++ Cargo.toml | 11 +++++++++++ src/main.rs | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.toml create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4fffb2f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +/Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..6437aa7 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "lull" +description = "a catalogue of soothing sounds" +version = "0.1.0" +authors = ["Max Bradbury "] +edition = "2018" + +[dependencies] +gio = "^0" +gtk = "^0" +rodio = "^0.11.0" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..a1e4b16 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,53 @@ +use gio::prelude::*; +use gtk::prelude::*; +use gtk::Orientation; +use rodio::Source; +use std::env::args; +use std::fs::File; +use std::io::BufReader; + +const SPACING: i32 = 16; + +fn build_ui(application: >k::Application) { + let window = gtk::ApplicationWindow::new(application); + + window.set_title("lull"); + window.set_border_width(SPACING as u32); + window.set_position(gtk::WindowPosition::Center); + window.set_default_size(400, 100); + + let vertical = gtk::Box::new(Orientation::Vertical, SPACING); + window.add(&vertical); + + // todo create user dir if it does not exist + + // todo open user dir in file browser if it is empty + + // todo iterate over audio files in user dir + // todo create row for each audio file + + window.show_all(); + + let device = rodio::default_output_device().unwrap(); + + let file = File::open("/home/max/being-harsh.mp3") + .expect("Couldn't open audio file"); + + let source = rodio::Decoder::new(BufReader::new(file)) + .expect("Couldn't decode audio"); + + rodio::play_raw(&device, source.convert_samples()); +} + +fn main() { + let application = gtk::Application::new( + Some("dev.tinybird.max.lull"), + Default::default() + ).expect("Initialization failed..."); + + application.connect_activate(|app| { + build_ui(app); + }); + + application.run(&args().collect::>()); +}