view subtly/glib.rb @ 4:705abf5135fe

Added GObject#signal_connect
author unexist
date Sun, 13 Dec 2009 04:30:39 +0100
parents 87b46f01d08d
children da4347585d4f
line wrap: on
line source
##
# @package subtly
#
# @file Glib bindings
# @author Christoph Kappel <unexist@dorfelite.net>
# @version $Id: subtly/glib.rb,v 4 1260675039.0-3600 unexist $
#
# This program can be distributed under the terms of the GNU GPL.
##

require "ffi"

module Subtly
  module GThread
    extend FFI::Library

    ffi_lib("libgthread-2.0")

    ## ffi_init
    # Init thread system
    #
    # @param  [Pointer, #read]  Just don't use, #GThreadFunctions
    ##

    attach_function(:ffi_init,
      :g_thread_init, [ :pointer ], :void
    )
  end

  module GObject
    extend FFI::Library

    ffi_lib("libgobject-2.0")

    # Callback type
    callback :g_callback2, [ :pointer, :pointer ], :void
    callback :g_callback3, [ :pointer, :int, :pointer ], :void
    callback :g_callback4, [ :pointer, :string, :string, :pointer ], :void

    ## ffi_signal_connect
    # Add signal callback
    #
    # @param  [Pointer, #read]  Widget to attach callback
    # @param  [String,  #read]  Signal name
    # @param  [Pointer, #read]  Callback function
    # @param  [Pointer, #read]  Callback data
    ##

    attach_function(:ffi_signal_connect2,
      :g_signal_connect_data, [ :pointer, :string, :g_callback2, :pointer, :pointer, :int ], :ulong
    )
    attach_function(:ffi_signal_connect3,
      :g_signal_connect_data, [ :pointer, :string, :g_callback3, :pointer, :pointer, :int ], :ulong
    )
    attach_function(:ffi_signal_connect4,
      :g_signal_connect_data, [ :pointer, :string, :g_callback4, :pointer, :pointer, :int ], :ulong
    )
  end
end