1.8 <AdwAvatar>

Class: <AdwAvatar>

It derives from <GtkWidget>.

A widget displaying an image, with a generated fallback.

<AdwAvatar> is a widget that shows a round avatar.

<AdwAvatar> generates an avatar with the initials of the Avatar:text on top of a colored background.

The color is picked based on the hash of the Avatar:text.

If Avatar:show-initials is set to FALSE, Avatar:icon-name or adw-avatar-default-symbolic is shown instead of the initials.

Use Avatar:custom-image to set a custom image.

CSS nodes

<AdwAvatar> has a single CSS node with name avatar.

Accessibility

<AdwAvatar> uses the Gtk.AccessibleRole.img role.

Properties

Property: avatar:custom-image self

A custom image paintable.

Custom image is displayed instead of initials or icon.

Its value is a <GdkPaintable>, or #f.

Set it with (set! (avatar:custom-image self) value).

Property: avatar:icon-name self

The name of an icon to use as a fallback.

If no name is set, adw-avatar-default-symbolic will be used.

Its value is a string, or #f.

Set it with (set! (avatar:icon-name self) value).

Property: avatar:show-initials self

Whether initials are used instead of an icon on the fallback avatar.

See Avatar:icon-name for how to change the fallback icon.

Its value is a boolean.

Set it with (set! (avatar:show-initials self) value).

Property: avatar:size self

The size of the avatar.

Its value is a 32-bit integer.

Set it with (set! (avatar:size self) value).

Property: avatar:text self

Sets the text used to generate the fallback initials and color.

It’s only used to generate the color if Avatar:show-initials is FALSE.

Its value is a string, or #f.

Set it with (set! (avatar:text self) value).

Procedures

Method: avatar:draw-to-texture self scale-factor ⇒ %return
Method: draw-to-texture self scale-factor ⇒ %return

Renders self into a <GdkTexture> at scale-factor.

This can be used to export the fallback avatar.

self

Passed: a <AdwAvatar>.

an avatar

scale-factor

Passed: a 32-bit integer.

The scale factor

%return

Returned: a <GdkTexture>.

the texture

Method: avatar:get-custom-image self ⇒ %return
Method: get-custom-image self ⇒ %return

Gets the custom image paintable.

self

Passed: a <AdwAvatar>.

an avatar

%return

Returned: a <GdkPaintable>, or #f.

the custom image

Method: avatar:get-icon-name self ⇒ %return
Method: get-icon-name self ⇒ %return

Gets the name of an icon to use as a fallback.

self

Passed: a <AdwAvatar>.

an avatar

%return

Returned: a string, or #f.

the icon name

Method: avatar:get-show-initials? self ⇒ %return
Method: get-show-initials? self ⇒ %return

Gets whether initials are used instead of an icon on the fallback avatar.

self

Passed: a <AdwAvatar>.

an avatar

%return

Returned: a boolean.

whether initials are used instead of an icon as fallback

Method: avatar:get-size self ⇒ %return
Method: get-size self ⇒ %return

Gets the size of the avatar.

self

Passed: a <AdwAvatar>.

an avatar

%return

Returned: a 32-bit integer.

the size of the avatar

Method: avatar:get-text self ⇒ %return
Method: get-text self ⇒ %return

Gets the text used to generate the fallback initials and color.

self

Passed: a <AdwAvatar>.

an avatar

%return

Returned: a string, or #f.

the text used to generate the fallback initials and color

Procedure: avatar:new size text show-initials ⇒ %return

Creates a new <AdwAvatar>.

size

Passed: a 32-bit integer.

The size of the avatar

text

Passed: a string, or #f.

the text used to get the initials and color

show-initials

Passed: a boolean.

whether to use initials instead of an icon as fallback

%return

Returned: a <GtkWidget>.

the newly created <AdwAvatar>

Method: avatar:set-custom-image self [custom-image]
Method: set-custom-image self [custom-image]

Sets the custom image paintable.

Custom image is displayed instead of initials or icon.

self

Passed: a <AdwAvatar>.

an avatar

custom-image

Passed, or left out: a <GdkPaintable>, or #f.

a custom image

Method: avatar:set-icon-name self [icon-name]
Method: set-icon-name self [icon-name]

Sets the name of an icon to use as a fallback.

If no name is set, adw-avatar-default-symbolic will be used.

self

Passed: a <AdwAvatar>.

an avatar

icon-name

Passed, or left out: a string, or #f.

the icon name

Method: avatar:set-show-initials self show-initials
Method: set-show-initials self show-initials

Sets whether to use initials instead of an icon on the fallback avatar.

See Avatar:icon-name for how to change the fallback icon.

self

Passed: a <AdwAvatar>.

an avatar

show-initials

Passed: a boolean.

whether to use initials instead of an icon as fallback

Method: avatar:set-size self size
Method: set-size self size

Sets the size of the avatar.

self

Passed: a <AdwAvatar>.

an avatar

size

Passed: a 32-bit integer.

The size of the avatar

Method: avatar:set-text self [text]
Method: set-text self [text]

Sets the text used to generate the fallback initials and color.

It’s only used to generate the color if Avatar:show-initials is FALSE.

self

Passed: a <AdwAvatar>.

an avatar

text

Passed, or left out: a string, or #f.

the text used to get the initials and color