gs-remote-icon

gs-remote-icon — A GIcon implementation for remote icons

Functions

GIcon * gs_remote_icon_new ()
const gchar * gs_remote_icon_get_uri ()
gboolean gs_remote_icon_ensure_cached ()

Types and Values

Description

GsRemoteIcon is a GIcon implementation which represents remote icons — icons which have an HTTP or HTTPS URI. It provides a well-known local filename for a cached copy of the icon, accessible as “file”, and a method to download the icon to the cache, gs_remote_icon_ensure_cached().

Constructing a GsRemoteIcon does not guarantee that the icon is cached. Call gs_remote_icon_ensure_cached() for that.

GsRemoteIcon is immutable after construction and hence is entirely thread safe.

FIXME: Currently does no cache invalidation.

Functions

gs_remote_icon_new ()

GIcon *
gs_remote_icon_new (const gchar *uri);

Create a new GsRemoteIcon representing uri . The “file” of the resulting icon will represent the local cache location for the icon.

Parameters

uri

remote URI of the icon

 

Returns

a new remote icon.

[transfer full]

Since: 40


gs_remote_icon_get_uri ()

const gchar *
gs_remote_icon_get_uri (GsRemoteIcon *self);

Gets the value of “uri”.

Parameters

self

a GsRemoteIcon

 

Returns

remote URI of the icon.

[not nullable]

Since: 40


gs_remote_icon_ensure_cached ()

gboolean
gs_remote_icon_ensure_cached (GsRemoteIcon *self,
                              SoupSession *soup_session,
                              guint maximum_icon_size,
                              guint scale,
                              GCancellable *cancellable,
                              GError **error);

Ensure the given icon is present in the local cache, potentially downloading it from its remote server if needed. This will do network and disk I/O.

maximum_icon_size specifies the maximum size (in logical pixels) of the icon which should be saved to the cache. This is the maximum size that the icon can ever be used at, as icons can be downscaled but never upscaled. Typically this will be 160px. The device scale factor (gtk_widget_get_scale_factor()) is provided separately as scale .

This can be called from any thread, as GsRemoteIcon is immutable and hence thread-safe.

Parameters

self

a GsRemoteIcon

 

soup_session

a SoupSession to use to download the icon

 

maximum_icon_size

maximum size (in logical pixels) of the icon to save

 

scale

scale the icon will be used at

 

cancellable

a GCancellable, or NULL.

[nullable]

error

return location for a GError, or NULL

 

Returns

TRUE on success, FALSE otherwise

Since: 48

Types and Values

GS_TYPE_REMOTE_ICON

#define GS_TYPE_REMOTE_ICON (gs_remote_icon_get_type ())

GsRemoteIcon

typedef struct _GsRemoteIcon GsRemoteIcon;