diff --git a/Cargo.toml b/Cargo.toml index fe598ec76..6e4526292 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,16 @@ name = "pnmixer-rs" version = "0.1.0" authors = ["Julian Ospald "] +[lib] +name = "pnmixerlib" +path = "src/lib.rs" +doc = true + +[[bin]] +name = "pnmixer-rs" +path = "src/bin.rs" +doc = false + [dependencies] alsa = "^0.1.8" alsa-sys = "^0.1.1" diff --git a/src/bin.rs b/src/bin.rs new file mode 100644 index 000000000..99d9c28d6 --- /dev/null +++ b/src/bin.rs @@ -0,0 +1,34 @@ +#![feature(alloc_system)] +extern crate alloc_system; + +extern crate pnmixerlib; + +use pnmixerlib::*; + +use app_state::*; +#[cfg(feature = "notify")] +use libnotify::*; +use std::rc::Rc; + +fn main() { + gtk::init().unwrap(); + + // TODO: error handling + #[cfg(feature = "notify")] + init("PNMixer-rs").unwrap(); + + flexi_logger::LogOptions::new() + .log_to_file(false) + // ... your configuration options go here ... + .init(Some("pnmixer=debug".to_string())) + .unwrap_or_else(|e| panic!("Logger initialization failed with {}", e)); + + let apps = Rc::new(AppS::new()); + + ui_entry::init(apps); + + gtk::main(); + + #[cfg(feature = "notify")] + uninit(); +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 000000000..73238aca2 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,60 @@ +#![feature(alloc_system)] +extern crate alloc_system; + +pub extern crate flexi_logger; +#[macro_use] +pub extern crate log; + +#[macro_use] +pub extern crate error_chain; + +#[macro_use] +pub extern crate serde_derive; +pub extern crate toml; +pub extern crate serde; + +pub extern crate alsa; +pub extern crate alsa_sys; +pub extern crate ffi; +pub extern crate gdk; +pub extern crate gdk_pixbuf; +pub extern crate gdk_pixbuf_sys; +pub extern crate gdk_sys; +pub extern crate gio; +pub extern crate glib; +pub extern crate glib_sys; +pub extern crate gobject_sys; +pub extern crate gtk; +pub extern crate gtk_sys; +pub extern crate libc; +pub extern crate png; +pub extern crate which; +pub extern crate xdg; + +#[cfg(feature = "notify")] +pub extern crate libnotify; + +#[macro_use] +pub mod errors; + +#[macro_use] +pub mod glade_helpers; + +pub mod alsa_card; +pub mod app_state; +pub mod audio; +pub mod prefs; +pub mod support_alsa; +pub mod support_audio; +pub mod support_cmd; +#[macro_use] +pub mod support_ui; +pub mod ui_entry; +pub mod ui_popup_menu; +pub mod ui_popup_window; +pub mod ui_prefs_dialog; +pub mod ui_tray_icon; + +#[cfg(feature = "notify")] +pub mod notif; + diff --git a/src/main.rs b/src/main.rs deleted file mode 100644 index c74252a2b..000000000 --- a/src/main.rs +++ /dev/null @@ -1,92 +0,0 @@ -#![feature(alloc_system)] -extern crate alloc_system; - -extern crate flexi_logger; -#[macro_use] -extern crate log; - -#[macro_use] -extern crate error_chain; - -#[macro_use] -extern crate serde_derive; -extern crate toml; -extern crate serde; - -extern crate alsa; -extern crate alsa_sys; -extern crate ffi; -extern crate gdk; -extern crate gdk_pixbuf; -extern crate gdk_pixbuf_sys; -extern crate gdk_sys; -extern crate gio; -extern crate glib; -extern crate glib_sys; -extern crate gobject_sys; -extern crate gtk; -extern crate gtk_sys; -extern crate libc; -extern crate png; -extern crate which; -extern crate xdg; - -#[cfg(feature = "notify")] -extern crate libnotify; - -use std::rc::Rc; - -#[macro_use] -mod errors; - -#[macro_use] -mod glade_helpers; - -mod alsa_card; -mod app_state; -mod audio; -mod prefs; -mod support_alsa; -mod support_audio; -mod support_cmd; -#[macro_use] -mod support_ui; -mod ui_entry; -mod ui_popup_menu; -mod ui_popup_window; -mod ui_prefs_dialog; -mod ui_tray_icon; - -#[cfg(feature = "notify")] -mod notif; - - - -use app_state::*; -#[cfg(feature = "notify")] -use libnotify::*; - - - -fn main() { - gtk::init().unwrap(); - - // TODO: error handling - #[cfg(feature = "notify")] - init("PNMixer-rs").unwrap(); - - flexi_logger::LogOptions::new() - .log_to_file(false) - // ... your configuration options go here ... - .init(Some("pnmixer=debug".to_string())) - .unwrap_or_else(|e| panic!("Logger initialization failed with {}", e)); - - let apps = Rc::new(AppS::new()); - - ui_entry::init(apps); - - gtk::main(); - - #[cfg(feature = "notify")] - uninit(); -}