calls-best-match: AdwAvatar API changes

https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/migrating-libhandy-1-4-to-libadwaita.html#adapt-to-adwavatar-api-changes

This is *not* ideal, since it relies on Folks returning a GFileIcon
internally, and it's also blocking. However, better to use something
simple that compiles and works to begin with.

Part-of: <https://gitlab.gnome.org/GNOME/calls/-/merge_requests/714>
This commit is contained in:
Anton Lazarev
2023-12-13 15:52:56 -08:00
parent 52a0963e6c
commit 12b78ca5f6
4 changed files with 27 additions and 9 deletions

View File

@@ -282,7 +282,7 @@ calls_best_match_class_init (CallsBestMatchClass *klass)
g_param_spec_object ("avatar",
"Avatar",
"The avatar of the best match",
G_TYPE_LOADABLE_ICON,
GDK_TYPE_TEXTURE,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY);
props[PROP_PRIMARY_INFO] =
@@ -452,15 +452,32 @@ calls_best_match_get_name (CallsBestMatch *self)
*
* Returns: (nullable): The avatar of a matched contact or %NULL when there's no match.
*/
GLoadableIcon *
GdkTexture *
calls_best_match_get_avatar (CallsBestMatch *self)
{
GdkTexture *output;
GLoadableIcon *loadable_icon;
g_autoptr (GError) error = NULL;
g_return_val_if_fail (CALLS_IS_BEST_MATCH (self), NULL);
if (self->matched_individual)
return folks_avatar_details_get_avatar (FOLKS_AVATAR_DETAILS (self->matched_individual));
else
if (!self->matched_individual)
return NULL;
loadable_icon = folks_avatar_details_get_avatar (FOLKS_AVATAR_DETAILS (self->matched_individual));
if (!G_IS_FILE_ICON (loadable_icon)) {
return NULL;
}
output = gdk_texture_new_from_file (g_file_icon_get_file (G_FILE_ICON (loadable_icon)), &error);
if (error != NULL) {
g_print ("Failed to read avatar icon file: %s", error->message);
return NULL;
}
return output;
}
/**