Callbacks¶
| AsyncReadyCallback(source_object, res, *user_data) | |
| BusAcquiredCallback(connection, name, *user_data) | |
| BusNameAcquiredCallback(connection, name, *user_data) | |
| BusNameAppearedCallback(connection, name, name_owner, *user_data) | |
| BusNameLostCallback(connection, name, *user_data) | |
| BusNameVanishedCallback(connection, name, *user_data) | |
| CancellableSourceFunc(cancellable, *user_data) | |
| DBusInterfaceGetPropertyFunc(connection, sender, object_path, interface_name, property_name, error, *user_data) | |
| DBusInterfaceMethodCallFunc(connection, sender, object_path, interface_name, method_name, parameters, invocation, *user_data) | |
| DBusInterfaceSetPropertyFunc(connection, sender, object_path, interface_name, property_name, value, error, *user_data) | |
| DBusMessageFilterFunction(connection, message, incoming, *user_data) | |
| DBusProxyTypeFunc(manager, object_path, interface_name, *user_data) | |
| DBusSignalCallback(connection, sender_name, object_path, interface_name, signal_name, parameters, *user_data) | |
| DBusSubtreeDispatchFunc(connection, sender, object_path, interface_name, node, out_user_data, *user_data) | |
| DBusSubtreeIntrospectFunc(connection, sender, object_path, node, *user_data) | |
| DatagramBasedSourceFunc(datagram_based, condition, *user_data) | |
| DesktopAppLaunchCallback(appinfo, pid, *user_data) | |
| FileMeasureProgressCallback(reporting, current_size, num_dirs, num_files, *user_data) | |
| FileProgressCallback(current_num_bytes, total_num_bytes, *user_data) | |
| FileReadMoreCallback(file_contents, file_size, *callback_data) | |
| IOSchedulerJobFunc(job, cancellable, *user_data) | |
| PollableSourceFunc(pollable_stream, *user_data) | |
| ReallocFunc(data, size) | |
| SettingsBindGetMapping(value, variant, *user_data) | |
| SettingsBindSetMapping(value, expected_type, *user_data) | |
| SettingsGetMapping(value, *user_data) | |
| SimpleAsyncThreadFunc(res, object, cancellable) | |
| SocketSourceFunc(socket, condition, *user_data) | |
| TaskThreadFunc(task, source_object, task_data, cancellable) | |
| VfsFileLookupFunc(vfs, identifier, *user_data) | 
Details¶
- 
Gio.AsyncReadyCallback(source_object, res, *user_data)¶
- Parameters: - source_object (GObject.ObjectorNone) – the object the asynchronous operation was started with.
- res (Gio.AsyncResult) – aGio.AsyncResult.
- user_data (objectorNone) – user data passed to the callback.
 - Type definition for a function that will be called back when an asynchronous operation within GIO has been completed. - Gio.AsyncReadyCallbackcallbacks from- Gio.Taskare guaranteed to be invoked in a later iteration of the- thread-default main contextwhere the- Gio.Taskwas created. All other users of- Gio.AsyncReadyCallbackmust likewise call it asynchronously in a later iteration of the main context.
- source_object (
- 
Gio.BusAcquiredCallback(connection, name, *user_data)¶
- Parameters: - connection (Gio.DBusConnection) – TheGio.DBusConnectionto a message bus.
- name (str) – The name that is requested to be owned.
- user_data (objectorNone) – User data passed toGio.bus_own_name().
 - Invoked when a connection to a message bus has been obtained. - New in version 2.26. 
- connection (
- 
Gio.BusNameAcquiredCallback(connection, name, *user_data)¶
- Parameters: - connection (Gio.DBusConnection) – TheGio.DBusConnectionon which to acquired the name.
- name (str) – The name being owned.
- user_data (objectorNone) – User data passed toGio.bus_own_name() orGio.bus_own_name_on_connection().
 - Invoked when the name is acquired. - New in version 2.26. 
- connection (
- 
Gio.BusNameAppearedCallback(connection, name, name_owner, *user_data)¶
- Parameters: - connection (Gio.DBusConnection) – TheGio.DBusConnectionthe name is being watched on.
- name (str) – The name being watched.
- name_owner (str) – Unique name of the owner of the name being watched.
- user_data (objectorNone) – User data passed toGio.bus_watch_name().
 - Invoked when the name being watched is known to have to have an owner. - New in version 2.26. 
- connection (
- 
Gio.BusNameLostCallback(connection, name, *user_data)¶
- Parameters: - connection (Gio.DBusConnection) – TheGio.DBusConnectionon which to acquire the name orNoneif the connection was disconnected.
- name (str) – The name being owned.
- user_data (objectorNone) – User data passed toGio.bus_own_name() orGio.bus_own_name_on_connection().
 - Invoked when the name is lost or connection has been closed. - New in version 2.26. 
- connection (
- 
Gio.BusNameVanishedCallback(connection, name, *user_data)¶
- Parameters: - connection (Gio.DBusConnection) – TheGio.DBusConnectionthe name is being watched on, orNone.
- name (str) – The name being watched.
- user_data (objectorNone) – User data passed toGio.bus_watch_name().
 - Invoked when the name being watched is known not to have to have an owner. - This is also invoked when the - Gio.DBusConnectionon which the watch was established has been closed. In that case, connection will be- None.- New in version 2.26. 
- connection (
- 
Gio.CancellableSourceFunc(cancellable, *user_data)¶
- Parameters: - cancellable (Gio.CancellableorNone) – theGio.Cancellable
- user_data (objectorNone) – data passed in by the user.
 - Returns: - it should return - Falseif the source should be removed.- Return type: - This is the function type of the callback used for the - GLib.Sourcereturned by- Gio.Cancellable.source_new().- New in version 2.28. 
- cancellable (
- 
Gio.DBusInterfaceGetPropertyFunc(connection, sender, object_path, interface_name, property_name, error, *user_data)¶
- Parameters: - connection (Gio.DBusConnection) – AGio.DBusConnection.
- sender (str) – The unique bus name of the remote caller.
- object_path (str) – The object path that the method was invoked on.
- interface_name (str) – The D-Bus interface name for the property.
- property_name (str) – The name of the property to get the value of.
- error (GLib.Error) – Return location for error.
- user_data (objectorNone) – The user_dataobjectpassed toGio.DBusConnection.register_object().
 - Returns: - A - GLib.Variantwith the value for property_name or- Noneif error is set. If the returned- GLib.Variantis floating, it is consumed - otherwise its reference count is decreased by one.- Return type: - The type of the get_property function in - Gio.DBusInterfaceVTable.- New in version 2.26. 
- connection (
- 
Gio.DBusInterfaceMethodCallFunc(connection, sender, object_path, interface_name, method_name, parameters, invocation, *user_data)¶
- Parameters: - connection (Gio.DBusConnection) – AGio.DBusConnection.
- sender (str) – The unique bus name of the remote caller.
- object_path (str) – The object path that the method was invoked on.
- interface_name (str) – The D-Bus interface name the method was invoked on.
- method_name (str) – The name of the method that was invoked.
- parameters (GLib.Variant) – AGLib.Varianttuple with parameters.
- invocation (Gio.DBusMethodInvocation) – AGio.DBusMethodInvocationobject that must be used to return a value or error.
- user_data (objectorNone) – The user_dataobjectpassed toGio.DBusConnection.register_object().
 - The type of the method_call function in - Gio.DBusInterfaceVTable.- New in version 2.26. 
- connection (
- 
Gio.DBusInterfaceSetPropertyFunc(connection, sender, object_path, interface_name, property_name, value, error, *user_data)¶
- Parameters: - connection (Gio.DBusConnection) – AGio.DBusConnection.
- sender (str) – The unique bus name of the remote caller.
- object_path (str) – The object path that the method was invoked on.
- interface_name (str) – The D-Bus interface name for the property.
- property_name (str) – The name of the property to get the value of.
- value (GLib.Variant) – The value to set the property to.
- error (GLib.Error) – Return location for error.
- user_data (objectorNone) – The user_dataobjectpassed toGio.DBusConnection.register_object().
 - Returns: - Trueif the property was set to value,- Falseif error is set.- Return type: - The type of the set_property function in - Gio.DBusInterfaceVTable.- New in version 2.26. 
- connection (
- 
Gio.DBusMessageFilterFunction(connection, message, incoming, *user_data)¶
- Parameters: - connection (Gio.DBusConnection) – AGio.DBusConnection.
- message (Gio.DBusMessage) – A lockedGio.DBusMessagethat the filter function takes ownership of.
- incoming (bool) –Trueif it is a message received from the other peer,Falseif it is a message to be sent to the other peer.
- user_data (objectorNone) – User data passed when adding the filter.
 - Returns: - A - Gio.DBusMessagethat will be freed with- GObject.Object.unref() or- Noneto drop the message. Passive filter functions can simply return the passed message object.- Return type: - Signature for function used in - Gio.DBusConnection.add_filter().- A filter function is passed a - Gio.DBusMessageand expected to return a- Gio.DBusMessagetoo. Passive filter functions that don’t modify the message can simply return the message object:- static GDBusMessage * passive_filter (GDBusConnection *connection GDBusMessage *message, gboolean incoming, gpointer user_data) { // inspect @message return message; }- Filter functions that wants to drop a message can simply return - None:- static GDBusMessage * drop_filter (GDBusConnection *connection GDBusMessage *message, gboolean incoming, gpointer user_data) { if (should_drop_message) { g_object_unref (message); message = NULL; } return message; }- Finally, a filter function may modify a message by copying it: - static GDBusMessage * modifying_filter (GDBusConnection *connection GDBusMessage *message, gboolean incoming, gpointer user_data) { GDBusMessage *copy; GError *error; error = NULL; copy = g_dbus_message_copy (message, &error); // handle @error being set g_object_unref (message); // modify @copy return copy; }- If the returned - Gio.DBusMessageis different from message and cannot be sent on connection (it could use features, such as file descriptors, not compatible with connection), then a warning is logged to standard error. Applications can check this ahead of time using- Gio.DBusMessage.to_blob() passing a- Gio.DBusCapabilityFlagsvalue obtained from connection.- New in version 2.26. 
- connection (
- 
Gio.DBusProxyTypeFunc(manager, object_path, interface_name, *user_data)¶
- Parameters: - manager (Gio.DBusObjectManagerClient) – AGio.DBusObjectManagerClient.
- object_path (str) – The object path of the remote object.
- interface_name (strorNone) – The interface name of the remote object orNoneif aGio.DBusObjectProxyGObject.GTypeis requested.
- user_data (objectorNone) – User data.
 - Returns: - A - GObject.GTypeto use for the remote object. The returned type must be a- Gio.DBusProxyor- Gio.DBusObjectProxy-derived type.- Return type: - Function signature for a function used to determine the - GObject.GTypeto use for an interface proxy (if interface_name is not- None) or object proxy (if interface_name is- None).- This function is called in the - thread-default main loopthat manager was constructed in.- New in version 2.30. 
- manager (
- 
Gio.DBusSignalCallback(connection, sender_name, object_path, interface_name, signal_name, parameters, *user_data)¶
- Parameters: - connection (Gio.DBusConnection) – AGio.DBusConnection.
- sender_name (strorNone) – The unique bus name of the sender of the signal, orNoneon a peer-to-peer D-Bus connection.
- object_path (str) – The object path that the signal was emitted on.
- interface_name (str) – The name of the interface.
- signal_name (str) – The name of the signal.
- parameters (GLib.Variant) – AGLib.Varianttuple with parameters for the signal.
- user_data (objectorNone) – User data passed when subscribing to the signal.
 - Signature for callback function used in - Gio.DBusConnection.signal_subscribe().- New in version 2.26. 
- connection (
- 
Gio.DBusSubtreeDispatchFunc(connection, sender, object_path, interface_name, node, out_user_data, *user_data)¶
- Parameters: - connection (Gio.DBusConnection) – AGio.DBusConnection.
- sender (str) – The unique bus name of the remote caller.
- object_path (str) – The object path that was registered withGio.DBusConnection.register_subtree().
- interface_name (str) – The D-Bus interface name that the method call or property access is for.
- node (str) – A node that is a child of object_path (relative to object_path) orNonefor the root of the subtree.
- out_user_data (object) – Return location for user data to pass to functions in the returnedGio.DBusInterfaceVTable.
- user_data (objectorNone) – The user_dataobjectpassed toGio.DBusConnection.register_subtree().
 - Returns: - A - Gio.DBusInterfaceVTableor- Noneif you don’t want to handle the methods.- Return type: - The type of the dispatch function in - Gio.DBusSubtreeVTable.- Subtrees are flat. node, if non- - None, is always exactly one segment of the object path (ie: it never contains a slash).- New in version 2.26. 
- connection (
- 
Gio.DBusSubtreeIntrospectFunc(connection, sender, object_path, node, *user_data)¶
- Parameters: - connection (Gio.DBusConnection) – AGio.DBusConnection.
- sender (str) – The unique bus name of the remote caller.
- object_path (str) – The object path that was registered withGio.DBusConnection.register_subtree().
- node (str) – A node that is a child of object_path (relative to object_path) orNonefor the root of the subtree.
- user_data (objectorNone) – The user_dataobjectpassed toGio.DBusConnection.register_subtree().
 - Returns: - A - None-terminated array of pointers to- Gio.DBusInterfaceInfo, or- None.- Return type: - The type of the introspect function in - Gio.DBusSubtreeVTable.- Subtrees are flat. node, if non- - None, is always exactly one segment of the object path (ie: it never contains a slash).- This function should return - Noneto indicate that there is no object at this node.- If this function returns non- - None, the return value is expected to be a- None-terminated array of pointers to- Gio.DBusInterfaceInfostructures describing the interfaces implemented by node. This array will have- Gio.DBusInterfaceInfo.unref() called on each item before being freed with- GLib.free().- The difference between returning - Noneand an array containing zero items is that the standard DBus interfaces will returned to the remote introspector in the empty array case, but not in the- Nonecase.- New in version 2.26. 
- connection (
- 
Gio.DatagramBasedSourceFunc(datagram_based, condition, *user_data)¶
- Parameters: - datagram_based (Gio.DatagramBased) – theGio.DatagramBased
- condition (GLib.IOCondition) – the current condition at the source fired
- user_data (objectorNone) – data passed in by the user
 - Returns: - GLib.SOURCE_REMOVEif the source should be removed,- GLib.SOURCE_CONTINUEotherwise- Return type: - This is the function type of the callback used for the - GLib.Sourcereturned by- Gio.DatagramBased.create_source().- New in version 2.48. 
- datagram_based (
- 
Gio.DesktopAppLaunchCallback(appinfo, pid, *user_data)¶
- Parameters: - appinfo (Gio.DesktopAppInfo) – aGio.DesktopAppInfo
- pid (int) – Process identifier
- user_data (objectorNone) – User data
 - During invocation, - Gio.DesktopAppInfo.launch_uris_as_manager() may create one or more child processes. This callback is invoked once for each, providing the process ID.
- appinfo (
- 
Gio.FileMeasureProgressCallback(reporting, current_size, num_dirs, num_files, *user_data)¶
- Parameters: - reporting (bool) –Trueif more reports will come
- current_size (int) – the current cumulative size measurement
- num_dirs (int) – the number of directories visited so far
- num_files (int) – the number of non-directory files encountered
- user_data (objectorNone) – the data passed to the original request for this callback
 - This callback type is used by g_file_measure_disk_usage() to make periodic progress reports when measuring the amount of disk spaced used by a directory. - These calls are made on a best-effort basis and not all types of - Gio.Filewill support them. At the minimum, however, one call will always be made immediately.- In the case that there is no support, reporting will be set to - False(and the other values undefined) and no further calls will be made. Otherwise, the reporting will be- Trueand the other values all-zeros during the first (immediate) call. In this way, you can know which type of progress UI to show without a delay.- For g_file_measure_disk_usage() the callback is made directly. For g_file_measure_disk_usage_async() the callback is made via the default main context of the calling thread (ie: the same way that the final async result would be reported). - current_size is in the same units as requested by the operation (see - Gio.FileMeasureFlags.APPARENT_SIZE).- The frequency of the updates is implementation defined, but is ideally about once every 200ms. - The last progress callback may or may not be equal to the final result. Always check the async result to get the final value. - New in version 2.38. 
- reporting (
- 
Gio.FileProgressCallback(current_num_bytes, total_num_bytes, *user_data)¶
- Parameters: - When doing file operations that may take a while, such as moving a file or copying a file, a progress callback is used to pass how far along that operation is to the application. 
- 
Gio.FileReadMoreCallback(file_contents, file_size, *callback_data)¶
- Parameters: - Returns: - Return type: - When loading the partial contents of a file with g_file_load_partial_contents_async(), it may become necessary to determine if any more data from the file should be loaded. A - Gio.FileReadMoreCallbackfunction facilitates this by returning- Trueif more data should be read, or- Falseotherwise.
- 
Gio.IOSchedulerJobFunc(job, cancellable, *user_data)¶
- Parameters: - job (Gio.IOSchedulerJob) – aGio.IOSchedulerJob.
- cancellable (Gio.CancellableorNone) – optionalGio.Cancellableobject,Noneto ignore.
- user_data (objectorNone) – the data to pass to callback function
 - Returns: - Trueif this function should be called again to complete the job,- Falseif the job is complete (or cancelled)- Return type: - I/O Job function. - Long-running jobs should periodically check the cancellable to see if they have been cancelled. 
- job (
- 
Gio.PollableSourceFunc(pollable_stream, *user_data)¶
- Parameters: - pollable_stream (GObject.Object) – theGio.PollableInputStreamorGio.PollableOutputStream
- user_data (objectorNone) – data passed in by the user.
 - Returns: - it should return - Falseif the source should be removed.- Return type: - This is the function type of the callback used for the - GLib.Sourcereturned by- Gio.PollableInputStream.create_source() and- Gio.PollableOutputStream.create_source().- New in version 2.28. 
- pollable_stream (
- 
Gio.ReallocFunc(data, size)¶
- Parameters: - Returns: - a pointer to the reallocated memory - Return type: - Changes the size of the memory block pointed to by data to size bytes. - The function should have the same semantics as realloc(). 
- 
Gio.SettingsBindGetMapping(value, variant, *user_data)¶
- Parameters: - value (GObject.Value) – return location for the property value
- variant (GLib.Variant) – theGLib.Variant
- user_data (objectorNone) – user data that was specified when the binding was created
 - Returns: - Return type: - The type for the function that is used to convert from - Gio.Settingsto an object property. The value is already initialized to hold values of the appropriate type.
- value (
- 
Gio.SettingsBindSetMapping(value, expected_type, *user_data)¶
- Parameters: - value (GObject.Value) – aGObject.Valuecontaining the property value to map
- expected_type (GLib.VariantType) – theGLib.VariantTypeto create
- user_data (objectorNone) – user data that was specified when the binding was created
 - Returns: - a new - GLib.Variantholding the data from value, or- Nonein case of an error- Return type: - The type for the function that is used to convert an object property value to a - GLib.Variantfor storing it in- Gio.Settings.
- value (
- 
Gio.SettingsGetMapping(value, *user_data)¶
- Parameters: - value (GLib.Variant) – theGLib.Variantto map, orNone
- user_data (objectorNone) – the user data that was passed toGio.Settings.get_mapped()
 - Returns: - Trueif the conversion succeeded,- Falsein case of an error- result: - the result of the mapping - Return type: - The type of the function that is used to convert from a value stored in a - Gio.Settingsto a value that is useful to the application.- If the value is successfully mapped, the result should be stored at result and - Truereturned. If mapping fails (for example, if value is not in the right format) then- Falseshould be returned.- If value is - Nonethen it means that the mapping function is being given a “last chance” to successfully return a valid value.- Truemust be returned in this case.
- value (
- 
Gio.SimpleAsyncThreadFunc(res, object, cancellable)¶
- Parameters: - res (Gio.SimpleAsyncResult) – aGio.SimpleAsyncResult.
- object (GObject.Object) – aGObject.Object.
- cancellable (Gio.CancellableorNone) – optionalGio.Cancellableobject,Noneto ignore.
 - Simple thread function that runs an asynchronous operation and checks for cancellation. 
- res (
- 
Gio.SocketSourceFunc(socket, condition, *user_data)¶
- Parameters: - socket (Gio.Socket) – theGio.Socket
- condition (GLib.IOCondition) – the current condition at the source fired.
- user_data (objectorNone) – data passed in by the user.
 - Returns: - it should return - Falseif the source should be removed.- Return type: - This is the function type of the callback used for the - GLib.Sourcereturned by g_socket_create_source().- New in version 2.22. 
- socket (
- 
Gio.TaskThreadFunc(task, source_object, task_data, cancellable)¶
- Parameters: - task (Gio.Task) – theGio.Task
- source_object (GObject.Object) – task’s source object
- task_data (objectorNone) – task’s task data
- cancellable (Gio.CancellableorNone) – task’sGio.Cancellable, orNone
 - The prototype for a task function to be run in a thread via - Gio.Task.run_in_thread() or- Gio.Task.run_in_thread_sync().- If the return-on-cancel flag is set on task, and cancellable gets cancelled, then the - Gio.Taskwill be completed immediately (as though- Gio.Task.return_error_if_cancelled() had been called), without waiting for the task function to complete. However, the task function will continue running in its thread in the background. The function therefore needs to be careful about how it uses externally-visible state in this case. See- Gio.Task.set_return_on_cancel() for more details.- Other than in that case, task will be completed when the - Gio.TaskThreadFuncreturns, not when it calls a- g_task_return_function.- New in version 2.36. 
- task (
- 
Gio.VfsFileLookupFunc(vfs, identifier, *user_data)¶
- Parameters: - Returns: - a - Gio.Filefor identifier.- Return type: - This function type is used by - Gio.Vfs.register_uri_scheme() to make it possible for a client to associate an URI scheme to a different- Gio.Fileimplementation.- The client should return a reference to the new file that has been created for uri, or - Noneto continue with the default implementation.- New in version 2.50.