Callbacks¶
| ChildWatchFunc(pid, status, *user_data) | |
| ClearHandleFunc(handle_id) | |
| CompareDataFunc(a, b, *user_data) | |
| CompareFunc(a, b) | |
| CopyFunc(src, data) | |
| DataForeachFunc(key_id, data, *user_data) | |
| DestroyNotify(data) | |
| DuplicateFunc(data, *user_data) | |
| EqualFunc(a, b) | |
| FreeFunc(data) | |
| Func(data, *user_data) | |
| HFunc(key, value, *user_data) | |
| HRFunc(key, value, *user_data) | |
| HashFunc(key) | |
| HookCheckFunc(data) | |
| HookCheckMarshaller(hook, marshal_data) | |
| HookCompareFunc(new_hook, sibling) | |
| HookFinalizeFunc(hook_list, hook) | |
| HookFindFunc(hook, data) | |
| HookFunc(data) | |
| HookMarshaller(hook, marshal_data) | |
| IOFunc(source, condition, data) | |
| LogFunc(log_domain, log_level, message, *user_data) | |
| LogWriterFunc(log_level, fields, *user_data) | |
| NodeForeachFunc(node, data) | |
| NodeTraverseFunc(node, data) | |
| OptionArgFunc(option_name, value, data) | |
| OptionErrorFunc(context, group, data) | |
| OptionParseFunc(context, group, data) | |
| PollFunc(ufds, nfsd, timeout_) | |
| PrintFunc(string) | |
| RegexEvalCallback(match_info, result, *user_data) | |
| ScannerMsgFunc(scanner, message, error) | |
| SequenceIterCompareFunc(a, b, data) | |
| SourceDisposeFunc(source) | |
| SourceDummyMarshal() | |
| SourceFunc(*user_data) | |
| SpawnChildSetupFunc(*user_data) | |
| TestDataFunc(*user_data) | |
| TestFixtureFunc(fixture, *user_data) | |
| TestFunc() | |
| TestLogFatalFunc(log_domain, log_level, message, *user_data) | |
| ThreadFunc(data) | |
| TranslateFunc(str, data) | |
| TraverseFunc(key, value, data) | |
| UnixFDSourceFunc(fd, condition, *user_data) | |
| VoidFunc() | 
Details¶
- 
GLib.ChildWatchFunc(pid, status, *user_data)¶
- Parameters: - pid (int) – the process id of the child process
- status (int) – Status information about the child process, encoded in a platform-specific manner
- user_data (objectorNone) – user data passed toGLib.child_watch_add()
 - Prototype of a #GChildWatchSource callback, called when a child process has exited. To interpret status, see the documentation for - GLib.spawn_check_exit_status().
- pid (
- 
GLib.ClearHandleFunc(handle_id)¶
- Parameters: - handle_id ( - int) – the handle ID to clear- Specifies the type of function passed to g_clear_handle_id(). The implementation is expected to free the resource identified by handle_id; for instance, if handle_id is a - GLib.SourceID,- GLib.Source.remove() can be used.- New in version 2.56. 
- 
GLib.CompareDataFunc(a, b, *user_data)¶
- Parameters: - Returns: - negative value if a < b; zero if a = b; positive value if a > b - Return type: - Specifies the type of a comparison function used to compare two values. The function should return a negative integer if the first value comes before the second, 0 if they are equal, or a positive integer if the first value comes after the second. 
- 
GLib.CompareFunc(a, b)¶
- Parameters: - Returns: - negative value if a < b; zero if a = b; positive value if a > b - Return type: - Specifies the type of a comparison function used to compare two values. The function should return a negative integer if the first value comes before the second, 0 if they are equal, or a positive integer if the first value comes after the second. 
- 
GLib.CopyFunc(src, data)¶
- Parameters: - Returns: - A pointer to the copy - Return type: - A function of this signature is used to copy the node data when doing a deep-copy of a tree. - New in version 2.4. 
- 
GLib.DataForeachFunc(key_id, data, *user_data)¶
- Parameters: - Specifies the type of function passed to - GLib.dataset_foreach(). It is called with each #GQuark id and associated data element, together with the user_data parameter supplied to- GLib.dataset_foreach().
- 
GLib.DestroyNotify(data)¶
- Parameters: - data ( - objector- None) – the data element.- Specifies the type of function which is called when a data element is destroyed. It is passed the pointer to the data element and should free any memory and resources allocated for it. 
- 
GLib.DuplicateFunc(data, *user_data)¶
- Parameters: - Returns: - a duplicate of data - Return type: - The type of functions that are used to ‘duplicate’ an object. What this means depends on the context, it could just be incrementing the reference count, if data is a ref-counted object. 
- 
GLib.EqualFunc(a, b)¶
- Parameters: - Returns: - Return type: - Specifies the type of a function used to test two values for equality. The function should return - Trueif both values are equal and- Falseotherwise.
- 
GLib.FreeFunc(data)¶
- Parameters: - data ( - objector- None) – a data pointer- Declares a type of function which takes an arbitrary data pointer argument and has no return value. It is not currently used in GLib or GTK+. 
- 
GLib.Func(data, *user_data)¶
- Parameters: - Specifies the type of functions passed to g_list_foreach() and g_slist_foreach(). 
- 
GLib.HFunc(key, value, *user_data)¶
- Parameters: - Specifies the type of the function passed to g_hash_table_foreach(). It is called with each key/value pair, together with the user_data parameter which is passed to g_hash_table_foreach(). 
- 
GLib.HRFunc(key, value, *user_data)¶
- Parameters: - Returns: - Trueif the key/value pair should be removed from the- GLib.HashTable- Return type: - Specifies the type of the function passed to g_hash_table_foreach_remove(). It is called with each key/value pair, together with the user_data parameter passed to g_hash_table_foreach_remove(). It should return - Trueif the key/value pair should be removed from the- GLib.HashTable.
- 
GLib.HashFunc(key)¶
- Parameters: - key ( - objector- None) – a key- Returns: - the hash value corresponding to the key - Return type: - int- Specifies the type of the hash function which is passed to g_hash_table_new() when a - GLib.HashTableis created.- The function is passed a key and should return a - inthash value. The functions- GLib.direct_hash(),- GLib.int_hash() and- GLib.str_hash() provide hash functions which can be used when the key is a- object,- int, and- strrespectively.- GLib.direct_hash() is also the appropriate hash function for keys of the form- GINT_TO_POINTER (n)(or similar macros).- A good hash functions should produce hash values that are evenly distributed over a fairly large range. The modulus is taken with the hash table size (a prime number) to find the ‘bucket’ to place each key into. The function should also be very fast, since it is called for each key lookup. - Note that the hash functions provided by GLib have these qualities, but are not particularly robust against manufactured keys that cause hash collisions. Therefore, you should consider choosing a more secure hash function when using a - GLib.HashTablewith keys that originate in untrusted data (such as HTTP requests). Using- GLib.str_hash() in that situation might make your application vulnerable to Algorithmic Complexity Attacks.- The key to choosing a good hash is unpredictability. Even cryptographic hashes are very easy to find collisions for when the remainder is taken modulo a somewhat predictable prime number. There must be an element of randomness that an attacker is unable to guess. 
- 
GLib.HookCheckFunc(data)¶
- Parameters: - data ( - objector- None) – the data field of the- GLib.Hookis passed to the hook function here- Returns: - Falseif the- GLib.Hookshould be destroyed- Return type: - bool- Defines the type of a hook function that can be invoked by - GLib.HookList.invoke_check().
- 
GLib.HookCheckMarshaller(hook, marshal_data)¶
- Parameters: - Returns: - Falseif hook should be destroyed- Return type: - Defines the type of function used by g_hook_list_marshal_check(). 
- 
GLib.HookCompareFunc(new_hook, sibling)¶
- Parameters: - Returns: - a value <= 0 if new_hook should be before sibling - Return type: - Defines the type of function used to compare - GLib.Hookelements in g_hook_insert_sorted().
- 
GLib.HookFinalizeFunc(hook_list, hook)¶
- Parameters: - hook_list (GLib.HookList) – aGLib.HookList
- hook (GLib.Hook) – the hook in hook_list that gets finalized
 - Defines the type of function to be called when a hook in a list of hooks gets finalized. 
- hook_list (
- 
GLib.HookFindFunc(hook, data)¶
- Parameters: - Returns: - Return type: - Defines the type of the function passed to g_hook_find(). 
- 
GLib.HookFunc(data)¶
- Parameters: - data ( - objector- None) – the data field of the- GLib.Hookis passed to the hook function here- Defines the type of a hook function that can be invoked by - GLib.HookList.invoke().
- 
GLib.HookMarshaller(hook, marshal_data)¶
- Parameters: - Defines the type of function used by g_hook_list_marshal(). 
- 
GLib.IOFunc(source, condition, data)¶
- Parameters: - source (GLib.IOChannel) – theGLib.IOChannelevent source
- condition (GLib.IOCondition) – the condition which has been satisfied
- data (objectorNone) – user data set inGLib.io_add_watch() orGLib.io_add_watch()
 - Returns: - the function should return - Falseif the event source should be removed- Return type: - Specifies the type of function passed to - GLib.io_add_watch() or- GLib.io_add_watch(), which is called when the requested condition on a- GLib.IOChannelis satisfied.
- source (
- 
GLib.LogFunc(log_domain, log_level, message, *user_data)¶
- Parameters: - log_domain (str) – the log domain of the message
- log_level (GLib.LogLevelFlags) – the log level of the message (including the fatal and recursion flags)
- message (str) – the message to process
- user_data (objectorNone) – user data, set inGLib.log_set_handler()
 - Specifies the prototype of log handler functions. - The default log handler, - GLib.log_default_handler(), automatically appends a new-line character to message when printing it. It is advised that any custom log handler functions behave similarly, so that logging calls in user code do not need modifying to add a new-line character to the message if the log handler is changed.- This is not used if structured logging is enabled; see Using Structured Logging. 
- log_domain (
- 
GLib.LogWriterFunc(log_level, fields, *user_data)¶
- Parameters: - log_level (GLib.LogLevelFlags) – log level of the message
- fields ([GLib.LogField]) – fields forming the message
- user_data (objectorNone) – user data passed toGLib.log_set_writer_func()
 - Returns: - GLib.LogWriterOutput.HANDLEDif the log entry was handled successfully;- GLib.LogWriterOutput.UNHANDLEDotherwise- Return type: - Writer function for log entries. A log entry is a collection of one or more - GLib.LogFields, using the standard field names from journal specification. See g_log_structured() for more information.- Writer functions must ignore fields which they do not recognise, unless they can write arbitrary binary output, as field values may be arbitrary binary. - log_level is guaranteed to be included in fields as the - PRIORITYfield, but is provided separately for convenience of deciding whether or where to output the log entry.- Writer functions should return - GLib.LogWriterOutput.HANDLEDif they handled the log message successfully or if they deliberately ignored it. If there was an error handling the message (for example, if the writer function is meant to send messages to a remote logging server and there is a network error), it should return- GLib.LogWriterOutput.UNHANDLED. This allows writer functions to be chained and fall back to simpler handlers in case of failure.- New in version 2.50. 
- log_level (
- 
GLib.NodeForeachFunc(node, data)¶
- Parameters: - Specifies the type of function passed to g_node_children_foreach(). The function is called with each child node, together with the user data passed to g_node_children_foreach(). 
- 
GLib.NodeTraverseFunc(node, data)¶
- Parameters: - Returns: - Trueto stop the traversal.- Return type: - Specifies the type of function passed to g_node_traverse(). The function is called with each of the nodes visited, together with the user data passed to g_node_traverse(). If the function returns - True, then the traversal is stopped.
- 
GLib.OptionArgFunc(option_name, value, data)¶
- Parameters: - option_name (str) – The name of the option being parsed. This will be either a single dash followed by a single letter (for a short name) or two dashes followed by a long option name.
- value (str) – The value to be parsed.
- data (objectorNone) – User data added to theGLib.OptionGroupcontaining the option when it was created withGLib.OptionGroup.new()
 - Returns: - Trueif the option was successfully parsed,- Falseif an error occurred, in which case error should be set with g_set_error()- Return type: - The type of function to be passed as callback for - GLib.OptionArg.CALLBACKoptions.
- option_name (
- 
GLib.OptionErrorFunc(context, group, data)¶
- Parameters: - context (GLib.OptionContext) – The activeGLib.OptionContext
- group (GLib.OptionGroup) – The group to which the function belongs
- data (objectorNone) – User data added to theGLib.OptionGroupcontaining the option when it was created withGLib.OptionGroup.new()
 - The type of function to be used as callback when a parse error occurs. 
- context (
- 
GLib.OptionParseFunc(context, group, data)¶
- Parameters: - context (GLib.OptionContext) – The activeGLib.OptionContext
- group (GLib.OptionGroup) – The group to which the function belongs
- data (objectorNone) – User data added to theGLib.OptionGroupcontaining the option when it was created withGLib.OptionGroup.new()
 - Returns: - Trueif the function completed successfully,- Falseif an error occurred, in which case error should be set with g_set_error()- Return type: - The type of function that can be called before and after parsing. 
- context (
- 
GLib.PollFunc(ufds, nfsd, timeout_)¶
- Parameters: - ufds (GLib.PollFD) – an array ofGLib.PollFDelements
- nfsd (int) – the number of elements in ufds
- timeout (int) – the maximum time to wait for an event of the file descriptors. A negative value indicates an infinite timeout.
 - Returns: - the number of - GLib.PollFDelements which have events or errors reported, or -1 if an error occurred.- Return type: - Specifies the type of function passed to g_main_context_set_poll_func(). The semantics of the function should match those of the poll() system call. 
- ufds (
- 
GLib.PrintFunc(string)¶
- Parameters: - string ( - str) – the message to output- Specifies the type of the print handler functions. These are called with the complete formatted string to output. 
- 
GLib.RegexEvalCallback(match_info, result, *user_data)¶
- Parameters: - match_info (GLib.MatchInfo) – theGLib.MatchInfogenerated by the match. UseGLib.MatchInfo.get_regex() andGLib.MatchInfo.get_string() if you need theGLib.Regexor the matched string.
- result (GLib.String) – aGLib.Stringcontaining the new string
- user_data (objectorNone) – user data passed to g_regex_replace_eval()
 - Returns: - Return type: - Specifies the type of the function passed to g_regex_replace_eval(). It is called for each occurrence of the pattern in the string passed to g_regex_replace_eval(), and it should append the replacement to result. - New in version 2.14. 
- match_info (
- 
GLib.ScannerMsgFunc(scanner, message, error)¶
- Parameters: - scanner (GLib.Scanner) – aGLib.Scanner
- message (str) – the message
- error (bool) –Trueif the message signals an error,Falseif it signals a warning.
 - Specifies the type of the message handler function. 
- scanner (
- 
GLib.SequenceIterCompareFunc(a, b, data)¶
- Parameters: - a (GLib.SequenceIter) – aGLib.SequenceIter
- b (GLib.SequenceIter) – aGLib.SequenceIter
- data (objectorNone) – user data
 - Returns: - zero if the iterators are equal, a negative value if a comes before b, and a positive value if b comes before a. - Return type: - A - GLib.SequenceIterCompareFuncis a function used to compare iterators. It must return zero if the iterators compare equal, a negative value if a comes before b, and a positive value if b comes before a.
- a (
- 
GLib.SourceDisposeFunc(source)¶
- Parameters: - source ( - GLib.Source) –- GLib.Sourcethat is currently being disposed- Dispose function for source. See g_source_set_dispose_function() for details. - New in version 2.64. 
- 
GLib.SourceDummyMarshal()¶
- This is just a placeholder for #GClosureMarshal, which cannot be used here for dependency reasons. 
- 
GLib.SourceFunc(*user_data)¶
- Parameters: - user_data ( - objector- None) – data passed to the function, set when the source was created with one of the above functions- Returns: - Falseif the source should be removed.- GLib.SOURCE_CONTINUEand- GLib.SOURCE_REMOVEare more memorable names for the return value.- Return type: - bool- Specifies the type of function passed to - GLib.timeout_add(),- GLib.timeout_add(),- GLib.idle_add(), and- GLib.idle_add().- When calling - GLib.Source.set_callback(), you may need to cast a function of a different type to this type. Use G_SOURCE_FUNC() to avoid warnings about incompatible function types.
- 
GLib.SpawnChildSetupFunc(*user_data)¶
- Parameters: - user_data ( - objector- None) – user data to pass to the function.- Specifies the type of the setup function passed to - GLib.spawn_async(),- GLib.spawn_sync() and- GLib.spawn_async_with_pipes(), which can, in very limited ways, be used to affect the child’s execution.- On POSIX platforms, the function is called in the child after GLib has performed all the setup it plans to perform, but before calling exec(). Actions taken in this function will only affect the child, not the parent. - On Windows, the function is called in the parent. Its usefulness on Windows is thus questionable. In many cases executing the child setup function in the parent can have ill effects, and you should be very careful when porting software to Windows that uses child setup functions. - However, even on POSIX, you are extremely limited in what you can safely do from a - GLib.SpawnChildSetupFunc, because any mutexes that were held by other threads in the parent process at the time of the fork() will still be locked in the child process, and they will never be unlocked (since the threads that held them don’t exist in the child). POSIX allows only async-signal-safe functions (see signal(7)) to be called in the child between fork() and exec(), which drastically limits the usefulness of child setup functions.- In particular, it is not safe to call any function which may call malloc(), which includes POSIX functions such as setenv(). If you need to set up the child environment differently from the parent, you should use - GLib.get_environ(),- GLib.environ_setenv(), and- GLib.environ_unsetenv(), and then pass the complete environment list to the- g_spawn...function.
- 
GLib.TestDataFunc(*user_data)¶
- Parameters: - user_data ( - objector- None) – the data provided when registering the test- The type used for test case functions that take an extra pointer argument. - New in version 2.28. 
- 
GLib.TestFixtureFunc(fixture, *user_data)¶
- Parameters: - The type used for functions that operate on test fixtures. This is used for the fixture setup and teardown functions as well as for the testcases themselves. - user_data is a pointer to the data that was given when registering the test case. - fixture will be a pointer to the area of memory allocated by the test framework, of the size requested. If the requested size was zero then fixture will be equal to user_data. - New in version 2.28. 
- 
GLib.TestFunc()¶
- The type used for test case functions. - New in version 2.28. 
- 
GLib.TestLogFatalFunc(log_domain, log_level, message, *user_data)¶
- Parameters: - log_domain (str) – the log domain of the message
- log_level (GLib.LogLevelFlags) – the log level of the message (including the fatal and recursion flags)
- message (str) – the message to process
- user_data (objectorNone) – user data, set in g_test_log_set_fatal_handler()
 - Returns: - Return type: - Specifies the prototype of fatal log handler functions. - New in version 2.22. 
- log_domain (
- 
GLib.ThreadFunc(data)¶
- Parameters: - data ( - objector- None) – data passed to the thread- Returns: - the return value of the thread - Return type: - objector- None- Specifies the type of the func functions passed to - GLib.Thread.new() or- GLib.Thread.try_new().
- 
GLib.TranslateFunc(str, data)¶
- Parameters: - str (str) – the untranslated string
- data (objectorNone) – user data specified when installing the function, e.g. inGLib.OptionGroup.set_translate_func()
 - Returns: - a translation of the string for the current locale. The returned string is owned by GLib and must not be freed. - Return type: - The type of functions which are used to translate user-visible strings, for –help output. 
- str (
- 
GLib.TraverseFunc(key, value, data)¶
- Parameters: - Returns: - Trueto stop the traversal- Return type: - Specifies the type of function passed to g_tree_traverse(). It is passed the key and value of each node, together with the user_data parameter passed to g_tree_traverse(). If the function returns - True, the traversal is stopped.
- 
GLib.UnixFDSourceFunc(fd, condition, *user_data)¶
- Parameters: - fd (int) – the fd that triggered the event
- condition (GLib.IOCondition) – the IO conditions reported on fd
- user_data (objectorNone) – user data passed to g_unix_fd_add()
 - Returns: - Falseif the source should be removed- Return type: - The type of functions to be called when a UNIX fd watch source triggers. 
- fd (
- 
GLib.VoidFunc()¶
- Declares a type of function which takes no arguments and has no return value. It is used to specify the type function passed to - GLib.atexit().