Klasse Avatar

Alle implementierten Schnittstellen:
PointerInterface

public class Avatar extends Widget
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`.

## Accessibility

`AdwAvatar` uses the `GTK_ACCESSIBLE_ROLE_IMG` role.

https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.Avatar.html

  • Konstruktordetails Linksymbol

    • Avatar Linksymbol

      public Avatar(PointerContainer pointer)
    • Avatar Linksymbol

      public Avatar(int size, @Nullable Str text, boolean show_initials)
      Creates a new `AdwAvatar`.
      Parameter:
      size - The size of the avatar
      text - the text used to get the initials and color
      show_initials - whether to use initials instead of an icon as fallback
    • Avatar Linksymbol

      public Avatar(int size, String text, boolean show_initials)
      Creates a new `AdwAvatar`.
      Parameter:
      size - The size of the avatar
      text - the text used to get the initials and color
      show_initials - whether to use initials instead of an icon as fallback
  • Methodendetails Linksymbol

    • getClassHandler Linksymbol

      public static ClassHandler getClassHandler()
    • drawToTexture Linksymbol

      public Texture drawToTexture(int scale_factor)
      Renders @self into a [class@Gdk.Texture] at @scale_factor.

      This can be used to export the fallback avatar.
      Parameter:
      scale_factor - The scale factor
      Gibt zurück:
      the texture
    • getCustomImage Linksymbol

      public Paintable getCustomImage()
      Gets the custom image paintable.
      Gibt zurück:
      the custom image
    • getIconName Linksymbol

      public Str getIconName()
      Gets the name of an icon to use as a fallback.
      Gibt zurück:
      the icon name
    • getShowInitials Linksymbol

      public boolean getShowInitials()
      Gets whether initials are used instead of an icon on the fallback avatar.
      Gibt zurück:
      whether initials are used instead of an icon as fallback
    • getSize Linksymbol

      public int getSize()
      Gets the size of the avatar.
      Gibt zurück:
      the size of the avatar
    • getText Linksymbol

      public Str getText()
      Gets the text used to generate the fallback initials and color.
      Gibt zurück:
      the text used to generate the fallback initials and color
    • setCustomImage Linksymbol

      public void setCustomImage(@Nullable Paintable custom_image)
      Sets the custom image paintable.

      Custom image is displayed instead of initials or icon.
      Parameter:
      custom_image - a custom image
    • setIconName Linksymbol

      public void setIconName(@Nullable Str icon_name)
      Sets the name of an icon to use as a fallback.

      If no name is set, `avatar-default-symbolic` will be used.
      Parameter:
      icon_name - the icon name
    • setIconName Linksymbol

      public void setIconName(String icon_name)
      Sets the name of an icon to use as a fallback.

      If no name is set, `avatar-default-symbolic` will be used.
      Parameter:
      icon_name - the icon name
    • setShowInitials Linksymbol

      public void setShowInitials(boolean show_initials)
      Sets whether to use initials instead of an icon on the fallback avatar.

      See [property@Avatar:icon-name] for how to change the fallback icon.
      Parameter:
      show_initials - whether to use initials instead of an icon as fallback
    • setSize Linksymbol

      public void setSize(int size)
      Sets the size of the avatar.
      Parameter:
      size - The size of the avatar
    • setText Linksymbol

      public void setText(@Nullable Str text)
      Sets the text used to generate the fallback initials and color.

      It's only used to generate the color if [property@Avatar:show-initials] is
      `FALSE`.
      Parameter:
      text - the text used to get the initials and color
    • setText Linksymbol

      public void setText(String text)
      Sets the text used to generate the fallback initials and color.

      It's only used to generate the color if [property@Avatar:show-initials] is
      `FALSE`.
      Parameter:
      text - the text used to get the initials and color
    • asAccessible Linksymbol

      public Accessible asAccessible()
      Implements interface Accessible. Call this to get access to interface functions.
      Setzt außer Kraft:
      asAccessible in Klasse Widget
      Gibt zurück:
      Accessible
    • asBuildable Linksymbol

      public Buildable asBuildable()
      Implements interface Buildable. Call this to get access to interface functions.
      Setzt außer Kraft:
      asBuildable in Klasse Widget
      Gibt zurück:
      Buildable
    • asConstraintTarget Linksymbol

      public ConstraintTarget asConstraintTarget()
      Implements interface ConstraintTarget. Call this to get access to interface functions.
      Setzt außer Kraft:
      asConstraintTarget in Klasse Widget
      Gibt zurück:
      ConstraintTarget
    • getTypeID Linksymbol

      public static long getTypeID()
    • getParentTypeID Linksymbol

      public static long getParentTypeID()
    • getTypeSize Linksymbol

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize Linksymbol

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize Linksymbol

      public static int getInstanceSize()