Thank you Andrea for that very helpful tip. I have a followup question:
How do I attach events in my ruby code to access the events I create in
Glade?
Here’s my question exactly:
Using glade, I created a file called “button.glade”. It is just a basic
window with a button in the middle of it. I set visible to true so it
would be visible. Then I selected the button object, clicked on the
“Signals” tab, and set the "clicked event to:
on_button1_clicked
In a similar fashion I set the on_window_destroy event to
on_window1_destroy.
I saved the file as button.glade with the property set to use libglade.
Then I ran this command:
ruby-glade-create-interface button.glade > button.rb
It created this skeleton program:
#!/usr/bin/env ruby
This file is gererated by ruby-glade-create-template 1.1.4.
require ‘libglade2’
class ButtonGlade
include GetText
attr :glade
def initialize(path_or_data, root = nil, domain = nil, localedir =
nil, flag = GladeXML::FILE)
bindtextdomain(domain, localedir, nil, “UTF-8”)
@glade = GladeXML.new(path_or_data, root, domain, localedir, flag)
{|handler| method(handler)}
end
def on_button1_clicked(widget)
puts “on_button1_clicked() is not implemented yet.”
end
def on_window1_destroy(widget)
puts “on_window1_destroy() is not implemented yet.”
end
end
Main program
if FILE == $0
Set values as your own application.
PROG_PATH = “button.glade”
PROG_NAME = “YOUR_APPLICATION_NAME”
ButtonGlade.new(PROG_PATH, nil, PROG_NAME)
Gtk.main
end
As you can see the methods “on_button1_clicked” and “on_window_destroy”
are easy to understand.
How do I make this exact same skeliton program for a GTKBuilder/ruby
program? I can get the window to pop-up using your advise from your
last post, but I can’t get the window to call Gtk.main_quit().
I’m attaching the file button.glade saved in gtkbuilder format. Can you
make a working file button.rb that has methods to destroy properly, and
spit out a message when you click the button?
Thanks in advance,
Eric