mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-12 04:30:22 +01:00
shared: add NM_GOBJECT_PROPERTIES_DEFINE()
Helper macros to define GObject property enum, the obj_properties array, and a _notify() function. We should move away from invoking property changed notifications by string, as we already do for signals. This macro simplifies the implementation of establishes a pattern for naming and usage.
This commit is contained in:
parent
ecd729706e
commit
f427909bf8
1 changed files with 17 additions and 0 deletions
|
|
@ -196,6 +196,23 @@
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define NM_GOBJECT_PROPERTIES_DEFINE(obj_type, ...) \
|
||||
typedef enum { \
|
||||
_PROPERTY_ENUMS_0, \
|
||||
__VA_ARGS__ \
|
||||
_PROPERTY_ENUMS_LAST, \
|
||||
} _PropertyEnums; \
|
||||
static GParamSpec *obj_properties[_PROPERTY_ENUMS_LAST] = { NULL, }; \
|
||||
static inline void \
|
||||
_notify (obj_type *obj, _PropertyEnums prop) \
|
||||
{ \
|
||||
nm_assert (G_IS_OBJECT (obj)); \
|
||||
nm_assert ((gsize) prop < G_N_ELEMENTS (obj_properties)); \
|
||||
g_object_notify_by_pspec ((GObject *) obj, obj_properties[prop]); \
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static inline gboolean
|
||||
nm_clear_g_source (guint *id)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue