24.11.08

GUI toolkit extravaganza part I: Ruby-GNOME2

Welcome to the first part of the GUI toolkit extravaganza. The previous post was an introduction to the GUI toolkit extravaganza. In this part, the first of 7, we will take a look at the Ruby-GNOME2 toolkit. Let's go ahead and take a peek at this interresting toolkit!

Ruby-GNOME2
Ruby-Gnome2 is a Ruby library that contains a set of bindings to various GNOME/GTK+2.0 libraries. Basically these are just Ruby wrappers around the GNOME/GTK+2.0 libs.

ease of installation
This toolkit is very easy to install if you happen to be using a system running GNOME and Ruby. If you use Ubuntu you only need to execute apt-get install ruby-gnome2.

documentation
There's quite a decent level of documentation for the Ruby-Gnome2 toolkit. There's a Wiki that includes the API reference and tutorials. There is quite a lot of documentation, but there are quite a lot of "fixme's" so not everything has been documented yet. The site also provides a few sample programs for instance a simple webbrowser, a simple audio player and the classic game Sokoban!
There are a few public mailinglists too.

supported platforms
You can probably guess this one. It runs only on systems running GNOME. So this one is restricted to Linux and Unix systems. No Windows or MacOS and no Linux systems running other window managers.

complexity
A simple window with one button is created by the following code. It's pretty straightforward, but the odd thing is that the buttoncode is written before the window code. It's also quite a big ammount of code lines for a such a simple window.


#!/usr/bin/env ruby

require 'gtk2'

button = Gtk::Button.new("Button")
button.signal_connect("clicked") {
puts "Ruby-GTK2"
}

window = Gtk::Window.new
window.set_default_size(100, 100)
window.signal_connect("delete_event") {
puts "delete event occurred"
false
}

window.signal_connect("destroy") {
puts "destroy event occurred"
Gtk.main_quit
}

window.border_width = 100
window.add(button)
window.show_all

Gtk.main


functionality
If you thought this toolkit was limited to using GTK2.0 drawing libraries you were wrong. This toolkit not only offers access to the GTK libraries but also, amongst others, the GDK, Pango, Poppler, ATK and libglade libraries. So you can see it provides far more then just GUI functionality. There's stuff for mulitmedia, text editing, creation of PDF, accessibility, internationalization and what not.

performance
This is just as fast as your average GNOME app.

looks
This toolkit provides decent looks since it uses the GNOME/GTK2.0 libraries. Here's what our code looks like when executed.



You can find the Ruby-GNOME2 toolkit at:
http://ruby-gnome2.sourceforge.jp/

Next one up is FXRuby!

No comments: