class GObject::Object
- GObject::Object
- Reference
- Object
Overview
The base object type.
All the fields in the GObject
structure are private to the implementation
and should never be accessed directly.
Since GLib 2.72, all #GObjects are guaranteed to be aligned to at least the alignment of the largest basic GLib type (typically this is #guint64 or #gdouble). If you need larger alignment for an element in a #GObject, you should allocate it on the heap (aligned), or arrange for your #GObject to be appropriately padded. This guarantee applies to the #GObject (or derived) struct, the #GObjectClass (or derived) struct, and any private data allocated by G_ADD_PRIVATE().
Direct Known Subclasses
- Gdk::Clipboard
- Gdk::ContentDeserializer
- Gdk::ContentProvider
- Gdk::ContentSerializer
- Gdk::Cursor
- Gdk::Device
- Gdk::DeviceTool
- Gdk::Display
- Gdk::DisplayManager
- Gdk::Drag
- Gdk::DrawContext
- Gdk::Drop
- Gdk::FrameClock
- Gdk::Monitor
- Gdk::Seat
- Gdk::Snapshot
- Gdk::Surface
- Gdk::Texture
- GdkPixbuf::Pixbuf
- GdkPixbuf::PixbufAnimation
- GdkPixbuf::PixbufAnimationIter
- GdkPixbuf::PixbufLoader
- Gio::AppInfoMonitor
- Gio::AppLaunchContext
- Gio::Application
- Gio::ApplicationCommandLine
- Gio::BytesIcon
- Gio::Cancellable
- Gio::CharsetConverter
- Gio::Credentials
- Gio::DBusActionGroup
- Gio::DBusAuthObserver
- Gio::DBusConnection
- Gio::DBusInterfaceSkeleton
- Gio::DBusMessage
- Gio::DBusMethodInvocation
- Gio::DBusObjectManagerClient
- Gio::DBusObjectManagerServer
- Gio::DBusObjectProxy
- Gio::DBusObjectSkeleton
- Gio::DBusProxy
- Gio::DBusServer
- Gio::DebugControllerDBus
- Gio::DesktopAppInfo
- Gio::Emblem
- Gio::EmblemedIcon
- Gio::FileEnumerator
- Gio::FileIcon
- Gio::FileInfo
- Gio::FileMonitor
- Gio::FilenameCompleter
- Gio::InetAddress
- Gio::InetAddressMask
- Gio::InputStream
- Gio::IOStream
- Gio::ListStore
- Gio::MenuAttributeIter
- Gio::MenuItem
- Gio::MenuLinkIter
- Gio::MenuModel
- Gio::MountOperation
- Gio::NetworkAddress
- Gio::NetworkService
- Gio::Notification
- Gio::OutputStream
- Gio::Permission
- Gio::PropertyAction
- Gio::Resolver
- Gio::Settings
- Gio::SettingsBackend
- Gio::SimpleAction
- Gio::SimpleActionGroup
- Gio::SimpleAsyncResult
- Gio::SimpleProxyResolver
- Gio::Socket
- Gio::SocketAddress
- Gio::SocketAddressEnumerator
- Gio::SocketClient
- Gio::SocketControlMessage
- Gio::SocketListener
- Gio::Subprocess
- Gio::SubprocessLauncher
- Gio::Task
- Gio::TestDBus
- Gio::ThemedIcon
- Gio::TlsCertificate
- Gio::TlsDatabase
- Gio::TlsInteraction
- Gio::TlsPassword
- Gio::UnixFDList
- Gio::UnixMountMonitor
- Gio::Vfs
- Gio::VolumeMonitor
- Gio::ZlibCompressor
- Gio::ZlibDecompressor
- GObject::Binding
- GObject::BindingGroup
- GObject::InitiallyUnowned
- GObject::SignalGroup
- GObject::TypeModule
- Gsk::GLShader
- Gsk::Renderer
- Gtk::AssistantPage
- Gtk::ATContext
- Gtk::BookmarkList
- Gtk::Builder
- Gtk::BuilderCScope
- Gtk::CellAreaContext
- Gtk::ColumnViewColumn
- Gtk::Constraint
- Gtk::ConstraintGuide
- Gtk::CssProvider
- Gtk::DirectoryList
- Gtk::EntryBuffer
- Gtk::EntryCompletion
- Gtk::EventController
- Gtk::Filter
- Gtk::FilterListModel
- Gtk::FlattenListModel
- Gtk::IconPaintable
- Gtk::IconTheme
- Gtk::IMContext
- Gtk::LayoutChild
- Gtk::LayoutManager
- Gtk::ListItem
- Gtk::ListItemFactory
- Gtk::ListStore
- Gtk::MapListModel
- Gtk::MediaStream
- Gtk::MultiSelection
- Gtk::NativeDialog
- Gtk::NoSelection
- Gtk::NotebookPage
- Gtk::PageSetup
- Gtk::PrintContext
- Gtk::Printer
- Gtk::PrintJob
- Gtk::PrintOperation
- Gtk::PrintSettings
- Gtk::RecentManager
- Gtk::SelectionFilterModel
- Gtk::Settings
- Gtk::Shortcut
- Gtk::ShortcutAction
- Gtk::ShortcutTrigger
- Gtk::SingleSelection
- Gtk::SizeGroup
- Gtk::SliceListModel
- Gtk::Sorter
- Gtk::SortListModel
- Gtk::StackPage
- Gtk::StringList
- Gtk::StringObject
- Gtk::StyleContext
- Gtk::TextBuffer
- Gtk::TextChildAnchor
- Gtk::TextMark
- Gtk::TextTag
- Gtk::TextTagTable
- Gtk::Tooltip
- Gtk::TreeListModel
- Gtk::TreeListRow
- Gtk::TreeModelFilter
- Gtk::TreeModelSort
- Gtk::TreeSelection
- Gtk::TreeStore
- Gtk::WidgetPaintable
- Gtk::WindowGroup
- Pango::Context
- Pango::Coverage
- Pango::Font
- Pango::FontFace
- Pango::FontFamily
- Pango::FontMap
- Pango::Fontset
- Pango::Layout
- Pango::Renderer
Defined in:
lib/gi-crystal/src/auto/g_object-2.0/object.crlib/gi-crystal/src/bindings/g_object/object.cr
Constructors
-
.cast(obj : GObject::Object) : self
Cast a
GObject::Object
toself
, throws aTypeCastError
if the cast can't be made. - .new(pointer : Pointer(Void), transfer : GICrystal::Transfer)
- .new
-
.newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self
Creates a new instance of a #GObject subtype and sets its properties.
DEPRECATED
Class Method Summary
-
.cast?(obj : GObject::Object) : self | Nil
Cast a
GObject::Object
toself
, returns nil if the cast can't be made. - .compat_control(what : UInt64, data : Pointer(Void) | Nil) : UInt64
-
.g_type : UInt64
Returns the type id (GType) registered in GLib type system.
-
.interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec
Find the #GParamSpec with the given name for an interface.
-
.interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec)
Lists the properties of an interface.Generally, the interface vtable passed in as g_iface will be the default vtable from g_type_default_interface_ref(), or, if you know the interface has already been loaded, g_type_default_interface_peek().
Macro Summary
-
previous_vfunc(*args)
To be used inside a vfunc (re)-implementation.
-
previous_vfunc!(*args)
To be used inside a vfunc (re)-implementation.
-
signal(signature)
Declares a GObject signal.
Instance Method Summary
-
#==(other : self)
Returns
true
if this reference is the same as other. -
#bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding
Creates a binding between source_property on source and target_property on target.
-
#bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding
Complete version of g_object_bind_property().
-
#data(key : String) : Pointer(Void) | Nil
Gets a named field from the objects table of associations (see g_object_set_data()).
-
#finalize
Called by the garbage collector.
-
#freeze_notify : Nil
Increases the freeze count on object.
-
#getv(names : Enumerable(String), values : Enumerable(_)) : Nil
Gets n_properties properties for an object.
- #hash(hasher)
-
#notify(property_name : String) : Nil
Emits a "notify" signal for the property property_name on object.
-
#notify_by_pspec(pspec : GObject::ParamSpec) : Nil
Emits a "notify" signal for the property specified by pspec on object.
- #notify_signal
-
#property(property_name : String, value : _) : Nil
Gets a property of an object.
-
#qdata(quark : UInt32) : Pointer(Void) | Nil
This function gets back user data pointers stored via g_object_set_qdata().
-
#ref_count : UInt32
Returns GObject reference counter.
-
#run_dispose : Nil
Releases all references to other objects.
-
#set_data(key : String, data : Pointer(Void) | Nil) : Nil
Each object carries around a table of associations from strings to pointers.
-
#set_property(property_name : String, value : _) : Nil
Sets a property on an object.
-
#steal_data(key : String) : Pointer(Void) | Nil
Remove a specified datum from the object's data associations, without invoking the association's destroy handler.
-
#steal_qdata(quark : UInt32) : Pointer(Void) | Nil
This function gets back user data pointers stored via g_object_set_qdata() and removes the data from object without invoking its destroy() function (if any was set).
-
#thaw_notify : Nil
Reverts the effect of a previous call to g_object_freeze_notify().
-
#to_unsafe : Pointer(Void)
Returns a pointer to the C object.
-
#watch_closure(closure : GObject::Closure) : Nil
This function essentially limits the life time of the closure to the life time of the object.
Constructor Detail
Cast a GObject::Object
to self
, throws a TypeCastError
if the cast can't be made.
Creates a new instance of a #GObject subtype and sets its properties.
Construction parameters (see %G_PARAM_CONSTRUCT, %G_PARAM_CONSTRUCT_ONLY) which are not explicitly specified are set to their default values.
DEPRECATED
Class Method Detail
Cast a GObject::Object
to self
, returns nil if the cast can't be made.
Returns the type id (GType) registered in GLib type system.
Find the #GParamSpec with the given name for an interface. Generally, the interface vtable passed in as g_iface will be the default vtable from g_type_default_interface_ref(), or, if you know the interface has already been loaded, g_type_default_interface_peek().
Lists the properties of an interface.Generally, the interface vtable passed in as g_iface will be the default vtable from g_type_default_interface_ref(), or, if you know the interface has already been loaded, g_type_default_interface_peek().
Macro Detail
To be used inside a vfunc (re)-implementation. Has the same meaning of super
, but works with GObject virtual functions.
Do nothing is the current vfunc doesn't have any previous implementation.
To be used inside a vfunc (re)-implementation. Has the same meaning of super
, but works with GObject virtual functions.
Raises NilAssertionError if the current vfunc doesn't have any previous implementation.
Declares a GObject signal.
Supported signal parameter types are:
- Integer types
- Float types
Instance Method Detail
Returns true
if this reference is the same as other. Invokes same?
.
Creates a binding between source_property on source and target_property on target.
Whenever the source_property is changed the target_property is updated using the same value. For instance:
|[ g_object_bind_property (action, "active", widget, "sensitive", 0); ]|
Will result in the "sensitive" property of the widget #GObject instance to be updated with the same value of the "active" property of the action #GObject instance.
If flags contains %G_BINDING_BIDIRECTIONAL then the binding will be mutual: if target_property on target changes then the source_property on source will be updated as well.
The binding will automatically be removed when either the source or the target instances are finalized. To remove the binding without affecting the source and the target you can just call g_object_unref() on the returned #GBinding instance.
Removing the binding by calling g_object_unref() on it must only be done if the binding, source and target are only used from a single thread and it is clear that both source and target outlive the binding. Especially it is not safe to rely on this if the binding, source or target can be finalized from different threads. Keep another reference to the binding and use g_binding_unbind() instead to be on the safe side.
A #GObject can have multiple bindings.
Complete version of g_object_bind_property().
Creates a binding between source_property on source and target_property on target, allowing you to set the transformation functions to be used by the binding.
If flags contains %G_BINDING_BIDIRECTIONAL then the binding will be mutual: if target_property on target changes then the source_property on source will be updated as well. The transform_from function is only used in case of bidirectional bindings, otherwise it will be ignored
The binding will automatically be removed when either the source or the target instances are finalized. This will release the reference that is being held on the #GBinding instance; if you want to hold on to the #GBinding instance, you will need to hold a reference to it.
To remove the binding, call g_binding_unbind().
A #GObject can have multiple bindings.
The same user_data parameter will be used for both transform_to and transform_from transformation functions; the notify function will be called once, when the binding is removed. If you need different data for each transformation function, please use g_object_bind_property_with_closures() instead.
Gets a named field from the objects table of associations (see g_object_set_data()).
Called by the garbage collector. Decreases the reference count of object. (i.e. its memory is freed).
Increases the freeze count on object. If the freeze count is non-zero, the emission of "notify" signals on object is stopped. The signals are queued until the freeze count is decreased to zero. Duplicate notifications are squashed so that at most one #GObject::notify signal is emitted for each property modified while the object is frozen.
This is necessary for accessors that modify multiple properties to prevent premature notification while the object is still being modified.
Gets n_properties properties for an object. Obtained properties will be set to values. All properties must be valid. Warnings will be emitted and undefined behaviour may result if invalid properties are passed in.
Emits a "notify" signal for the property property_name on object.
When possible, eg. when signaling a property change from within the class that registered the property, you should use g_object_notify_by_pspec() instead.
Note that emission of the notify signal may be blocked with g_object_freeze_notify(). In this case, the signal emissions are queued and will be emitted (in reverse order) when g_object_thaw_notify() is called.
Emits a "notify" signal for the property specified by pspec on object.
This function omits the property name lookup, hence it is faster than g_object_notify().
One way to avoid using g_object_notify() from within the class that registered the properties, and using g_object_notify_by_pspec() instead, is to store the GParamSpec used with g_object_class_install_property() inside a static array, e.g.:
|[ enum { PROP_0, PROP_FOO, PROP_LAST };
static GParamSpec *properties[PROP_LAST];
static void my_object_class_init (MyObjectClass *klass) { properties[PROP_FOO] = g_param_spec_int ("foo", "Foo", "The foo", 0, 100, 50, G_PARAM_READWRITE); g_object_class_install_property (gobject_class, PROP_FOO, properties[PROP_FOO]); } ]|
and then notify a change on the "foo" property with:
|[ g_object_notify_by_pspec (self, properties[PROP_FOO]); ]|
Gets a property of an object.
The value can be:
- an empty #GValue initialized by %G_VALUE_INIT, which will be automatically initialized with the expected type of the property (since GLib 2.60)
- a #GValue initialized with the expected type of the property
- a #GValue initialized with a type to which the expected type of the property can be transformed
In general, a copy is made of the property contents and the caller is responsible for freeing the memory by calling g_value_unset().
Note that g_object_get_property() is really intended for language bindings, g_object_get() is much more convenient for C programming.
This function gets back user data pointers stored via g_object_set_qdata().
Releases all references to other objects. This can be used to break reference cycles.
This function should only be called from object system implementations.
Each object carries around a table of associations from strings to pointers. This function lets you set an association.
If the object already had an association with that name, the old association will be destroyed.
Internally, the key is converted to a #GQuark using g_quark_from_string(). This means a copy of key is kept permanently (even after object has been finalized) — so it is recommended to only use a small, bounded set of values for key in your program, to avoid the #GQuark storage growing unbounded.
Sets a property on an object.
Remove a specified datum from the object's data associations, without invoking the association's destroy handler.
This function gets back user data pointers stored via g_object_set_qdata() and removes the data from object without invoking its destroy() function (if any was set). Usually, calling this function is only required to update user data pointers with a destroy notifier, for example: |[ void object_add_to_user_list (GObject *object, const gchar *new_string) { // the quark, naming the object data GQuark quark_string_list = g_quark_from_static_string ("my-string-list"); // retrieve the old string list GList *list = g_object_steal_qdata (object, quark_string_list);
// prepend new string list = g_list_prepend (list, g_strdup (new_string)); // this changed 'list', so we need to set it again g_object_set_qdata_full (object, quark_string_list, list, free_string_list); } static void free_string_list (gpointer data) { GList *node, *list = data;
for (node = list; node; node = node->next) g_free (node->data); g_list_free (list); } ]| Using g_object_get_qdata() in the above example, instead of g_object_steal_qdata() would have left the destroy function set, and thus the partial string list would have been freed upon g_object_set_qdata_full().
Reverts the effect of a previous call to g_object_freeze_notify(). The freeze count is decreased on object and when it reaches zero, queued "notify" signals are emitted.
Duplicate notifications for each property are squashed so that at most one #GObject::notify signal is emitted for each property, in the reverse order in which they have been queued.
It is an error to call this function when the freeze count is zero.
This function essentially limits the life time of the closure to the life time of the object. That is, when the object is finalized, the closure is invalidated by calling g_closure_invalidate() on it, in order to prevent invocations of the closure with a finalized (nonexisting) object. Also, g_object_ref() and g_object_unref() are added as marshal guards to the closure, to ensure that an extra reference count is held on object during invocation of the closure. Usually, this function will be called on closures that use this object as closure data.