DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Using Glade Interface File In Ruby-gnome2.

07.04.2005
| 5403 views |
  • submit to reddit
        
require 'gtk2'
require 'libglade2'

class SignalHandler
  def method_missing(method, *args)
    puts "#{method}: #{args}"
  end
end
sigmap = SignalHandler.new

Gtk.init
glade = GladeXML.new('hello.glade', nil, 'helloglade')
window = glade['main_window']
window.signal_connect("destroy") { Gtk.main_quit }
glade.signal_autoconnect_full do |source, target, signal, handler, data|
  source.signal_connect(signal) { sigmap.send(handler, data) }
end

window.show
Gtk.main

I did not know what file should I require. :(