mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-05 19:15:32 +00:00
record-row: Simplify add-action logic
Get rid of some code by avoiding special casing and potentially fix an issue (WIP).
This commit is contained in:
parent
0d6095b42a
commit
01f3757ce1
1 changed files with 14 additions and 24 deletions
|
@ -291,19 +291,15 @@ on_notify_can_add_contacts (CallsCallRecordRow *self)
|
||||||
|
|
||||||
contacts_provider = calls_manager_get_contacts_provider (calls_manager_get_default ());
|
contacts_provider = calls_manager_get_contacts_provider (calls_manager_get_default ());
|
||||||
|
|
||||||
if (!calls_contacts_provider_get_can_add_contacts (contacts_provider))
|
if (calls_contacts_provider_get_can_add_contacts (contacts_provider) &&
|
||||||
return;
|
self->contact) {
|
||||||
|
g_object_bind_property (self->contact, "has-individual",
|
||||||
g_signal_handlers_disconnect_by_data (contacts_provider, self);
|
action_new_contact, "enabled",
|
||||||
|
G_BINDING_SYNC_CREATE |
|
||||||
/* The record has a NULL id */
|
G_BINDING_INVERT_BOOLEAN);
|
||||||
if (!self->contact)
|
} else {
|
||||||
return;
|
g_simple_action_set_enabled (G_SIMPLE_ACTION (action_new_contact), FALSE);
|
||||||
|
}
|
||||||
g_object_bind_property (self->contact, "has-individual",
|
|
||||||
action_new_contact, "enabled",
|
|
||||||
G_BINDING_SYNC_CREATE |
|
|
||||||
G_BINDING_INVERT_BOOLEAN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -311,23 +307,17 @@ static void
|
||||||
setup_contact (CallsCallRecordRow *self)
|
setup_contact (CallsCallRecordRow *self)
|
||||||
{
|
{
|
||||||
GAction *action_copy = g_action_map_lookup_action (self->action_map, "copy-number");
|
GAction *action_copy = g_action_map_lookup_action (self->action_map, "copy-number");
|
||||||
GAction *action_new_contact = g_action_map_lookup_action (self->action_map, "new-contact");
|
|
||||||
g_autofree gchar *target = NULL;
|
g_autofree gchar *target = NULL;
|
||||||
CallsContactsProvider *contacts_provider;
|
CallsContactsProvider *contacts_provider;
|
||||||
|
|
||||||
contacts_provider = calls_manager_get_contacts_provider (calls_manager_get_default ());
|
contacts_provider = calls_manager_get_contacts_provider (calls_manager_get_default ());
|
||||||
|
|
||||||
if (calls_contacts_provider_get_can_add_contacts (contacts_provider)) {
|
g_signal_connect_swapped (contacts_provider,
|
||||||
on_notify_can_add_contacts (self);
|
"notify::can-add-contacts",
|
||||||
} else {
|
G_CALLBACK (on_notify_can_add_contacts),
|
||||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action_new_contact), FALSE);
|
self);
|
||||||
g_signal_connect_swapped (contacts_provider,
|
|
||||||
"notify::can-add-contacts",
|
|
||||||
G_CALLBACK (on_notify_can_add_contacts),
|
|
||||||
self);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
on_notify_can_add_contacts (self);
|
||||||
|
|
||||||
// Get the target number
|
// Get the target number
|
||||||
g_object_get (G_OBJECT (self->record),
|
g_object_get (G_OBJECT (self->record),
|
||||||
|
|
Loading…
Reference in a new issue