Created
October 9, 2019 15:34
-
-
Save drozdziak1/2c39605eb9231e7a3ac79333c4d5edcd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[macro_use] | |
extern crate log; | |
// To import all needed traits. | |
use gio::prelude::*; | |
use gtk::prelude::*; | |
use std::env; | |
fn main() { | |
env_logger::init(); | |
let uiapp = gtk::Application::new( | |
Some("org.gtkrsnotes.demo"), | |
gio::ApplicationFlags::FLAGS_NONE, | |
) | |
.expect("Application::new failed"); | |
uiapp.connect_activate(|app| { | |
// We create the main window. | |
let win = gtk::ApplicationWindow::new(app); | |
// Then we set its size and a title. | |
win.set_default_size(320, 200); | |
win.set_title("Basic example"); | |
win.connect_draw(|win_self, ctxt| { | |
info!("Obtained context"); | |
ctxt.set_source_rgb(0.0, 0.0, 0.0); | |
ctxt.rectangle(0.0, 0.0, 5.0, 30.0); | |
ctxt.fill(); | |
ctxt.stroke(); | |
ctxt.paint(); | |
Inhibit(false) | |
}); | |
println!("Showing all"); | |
// Don't forget to make all widgets visible. | |
win.show_all(); | |
}); | |
uiapp.run(&env::args().collect::<Vec<_>>()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment