Skip to content

Instantly share code, notes, and snippets.

@lidavidm
Last active November 9, 2015 04:54
Show Gist options
  • Save lidavidm/8573ccaa759dc2bb5807 to your computer and use it in GitHub Desktop.
Save lidavidm/8573ccaa759dc2bb5807 to your computer and use it in GitHub Desktop.
//! # Basic Sample
//!
//! This sample demonstrates how to create a toplevel `window`, set its title, size and position, how to add a `button` to this `window` and how to connect signals with actions.
#![crate_type = "bin"]
extern crate gtk;
use gtk::signal::StatusIconSignals;
use gtk::traits::*;
use gtk::widgets::*;
fn main() {
if gtk::init().is_err() {
println!("Failed to initialize GTK.");
return;
}
let status_icon = StatusIcon::new_from_icon_name("help-browser");
let menu = Menu::new().unwrap();
let menu_item = MenuItem::new_with_label("Test").unwrap();
menu.append(&menu_item);
let menu_item = MenuItem::new_with_label("Test 2").unwrap();
menu.append(&menu_item);
menu.show_all();
status_icon.connect_popup_menu(move |icon, button, activate_time| {
let a: Option<&MenuItem> = None;
menu.popup(a, a, button, activate_time);
});
gtk::main();
}
@lidavidm
Copy link
Author

lidavidm commented Nov 6, 2015

screenshot from 2015-11-05 20-17-13

@lidavidm
Copy link
Author

lidavidm commented Nov 9, 2015

screenshot from 2015-11-08 23-53-46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment