pnmixer-rust/src/app_state.rs

75 lines
2.2 KiB
Rust
Raw Normal View History

2017-06-27 22:23:12 +00:00
use gtk;
2017-07-01 22:03:21 +00:00
use audio::Audio;
2017-07-02 16:11:56 +00:00
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,
2017-07-01 22:03:21 +00:00
pub audio: Audio,
2017-06-30 15:24:26 +00:00
}
impl AppS {
pub fn new() -> AppS {
2017-07-01 14:55:35 +00:00
let builder_popup_window =
gtk::Builder::new_from_string(include_str!("../data/ui/popup-window.glade"));
let builder_popup_menu = gtk::Builder::new_from_string(include_str!("../data/ui/popup-menu.glade"));
2017-07-02 16:11:56 +00:00
let builder_prefs_dialog =
gtk::Builder::new_from_string(include_str!("../data/ui/prefs-dialog.glade"));
2017-06-30 15:24:26 +00:00
return AppS {
2017-07-02 16:11:56 +00:00
gui: Gui::new(builder_popup_window,
builder_popup_menu,
builder_prefs_dialog),
2017-07-01 22:03:21 +00:00
audio: Audio::new(None, Some(String::from("Master")))
2017-06-30 19:10:33 +00:00
.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,
2017-07-01 14:55:35 +00:00
pub popup_menu: PopupMenu,
2017-07-02 16:11:56 +00:00
pub prefs_dialog: PrefsDialog,
2017-06-30 15:24:26 +00:00
}
impl Gui {
2017-07-01 14:55:35 +00:00
pub fn new(builder_popup_window: gtk::Builder,
2017-07-02 16:11:56 +00:00
builder_popup_menu: gtk::Builder,
builder_prefs_dialog: gtk::Builder)
2017-07-01 14:55:35 +00:00
-> Gui {
2017-06-30 15:24:26 +00:00
return Gui {
2017-06-30 19:10:33 +00:00
status_icon: gtk::StatusIcon::new_from_icon_name("pnmixer"),
2017-07-01 14:55:35 +00:00
popup_window: PopupWindow::new(builder_popup_window),
popup_menu: PopupMenu::new(builder_popup_menu),
2017-07-02 16:11:56 +00:00
prefs_dialog: PrefsDialog::new(builder_prefs_dialog),
2017-06-30 19:10:33 +00:00
};
2017-06-30 15:24:26 +00:00
}
}
2017-07-02 16:11:56 +00:00
create_builder_item!(PopupWindow,
popup_window: gtk::Window,
vol_scale_adj: gtk::Adjustment,
vol_scale: gtk::Scale,
mute_check: gtk::CheckButton);
2017-07-01 14:55:35 +00:00
create_builder_item!(PopupMenu,
menu_window: gtk::Window,
menubar: gtk::MenuBar,
menu: gtk::Menu,
2017-07-02 16:11:56 +00:00
about_item: gtk::MenuItem,
prefs_item: gtk::MenuItem);
2017-06-30 15:24:26 +00:00
2017-06-27 22:23:12 +00:00
2017-07-02 16:11:56 +00:00
create_builder_item!(PrefsDialog,
prefs_dialog: gtk::Dialog,
card_combo: gtk::ComboBoxText,
chan_combo: gtk::ComboBoxText);