changeset 42:c6f35cf6c4f6

Added GObject.set
author unexist
date Sun, 24 Jan 2010 01:55:42 +0100
parents 9cd17ff76e97
children 0d42b4c43eb7
files subtly/gobject.rb
diffstat 1 files changed, 33 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/subtly/gobject.rb	Sun Jan 24 01:55:27 2010 +0100
+++ b/subtly/gobject.rb	Sun Jan 24 01:55:42 2010 +0100
@@ -11,17 +11,29 @@
 require "ffi"
 
 module Subtly
-  module GObject
+  module GObject # {{{
     extend FFI::Library
 
     ffi_lib("libgobject-2.0")
 
+    ## set {{{
+    # Set object options
+    #
+    # @param [Object,  #read]  object               A #GObject
+    # @param [String,  #read]  first_property_name  Name of the first property
+    # @param [Pointer, #read]  value                Value for property
+    ##
+
+    def self.set(object, name, value)
+      Subtly::GObject.ffi_set(object, name, value.to_wid, nil)
+    end # }}}
+
     # Callback type
     callback :g_callback2, [ :pointer, :pointer ],                     :void
     callback :g_callback3, [ :pointer, :pointer, :pointer ],           :void
     callback :g_callback4, [ :pointer, :pointer, :pointer, :pointer ], :void
 
-    ## ffi_signal_connect
+    ## ffi_signal_connect {{{
     # Add signal callback
     #
     # @param [Pointer, #read]  Widget to attach callback
@@ -39,5 +51,23 @@
     attach_function(:ffi_signal_connect4,
       :g_signal_connect_data, [ :pointer, :string, :g_callback4, :pointer, :pointer, :int ], :ulong
     )
-  end
+    # }}} 
+
+    private
+
+    ## ffi_set
+    # Set object options
+    #
+    # @param [Pointer, #read]  object               A #GObject
+    # @param [String,  #read]  first_property_name  Name of the first property
+    # @param [Pointer, #read]  value                Value for property
+    # @param [Pointer, #read]  data                 Nil data
+    ##
+
+    attach_function(:ffi_set,
+      :g_object_set, [ :pointer, :string, :pointer, :pointer ], :void
+    )
+  end # }}}
 end
+
+# vim:ts=2:bs=2:sw=2:et:fdm=marker