view subtly/gdk.rb @ 24:4652f9744833

Added selection atoms
author unexist
date Fri, 22 Jan 2010 14:37:21 +0100
parents 9d46c05b49f6
children 6838c7123945
line wrap: on
line source
##
# @package subtly
#
# @file Gdk bindings
# @author Christoph Kappel <unexist@dorfelite.net>
# @version $Id: subtly/gdk.rb,v 24 1264167441.0-3600 unexist $
#
# This program can be distributed under the terms of the GNU GPL.
##

require "ffi"

module Subtly
  module Gdk
    extend FFI::Library

    ffi_lib("libgdk-x11-2.0")

    ## ffi_thread_enter
    # Enter protected area
    ##
   
    attach_function(:ffi_thread_enter,
      :gdk_threads_init, [ ], :void
    )

    ## ffi_thread_leave
    # Leave protected area
    ##  
   
    attach_function(:ffi_thread_leave,
      :gdk_threads_enter, [ ], :void
    )

    ## ffi_parse_color
    # Parse color name
    #
    # @param  [String,  #read]   Color name
    # @param  [Pointer, #write]  Store color here
    ##
   
    attach_function(:ffi_parse_color,
      :gdk_color_parse, [ :string, :pointer ], :void
    )

    ## ffi_parse_key
    # Parse key name
    #
    # @param  [String,  #read]   Color name
    #
    # @return [Uint] Converted keyval
    ##

    attach_function(:ffi_parse_key,
      :gdk_keyval_from_name, [ :string ], :uint
    )

    # Color {{{
    class Color < FFI::Struct
      layout(
        :pixel, :uint,
        :red,   :uint,
        :green, :uint,
        :blue,  :uint
      )
    end # }}}

    # EventKey {{{
    class EventKey < FFI::Struct
      layout(
        :type,             :int,
        :window,           :pointer,
        :send_event,       :int8,
        :time,             :uint32,
        :state,            :uint,
        :keyval,           :uint,
        :length,           :int,
        :string,           :string,
        :hardware_keycode, :uint16,
        :group,            :uint8,
        :is_modifier,      :int8
      )
    end # }}}

    # Special keys
    Keys = enum(
      :return,    0xff0d,
      :escape,    0xff1b,
      :delete,    0xffff,
      :backspace, 0xff08,
      :tab,       0xff09,
      :colon,     0x10020a1
    )

    # List of selection atoms
    Selections = enum(
      :primary,   1,
      :secondary, 2,
      :clipboard, 69
    )
  end
end