1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-07-07 09:29:30 +00:00

contact-provider: Allow can-add-contacts to be reset

Under normal conditions it is not expected that whether we can add
contacts or not (based on the presence of the appropriate action on
gnome-contacts) changes.

Nevertheless it can be beneficial for debugging when installing patched
and unpatched versions of gnome-contacts.
This commit is contained in:
Evangelos Ribeiro Tzaras 2022-10-10 14:44:58 +02:00
parent d51151a028
commit 48a77cda5c

View file

@ -190,25 +190,39 @@ folks_prepare_cb (GObject *obj,
}
static void
set_can_add_contacts (CallsContactsProvider *self,
gboolean can_add)
{
g_assert (CALLS_IS_CONTACTS_PROVIDER (self));
g_info ("Can%s add contacts", can_add ? "" : "not");
if (self->can_add_contacts == can_add)
return;
self->can_add_contacts = can_add;
g_object_notify_by_pspec(G_OBJECT (self), props[PROP_CAN_ADD_CONTACTS]);
}
static void
on_contacts_actions_updated (CallsContactsProvider *self)
{
gboolean has_action;
gboolean action_enabled;
const char *contact_action_name = "new-contact-data";
g_assert (CALLS_IS_CONTACTS_PROVIDER (self));
if (self->can_add_contacts)
return;
has_action =
g_action_group_has_action (G_ACTION_GROUP (self->contacts_action_group),
contact_action_name);
action_enabled =
g_action_group_get_action_enabled (G_ACTION_GROUP (self->contacts_action_group),
contact_action_name);
if (g_action_group_has_action (G_ACTION_GROUP (self->contacts_action_group),
contact_action_name) &&
g_action_group_get_action_enabled (G_ACTION_GROUP (self->contacts_action_group),
contact_action_name)) {
g_debug ("Can add contacts");
self->can_add_contacts = TRUE;
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CAN_ADD_CONTACTS]);
}
set_can_add_contacts (self, has_action && action_enabled);
}