Put up the app window

This commit is contained in:
Savanni D'Gerinel 2024-02-04 10:25:45 -05:00
parent b414f3e0ea
commit c27ce7fe80
3 changed files with 66 additions and 2 deletions

8
Cargo.lock generated
View File

@ -864,6 +864,14 @@ dependencies = [
[[package]] [[package]]
name = "falling-sand" name = "falling-sand"
version = "0.1.0" version = "0.1.0"
dependencies = [
"cairo-rs",
"gio",
"glib",
"glib-build-tools 0.17.10",
"gtk4",
"libadwaita",
]
[[package]] [[package]]
name = "fastrand" name = "fastrand"

View File

@ -6,3 +6,11 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [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"

View File

@ -1,3 +1,51 @@
fn main() { use cairo::Context;
println!("Hello, world!"); 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();
} }