Class: Handy::Avatar

Inherits:
Gtk::DrawingArea
  • Object
show all
Defined in:
(unknown)

Instance Method Summary collapse

Constructor Details

#initialize(size, text, show_initials) ⇒ Gtk::Widget

Creates a new HdyAvatar.

Parameters:

  • size (Integer)

    the size of the avatar

  • text (String)

    the text used to get the initials and color

  • show_initials (Boolean)

    whether to use initials instead of an icon as fallback

Instance Method Details

#draw_to_pixbuf(size, scale_factor) ⇒ GdkPixbuf::Pixbuf

Renders self into a [classGdkPixbuf.Pixbuf] at size and scale_factor.

This can be used to export the fallback avatar.

Parameters:

  • size (Integer)

    the size of the pixbuf

  • scale_factor (Integer)

    the scale factor

Returns:

  • (GdkPixbuf::Pixbuf)

    the pixbuf

#draw_to_pixbuf_async(size, scale_factor, cancellable, callback, user_data) ⇒ nil

Renders asynchronously self into a pixbuf at size and scale_factor.

This can be used to export the fallback avatar.

Parameters:

  • size (Integer)

    the size of the pixbuf

  • scale_factor (Integer)

    the scale factor

  • cancellable (Gio::Cancellable)

    a cancellable

  • callback (Gio::AsyncReadyCallback)

    a [callbackGio.AsyncReadyCallback] to call when the avatar is generated

  • user_data (GObject)

    the data to pass to callback function

Returns:

  • (nil)

#draw_to_pixbuf_finish(async_result) ⇒ GdkPixbuf::Pixbuf

Finishes an asynchronous draw of an avatar to a pixbuf.

Parameters:

  • async_result (Gio::AsyncResult)

    a [ifaceGio.AsyncResult]

Returns:

  • (GdkPixbuf::Pixbuf)

    the resulting pixbuf

#icon_nameString

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.

Returns:

  • (String)

    icon-name

#icon_name=(icon_name) ⇒ String

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.

Parameters:

  • icon_name (String)

Returns:

  • (String)

    icon-name

  • (String)

    icon-name

#loadable_iconGio::LoadableIcon

A [ifaceGio.LoadableIcon] used to load the avatar.

Returns:

  • (Gio::LoadableIcon)

    loadable-icon

#loadable_icon=(loadable_icon) ⇒ Gio::LoadableIcon

A [ifaceGio.LoadableIcon] used to load the avatar.

Parameters:

  • loadable_icon (Gio::LoadableIcon)

Returns:

  • (Gio::LoadableIcon)

    loadable-icon

  • (Gio::LoadableIcon)

    loadable-icon

#set_image_load_func(load_image, user_data, destroy) ⇒ nil

A callback which is called when the custom image needs to be reloaded.

It will be called on [propertyAvatar:size] or [propertyGtk.Widget:scale-factor] changes.

Parameters:

  • load_image (Handy::AvatarImageLoadFunc)

    callback to set a custom image

  • user_data (GObject)

    user data passed to load_image

  • destroy (GLib::DestroyNotify)

    destroy notifier for user_data

Returns:

  • (nil)

#show_initialsBoolean

Gets whether initials are used instead of an icon on the fallback avatar.

Returns:

  • (Boolean)

    whether initials are used instead of an icon as fallback

#show_initials=(show_initials) ⇒ Boolean

Whether to show the initials or the fallback icon on the generated avatar.

Parameters:

  • show_initials (Boolean)

Returns:

  • (Boolean)

    show-initials

  • (Boolean)

    show-initials

#show_initials?Boolean

Whether to show the initials or the fallback icon on the generated avatar.

Returns:

  • (Boolean)

    show-initials

#sizeInteger

The avatar size of the avatar.

Returns:

  • (Integer)

    size

#size=(size) ⇒ Integer

The avatar size of the avatar.

Parameters:

  • size (Integer)

Returns:

  • (Integer)

    size

  • (Integer)

    size

#textString

Sets the text used to generate the fallback initials and color.

It's only used to generate the color if [propertyAvatar:show-initials] is FALSE.

Returns:

  • (String)

    text

#text=(text) ⇒ String

Sets the text used to generate the fallback initials and color.

It's only used to generate the color if [propertyAvatar:show-initials] is FALSE.

Parameters:

  • text (String)

Returns:

  • (String)

    text

  • (String)

    text