aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2021-01-24 21:11:26 +0100
committerJulian T <julian@jtle.dk>2021-01-24 21:11:26 +0100
commitdd943aa829493a9b27dedd826d5865c1e2a8e343 (patch)
treec8791123bb6b838c96e5facc546d046e05d6b7a3 /src
parent41ea2d8f94043d49fc26aaaa8030a73dcfdc2da9 (diff)
Add start of guirust-gui
Diffstat (limited to 'src')
-rw-r--r--src/bin/mod.rs78
-rw-r--r--src/main.rs3
2 files changed, 78 insertions, 3 deletions
diff --git a/src/bin/mod.rs b/src/bin/mod.rs
new file mode 100644
index 0000000..08d65de
--- /dev/null
+++ b/src/bin/mod.rs
@@ -0,0 +1,78 @@
+extern crate gtk;
+extern crate gdk_pixbuf;
+extern crate glib;
+
+use gtk::*;
+use gdk_pixbuf::{Pixbuf, Colorspace};
+use glib::Bytes;
+use std::process;
+
+struct App {
+ window: Window,
+ header: Header,
+ content: Content,
+}
+
+struct Header {
+ container: HeaderBar,
+}
+
+struct Content {
+ area: Image,
+}
+
+impl App {
+ fn new() -> App {
+ let window = Window::new(WindowType::Toplevel);
+ let header = Header::new();
+ let content = Content::new();
+
+ window.set_titlebar(Some(&header.container));
+ window.set_title("Pathtrace");
+ Window::set_default_icon_name("iconname");
+
+ window.add(&content.area);
+
+ window.connect_delete_event(move |_, _| {
+ main_quit();
+ Inhibit(false)
+ });
+
+ App { window, header, content }
+ }
+}
+
+impl Header {
+ fn new() -> Header {
+ let container = HeaderBar::new();
+
+ container.set_title(Some("Pathtrace"));
+ container.set_show_close_button(true);
+
+ Header { container }
+ }
+}
+
+impl Content {
+ fn new() -> Content {
+ // Create a test image
+ let imagebuff = vec![0; 300];
+ let buff = Pixbuf::from_bytes(&Bytes::from(&imagebuff), Colorspace::Rgb, false, 24, 10, 10, 30);
+ let area = Image::from_pixbuf(Some(&buff));
+
+ Content { area }
+ }
+}
+
+fn main() {
+ if gtk::init().is_err() {
+ eprintln!("failed to init GTK");
+ process::exit(1);
+ }
+
+ let app = App::new();
+
+ app.window.show_all();
+
+ gtk::main();
+}
diff --git a/src/main.rs b/src/main.rs
deleted file mode 100644
index e7a11a9..0000000
--- a/src/main.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-fn main() {
- println!("Hello, world!");
-}