pnmixer-rust/src/app_state.rs

62 lines
1.5 KiB
Rust
Raw Normal View History

2017-06-27 22:23:12 +00:00
use gtk;
2017-06-30 15:24:26 +00:00
use audio::AlsaCard;
use std::cell::RefCell;
use std::rc::Rc;
2017-06-27 22:23:12 +00:00
2017-06-28 15:53:19 +00:00
2017-06-30 15:24:26 +00:00
// TODO: destructors
2017-06-29 12:55:07 +00:00
2017-06-29 13:50:24 +00:00
// TODO: glade stuff, config, alsacard
2017-06-27 22:23:12 +00:00
pub struct AppS {
2017-06-30 15:24:26 +00:00
pub gui: Gui,
pub acard: Rc<RefCell<AlsaCard>>,
}
impl AppS {
pub fn new() -> AppS {
2017-06-30 19:10:33 +00:00
let builder_popup = gtk::Builder::new_from_string(include_str!("../data/ui/popup-window-vertical.glade"));
2017-06-30 15:24:26 +00:00
return AppS {
2017-06-30 19:10:33 +00:00
gui: Gui::new(builder_popup),
acard: AlsaCard::new(None, Some(String::from("Master")))
.unwrap(),
};
2017-06-30 15:24:26 +00:00
}
}
pub struct Gui {
2017-06-27 22:23:12 +00:00
pub status_icon: gtk::StatusIcon,
2017-06-30 15:24:26 +00:00
pub popup_window: PopupWindow,
}
impl Gui {
pub fn new(builder: gtk::Builder) -> Gui {
return Gui {
2017-06-30 19:10:33 +00:00
status_icon: gtk::StatusIcon::new_from_icon_name("pnmixer"),
popup_window: PopupWindow::new(builder),
};
2017-06-30 15:24:26 +00:00
}
}
pub struct PopupWindow {
pub window: gtk::Window,
pub vol_scale_adj: gtk::Adjustment,
pub vol_scale: gtk::Scale,
pub mute_check: gtk::CheckButton,
}
2017-06-27 22:23:12 +00:00
2017-06-30 15:24:26 +00:00
impl PopupWindow {
pub fn new(builder: gtk::Builder) -> PopupWindow {
return PopupWindow {
2017-06-30 19:10:33 +00:00
window: builder.get_object("popup_window").unwrap(),
vol_scale_adj: builder.get_object("vol_scale_adj").unwrap(),
vol_scale: builder.get_object("vol_scale").unwrap(),
mute_check: builder.get_object("mute_check").unwrap(),
};
2017-06-30 15:24:26 +00:00
}
2017-06-27 22:23:12 +00:00
}