1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-12-12 07:37:35 +00:00

History: use HdyAvatar

This disables the custom avatar. It will be added back later.

Signed-off-by: Julian Sparber <julian@sparber.net>
This commit is contained in:
Julian Sparber 2020-03-31 11:57:54 +02:00
parent 63e5bc8504
commit 4f03ab0441
No known key found for this signature in database
GPG key ID: 7A0E81F405F35D6A
2 changed files with 14 additions and 57 deletions

View file

@ -24,6 +24,7 @@
#include "calls-call-record-row.h"
#include "calls-best-match.h"
#include "contrib/hdy-avatar.h"
#include "util.h"
#include <glib/gi18n.h>
@ -34,14 +35,11 @@
#include <errno.h>
#define AVATAR_SIZE 32
struct _CallsCallRecordRow
{
GtkListBoxRow parent_instance;
GtkImage *avatar;
GtkWidget *avatar;
GtkImage *type;
GtkLabel *target;
GtkLabel *time;
@ -347,53 +345,11 @@ contact_name_cb (CallsCallRecordRow *self)
}
}
static void
set_avatar (CallsCallRecordRow *self,
GdkPixbuf *avatar)
avatar_text_changed_cb (HdyAvatar *avatar)
{
if (avatar)
{
gtk_image_set_from_pixbuf (self->avatar, avatar);
}
else
{
gtk_image_set_from_icon_name (self->avatar,
"avatar-default-symbolic",
GTK_ICON_SIZE_DND);
}
}
static void
contact_avatar_cb (CallsCallRecordRow *self,
gint size,
GdkPixbuf *avatar,
CallsBestMatch *contact)
{
if (size != AVATAR_SIZE)
{
return;
}
set_avatar (self, avatar);
}
static void
request_contact_avatar (CallsCallRecordRow *self)
{
GdkPixbuf *avatar;
if (!self->contact)
{
return;
}
avatar = calls_best_match_request_avatar
(self->contact, AVATAR_SIZE);
set_avatar (self, avatar);
const gchar *text = hdy_avatar_get_text (avatar);
hdy_avatar_set_show_initials (avatar, !g_ascii_isdigit (*text) && !strchr("#*+", *text));
}
@ -432,10 +388,6 @@ setup_contact (CallsCallRecordRow *self)
"notify::name",
G_CALLBACK (contact_name_cb),
self);
g_signal_connect_swapped (self->contact,
"avatar",
G_CALLBACK (contact_avatar_cb),
self);
}
@ -495,7 +447,6 @@ constructed (GObject *object)
setup_contact (self);
contact_name_cb (self);
request_contact_avatar (self);
G_OBJECT_CLASS (calls_call_record_row_parent_class)->constructed (object);
}
@ -579,6 +530,11 @@ static void
calls_call_record_row_init (CallsCallRecordRow *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
g_signal_connect (self->avatar,
"notify::text",
G_CALLBACK (avatar_text_changed_cb),
NULL);
}

View file

@ -12,14 +12,15 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImage" id="avatar">
<object class="HdyAvatar" id="avatar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">8</property>
<property name="margin_top">8</property>
<property name="margin_bottom">8</property>
<property name="icon-name">avatar-default-symbolic</property>
<property name="icon-size">6</property>
<property name="size">36</property>
<property name="text" bind-source="target" bind-property="label" bind-flags="sync-create"></property>
<property name="show-initials">True</property>
</object>
<packing>
<property name="position">0</property>