Avatar
Object Hierarchy:
Description:
[ CCode ( type_id = "adw_avatar_get_type ()" ) ]
[ Version ( since = "1.0" ) ]
public sealed class Avatar : Widget, Accessible, Buildable, ConstraintTarget
A widget displaying an image, with a generated fallback.
<picture> <source srcset="avatar-dark.png" media="(prefers-color-scheme: dark)"> <img src="avatar.png" alt="avatar">
</picture>
`AdwAvatar` is a widget that shows a round avatar.
`AdwAvatar` generates an avatar with the initials of the [property@Avatar:text] on top of a colored background.
The color is picked based on the hash of the [property@Avatar:text].
If [property@Avatar:show-initials] is set to `FALSE`, [property@Avatar:icon-name] or `avatar-default-symbolic` is shown instead of the
initials.
Use [property@Avatar:custom-image] to set a custom image.
CSS nodes
`AdwAvatar` has a single CSS node with name `avatar`.
Content:
Properties:
- public Paintable custom_image { get; set; }
A custom image to use instead of initials or icon.
- public string icon_name { get; set; }
The name of an icon to use as a fallback.
- public bool show_initials { get; set; }
Whether initials are used instead of an icon on the fallback avatar.
- public int size { get; set; }
The size of the avatar.
- public string text { get; set; }
Sets the text used to generate the fallback initials and color.
Creation methods:
Methods:
- public Texture draw_to_texture (int scale_factor)
Renders this into a [class@Gdk.
- public unowned Paintable? get_custom_image ()
Gets the custom image paintable.
- public unowned string? get_icon_name ()
Gets the name of an icon to use as a fallback.
- public bool get_show_initials ()
Gets whether initials are used instead of an icon on the fallback
avatar.
- public int get_size ()
Gets the size of the avatar.
- public unowned string? get_text ()
Gets the text used to generate the fallback initials and color.
- public void set_custom_image (Paintable? custom_image)
Sets the custom image paintable.
- public void set_icon_name (string? icon_name)
Sets the name of an icon to use as a fallback.
- public void set_show_initials (bool show_initials)
Sets whether to use initials instead of an icon on the fallback
avatar.
- public void set_size (int size)
Sets the size of the avatar.
- public void set_text (string? text)
Sets the text used to generate the fallback initials and color.
Inherited Members:
All known members inherited from class Gtk.Widget
All known members inherited from class GLib.Object
- @get
- @new
- @ref
- @set
- add_toggle_ref
- add_weak_pointer
- bind_property
- connect
- constructed
- disconnect
- dispose
- dup_data
- dup_qdata
- force_floating
- freeze_notify
- get_class
- get_data
- get_property
- get_qdata
- get_type
- getv
- interface_find_property
- interface_install_property
- interface_list_properties
- is_floating
- new_valist
- new_with_properties
- newv
- notify
- notify_property
- ref_count
- ref_sink
- remove_toggle_ref
- remove_weak_pointer
- replace_data
- replace_qdata
- set_data
- set_data_full
- set_property
- set_qdata
- set_qdata_full
- set_valist
- setv
- steal_data
- steal_qdata
- thaw_notify
- unref
- watch_closure
- weak_ref
- weak_unref
All known members inherited from interface Gtk.Accessible
- accessible_role
- get_accessible_role
- reset_property
- reset_relation
- reset_state
- update_property
- update_property_value
- update_relation
- update_relation_value
- update_state
- update_state_value
All known members inherited from interface Gtk.Buildable
- add_child
- custom_finished
- custom_tag_end
- custom_tag_start
- get_buildable_id
- get_id
- get_internal_child
- parser_finished
- set_buildable_property
- set_id