From 9d44052099ff5e1933e86d047bbb18cb1baaad54 Mon Sep 17 00:00:00 2001 From: daa84 Date: Wed, 16 Mar 2016 17:39:53 +0300 Subject: [PATCH] Initial gtk ui --- .gitignore | 2 + Cargo.lock | 214 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 14 ++++ build.rs | 4 + src/main.rs | 32 ++++++++ 5 files changed, 266 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 build.rs create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c6262ea --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +target +*.swp diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..1f41c12 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,214 @@ +[root] +name = "neovim-gtk" +version = "0.1.0" +dependencies = [ + "cairo-rs 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "glib 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "gtk 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "atk-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gobject-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "bitflags" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "c_vec" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "cairo-rs" +version = "0.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "c_vec 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-sys-rs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "cairo-sys-rs" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "gdk" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cairo-rs 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "gdk-pixbuf 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "gdk-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "pango 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "gdk-pixbuf" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "gdk-pixbuf-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "gdk-pixbuf-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gio-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gobject-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "gdk-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-sys-rs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gdk-pixbuf-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gio-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gobject-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "pango-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "gio-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gobject-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "glib" +version = "0.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "gio-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gobject-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "glib-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "gobject-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "gtk" +version = "0.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cairo-rs 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-sys-rs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gdk 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gdk-pixbuf 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "gdk-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gtk-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "pango 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "gtk-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "atk-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-sys-rs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gdk-pixbuf-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gdk-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gio-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gobject-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "pango-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "libc" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "pango" +version = "0.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "glib 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "pango-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "pango-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "glib-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gobject-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "pkg-config" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" + diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..f4bc866 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "neovim-gtk" +version = "0.1.0" +authors = ["daa84 "] +build = "build.rs" + +[dependencies] +cairo-rs = "0.0.8" +glib = "0.0.8" + +[dependencies.gtk] +version = "0.0.7" +features = ["v3_10"] + diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..8e12b51 --- /dev/null +++ b/build.rs @@ -0,0 +1,4 @@ + +fn main() { + println!("cargo:rustc-link-search=native=C:\\msys64\\mingw64\\lib"); +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..55546fa --- /dev/null +++ b/src/main.rs @@ -0,0 +1,32 @@ +extern crate gtk; +extern crate cairo; + +use gtk::prelude::*; +use gtk::{Window, WindowType, DrawingArea}; + +fn main() { + gtk::init().expect("Failed to initialize GTK"); + let window = Window::new(WindowType::Toplevel); + let drawing_area = DrawingArea::new(); + drawing_area.set_size_request(500, 500); + drawing_area.connect_draw(_gtk_draw); + window.add(&drawing_area); + window.show_all(); + window.connect_delete_event(|_,_| { + gtk::main_quit(); + Inhibit(false) + }); + + gtk::main(); +} + +fn _gtk_draw(drawing_area: &DrawingArea, ctx: &cairo::Context) -> Inhibit { + let width = drawing_area.get_allocated_width() as f64; + let height = drawing_area.get_allocated_height() as f64; + ctx.set_source_rgb(1.0, 0.0, 0.0); + ctx.arc(width / 2.0, height / 2.0, + width / 2.0, + 0.0, 2.0 * 3.14); + ctx.fill(); + Inhibit(true) +}