#------------------------------------- Enhance example -------------------------------
# This example sucks. Expect better examples soon.
# You should be able to get the idea anyway, since enhance is a really small library
# See also the Etk examples.
#-------------------------------------------------------------------------------------
require 'dl/ffcall-callback'
#require 'ruby-efl/enhance/ruby-enhance'
require File.dirname(File.expand_path(__FILE__)) + '/../ruby-enhance.rb'
include Etk
include Enhance
CClass.debug = true # uncomment this for lots of debug info
CClass.debug_level = [:misc]
EnhanceBase.init
EtkBase.init(0, nil)
en = EnhanceBase.new
en.signal_handling = Enhance::SIGNAL_STORE
en.file_load("window1", File.dirname(File.expand_path(__FILE__)) + "/dialog.glade")
window1 = en.var_get("window1")
class Event_Handlers
attr_accessor :somevar
def initialize
@somevar = nil
end
def cancel_clicked(target, data)
puts "Value of foo.bar is now: #{@somevar}"
end
end
h = Event_Handlers.new
# (1) As you can see, you can pass an object instance to autoconnect. it's more straightforward
en.autoconnect(h)
# (2) At this point if you could click the cancel button, @somevar would be nil at this point
# (3) But we can just reassing it to whatever we want, even another object
h.somevar = "Hej!"
win = Dialog.wrap(window1)
win << Etk::DeleteEventSignal.new { EtkBase.main_quit }
win.show
EtkBase.main
EtkBase.shutdown
en.free
EnhanceBase.shutdown