Handy.Avatar¶
- Subclasses:
 None
Methods¶
- Inherited:
 Gtk.DrawingArea (1), Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10)
- Structs:
 
class  | 
  | 
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
Virtual Methods¶
- Inherited:
 
Properties¶
- Inherited:
 
Name  | 
Type  | 
Flags  | 
Short Description  | 
|---|---|---|---|
r/w/en  | 
The name of the icon from the icon theme  | 
||
r/w/en  | 
The loadable icon used to load the avatar  | 
||
r/w/en  | 
Whether to show the initials  | 
||
r/w/en  | 
The size of the avatar  | 
||
r/w/en  | 
The text used to generate the color and the initials  | 
Style Properties¶
- Inherited:
 
Signals¶
- Inherited:
 
Fields¶
- Inherited:
 
Class Details¶
- class Handy.Avatar(**kwargs)¶
 - Bases:
 - Abstract:
 No
- Structure:
 
A widget displaying an image, with a generated fallback.
HdyAvataris a widget to display a round avatar.A provided image is made round before displaying, if no image is given this widget generates a round fallback with the initials of the [property`Avatar`:py:data::text<Handy.Avatar.props.text>] on top of a colored background.
The color is picked based on the hash of the [property`Avatar`:py:data::text<Handy.Avatar.props.text>].
If [property`Avatar`:py:data::show-initials<Handy.Avatar.props.show_initials>] is set to
FALSE,avatar-default-symbolicis shown instead of the initials.Use [method`Avatar`.set_loadable_icon] or [property`Avatar`:py:data::loadable-icon<Handy.Avatar.props.loadable_icon>] to set a custom image.
- CSS nodes
 
HdyAvatarhas a single CSS node with nameavatar.New in version 1.0.
- classmethod new(size, text, show_initials)¶
 - Parameters:
 - Returns:
 the newly created
HdyAvatar- Return type:
 
Creates a new
HdyAvatar.New in version 1.0.
- draw_to_pixbuf(size, scale_factor)¶
 - Parameters:
 - Returns:
 the pixbuf
- Return type:
 
Renders self into a [class`GdkPixbuf`.Pixbuf] at size and scale_factor.
This can be used to export the fallback avatar.
New in version 1.2.
- draw_to_pixbuf_async(size, scale_factor, cancellable, callback, *user_data)¶
 - Parameters:
 size (
int) – the size of the pixbufscale_factor (
int) – the scale factorcancellable (
Gio.CancellableorNone) – a cancellablecallback (
Gio.AsyncReadyCallbackorNone) – a [callback`Gio`.AsyncReadyCallback] to call when the avatar is generateduser_data (
objectorNone) – the data to pass to callback function
Renders asynchronously self into a pixbuf at size and scale_factor.
This can be used to export the fallback avatar.
New in version 1.2.
- draw_to_pixbuf_finish(async_result)¶
 - Parameters:
 async_result (
Gio.AsyncResult) – a [iface`Gio`.AsyncResult]- Returns:
 the resulting pixbuf
- Return type:
 
Finishes an asynchronous draw of an avatar to a pixbuf.
New in version 1.2.
- get_icon_name()¶
 - 
Gets the name of an icon to use as a fallback.
New in version 1.0.
 
- get_loadable_icon()¶
 - Returns:
 the [iface`Gio`.LoadableIcon]
- Return type:
 
Gets the [iface`Gio`.LoadableIcon] set via [method`Avatar`.set_loadable_icon].
New in version 1.2.
- get_show_initials()¶
 - Returns:
 whether initials are used instead of an icon as fallback
- Return type:
 
Gets whether initials are used instead of an icon on the fallback avatar.
New in version 1.0.
- get_size()¶
 - Returns:
 the size of the avatar
- Return type:
 
Gets the size of the avatar.
New in version 1.0.
- get_text()¶
 - 
Gets the text used to generate the fallback initials and color.
New in version 1.0.
 
- set_icon_name(icon_name)¶
 - 
Sets the name of an icon to use as a fallback.
If no name is set,
avatar-default-symbolicwill be used.New in version 1.0.
 
- set_image_load_func(load_image, *user_data)¶
 - Parameters:
 load_image (
Handy.AvatarImageLoadFuncorNone) – callback to set a custom image
A callback which is called when the custom image needs to be reloaded.
It will be called on [property`Avatar`:py:data::size<Handy.Avatar.props.size>] or [property`Gtk`.Widget:scale-factor] changes.
New in version 1.0.
Deprecated since version 1.2: use [method`Avatar`.set_loadable_icon] instead.
- set_loadable_icon(icon)¶
 - Parameters:
 icon (
Gio.LoadableIconorNone) – a [iface`Gio`.LoadableIcon]
Sets the [iface`Gio`.LoadableIcon] to use as an avatar.
The previous avatar is displayed till the new avatar is loaded, to immediately remove the custom avatar set the loadable-icon to
NULL.The [iface`Gio`.LoadableIcon] set via this function is preferred over a set [callback`AvatarImageLoadFunc`].
New in version 1.2.
- set_show_initials(show_initials)¶
 - Parameters:
 show_initials (
bool) – whether to use initials instead of an icon as fallback
Sets whether to use initials instead of an icon on the fallback avatar.
New in version 1.0.
Property Details¶
- Handy.Avatar.props.icon_name¶
 - Name:
 icon-name- Type:
 - Default Value:
 - Flags:
 
The name of an icon to use as a fallback.
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.
New in version 1.0.
- Handy.Avatar.props.loadable_icon¶
 - Name:
 loadable-icon- Type:
 - Default Value:
 - Flags:
 
A [iface`Gio`.LoadableIcon] used to load the avatar.
New in version 1.2.
- Handy.Avatar.props.show_initials¶
 - Name:
 show-initials- Type:
 - Default Value:
 - Flags:
 
Whether to show the initials or the fallback icon on the generated avatar.
New in version 1.0.
- Handy.Avatar.props.size¶
 - Name:
 size- Type:
 - Default Value:
 -1- Flags:
 
The avatar size of the avatar.
New in version 1.0.
- Handy.Avatar.props.text¶
 - Name:
 text- Type:
 - Default Value:
 - Flags:
 
Sets the text used to generate the fallback initials and color.
It’s only used to generate the color if [property`Avatar`:py:data::show-initials<Handy.Avatar.props.show_initials>] is
FALSE.New in version 1.0.