Skip to content

Instantly share code, notes, and snippets.

@drozdziak1
Created October 9, 2019 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drozdziak1/2c39605eb9231e7a3ac79333c4d5edcd to your computer and use it in GitHub Desktop.
Save drozdziak1/2c39605eb9231e7a3ac79333c4d5edcd to your computer and use it in GitHub Desktop.
#[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