class GObject::Object

Overrides for GObject, GObject's generic base class.

Public Instance Methods

get_property(property_name)
get_property_with_override(property_name) click to toggle source
# File lib/ffi-gobject/object.rb, line 27
def get_property_with_override property_name
  type_info = get_property_type property_name
  pspec = type_class.find_property property_name

  gvalue = GObject::Value.for_g_type pspec.value_type
  get_property_without_override property_name, gvalue

  case type_info.tag
  when :ghash, :glist
    adjust_value_to_type gvalue.get_value_plain, type_info
  else
    gvalue.get_value
  end
end
Also aliased as: get_property
get_property_without_override(property_name)
Alias for: get_property
method_missing(method, *args) click to toggle source

TODO: Generate accessor methods from GIR at class definition time

Calls superclass method
# File lib/ffi-gobject/object.rb, line 10
def method_missing(method, *args)
  if respond_to?("get_#{method}")
    return send("get_#{method}", *args)
  end
  if method.to_s =~ /(.*)=$/ && respond_to?("set_#{$1}")
    return send("set_#{$1}", *args)
  end
  super
end
set_property(property_name, value)
set_property_with_override(property_name, value) click to toggle source
# File lib/ffi-gobject/object.rb, line 42
def set_property_with_override property_name, value
  type_info = get_property_type property_name
  pspec = type_class.find_property property_name

  gvalue = GObject::Value.for_g_type pspec.value_type
  gvalue.set_value adjust_value_to_type(value, type_info)
  set_property_without_override property_name, gvalue
end
Also aliased as: set_property
set_property_without_override(property_name, value)
Alias for: set_property
signal_connect(event, &block) click to toggle source
# File lib/ffi-gobject/object.rb, line 20
def signal_connect(event, &block)
  GObject.signal_connect(self, event, &block)
end
type_class() click to toggle source
# File lib/ffi-gobject/object.rb, line 51
def type_class
  GObject::ObjectClass.wrap(self.to_ptr.get_pointer 0)
end

Private Instance Methods

adjust_value_to_type(val, type_info) click to toggle source

TODO: Move to ITypeInfo

# File lib/ffi-gobject/object.rb, line 69
def adjust_value_to_type val, type_info
  case type_info.flattened_tag
  when :ghash
    GLib::HashTable.from type_info.element_type, val
  when :glist
    GLib::List.from type_info.element_type, val
  when :strv
    GLib::Strv.from val
  else
    val
  end
end
get_property_type(property_name) click to toggle source
# File lib/ffi-gobject/object.rb, line 63
def get_property_type property_name
  prop = self.class.find_property property_name
  prop.property_type
end