adw-avatar

adw-avatar

Functions

Properties

char * icon-name Read / Write
gboolean show-initials Read / Write
int size Read / Write
char * text Read / Write

Types and Values

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── GtkWidget
            ╰── AdwAvatar

Implemented Interfaces

AdwAvatar implements GtkAccessible, GtkBuildable and GtkConstraintTarget.

Description

Functions

AdwAvatarImageLoadFunc ()

GdkPixbuf *
(*AdwAvatarImageLoadFunc) (int size,
                           gpointer user_data);

The returned GdkPixbuf is expected to be square with width and height set to size . The image is cropped to a circle without any scaling or transformation.

Parameters

size

the required size of the avatar

 

user_data

user data.

[closure]

Returns

the GdkPixbuf to use as a custom avatar or NULL to fallback to the generated avatar.

[nullable][transfer full]


adw_avatar_new ()

GtkWidget *
adw_avatar_new (int size,
                const char *text,
                gboolean show_initials);

Creates a new AdwAvatar.

Parameters

size

The size of the avatar

 

text

The text used to generate the color and initials if show_initials is TRUE. The color is selected at random if text is empty.

[nullable]

show_initials

whether to show the initials or the fallback icon on top of the color generated based on text .

 

Returns

the newly created AdwAvatar

Since: 1.0


adw_avatar_get_icon_name ()

const char *
adw_avatar_get_icon_name (AdwAvatar *self);

Gets the name of the icon in the icon theme to use when the icon should be displayed.

Parameters

self

a AdwAvatar

 

Returns

the name of the icon from the icon theme.

[nullable][transfer none]

Since: 1.0


adw_avatar_set_icon_name ()

void
adw_avatar_set_icon_name (AdwAvatar *self,
                          const char *icon_name);

Sets the name of the icon in the icon theme to use when the icon should be displayed. If no name is set, the avatar-default-symbolic icon will be used. If the name doesn't match a valid icon, it is an error and no icon will be displayed. If the icon theme is changed, the image will be updated automatically.

Parameters

self

a AdwAvatar

 

icon_name

the name of the icon from the icon theme.

[nullable]

Since: 1.0


adw_avatar_get_text ()

const char *
adw_avatar_get_text (AdwAvatar *self);

Get the text used to generate the fallback initials and color

Parameters

self

a AdwAvatar

 

Returns

returns the text used to generate the fallback initials. This is the internal string used by the AdwAvatar, and must not be modified.

[nullable][transfer none]

Since: 1.0


adw_avatar_set_text ()

void
adw_avatar_set_text (AdwAvatar *self,
                     const char *text);

Set the text used to generate the fallback initials color

Parameters

self

a AdwAvatar

 

text

the text used to get the initials and color.

[nullable]

Since: 1.0


adw_avatar_get_show_initials ()

gboolean
adw_avatar_get_show_initials (AdwAvatar *self);

Returns whether initials are used for the fallback or the icon.

Parameters

self

a AdwAvatar

 

Returns

TRUE if the initials are used for the fallback.

Since: 1.0


adw_avatar_set_show_initials ()

void
adw_avatar_set_show_initials (AdwAvatar *self,
                              gboolean show_initials);

Sets whether the initials should be shown on the fallback avatar or the icon.

Parameters

self

a AdwAvatar

 

show_initials

whether the initials should be shown on the fallback avatar or the icon.

 

Since: 1.0


adw_avatar_set_image_load_func ()

void
adw_avatar_set_image_load_func (AdwAvatar *self,
                                AdwAvatarImageLoadFunc load_image,
                                gpointer user_data,
                                GDestroyNotify destroy);

A callback which is called when the custom image need to be reloaded for some reason (e.g. scale-factor changes).

Parameters

self

a AdwAvatar

 

load_image

callback to set a custom image.

[closure user_data][nullable]

user_data

user data passed to load_image .

[nullable]

destroy

destroy notifier for user_data .

[nullable]

Since: 1.0


adw_avatar_get_size ()

int
adw_avatar_get_size (AdwAvatar *self);

Returns the size of the avatar.

Parameters

self

a AdwAvatar

 

Returns

the size of the avatar.

Since: 1.0


adw_avatar_set_size ()

void
adw_avatar_set_size (AdwAvatar *self,
                     int size);

Sets the size of the avatar.

Parameters

self

a AdwAvatar

 

size

The size to be used for the avatar

 

Since: 1.0


adw_avatar_draw_to_pixbuf ()

GdkPixbuf *
adw_avatar_draw_to_pixbuf (AdwAvatar *self,
                           int size,
                           int scale_factor);

Renders self into a pixbuf at size and scale_factor . This can be used to export the fallback avatar.

Parameters

self

a AdwAvatar

 

size

The size of the pixbuf

 

scale_factor

The scale factor

 

Returns

the pixbuf.

[transfer full]

Since: 1.0

Types and Values

ADW_TYPE_AVATAR

#define ADW_TYPE_AVATAR (adw_avatar_get_type())

AdwAvatar

typedef struct _AdwAvatar AdwAvatar;

Property Details

The “icon-name” property

  “icon-name”                char *

The name of the icon in the icon theme to use when the icon should be displayed. If no name is set, the avatar-default-symbolic icon will be used. If the name doesn't match a valid icon, it is an error and no icon will be displayed. If the icon theme is changed, the image will be updated automatically.

Owner: AdwAvatar

Flags: Read / Write

Default value: NULL

Since: 1.0


The “show-initials” property

  “show-initials”            gboolean

Whether to show the initials.

Owner: AdwAvatar

Flags: Read / Write

Default value: FALSE


The “size” property

  “size”                     int

The avatar size of the avatar.

Owner: AdwAvatar

Flags: Read / Write

Allowed values: >= -1

Default value: -1

Since: 1.0


The “text” property

  “text”                     char *

The text used for the initials and for generating the color. If “show-initials” is FALSE it's only used to generate the color.

Owner: AdwAvatar

Flags: Read / Write

Default value: NULL

Since: 1.0