I have an interface that I created in Glade3. I’ve used
ruby-glade-create-template to create my initial code file. In the glade
template I made a horizontal box with one cell which I named gl_box.
I my code I’ve since created a Gtk::DrawingArea object which I would
like to pack into the gl_box. I’ve attached the code. The attempt I made
is at line 24.
#!/usr/bin/env ruby
This file is gererated by ruby-glade-create-template 1.1.4.
require ‘libglade2’
require ‘drawing_area’
class Interface02Glade < Gtk::Window
include GetText
attr :glade
def initialize(path_or_data, root = nil, domain = nil, localedir =
nil, flag = GladeXML::FILE)
super(“DRCAM”)
bindtextdomain(domain, localedir, nil, “UTF-8”)
@glade = GladeXML.new(path_or_data, root, domain, localedir, flag)
{|handler| method(handler)}
glconfig = create_glconfig
set_reallocate_redraws(true)
signal_connect("delete_event"){ Gtk.main_quit}
@cnc_drawing_area = CNCDrawingArea.new(glconfig)
@cnc_drawing_area.set_size_request(640,480)
#gl_box.pack_start(@cnc_drawing_area, true, true, 0)
end
def create_glconfig # Gdk::GLConfig.new([screen,]
attrib_list/mode)–Returns an OpenGL frame buffer configuration that
matches the specified configuration.
# Try double-buffered visual
glconfig = Gdk::GLConfig.new(Gdk::GLConfig::MODE_RGB|
Gdk::GLConfig::MODE_DEPTH|
Gdk::GLConfig::MODE_DOUBLE)
unless glconfig
puts "*** Cannot find the double-buffered visual."
puts "*** Trying single-buffered visual."
# Try single-buffered visual
glconfig = Gdk::GLConfig.new(Gdk::GL::MODE_RGB|
Gdk::GL::MODE_DEPTH)
raise "No appropriate OpenGL-capable visual found." unless
glconfig
end
glconfig
end
end
Main program
if FILE == $0
Set values as your own application.
PROG_PATH = “interface_layouts/interface-02.glade”
PROG_NAME = “YOUR_APPLICATION_NAME”
Interface02Glade.new(PROG_PATH, nil, PROG_NAME)
Gtk.main
end
What is the correct way to reference the widgets made via Glade3? Thanks
in advance for any help.