class Gtk::GObject
Attributes
native[RW]
type[RW]
Public Class Methods
new(*args)
click to toggle source
# File lib/gtk.rb, line 101 def initialize *args raise "hell" unless args.size == 1 && args.first.is_a?(FFI::Pointer) @native = args.first end
type_register()
click to toggle source
# File lib/gtk.rb, line 106 def self.type_register type_name = name.gsub(/::/,'__') cell_progress_info = Lib::GTypeInfo.new @type = Lib.g_type_register_static( superclass.type, type_name, cell_progress_info.ref, 0 ) end
Public Instance Methods
method_missing(method,*args)
click to toggle source
# File lib/gtk.rb, line 128 def method_missing method,*args method = "set_#{method.to_s[0..-2]}".to_sym if method.to_s[-1] == '=' getter = "get_#{method}".to_sym klass = self.class while klass raise "hell #{method} #{self.inspect}" if klass == Object return send(getter,*args) if respond_to?(getter) name = "gtk_#{klass.name.split('::').last.underscore}_#{method}".to_sym getter_name = "gtk_#{klass.name.split('::').last.underscore}_#{getter}".to_sym if m = (Lib.attached_methods[name] || Lib.attached_methods[getter_name]) raise "#{self.class.name}: #{method}" unless m if m[:args].last == :varargs raise ArgumentError.new unless m[:args].size <= (args.size+1) else raise ArgumentError.new unless m[:args].size == (args.size+1) end types = m[:args][1..-1] args = args.map do |arg| type = types.shift if arg.is_a?(GObject) arg.native elsif arg.is_a?(Symbol) && type.respond_to?(:superclass) && type.superclass == Enums type[arg] else arg end end return Lib.send(m[:name],@native,*args) end klass = klass.superclass end end
signal_connect(name,&block)
click to toggle source
# File lib/gtk.rb, line 117 def signal_connect(name,&block) callback = FFI::Function.new(:void, [:pointer]) do |data| block.call end Lib.g_signal_connect_data(native,name,callback,nil,nil,0) end
unref()
click to toggle source
# File lib/gtk.rb, line 124 def unref Lib.g_object_unref(native) end