From 0bc8c7bc4e0c0f046d2d19a9b25db19e72130bc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sat, 27 Jun 2020 13:08:51 +0200 Subject: [PATCH] calls-call-record-row: Print 'Anonymous caller' on empty numbers If no number is present use `Anonymous caller` instead of an empty label in the call history. See: #144 --- src/calls-call-record-row.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/calls-call-record-row.c b/src/calls-call-record-row.c index 9321af2..7ff9337 100644 --- a/src/calls-call-record-row.c +++ b/src/calls-call-record-row.c @@ -36,6 +36,9 @@ #include +#define ANONYMOUS_CALLER _("Anonymous caller") + + struct _CallsCallRecordRow { GtkListBoxRow parent_instance; @@ -339,15 +342,20 @@ contact_name_cb (CallsCallRecordRow *self) } else { - gchar *target; + g_autofree gchar *target = NULL; g_object_get (G_OBJECT (self->record), "target", &target, NULL); - gtk_label_set_text (self->target, target); - - g_free (target); + if (!g_strcmp0 (target, "")) + { + gtk_label_set_text (self->target, ANONYMOUS_CALLER); + } + else + { + gtk_label_set_text (self->target, target); + } } } @@ -355,7 +363,16 @@ static void avatar_text_changed_cb (HdyAvatar *avatar) { const gchar *text = hdy_avatar_get_text (avatar); - hdy_avatar_set_show_initials (avatar, !g_ascii_isdigit (*text) && !strchr("#*+", *text)); + gboolean show_initials = TRUE; + + if (strchr("#*+", *text) + || g_ascii_isdigit (*text) + || !g_strcmp0 (text, ANONYMOUS_CALLER)) + { + show_initials = FALSE; + } + + hdy_avatar_set_show_initials (avatar, show_initials); }