Class: Vips::Object
- Inherits:
-
GObject::GObject
- Object
- GObject::GObject
- Vips::Object
- Defined in:
- lib/vips/object.rb
Direct Known Subclasses
Connection, Image, Interpolate, MutableImage, Operation, Region
Defined Under Namespace
Modules: ObjectLayout Classes: ManagedStruct, Struct
Instance Attribute Summary
Attributes inherited from GObject::GObject
Class Method Summary collapse
-
.print_all ⇒ Object
print all active VipsObjects, with their reference counts.
Instance Method Summary collapse
- #get(name) ⇒ Object
-
#get_pspec(name) ⇒ Object
return a pspec, or nil …
-
#get_typeof(name) ⇒ Object
return a gtype, 0 on not found.
-
#get_typeof_error(name) ⇒ Object
return a gtype, raise an error on not found.
- #set(name, value) ⇒ Object
- #signal_connect(name, handler = nil, &block) ⇒ Object
Methods inherited from GObject::GObject
#ffi_managed_struct, ffi_managed_struct, #ffi_struct, ffi_struct, #initialize
Constructor Details
This class inherits a constructor from GObject::GObject
Class Method Details
Instance Method Details
#get(name) ⇒ Object
233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/vips/object.rb', line 233 def get name gtype = get_typeof_error name gvalue = GObject::GValue.alloc gvalue.init gtype GObject.g_object_get_property self, name, gvalue result = gvalue.get gvalue.unset GLib.logger.debug("Vips::Object.get") { "#{name} == #{result}" } result end |
#get_pspec(name) ⇒ Object
return a pspec, or nil … nil wil leave a message in the error log which you must clear
202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/vips/object.rb', line 202 def get_pspec name ppspec = GObject::GParamSpecPtr.new argument_class = Vips::ArgumentClassPtr.new argument_instance = Vips::ArgumentInstancePtr.new result = Vips.vips_object_get_argument self, name, ppspec, argument_class, argument_instance return nil if result != 0 ppspec[:value] end |
#get_typeof(name) ⇒ Object
return a gtype, 0 on not found
223 224 225 226 227 228 229 230 231 |
# File 'lib/vips/object.rb', line 223 def get_typeof name pspec = get_pspec name unless pspec Vips.vips_error_clear return 0 end pspec[:value_type] end |
#get_typeof_error(name) ⇒ Object
return a gtype, raise an error on not found
215 216 217 218 219 220 |
# File 'lib/vips/object.rb', line 215 def get_typeof_error name pspec = get_pspec name raise Vips::Error unless pspec pspec[:value_type] end |
#set(name, value) ⇒ Object
246 247 248 249 250 251 252 253 254 255 |
# File 'lib/vips/object.rb', line 246 def set name, value GLib.logger.debug("Vips::Object.set") { "#{name} = #{value}" } gtype = get_typeof_error name gvalue = GObject::GValue.alloc gvalue.init gtype gvalue.set value GObject.g_object_set_property self, name, gvalue gvalue.unset end |
#signal_connect(name, handler = nil, &block) ⇒ Object
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/vips/object.rb', line 257 def signal_connect name, handler = nil, &block marshal = MARSHAL_ALL[name.to_sym] raise Vips::Error, "unsupported signal #{name}" if marshal.nil? if block # our block as a Proc prc = block elsif handler # We assume the hander is a Proc (perhaps we should test) prc = handler else raise Vips::Error, "must supply either block or handler" end # The marshal function will make a closure with the right type signature # for the selected signal callback = marshal.call(prc) # we need to make sure this is not GCd while self is alive @references << callback GObject.g_signal_connect_data(self, name.to_s, callback, nil, nil, 0) end |