Initial gtk ui

This commit is contained in:
daa84 2016-03-16 17:39:53 +03:00
commit 9d44052099
5 changed files with 266 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
target
*.swp

214
Cargo.lock generated Normal file
View File

@ -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"

14
Cargo.toml Normal file
View File

@ -0,0 +1,14 @@
[package]
name = "neovim-gtk"
version = "0.1.0"
authors = ["daa84 <daa84@inbox.ru>"]
build = "build.rs"
[dependencies]
cairo-rs = "0.0.8"
glib = "0.0.8"
[dependencies.gtk]
version = "0.0.7"
features = ["v3_10"]

4
build.rs Normal file
View File

@ -0,0 +1,4 @@
fn main() {
println!("cargo:rustc-link-search=native=C:\\msys64\\mingw64\\lib");
}

32
src/main.rs Normal file
View File

@ -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)
}