Showing posts with label Ruby-GNOME2. Show all posts
Showing posts with label Ruby-GNOME2. Show all posts

18.1.09

GUI toolkit extravaganza wrap-up

Folks, I have decided to conclude the GUI toolkit extravaganza. There were two more toolkits to follow, monkeybars and qtruby. But alas, I am not going to check those out any time soon. I just don't feel very curious about these toolkits anymore and want to do some more exploring of Shoes. But I'll take those two toolkits along in the following overview.

The big question is off course, which one is the best? It all depends on what you need and what effort you are willing to invest (ooh how cliché!). When it comes to GUI toolkits for Ruby, there are three basic categories: system-dependant, system-independent and the category for those that won't fit elsewhere. Let's take a brief look at each category:

System-dependant: ruby-gnome2 and qtruby
These are toolkits specifically written to support a certain system, a specific window manager for example. These toolkits offer a big load of functions, sometimes not even restricted to graphics. For example, ruby-gnome2 has some audio functionality as well. The amount of available functionality and the fact that you need to understand the given window manager as well, makes these toolkits a bit complex and the learning curve steep. I would only consider to learn and use these if I really needed to use some system specific functionality that other toolkits don't provide. Otherwise I'd walk on and find something more simple which I could use in more situations.

If you need to do some qt stuff here's some info:
a book
korundrun
: bindings for KDE and qt api's
KDE techbase

System-independent: fxruby and wxruby
Usually these toolkits are a layer cake of wrappers and libraries. Both are supported by many systems and allow you to code an app that looks the same on different systems. There is not much difference between these two toolkits. Fx is older which is bad because it just looks a bit dated, but on the other hand there is a decent amount of documentation, including a book on fxruby. Wx is a bit younger and looks better. One other difference is that wx is truly native, so all widgets are in the same style your window manager is. Fx looks mostly the same on different platforms. Both toolkits provide all standard GUI functions.

If you are looking for a toolkit to make mainstream GUI's I'd go for one of these. Walk on if you want something different, something that's more suited for beginners or something more fun.
Link
The category for those that won't fit elsewhere: Monkeybars & Shoes
Monkeybars:
This toolkit is for rubyists who evolved from Javabut still want to code swing but this time using Ruby code. So if you learned Swing in a past life and don't want to learn a new GUI language again, I guess this is for you! Here's some background info:
project page
Linkscreencastic screencast

Shoes:
My personal choice and recommendation. If you don't have very specific wishes you should try shoes and see if it fits! Why? Because it's the easiest and most enjoyable. If you later find that you need something which Shoes can't do you can always choose to learn something else.
To learn Shoes you only need to take 10 steps, so stay tuned as we take 10 steps with Shoes in the following postings!

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!