Sha256: 979af188ae1d161c5bf88e926d6b8cb07c970004dd62e4f3737bf9ac2a6e8cd0

Contents?: true

Size: 821 Bytes

Versions: 3

Compression:

Stored size: 821 Bytes

Contents

module FFI
  module Tk
    extend FFI::Library
    ffi_lib 'libtk8.5.so', 'libtk.so', *::Tk::LIBPATH[:tk]

    attach_function :Tk_Init, [:pointer], :int
    attach_function :Tk_MainLoop, [], :void

    module_function

    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

3 entries across 3 versions & 1 rubygems

Version Path
ffi-tk-2010.01.02 lib/ffi-tk/ffi/tk.rb
ffi-tk-2009.12.14 lib/ffi-tk/ffi/tk.rb
ffi-tk-2009.11.29 lib/ffi-tk/ffi/tk.rb