mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2024-12-12 07:37:35 +00:00
BestMatch: add has-individual property
This commit is contained in:
parent
f1946aff79
commit
6d3b75262d
2 changed files with 33 additions and 6 deletions
|
@ -47,6 +47,7 @@ enum {
|
||||||
PROP_PHONE_NUMBER,
|
PROP_PHONE_NUMBER,
|
||||||
PROP_NAME,
|
PROP_NAME,
|
||||||
PROP_AVATAR,
|
PROP_AVATAR,
|
||||||
|
PROP_HAS_INDIVIDUAL,
|
||||||
PROP_LAST_PROP,
|
PROP_LAST_PROP,
|
||||||
};
|
};
|
||||||
static GParamSpec *props[PROP_LAST_PROP];
|
static GParamSpec *props[PROP_LAST_PROP];
|
||||||
|
@ -83,6 +84,7 @@ update_best_match (CallsBestMatch *self)
|
||||||
{
|
{
|
||||||
g_autoptr (GeeSortedSet) individuals = folks_search_view_get_individuals (self->view);
|
g_autoptr (GeeSortedSet) individuals = folks_search_view_get_individuals (self->view);
|
||||||
FolksIndividual *best_match = NULL;
|
FolksIndividual *best_match = NULL;
|
||||||
|
gboolean notify_has_individual = FALSE;
|
||||||
|
|
||||||
if (!gee_collection_get_is_empty (GEE_COLLECTION (individuals)))
|
if (!gee_collection_get_is_empty (GEE_COLLECTION (individuals)))
|
||||||
best_match = gee_sorted_set_first (individuals);
|
best_match = gee_sorted_set_first (individuals);
|
||||||
|
@ -93,6 +95,7 @@ update_best_match (CallsBestMatch *self)
|
||||||
if (self->best_match) {
|
if (self->best_match) {
|
||||||
g_signal_handlers_disconnect_by_data (self->best_match, self);
|
g_signal_handlers_disconnect_by_data (self->best_match, self);
|
||||||
g_clear_object (&self->best_match);
|
g_clear_object (&self->best_match);
|
||||||
|
notify_has_individual = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (best_match) {
|
if (best_match) {
|
||||||
|
@ -105,10 +108,13 @@ update_best_match (CallsBestMatch *self)
|
||||||
"notify::avatar",
|
"notify::avatar",
|
||||||
G_CALLBACK (notify_avatar),
|
G_CALLBACK (notify_avatar),
|
||||||
self);
|
self);
|
||||||
|
notify_has_individual = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
notify_name (self);
|
notify_name (self);
|
||||||
notify_avatar (self);
|
notify_avatar (self);
|
||||||
|
if (notify_has_individual)
|
||||||
|
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_HAS_INDIVIDUAL]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -142,6 +148,11 @@ get_property (GObject *object,
|
||||||
|
|
||||||
switch (property_id)
|
switch (property_id)
|
||||||
{
|
{
|
||||||
|
case PROP_HAS_INDIVIDUAL:
|
||||||
|
g_value_set_boolean (value,
|
||||||
|
calls_best_match_has_individual (self));
|
||||||
|
break;
|
||||||
|
|
||||||
case PROP_PHONE_NUMBER:
|
case PROP_PHONE_NUMBER:
|
||||||
g_value_set_string (value,
|
g_value_set_string (value,
|
||||||
calls_best_match_get_phone_number (self));
|
calls_best_match_get_phone_number (self));
|
||||||
|
@ -190,6 +201,13 @@ calls_best_match_class_init (CallsBestMatchClass *klass)
|
||||||
object_class->get_property = get_property;
|
object_class->get_property = get_property;
|
||||||
object_class->dispose = dispose;
|
object_class->dispose = dispose;
|
||||||
|
|
||||||
|
props[PROP_HAS_INDIVIDUAL] =
|
||||||
|
g_param_spec_boolean ("has-individual",
|
||||||
|
"Has individual",
|
||||||
|
"Whether a matching individual was found or not",
|
||||||
|
FALSE,
|
||||||
|
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY);
|
||||||
|
|
||||||
props[PROP_PHONE_NUMBER] =
|
props[PROP_PHONE_NUMBER] =
|
||||||
g_param_spec_string ("phone_number",
|
g_param_spec_string ("phone_number",
|
||||||
"Phone number",
|
"Phone number",
|
||||||
|
@ -230,6 +248,14 @@ calls_best_match_new (const gchar *number)
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
calls_best_match_has_individual (CallsBestMatch *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (CALLS_IS_BEST_MATCH (self), FALSE);
|
||||||
|
|
||||||
|
return !!self->best_match;
|
||||||
|
}
|
||||||
|
|
||||||
const gchar *
|
const gchar *
|
||||||
calls_best_match_get_phone_number (CallsBestMatch *self)
|
calls_best_match_get_phone_number (CallsBestMatch *self)
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,12 +33,13 @@ G_BEGIN_DECLS
|
||||||
|
|
||||||
G_DECLARE_FINAL_TYPE (CallsBestMatch, calls_best_match, CALLS, BEST_MATCH, GObject);
|
G_DECLARE_FINAL_TYPE (CallsBestMatch, calls_best_match, CALLS, BEST_MATCH, GObject);
|
||||||
|
|
||||||
CallsBestMatch *calls_best_match_new (const gchar *phone_number);
|
CallsBestMatch *calls_best_match_new (const gchar *phone_number);
|
||||||
const gchar * calls_best_match_get_phone_number (CallsBestMatch *self);
|
gboolean calls_best_match_has_individual (CallsBestMatch *self);
|
||||||
void calls_best_match_set_phone_number (CallsBestMatch *self,
|
const gchar * calls_best_match_get_phone_number (CallsBestMatch *self);
|
||||||
const gchar *phone_number);
|
void calls_best_match_set_phone_number (CallsBestMatch *self,
|
||||||
const gchar * calls_best_match_get_name (CallsBestMatch *self);
|
const gchar *phone_number);
|
||||||
GLoadableIcon *calls_best_match_get_avatar (CallsBestMatch *self);
|
const gchar * calls_best_match_get_name (CallsBestMatch *self);
|
||||||
|
GLoadableIcon *calls_best_match_get_avatar (CallsBestMatch *self);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue