Skip to content

Instantly share code, notes, and snippets.

@ivanovaleksey
Created December 25, 2017 11:55
Show Gist options
  • Save ivanovaleksey/34d498e76033f74f1b4a5edf445aa135 to your computer and use it in GitHub Desktop.
Save ivanovaleksey/34d498e76033f74f1b4a5edf445aa135 to your computer and use it in GitHub Desktop.
GtkRevealer
extern crate gtk;
use gtk::*;
fn main() {
if gtk::init().is_err() {
eprintln!("failed to initialize GTK Application");
std::process::exit(1);
}
let window = Window::new(WindowType::Toplevel);
window.set_default_size(400, 200);
let header = HeaderBar::new();
header.set_show_close_button(true);
header.set_title("App");
window.set_titlebar(&header);
let vbox = Box::new(Orientation::Vertical, 0);
window.add(&vbox);
let revealer = Revealer::new();
revealer.set_transition_type(RevealerTransitionType::SlideRight);
revealer.set_transition_duration(2000);
let label_1 = Label::new("Test label");
revealer.add(&label_1);
let btn = Button::new_with_label("Show/Hide");
let revealer_1 = revealer.clone();
btn.connect_clicked(move |_| {
let cur = revealer_1.get_reveal_child();
println!("{:?}", cur);
revealer_1.set_reveal_child(!cur);
});
vbox.pack_start(&btn, true, true, 0);
vbox.pack_end(&revealer, true, true, 0);
window.show_all();
gtk::main();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment