Skip to content

Instantly share code, notes, and snippets.

@hasufell hasufell/main.rs
Last active Aug 27, 2016

Embed
What would you like to do?
extern crate gtk;
extern crate gdk;
#[macro_use]
extern crate lazy_static;
use gdk::EventButton;
use gdk::EventType;
use std::boxed::Box;
use std::rc::Rc;
use std::sync::Arc;
use gtk::prelude::*;
use gtk::{
Builder,
StatusIcon,
};
fn main() {
gtk::init().unwrap();
let tray_icon = StatusIcon::new_from_icon_name("pnmixer");
tray_icon.set_visible(true);
let builder = Rc::new(Builder::new_from_file("data/ui/popup-window-vertical.glade"));
// 1st binding
let b1 = builder.clone();
tray_icon.connect_activate(move |_| {
let popup_window: gtk::Window = b1
.get_object("popup_window").unwrap();
popup_window.show_all();
});
// 2nd binding
let b2 = builder.clone();
tray_icon.connect_button_press_event(move |_, e| {
let bt = e.as_ref().button;
match bt {
3 => {
let popup_window: gtk::Window = b2
.get_object("popup_window").unwrap();
popup_window.show_all();
return true;
},
_ => {
println!("Blah");
return false;
}
}
});
gtk::main();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.