Put up the app window
This commit is contained in:
parent
b414f3e0ea
commit
c27ce7fe80
|
@ -864,6 +864,14 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "falling-sand"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cairo-rs",
|
||||
"gio",
|
||||
"glib",
|
||||
"glib-build-tools 0.17.10",
|
||||
"gtk4",
|
||||
"libadwaita",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
|
|
|
@ -6,3 +6,11 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
adw = { version = "0.5", package = "libadwaita", features = [ "v1_4" ] }
|
||||
cairo-rs = { version = "0.18" }
|
||||
gio = { version = "0.18" }
|
||||
glib = { version = "0.18" }
|
||||
gtk = { version = "0.7", package = "gtk4", features = [ "v4_10" ] }
|
||||
|
||||
[build-dependencies]
|
||||
glib-build-tools = "0.17"
|
|
@ -1,3 +1,51 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
use cairo::Context;
|
||||
use glib::Object;
|
||||
use gtk::{prelude::*, subclass::prelude::*};
|
||||
|
||||
const WIDTH: i32 = 600;
|
||||
const HEIGHT: i32 = 600;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct SandPrivate;
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for SandPrivate {
|
||||
const NAME: &'static str = "Sand";
|
||||
type Type = Sand;
|
||||
type ParentType = gtk::DrawingArea;
|
||||
}
|
||||
|
||||
impl ObjectImpl for SandPrivate {}
|
||||
impl WidgetImpl for SandPrivate {}
|
||||
impl DrawingAreaImpl for SandPrivate {}
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct Sand(ObjectSubclass<SandPrivate>) @extends gtk::DrawingArea, gtk::Widget;
|
||||
}
|
||||
|
||||
impl Sand {
|
||||
pub fn new() -> Self {
|
||||
let s: Self = Object::builder().build();
|
||||
s.set_width_request(WIDTH);
|
||||
s.set_height_request(HEIGHT);
|
||||
|
||||
s
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let app = gtk::Application::builder()
|
||||
.application_id("com.luminescent-dreams.falling-sand")
|
||||
.build();
|
||||
|
||||
app.connect_activate(move |app| {
|
||||
let window = gtk::ApplicationWindow::new(app);
|
||||
window.present();
|
||||
|
||||
let sand = Sand::new();
|
||||
|
||||
window.set_child(Some(&sand));
|
||||
});
|
||||
|
||||
app.run();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue