How to use Builder.connect_signals?


#1

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


#2

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