mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-29 09:10:10 +01:00
shared: add nm_g_variant_lookup() and nm_g_variant_lookup_value() helpers
It's often convenient to accept %NULL as dictionary argument.
This commit is contained in:
parent
455cec9986
commit
c7e6573eb4
1 changed files with 18 additions and 0 deletions
|
|
@ -1051,6 +1051,24 @@ nm_g_variant_unref_floating (GVariant *var)
|
|||
g_variant_unref (var);
|
||||
}
|
||||
|
||||
#define nm_g_variant_lookup(dictionary, ...) \
|
||||
({ \
|
||||
GVariant *const _dictionary = (dictionary); \
|
||||
\
|
||||
( _dictionary \
|
||||
&& g_variant_lookup (_dictionary, __VA_ARGS__)); \
|
||||
})
|
||||
|
||||
static inline GVariant *
|
||||
nm_g_variant_lookup_value (GVariant *dictionary,
|
||||
const char *key,
|
||||
const GVariantType *expected_type)
|
||||
{
|
||||
return dictionary
|
||||
? g_variant_lookup_value (dictionary, key, expected_type)
|
||||
: NULL;
|
||||
}
|
||||
|
||||
static inline void
|
||||
nm_g_source_destroy_and_unref (GSource *source)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue