Wednesday, January 25, 2006

Ruby-Gnome2 Gtk::TrayIcon

I was playing with the Gtk::TrayIcon to create something like Gaim's tray icon. As you can see from the example, it is definately no so helpful to a GTK/GTK2 newbie like me.

I want to create a button-like icon where I can click on it and a new window pops up, like Gaim. :) The example only shows how to add Gtk::Label and I was wondering how the hell to put a icon where I can click. The trick is to use Gtk::EventBox and wrapped inside the icon you want to use. I will save you the trouble of going through the loop by showing you the code below.

require ‘gtktrayicon‘


window =
window.title = “Test window for fun and maybe profit“

tray =“test“)

icon =“tools.svg“, 24, 24))
clickableIcon =

clickableIcon.signal_connect(“button_press_event“) {
puts “hello world”




1 comment:

Jazz said...

Thank's man!!!

You really saved me a lot of problems :)

Now I can only concentrate on creating menus, etc.