Module: GObject

Defined in:
lib/ffi-gobject.rb,
lib/ffi-gobject/value.rb,
lib/ffi-gobject/object.rb,
lib/ffi-gobject/closure.rb,
lib/gir_ffi-base/gobject.rb,
lib/ffi-gobject/param_spec.rb,
lib/ffi-gobject/object_class.rb,
lib/ffi-gobject/ruby_closure.rb,
lib/gir_ffi-base/gobject/lib.rb,
lib/ffi-gobject/initially_unowned.rb

Overview

The part of the GObject namespace that is needed by GirFFI.

:reek:TooManyConstants because it needs to hold the type constants.

Defined Under Namespace

Modules: Lib Classes: Closure, InitiallyUnowned, Object, ObjectClass, ParamSpec, RubyClosure, Value

Constant Summary collapse

TYPE_INVALID =
type_from_name("invalid")
TYPE_NONE =
type_from_name("void")
TYPE_INTERFACE =
type_from_name("GInterface")
TYPE_CHAR =
type_from_name("gchar")
TYPE_UCHAR =
type_from_name("guchar")
TYPE_BOOLEAN =
type_from_name("gboolean")
TYPE_INT =
type_from_name("gint")
TYPE_UINT =
type_from_name("guint")
TYPE_LONG =
type_from_name("glong")
TYPE_ULONG =
type_from_name("gulong")
TYPE_INT64 =
type_from_name("gint64")
TYPE_UINT64 =
type_from_name("guint64")
TYPE_ENUM =
type_from_name("GEnum")
TYPE_FLAGS =
type_from_name("GFlags")
TYPE_FLOAT =
type_from_name("gfloat")
TYPE_DOUBLE =
type_from_name("gdouble")
TYPE_STRING =
type_from_name("gchararray")
TYPE_POINTER =
type_from_name("gpointer")
TYPE_BOXED =
type_from_name("GBoxed")
TYPE_PARAM =
type_from_name("GParam")
TYPE_OBJECT =
type_from_name("GObject")
TYPE_GTYPE =
type_from_name("GType")
TYPE_VARIANT =
type_from_name("GVariant")
TYPE_ARRAY =
Lib.g_array_get_type
TYPE_BYTE_ARRAY =
Lib.g_byte_array_get_type
TYPE_ERROR =
Lib.g_error_get_type
TYPE_HASH_TABLE =
Lib.g_hash_table_get_type
TYPE_STRV =
Lib.g_strv_get_type

Class Method Summary collapse

Class Method Details

.signal_connect(object, detailed_signal, data = nil, after = false, &block) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/ffi-gobject.rb', line 50

def self.signal_connect(object, detailed_signal, data = nil, after = false, &block)
  block or raise ArgumentError, "Block needed"

  signal_name, = detailed_signal.split("::")
  sig_info = object.class.find_signal signal_name

  closure = sig_info.wrap_in_closure do |*args|
    yield(*args << data)
  end

  signal_connect_closure object, detailed_signal, closure, after
end

.signal_connect_after(object, detailed_signal, data = nil, &block) ⇒ Object



63
64
65
# File 'lib/ffi-gobject.rb', line 63

def self.signal_connect_after(object, detailed_signal, data = nil, &block)
  signal_connect object, detailed_signal, data, true, &block
end

.signal_emit(object, detailed_signal, *args) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ffi-gobject.rb', line 38

def self.signal_emit(object, detailed_signal, *args)
  signal, detail = detailed_signal.split("::")
  signal_id = signal_lookup_from_instance signal, object
  detail_quark = GLib.quark_from_string(detail)

  sig_info = object.class.find_signal signal
  argument_gvalues = sig_info.arguments_to_gvalues object, args
  return_gvalue = sig_info.gvalue_for_return_value

  signal_emitv argument_gvalues, signal_id, detail_quark, return_gvalue
end

.signal_lookup_from_instance(signal, object) ⇒ Object



34
35
36
# File 'lib/ffi-gobject.rb', line 34

def self.signal_lookup_from_instance(signal, object)
  signal_lookup signal, type_from_instance(object)
end

.type_from_instance(instance) ⇒ Object



26
27
28
# File 'lib/ffi-gobject.rb', line 26

def self.type_from_instance(instance)
  type_from_instance_pointer instance.to_ptr
end

.type_from_instance_pointer(inst_ptr) ⇒ Object



19
20
21
22
23
24
# File 'lib/ffi-gobject.rb', line 19

def self.type_from_instance_pointer(inst_ptr)
  return nil if inst_ptr.null?

  klsptr = inst_ptr.get_pointer 0
  klsptr.get_gtype 0
end

.type_from_name(name) ⇒ Object



12
13
14
# File 'lib/gir_ffi-base/gobject.rb', line 12

def self.type_from_name(name)
  Lib.g_type_from_name name
end

.type_fundamental(gtype) ⇒ Object



16
17
18
# File 'lib/gir_ffi-base/gobject.rb', line 16

def self.type_fundamental(gtype)
  Lib.g_type_fundamental gtype
end

.type_name_from_instance(instance) ⇒ Object



30
31
32
# File 'lib/ffi-gobject.rb', line 30

def self.type_name_from_instance(instance)
  type_name type_from_instance instance
end