1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-12-04 20:07:36 +00:00

Reintroduce GParamSpec props arrays & replace g_object_notify with g_object_notify_by_pspec

This commit is contained in:
Daniel Abrecht 2020-03-17 21:54:25 +00:00 committed by Julian Sparber
parent 4055503336
commit cad79a4834
3 changed files with 54 additions and 41 deletions

View file

@ -58,6 +58,7 @@ enum {
PROP_LAST_PROP
};
static GParamSpec *props[PROP_LAST_PROP];
static void
change_state (CallsCall *call,
@ -72,7 +73,7 @@ change_state (CallsCall *call,
}
self->state = state;
g_object_notify (G_OBJECT (call), "state");
g_object_notify_by_pspec (G_OBJECT (call), props[PROP_CALL_STATE]);
g_signal_emit_by_name (call,
"state-changed",
state,
@ -250,28 +251,32 @@ calls_dummy_call_class_init (CallsDummyCallClass *klass)
object_class->constructed = constructed;
object_class->finalize = finalize;
g_object_class_install_property (
object_class,
PROP_NUMBER_CONSTRUCTOR,
props[PROP_NUMBER_CONSTRUCTOR] =
g_param_spec_string ("number-constructor",
_("Number (constructor)"),
_("The dialed number (dummy class constructor)"),
"+441234567890",
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (object_class, PROP_NUMBER_CONSTRUCTOR, props[PROP_NUMBER_CONSTRUCTOR]);
g_object_class_install_property (
object_class,
PROP_INBOUND_CONSTRUCTOR,
props[PROP_INBOUND_CONSTRUCTOR] =
g_param_spec_boolean ("inbound-constructor",
_("Inbound (constructor)"),
_("Whether the calls is inbound (dummy class constructor)"),
FALSE,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (object_class, PROP_INBOUND_CONSTRUCTOR, props[PROP_INBOUND_CONSTRUCTOR]);
g_object_class_override_property (object_class, PROP_CALL_NUMBER, "number");
g_object_class_override_property (object_class, PROP_CALL_INBOUND, "inbound");
g_object_class_override_property (object_class, PROP_CALL_STATE, "state");
g_object_class_override_property (object_class, PROP_CALL_NAME, "name");
#define IMPLEMENTS(ID, NAME) \
g_object_class_override_property (object_class, ID, NAME); \
props[ID] = g_object_class_find_property(object_class, NAME);
IMPLEMENTS(PROP_CALL_NUMBER, "number");
IMPLEMENTS(PROP_CALL_INBOUND, "inbound");
IMPLEMENTS(PROP_CALL_STATE, "state");
IMPLEMENTS(PROP_CALL_NAME, "name");
#undef IMPLEMENTS
}

View file

@ -60,7 +60,7 @@ enum {
PROP_LAST_PROP,
};
static GParamSpec *props[PROP_LAST_PROP];
static void
change_state (CallsMMCall *self,
@ -74,7 +74,7 @@ change_state (CallsMMCall *self,
}
self->state = state;
g_object_notify (G_OBJECT (self), "state");
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CALL_STATE]);
g_signal_emit_by_name (CALLS_CALL (self),
"state-changed",
state,
@ -87,7 +87,7 @@ notify_number_cb (CallsMMCall *self,
const gchar *number)
{
g_string_assign (self->number, number);
g_object_notify (G_OBJECT (self), "number");
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CALL_NUMBER]);
}
@ -390,20 +390,23 @@ calls_mm_call_class_init (CallsMMCallClass *klass)
object_class->dispose = dispose;
object_class->finalize = finalize;
g_object_class_install_property (
object_class,
PROP_MM_CALL,
g_param_spec_object ("mm-call",
_("MM call"),
_("A libmm-glib proxy object for the underlying call object"),
MM_TYPE_CALL,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
props[PROP_MM_CALL] = g_param_spec_object ("mm-call",
_("MM call"),
_("A libmm-glib proxy object for the underlying call object"),
MM_TYPE_CALL,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (object_class, PROP_MM_CALL, props[PROP_MM_CALL]);
g_object_class_override_property (object_class, PROP_CALL_NUMBER, "number");
g_object_class_override_property (object_class, PROP_CALL_INBOUND, "inbound");
g_object_class_override_property (object_class, PROP_CALL_STATE, "state");
g_object_class_override_property (object_class, PROP_CALL_NAME, "name");
#define IMPLEMENTS(ID, NAME) \
g_object_class_override_property (object_class, ID, NAME); \
props[ID] = g_object_class_find_property(object_class, NAME);
IMPLEMENTS(PROP_CALL_NUMBER, "number");
IMPLEMENTS(PROP_CALL_INBOUND, "inbound");
IMPLEMENTS(PROP_CALL_STATE, "state");
IMPLEMENTS(PROP_CALL_NAME, "name");
#undef IMPLEMENTS
}

View file

@ -65,6 +65,7 @@ enum {
PROP_LAST_PROP,
};
static GParamSpec *props[PROP_LAST_PROP];
enum {
SIGNAL_TONE,
@ -84,7 +85,7 @@ change_state (CallsOfonoCall *self,
}
self->state = state;
g_object_notify (G_OBJECT (self), "state");
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CALL_STATE]);
g_signal_emit_by_name (CALLS_CALL (self),
"state-changed",
state,
@ -354,29 +355,33 @@ calls_ofono_call_class_init (CallsOfonoCallClass *klass)
object_class->dispose = dispose;
object_class->finalize = finalize;
g_object_class_install_property (
object_class,
PROP_VOICE_CALL,
props[PROP_VOICE_CALL] =
g_param_spec_object ("voice-call",
_("Voice call"),
_("A GDBO proxy object for the underlying call object"),
GDBO_TYPE_VOICE_CALL,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (object_class, PROP_VOICE_CALL, props[PROP_VOICE_CALL]);
g_object_class_install_property (
object_class,
PROP_PROPERTIES,
props[PROP_PROPERTIES] =
g_param_spec_variant ("properties",
_("Properties"),
_("The a{sv} dictionary of properties for the voice call object"),
G_VARIANT_TYPE_ARRAY,
NULL,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (object_class, PROP_PROPERTIES, props[PROP_PROPERTIES]);
g_object_class_override_property (object_class, PROP_CALL_NUMBER, "number");
g_object_class_override_property (object_class, PROP_CALL_INBOUND, "inbound");
g_object_class_override_property (object_class, PROP_CALL_STATE, "state");
g_object_class_override_property (object_class, PROP_CALL_NAME, "name");
#define IMPLEMENTS(ID, NAME) \
g_object_class_override_property (object_class, ID, NAME); \
props[ID] = g_object_class_find_property(object_class, NAME);
IMPLEMENTS(PROP_CALL_NUMBER, "number");
IMPLEMENTS(PROP_CALL_INBOUND, "inbound");
IMPLEMENTS(PROP_CALL_STATE, "state");
IMPLEMENTS(PROP_CALL_NAME, "name");
#undef IMPLEMENTS
signals[SIGNAL_TONE] =
g_signal_newv ("tone",