Sha256: 79f44df9197ef23630052921194c6d873289820ec12394e14c5cf1912dcaa905
Contents?: true
Size: 1.63 KB
Versions: 1
Compression:
Stored size: 1.63 KB
Contents
module FFI module Tk extend FFI::Library ffi_lib 'libtk8.5.so', 'libtk.so', *::Tk::LIBPATH[:tk] class XColor < FFI::Struct layout( :pixel, :ulong, :red, :ushort, :green, :ushort, :blue, :ushort, :flags, :char, :pad, :char ) def red self[:red] end def green self[:green] end def blue self[:blue] end end # This is opaque class Window < FFI::Struct end attach_function :Tk_Init, [:pointer], :int attach_function :Tk_MainWindow, [Tcl::Interp], Window attach_function :Tk_GetColor, [Tcl::Interp, Window, name = :string], XColor attach_function :Tk_MainLoop, [], :void module_function def get_color(interp, string) if ::Tk::RUN_EVENTLOOP_ON_MAIN_THREAD XColor.new(Tk_GetColor(interp, Tk_MainWindow(interp), string)) else Tcl.thread_sender.thread_send{ XColor.new(Tk_GetColor(interp, Tk_MainWindow(interp), string)) } end end def mainloop if ::Tk::RUN_EVENTLOOP_ON_MAIN_THREAD Tk_MainLoop() else Tcl.thread_sender.thread_send{ Tk_MainLoop() } end end def init(interp) if ::Tk::RUN_EVENTLOOP_ON_MAIN_THREAD if Tk_Init(interp) == 1 message = Tcl.Tcl_GetStringResult(interp) raise RuntimeError, message end else Tcl.thread_sender.thread_send do if Tk_Init(interp) == 1 message = Tcl.Tcl_GetStringResult(interp) raise RuntimeError, message end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ffi-tk-2010.02 | lib/ffi-tk/ffi/tk.rb |