Top | ![]() |
![]() |
![]() |
![]() |
GdkPixbuf * | (*HdyAvatarImageLoadFunc) () |
GtkWidget * | hdy_avatar_new () |
const gchar * | hdy_avatar_get_icon_name () |
void | hdy_avatar_set_icon_name () |
const gchar * | hdy_avatar_get_text () |
void | hdy_avatar_set_text () |
gboolean | hdy_avatar_get_show_initials () |
void | hdy_avatar_set_show_initials () |
void | hdy_avatar_set_image_load_func () |
gint | hdy_avatar_get_size () |
void | hdy_avatar_set_size () |
GdkPixbuf * | hdy_avatar_draw_to_pixbuf () |
void | hdy_avatar_draw_to_pixbuf_async () |
GdkPixbuf * | hdy_avatar_draw_to_pixbuf_finish () |
GLoadableIcon * | hdy_avatar_get_loadable_icon () |
void | hdy_avatar_set_loadable_icon () |
char * | icon-name | Read / Write |
GLoadableIcon * | loadable-icon | Read / Write |
gboolean | show-initials | Read / Write |
int | size | Read / Write |
char * | text | Read / Write |
HdyAvatar is 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 “text”
on top of a colord background.
The color is picked based on the hash of the “text”.
If “show-initials” is set to FALSE
, avatar-default-symbolic
is
shown in place of the initials.
Use hdy_avatar_set_loadable_icon()
or “loadable-icon” to set a
custom image.
GdkPixbuf * (*HdyAvatarImageLoadFunc) (gint size
,gpointer user_data
);
HdyAvatarImageLoadFunc
has been deprecated since version 1.2 and should not be used in newly-written code.
use hdy_avatar_set_loadable_icon()
instead.
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.
the GdkPixbuf to use as a custom avatar
or NULL
to fallback to the generated avatar.
[nullable][transfer full]
GtkWidget * hdy_avatar_new (gint size
,const gchar *text
,gboolean show_initials
);
Creates a new HdyAvatar.
size |
The size of the avatar |
|
text |
The text used to generate the color and initials if
|
[nullable] |
show_initials |
whether to show the initials or the fallback icon on
top of the color generated based on |
const gchar *
hdy_avatar_get_icon_name (HdyAvatar *self
);
Gets the name of the icon in the icon theme to use when the icon should be displayed.
Since: 1.0
void hdy_avatar_set_icon_name (HdyAvatar *self
,const gchar *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.
Since: 1.0
const gchar *
hdy_avatar_get_text (HdyAvatar *self
);
Get the text used to generate the fallback initials and color
returns the text used to generate the fallback initials. This is the internal string used by the HdyAvatar, and must not be modified.
[nullable][transfer none]
void hdy_avatar_set_text (HdyAvatar *self
,const gchar *text
);
Set the text used to generate the fallback initials color
gboolean
hdy_avatar_get_show_initials (HdyAvatar *self
);
Returns whether initials are used for the fallback or the icon.
void hdy_avatar_set_show_initials (HdyAvatar *self
,gboolean show_initials
);
Sets whether the initials should be shown on the fallback avatar or the icon.
void hdy_avatar_set_image_load_func (HdyAvatar *self
,HdyAvatarImageLoadFunc load_image
,gpointer user_data
,GDestroyNotify destroy
);
hdy_avatar_set_image_load_func
has been deprecated since version 1.2 and should not be used in newly-written code.
use hdy_avatar_set_loadable_icon()
instead.
A callback which is called when the custom image need to be reloaded for some reason (e.g. scale-factor changes).
void hdy_avatar_set_size (HdyAvatar *self
,gint size
);
Sets the size of the avatar.
GdkPixbuf * hdy_avatar_draw_to_pixbuf (HdyAvatar *self
,gint size
,gint scale_factor
);
Renders self
into a pixbuf at size
and scale_factor
. This can be used to export the fallback avatar.
Since: 1.2
void hdy_avatar_draw_to_pixbuf_async (HdyAvatar *self
,gint size
,gint scale_factor
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
);
Renders asynchronously self
into a pixbuf at size
and scale_factor
.
This can be used to export the fallback avatar.
self |
||
size |
The size of the pixbuf |
|
scale_factor |
The scale factor |
|
cancellable |
optional GCancellable object, |
[nullable] |
callback |
a GAsyncReadyCallback to call when the avatar is generated. |
[scope async] |
user_data |
the data to pass to callback function. |
[closure] |
Since: 1.2
GdkPixbuf * hdy_avatar_draw_to_pixbuf_finish (HdyAvatar *self
,GAsyncResult *async_result
);
Finishes an asynchronous draw of an avatar to a pixbuf.
Since: 1.2
GLoadableIcon *
hdy_avatar_get_loadable_icon (HdyAvatar *self
);
Gets the GLoadableIcon set via hdy_avatar_set_loadable_icon()
.
Since: 1.2
void hdy_avatar_set_loadable_icon (HdyAvatar *self
,GLoadableIcon *icon
);
Sets the GLoadableIcon 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 GLoadableIcon set via this function is prefered over a set HdyAvatarImageLoadFunc.
Since: 1.2
“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: HdyAvatar
Flags: Read / Write
Default value: NULL
Since: 1.0
“loadable-icon”
property“loadable-icon” GLoadableIcon *
A GLoadableIcon used to load the avatar.
Owner: HdyAvatar
Flags: Read / Write
Since: 1.2
“show-initials”
property“show-initials” gboolean
Whether to show the initials.
Owner: HdyAvatar
Flags: Read / Write
Default value: FALSE
“size”
property “size” int
The avatar size of the avatar.
Owner: HdyAvatar
Flags: Read / Write
Allowed values: >= -1
Default value: -1
“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: HdyAvatar
Flags: Read / Write
Default value: NULL