1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-05-21 04:29:31 +00:00

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;
}
/**

View file

@ -25,6 +25,7 @@
#ifndef CALLS_BEST_MATCH_H__
#define CALLS_BEST_MATCH_H__
#include <gdk/gdk.h>
#include <gio/gio.h>
G_BEGIN_DECLS
@ -40,7 +41,7 @@ const char *calls_best_match_get_phone_number (CallsBestMatch *self);
void calls_best_match_set_phone_number (CallsBestMatch *self,
const char *phone_number);
const char *calls_best_match_get_name (CallsBestMatch *self);
GLoadableIcon *calls_best_match_get_avatar (CallsBestMatch *self);
GdkTexture *calls_best_match_get_avatar (CallsBestMatch *self);
const char *calls_best_match_get_primary_info (CallsBestMatch *self);
const char *calls_best_match_get_secondary_info (CallsBestMatch *self);

View file

@ -357,7 +357,7 @@ setup_contact (CallsCallRecordRow *self)
G_BINDING_SYNC_CREATE);
g_object_bind_property (self->contact, "avatar",
self->avatar, "loadable-icon",
self->avatar, "custom-image",
G_BINDING_SYNC_CREATE);
}

View file

@ -138,14 +138,14 @@ calls_ui_call_data_get_can_dtmf (CuiCall *call_data)
}
static GLoadableIcon *
static GdkPaintable *
calls_ui_call_data_get_avatar_icon (CuiCall *call_data)
{
CallsUiCallData *self = (CallsUiCallData *) call_data;
g_return_val_if_fail (CALLS_UI_CALL_DATA (self), NULL);
return calls_best_match_get_avatar (self->best_match);
return GDK_PAINTABLE (calls_best_match_get_avatar (self->best_match));
}