pnmixer-rust/src/ui_entry.rs

60 lines
1.5 KiB
Rust
Raw Normal View History

2017-06-29 12:55:07 +00:00
use app_state::*;
2017-07-07 10:03:53 +00:00
use gtk;
use prefs::*;
2017-07-06 22:28:55 +00:00
use std::cell::RefCell;
2017-07-07 10:03:53 +00:00
use std::rc::Rc;
2017-07-01 14:55:35 +00:00
use ui_popup_menu::*;
2017-06-29 12:55:07 +00:00
use ui_popup_window::*;
2017-07-08 00:38:49 +00:00
use ui_prefs_dialog::*;
2017-06-29 12:55:07 +00:00
use ui_tray_icon::*;
2017-07-08 00:38:49 +00:00
use audio::{AudioUser, AudioSignal};
2017-06-29 12:55:07 +00:00
2017-07-07 10:03:53 +00:00
pub struct Gui {
_cant_construct: (),
pub tray_icon: TrayIcon,
pub popup_window: PopupWindow,
pub popup_menu: PopupMenu,
/* prefs_dialog is dynamically created and destroyed */
pub prefs_dialog: RefCell<Option<PrefsDialog>>,
}
impl Gui {
2017-07-07 20:10:45 +00:00
pub fn new(builder_popup_window: gtk::Builder,
builder_popup_menu: gtk::Builder,
prefs: &Prefs)
-> Gui {
2017-07-07 10:03:53 +00:00
return Gui {
2017-07-07 20:10:45 +00:00
_cant_construct: (),
tray_icon: TrayIcon::new(prefs).unwrap(),
popup_window: PopupWindow::new(builder_popup_window),
popup_menu: PopupMenu::new(builder_popup_menu),
prefs_dialog: RefCell::new(None),
};
2017-07-07 10:03:53 +00:00
}
}
2017-06-30 15:24:26 +00:00
pub fn init(appstate: Rc<AppS>) {
2017-06-30 19:10:33 +00:00
{
2017-07-08 00:38:49 +00:00
let apps = appstate.clone();
appstate.audio.connect_handler(
Box::new(move |s, u| match (s, u) {
(AudioSignal::ValuesChanged, AudioUser::Unknown) => {
debug!("Appstate references: {}!", Rc::strong_count(&apps));
2017-07-06 22:28:55 +00:00
2017-07-08 00:38:49 +00:00
}
_ => debug!("Nix"),
}),
);
2017-06-30 19:10:33 +00:00
}
2017-06-30 15:24:26 +00:00
2017-06-30 19:10:33 +00:00
init_tray_icon(appstate.clone());
init_popup_window(appstate.clone());
2017-07-01 14:55:35 +00:00
init_popup_menu(appstate.clone());
2017-07-08 00:38:49 +00:00
init_prefs_callback(appstate.clone());
2017-06-29 12:55:07 +00:00
}