1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-11-19 01:51:46 +00:00

CallsCallDisplay: Make sure that the contact infomation is updated

This is done by binding the contact information to the UI.
This commit is contained in:
Julian Sparber 2021-01-28 17:07:26 +01:00 committed by Evangelos Ribeiro Tzaras
parent 501d29145f
commit 2206c3733c

View file

@ -25,7 +25,6 @@
#include "config.h" #include "config.h"
#include "calls-manager.h" #include "calls-manager.h"
#include "calls-call-display.h" #include "calls-call-display.h"
#include "calls-party.h"
#include "util.h" #include "util.h"
#include <glib/gi18n.h> #include <glib/gi18n.h>
@ -38,6 +37,7 @@ struct _CallsCallDisplay
{ {
GtkOverlay parent_instance; GtkOverlay parent_instance;
CallsBestMatch *contact;
CallsCall *call; CallsCall *call;
GTimer *timer; GTimer *timer;
guint timeout; guint timeout;
@ -312,24 +312,29 @@ calls_call_display_new (CallsCall *call)
} }
// FIXME: this should direclty use CallsBestMatch since the matching contact could change over time
static void static void
set_party (CallsCallDisplay *self) set_party (CallsCallDisplay *self)
{ {
GtkWidget *image; // FIXME: use HdyAvatar and the contact avatar
const gchar *name, *number; GtkWidget *image = gtk_image_new_from_icon_name ("avatar-default-symbolic", GTK_ICON_SIZE_DIALOG);
g_autoptr (CallsParty) party = calls_party_new (calls_manager_get_contact_name (self->call),
calls_call_get_number (self->call));
image = calls_party_create_image (party);
gtk_box_pack_end (self->party_box, image, TRUE, TRUE, 0); gtk_box_pack_end (self->party_box, image, TRUE, TRUE, 0);
gtk_image_set_pixel_size (GTK_IMAGE (image), 100); gtk_image_set_pixel_size (GTK_IMAGE (image), 100);
gtk_widget_show (image); gtk_widget_show (image);
name = calls_party_get_name (party); self->contact = calls_call_get_contact (self->call);
number = calls_party_get_number (party);
g_object_bind_property (self->contact, "name",
self->primary_contact_info, "label",
G_BINDING_SYNC_CREATE);
g_object_bind_property (self->contact, "phone-number",
self->secondary_contact_info, "label",
G_BINDING_SYNC_CREATE);
g_object_bind_property (self->contact, "has-individual",
self->secondary_contact_info, "visible",
G_BINDING_INVERT_BOOLEAN | G_BINDING_SYNC_CREATE);
gtk_label_set_text (self->primary_contact_info, name != NULL ? name : number);
gtk_label_set_text (self->secondary_contact_info, name != NULL ? number : NULL);
} }
@ -450,6 +455,7 @@ dispose (GObject *object)
stop_timeout (self); stop_timeout (self);
g_clear_object (&self->call); g_clear_object (&self->call);
g_clear_object (&self->contact);
G_OBJECT_CLASS (calls_call_display_parent_class)->dispose (object); G_OBJECT_CLASS (calls_call_display_parent_class)->dispose (object);
} }