[calls] record-row: Handle calls with NULL id gracefully
- From: Evangelos Ribeiro Tzaras <devrtz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [calls] record-row: Handle calls with NULL id gracefully
- Date: Tue, 22 Feb 2022 09:30:40 +0000 (UTC)
commit 5b171bf2c5e16405ba3795a79565afa63175d416
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date: Thu Feb 17 11:57:14 2022 +0100
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).
src/calls-call-record-row.c | 51 +++++++++++++++++++++++++++------------------
1 file changed, 31 insertions(+), 20 deletions(-)
---
diff --git a/src/calls-call-record-row.c b/src/calls-call-record-row.c
index 5b55c45c..4a1024d4 100644
--- a/src/calls-call-record-row.c
+++ b/src/calls-call-record-row.c
@@ -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 */
- gtk_actionable_set_action_target (GTK_ACTIONABLE (self->button),
- "(ss)", 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]