pnmixer-rust/src/ui_tray_icon.rs

26 lines
571 B
Rust
Raw Normal View History

2017-06-29 12:55:07 +00:00
use app_state::*;
use gtk::prelude::*;
2017-06-30 15:24:26 +00:00
use std::rc::Rc;
2017-06-29 12:55:07 +00:00
2017-06-30 15:24:26 +00:00
pub fn init_tray_icon(appstate: Rc<AppS>) {
2017-06-29 12:55:07 +00:00
2017-06-30 15:24:26 +00:00
let tray_icon = &appstate.clone().gui.status_icon;
2017-06-30 19:10:33 +00:00
tray_icon.connect_activate(move |_| {
on_tray_icon_activate(&appstate.clone())
});
2017-06-30 15:24:26 +00:00
tray_icon.set_visible(true);
}
2017-06-29 12:55:07 +00:00
2017-06-30 15:24:26 +00:00
fn on_tray_icon_activate(appstate: &AppS) {
let popup_window = &appstate.gui.popup_window.window;
if popup_window.get_visible() {
popup_window.hide();
} else {
popup_window.show_now();
}
2017-06-29 12:55:07 +00:00
}