GithubHelp home page GithubHelp logo

rgtk's Introduction

rgtk Build Status

Rust bindings and wrappers for GTK+, GLib and Cairo.

Installation

rgtk uses autoconf tools to build, so you should install them on your system.

For debian based systems:

> apt-get install autoconf

For OSX:

> brew install autoconf

You should also install GTK+, GLib and Cairo development files before installing rgtk. Optionally, it is recommended to install the debug packages containing helpful debug symbols.

For debian based system:

> apt-get install libgtk-3-dev   libglib2.0-dev   libcairo2-dev
> apt-get install libgtk-3-0-dbg libglib2.0-0-dbg libcairo2-dbg

For OSX:

> apt-get install gtk+3

rgtk targets GTK+ 3.12 but can also compile older versions 3.6, 3.8 and 3.10. Setting the environment variable GTK_VERSION to any of GTK_3_6, GTK_3_8, GTK_3_10, GTK_3_12 allows pick a version. The default is GTK_3_12.

We are currently targetting rust master compiler to build rgtk, make sure you have the latest version before submitting any bugs.

Then you can build rgtk by generating the make file and then running make.

> ./configure
> make

In src/bin you can find some tests showing of some functionality, these can be build and run as follows:

> make gtktest
> ./target/gtktest

> make cairotest
> ./target/cairotest

rgtk should build and work on both OSX and GNU/Linux. We plan on adding windows support in the future.

Finally build documentation using:

> make doc

Your local copy can be accessed using your browser at

file:///{rgtk_location}/doc/rgtk/index.html

You can also access a daily build of the docs via the internet:

http://rust-ci.org/jeremyletang/rgtk/doc/rgtk/

Use rgtk

To implement GTK+ inheritance in rust, we implemented gtk superclasses as traits located in rgtk::gtk::traits::*. The various widgets implement these traits and live in rgtk::gtk::*.

For your convenience the various traits are reexported in the rgtk::* namespace as Gtk{trait_name}Trait so you can just use...

extern mod rgtk;
use rgtk::*;

...to easily access all the gtk widgets and all traits methods:

let button = gtk::Button:new(); // You have access to the struct methods of gtk::Button aswell
                                // as the trait methods from gtk::traits::Button as GtkButtonTrait.

Contribute

Contributor you're welcome!

You probably know but Gtk+ uses its own GObject system: inherited class and interface.

To respect this design, I follow a special design on rgtk:

  • Interface -> Implement them on a trait with only default methods.
  • Class -> Implement the construct on the class impl and other methods on a traits.
  • Sub-class -> Implement all the methods on the class.

Example for GtkOrientable, GtkBox, GtkButtonBox:

GtkOrientable is an interface with all methods implemented as default method of the trait gtk::traits::Orientable.

GtkBox is a class with constructors implemented on the struct gtk::Box, and the other method as default methods of the trait gtk::traits::Box. So gtk::Box implements gtk::traits::Orientable and gtk::traits::Box.

GtkButtonBox is a sub-class of GtkBox, the struct gtk::ButtonBox implements all the methods of GtkButtonBox and the traits gtk::traits::Orientable and gtk::traits::Box.

Finally, all the gtk widgets implement the trait gtk::traits::Widget.

License

rgtk is available under the same license term as GTK+: the LGPL (Lesser General Public license).

rgtk's People

Contributors

jeremyletang avatar mathijshenquet avatar guillaumegomez avatar blei avatar

Watchers

James Cloos avatar Edward Shaw avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.