GObject-2.0 Python API Documentation

Class: GObject.Binding

Subclass of: GObject.Object

#GBinding is the representation of a binding between a property on a #GObject instance (or source) and another property on another #GObject instance (or target). Whenever the source property changes, the same value is applied to the target property; for instance, the following binding: |[ g_object_bind_property (object1, "property-a", object2, "property-b", G_BINDING_DEFAULT); ]| will cause <emphasis>object2:property-b</emphasis> to be updated every time g_object_set() or the specific accessor changes the value of <emphasis>object1:property-a</emphasis>. It is possible to create a bidirectional binding between two properties of two #GObject instances, so that if either property changes, the other is updated as well, for instance: |[ g_object_bind_property (object1, "property-a", object2, "property-b", G_BINDING_BIDIRECTIONAL); ]| will keep the two properties in sync. It is also possible to set a custom transformation function (in both directions, in case of a bidirectional binding) to apply a custom transformation from the source value to the target value before applying it; for instance, the following binding: |[ g_object_bind_property_full (adjustment1, "value", adjustment2, "value", G_BINDING_BIDIRECTIONAL, celsius_to_fahrenheit, fahrenheit_to_celsius, NULL, NULL); ]| will keep the <emphasis>value</emphasis> property of the two adjustments in sync; the <function>celsius_to_fahrenheit</function> function will be called whenever the <emphasis>adjustment1:value</emphasis> property changes and will transform the current value of the property before applying it to the <emphasis>adjustment2:value</emphasis> property; vice versa, the <function>fahrenheit_to_celsius</function> function will be called whenever the <emphasis>adjustment2:value</emphasis> property changes, and will transform the current value of the property before applying it to the <emphasis>adjustment1:value</emphasis>. Note that #GBinding does not resolve cycles by itself; a cycle like |[ object1:propertyA -> object2:propertyB object2:propertyB -> object3:propertyC object3:propertyC -> object1:propertyA ]| might lead to an infinite loop. The loop, in this particular case, can be avoided if the objects emit the #GObject::notify signal only if the value has effectively been changed. A binding is implemented using the #GObject::notify signal, so it is susceptible to all the various ways of blocking a signal emission, like g_signal_stop_emission() or g_signal_handler_block(). A binding will be severed, and the resources it allocates freed, whenever either one of the #GObject instances it refers to are finalized, or when the #GBinding instance loses its last reference. #GBinding is available since GObject 2.26

Properties

string"target-property"construct-only

The name of the property of #GBinding:target that should be used as the target of the binding

GObject.Object"source"construct-only

The #GObject that should be used as the source of the binding

GObject.BindingFlags"flags"construct-only

Flags to be used to control the #GBinding

GObject.Object"target"construct-only

The #GObject that should be used as the target of the binding

string"source-property"construct-only

The name of the property of #GBinding:source that should be used as the source of the binding

Methods

GObject.Objectget_source()

stringget_source_property()

GObject.Objectget_target()

stringget_target_property()

Abstract Class: GObject.InitiallyUnowned

Known subclasses: Gtk.Adjustment, Gtk.Widget, Gtk.CellRenderer, Gtk.FileFilter, Gtk.CellArea, Gtk.TreeViewColumn, Gtk.RecentFilter

Subclass of: GObject.Object

All the fields in the <structname>GInitiallyUnowned</structname> structure are private to the #GInitiallyUnowned implementation and should never be accessed directly.

Methods

GObject.Bindingbind_property(source, source_property, target, target_property, flags)(static method)

GObject.Bindingbind_property_full(source, source_property, target, target_property, flags, transform_to, transform_from, user_data, notify)(static method)

GObject.Bindingbind_property_with_closures(source, source_property, target, target_property, flags, transform_to, transform_from)(static method)

GObject.gsizecompat_control(what, data)(static method)

GObject.ParamSpecinterface_find_property(g_iface, property_name)(static method)

voidinterface_install_property(g_iface, pspec)(static method)

Array, intinterface_list_properties(g_iface)(static method)

GObject.Objectnewv(object_type, n_parameters, parameters)(static method)

voidtype_init()(static method)

Abstract Class: GObject.Object

Known subclasses: Gio.SocketListener, Atk.Registry, Atk.Object, Gtk.PrintOperation, Gio.NetworkService, Gio.ZlibDecompressor, Gtk.PageSetup, Gio.ApplicationCommandLine, Gtk.Style, Gio.FilenameCompleter, Gio.DBusServer, Atk.ObjectFactory, Gio.UnixFDList, Gtk.TextBuffer, Gio.Permission, Gtk.SizeGroup, Gio.Cancellable, Gio.CharsetConverter, Gio.IOStream, Gio.OutputStream, Gio.AppLaunchContext, Gio.ZlibCompressor, Gtk.StatusIcon, Gio.SocketControlMessage, Gtk.Tooltip, Gtk.TreeModelFilter, Gtk.ListStore, Atk.Hyperlink, Atk.StateSet, Gtk.EntryBuffer, Gtk.StyleContext, Gio.Application, Gio.DBusMessage, Gio.VolumeMonitor, Gio.SimpleAction, Gtk.AccelMap, GooCanvas.CanvasStyle, Gio.Socket, Gio.SimpleAsyncResult, Gtk.TreeStore, Gio.SocketClient, Gtk.TreeModelSort, Gio.MountOperation, Gio.Resolver, Gtk.TextTagTable, Gio.UnixMountMonitor, Gio.Vfs, Gtk.PrintContext, Gtk.ActionGroup, Gtk.CssProvider, Gio.InputStream, Gio.DBusProxy, Gtk.Action, Gtk.TextTag, Atk.Util, Gio.DBusMethodInvocation, Gtk.TextMark, GObject.Binding, GObject.InitiallyUnowned, Gio.DesktopAppInfo, Gtk.CellAreaContext, Gtk.TreeSelection, Gio.FileMonitor, GooCanvas.CanvasItemModelSimple, Gio.InetAddress, Gio.NetworkAddress, Gtk.AccelGroup, Gio.SocketAddress, Gio.FileEnumerator, Gio.SocketAddressEnumerator, Gtk.PrintSettings, Gtk.Builder, Gio.SimpleActionGroup, Gio.DBusConnection, Atk.Relation, Gtk.IMContext, Gio.Credentials, Gtk.StyleProperties, GObject.Object, GObject.TypeModule, Gtk.WindowGroup, Gtk.TextChildAnchor, Gio.FileInfo, Gtk.ThemingEngine, Gtk.RecentManager, Gio.Emblem, Gtk.IconTheme, Gio.TlsCertificate, Gtk.IconFactory, GooCanvas.CanvasItemSimple, Gio.ThemedIcon, Gtk.RcStyle, Gio.FileIcon, Gtk.Settings, Gio.Settings, Atk.RelationSet, Gtk.EntryCompletion, Gio.EmblemedIcon, Gtk.UIManager, Gio.DBusAuthObserver, Gtk.Clipboard, Atk.Misc

Subclass of: GObject.Object

All the fields in the <structname>GObject</structname> structure are private to the #GObject implementation and should never be accessed directly.

Methods

voidforce_floating()

voidfreeze_notify()

gpointerget_data(key)

gpointerget_qdata(quark)

boolis_floating()

voidnotify_by_pspec(pspec)

GObject.Objectref_sink()

voidrun_dispose()

voidset_data(key, data)

gpointersteal_data(key)

gpointersteal_qdata(quark)

voidthaw_notify()

voidunref()

voidwatch_closure(closure)

voidconstructed()

voiddispatch_properties_changed(n_pspecs, pspecs)

voiddispose()

voidfinalize()

voidget_property(property_id, value, pspec)

voidnotify(pspec)

voidset_property(property_id, value, pspec)

Abstract Class: GObject.TypeModule

Implements: GObject.TypePlugin

Known subclasses: Gio.IOModule

Subclass of: GObject.Object

#GTypeModule provides a simple implementation of the #GTypePlugin interface. The model of #GTypeModule is a dynamically loaded module which implements some number of types and interface implementations. When the module is loaded, it registers its types and interfaces using g_type_module_register_type() and g_type_module_add_interface(). As long as any instances of these types and interface implementations are in use, the module is kept loaded. When the types and interfaces are gone, the module may be unloaded. If the types and interfaces become used again, the module will be reloaded. Note that the last unref can not happen in module code, since that would lead to the caller's code being unloaded before g_object_unref() returns to it. Keeping track of whether the module should be loaded or not is done by using a use count - it starts at zero, and whenever it is greater than zero, the module is loaded. The use count is maintained internally by the type system, but also can be explicitly controlled by g_type_module_use() and g_type_module_unuse(). Typically, when loading a module for the first type, g_type_module_use() will be used to load it so that it can initialize its types. At some later point, when the module no longer needs to be loaded except for the type implementations it contains, g_type_module_unuse() is called. #GTypeModule does not actually provide any implementation of module loading and unloading. To create a particular module type you must derive from #GTypeModule and implement the load and unload functions in #GTypeModuleClass.

Methods

voidadd_interface(instance_type, interface_type, interface_info)

GTyperegister_enum(name, const_static_values)

GTyperegister_flags(name, const_static_values)

GTyperegister_type(parent_type, type_name, type_info, flags)

voidset_name(name)

voidunuse()

booluse()

boolload()

voidunload()

Interface: GObject.TypePlugin

Classes implementing GObject.TypePlugin: GObject.TypeModule, Gio.IOModule

The GObject type system supports dynamic loading of types. The #GTypePlugin interface is used to handle the lifecycle of dynamically loaded types. It goes as follows: <orderedlist> <listitem><para> The type is initially introduced (usually upon loading the module the first time, or by your main application that knows what modules introduces what types), like this: |[ new_type_id = g_type_register_dynamic (parent_type_id, "TypeName", new_type_plugin, type_flags); ]| where <literal>new_type_plugin</literal> is an implementation of the #GTypePlugin interface. </para></listitem> <listitem><para> The type's implementation is referenced, e.g. through g_type_class_ref() or through g_type_create_instance() (this is being called by g_object_new()) or through one of the above done on a type derived from <literal>new_type_id</literal>. </para></listitem> <listitem><para> This causes the type system to load the type's implementation by calling g_type_plugin_use() and g_type_plugin_complete_type_info() on <literal>new_type_plugin</literal>. </para></listitem> <listitem><para> At some point the type's implementation isn't required anymore, e.g. after g_type_class_unref() or g_type_free_instance() (called when the reference count of an instance drops to zero). </para></listitem> <listitem><para> This causes the type system to throw away the information retrieved from g_type_plugin_complete_type_info() and then it calls g_type_plugin_unuse() on <literal>new_type_plugin</literal>. </para></listitem> <listitem><para> Things may repeat from the second step. </para></listitem> </orderedlist> So basically, you need to implement a #GTypePlugin type that carries a use_count, once use_count goes from zero to one, you need to load the implementation to successfully handle the upcoming g_type_plugin_complete_type_info() call. Later, maybe after succeeding use/unuse calls, once use_count drops to zero, you can unload the implementation again. The type system makes sure to call g_type_plugin_use() and g_type_plugin_complete_type_info() again when the type is needed again. #GTypeModule is an implementation of #GTypePlugin that already implements most of this except for the actual module loading and unloading. It even handles multiple registered types per module.

Methods

voidcomplete_interface_info(instance_type, interface_type, info)

voidcomplete_type_info(g_type, info, value_table)

voidunuse()

voiduse()