mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2024-11-17 07:46:03 +00:00
record-row: Handle calls with NULL id gracefully
Shuffles some code around so that the property bindings are at the end. This allows us to return early if there is a NULL contact (as is the case for anonymous callers).
This commit is contained in:
parent
cd075d9269
commit
5b171bf2c5
1 changed files with 31 additions and 20 deletions
|
@ -310,15 +310,40 @@ setup_contact (CallsCallRecordRow *self)
|
|||
g_autofree gchar *target = NULL;
|
||||
CallsContactsProvider *contacts_provider;
|
||||
|
||||
contacts_provider = calls_manager_get_contacts_provider (calls_manager_get_default ());
|
||||
|
||||
if (calls_contacts_provider_get_can_add_contacts (contacts_provider)) {
|
||||
on_notify_can_add_contacts (self);
|
||||
} else {
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action_new_contact), FALSE);
|
||||
g_signal_connect_swapped (contacts_provider,
|
||||
"notify::can-add-contacts",
|
||||
G_CALLBACK (on_notify_can_add_contacts),
|
||||
self);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Get the target number
|
||||
g_object_get (G_OBJECT (self->record),
|
||||
"target", &target,
|
||||
NULL);
|
||||
|
||||
if (!target || target[0] == '\0') {
|
||||
gtk_actionable_set_action_name (GTK_ACTIONABLE (self->button), NULL);
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action_copy), FALSE);
|
||||
} else {
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action_copy), TRUE);
|
||||
}
|
||||
|
||||
// Look up the best match object
|
||||
contacts_provider = calls_manager_get_contacts_provider (calls_manager_get_default ());
|
||||
self->contact = calls_contacts_provider_lookup_id (contacts_provider, target);
|
||||
|
||||
if (!self->contact) {
|
||||
gtk_label_set_text (self->target, calls_best_match_get_primary_info (NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
g_object_bind_property (self->contact, "primary-info",
|
||||
self->target, "label",
|
||||
G_BINDING_SYNC_CREATE);
|
||||
|
@ -331,23 +356,6 @@ setup_contact (CallsCallRecordRow *self)
|
|||
self->avatar, "loadable-icon",
|
||||
G_BINDING_SYNC_CREATE);
|
||||
|
||||
if (calls_contacts_provider_get_can_add_contacts (contacts_provider)) {
|
||||
on_notify_can_add_contacts (self);
|
||||
} else {
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action_new_contact), FALSE);
|
||||
g_signal_connect_swapped (contacts_provider,
|
||||
"notify::can-add-contacts",
|
||||
G_CALLBACK (on_notify_can_add_contacts),
|
||||
self);
|
||||
}
|
||||
|
||||
|
||||
if (target[0] == '\0') {
|
||||
gtk_actionable_set_action_name (GTK_ACTIONABLE (self->button), NULL);
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action_copy), FALSE);
|
||||
} else {
|
||||
g_simple_action_set_enabled (G_SIMPLE_ACTION (action_copy), TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -453,8 +461,11 @@ constructed (GObject *object)
|
|||
gtk_actionable_set_action_name (GTK_ACTIONABLE (self->button), action_name);
|
||||
|
||||
/* TODO add origin ID to action target */
|
||||
if (target && *target)
|
||||
gtk_actionable_set_action_target (GTK_ACTIONABLE (self->button),
|
||||
"(ss)", target, "");
|
||||
else
|
||||
;
|
||||
|
||||
setup_time (self, inbound, answered, end);
|
||||
calls_date_time_unref (answered);
|
||||
|
|
Loading…
Reference in a new issue