Forum: Ruby-Gnome 2 How to use Builder.connect_signals?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
73774e40803092ae5ef7ec4efaab11a5?d=identicon&s=25 Daniel King (danielking)
on 2008-12-18 10:46
I think it's different with the one in pygtk. If I define a class with
member functions such as 'on_window_destory', how can I make the signal
'destroy' which defined in a gtkbuilder file(an xml file generated by
glade3) connect to the handler 'on_window_destory' automatically?


class MainWindow
  def initialize
    @builder = Builder.new
    @builder << 'ui/main.ui'
    @builder.connect_signals{|name|

    }

    @win = @builder.get_object 'window'
    @win.show_all
  end

  def on_window_destory
    main_quit
  end
end
73774e40803092ae5ef7ec4efaab11a5?d=identicon&s=25 Daniel King (danielking)
on 2008-12-18 11:34
I got the answer by myself.

class MainWindow
  def initialize
    @builder = Builder.new
    @builder << 'ui/main.ui'
    @builder.connect_signals{|name|
      method(name)
    }

    @win = @builder['window']
    @win.show_all
  end

  def on_window_destroy
    main_quit
  end

end
This topic is locked and can not be replied to.