OssoABookAvatar

OssoABookAvatar — Avatar representation.

Synopsis

                    OssoABookAvatar;
                    OssoABookAvatarIface;
gpointer            osso_abook_avatar_get_image_token   (OssoABookAvatar *avatar);
GdkPixbuf*          osso_abook_avatar_get_image         (OssoABookAvatar *avatar);
GdkPixbuf*          osso_abook_avatar_get_image_scaled  (OssoABookAvatar *avatar,
                                                         int width,
                                                         int height,
                                                         gboolean crop);
GdkPixbuf*          osso_abook_avatar_get_image_rounded (OssoABookAvatar *avatar,
                                                         int width,
                                                         int height,
                                                         gboolean crop,
                                                         int radius,
                                                         const guint8 border_color[4]);
GdkPixbuf*          osso_abook_avatar_get_server_image  (OssoABookAvatar *avatar);
GdkPixbuf*          osso_abook_avatar_get_server_image_scaled
                                                        (OssoABookAvatar *avatar,
                                                         int width,
                                                         int height,
                                                         gboolean crop);
const char*         osso_abook_avatar_get_fallback_icon_name
                                                        (OssoABookAvatar *avatar);
gboolean            osso_abook_avatar_is_user_selected  (OssoABookAvatar *avatar);
gboolean            osso_abook_avatar_is_done_loading   (OssoABookAvatar *avatar);

Object Hierarchy

  GInterface
   +----OssoABookAvatar

Prerequisites

OssoABookAvatar requires GObject.

Known Implementations

OssoABookAvatar is implemented by OssoABookContact, OssoABookGconfContact, OssoABookSelfContact and OssoABookVoicemailContact.

Properties

  "avatar-image"             GdkPixbuf*            : Read
  "avatar-user-selected"     gboolean              : Read
  "done-loading"             gboolean              : Read
  "server-image"             GdkPixbuf*            : Read

Signals

  "load-error"                                     : Run Last

Description

OssoABookAvatar is an interface that represents the user's avatar.

Details

OssoABookAvatar

typedef struct _OssoABookAvatar OssoABookAvatar;

Dummy type for the OssoABookAvatar interface.


OssoABookAvatarIface

typedef struct {
        GdkPixbuf *  (* get_image_scaled)        (OssoABookAvatar *avatar,
                                                  int              width,
                                                  int              height,
                                                  gboolean         crop);

        GdkPixbuf *  (* get_server_image_scaled) (OssoABookAvatar *avatar,
                                                  int              width,
                                                  int              height,
                                                  gboolean         crop);

        const char * (* get_fallback_icon_name)  (OssoABookAvatar *avatar);

        void         (* load_error)              (OssoABookAvatar *avatar,
                                                  const GError    *error);
} OssoABookAvatarIface;

Virtual methods of the OssoABookAvatar interface.

get_image_scaled () virtual method for osso_abook_avatar_get_image_scaled()
get_server_image_scaled () virtual method for osso_abook_avatar_get_server_image_scaled()
get_fallback_icon_name () virtual method for osso_abook_avatar_get_fallback_icon_name()
load_error () virtual method for "load-error"

osso_abook_avatar_get_image_token ()

gpointer            osso_abook_avatar_get_image_token   (OssoABookAvatar *avatar);

Retrieves the image token for this avatar. The image token is an opaque value that is associated with the avatar image. It is useful for example for a cache to determine whether the cached image is out-of-date or not.

avatar : a OssoABookAvatar
Returns : the avatar image token

osso_abook_avatar_get_image ()

GdkPixbuf*          osso_abook_avatar_get_image         (OssoABookAvatar *avatar);

Retrieves the avatar image from avatar.

avatar : a OssoABookAvatar
Returns : the avatar image. The returned GdkPixbuf is owned by the avatar object and should not be modified or freed.

osso_abook_avatar_get_image_scaled ()

GdkPixbuf*          osso_abook_avatar_get_image_scaled  (OssoABookAvatar *avatar,
                                                         int width,
                                                         int height,
                                                         gboolean crop);

Retrieves the avatar image from avatar. If width and height are -1, the full image is returned; otherwise, the image will be scaled to the desired size.

The crop argument specifies how to deal with images that don't fit the target aspect of width and height. There are two options for dealing with such images. Either the aspect of the image is kept and letterbox stripes are added to the scaled image to enforce the target aspect. Alternately, the target aspect is enforced by cropping parts of the scaled image. When crop is FALSE, strips are added, when crop is TRUE the scaled image is cropped. The Contacts application usually prefers to crop, as this seems to look more aesthetically pleasing for typical avatar images.

Note

Usually there is no need to cache the returned GdkPixbuf since the most recently used images are stored in a OssoABookAvatarCache.

avatar : a OssoABookAvatar
width : desired width of the avatar image, or -1
height : desired height of the avatar image, or -1
crop : whether the image should be cropped or downscaled
Returns : the avatar image. You should use g_object_unref() after you're done using it.

osso_abook_avatar_get_image_rounded ()

GdkPixbuf*          osso_abook_avatar_get_image_rounded (OssoABookAvatar *avatar,
                                                         int width,
                                                         int height,
                                                         gboolean crop,
                                                         int radius,
                                                         const guint8 border_color[4]);

Retrieves the avatar image from avatar. If width and height are -1, the full image is returned; otherwise, the image will be scaled to the desired size. If radius is 0 the corners are not cut at all. With a radius of -1 an optimal value is chosen automatically.

The elements of the border_color tuple are in the range [0..255]. They describe the ARGB components of the border color (alpha, red, gree, blue). When border_color is NULL no border is drawn.

The crop argument specifies how to deal with images that don't fit the target aspect of width and height. There are two options for dealing with such images. Either the aspect of the image is kept and letterbox stripes are added to the scaled image to enforce the target aspect. Alternately, the target aspect is enforced by cropping parts of the scaled image. When crop is FALSE, strips are added, when crop is TRUE the scaled image is cropped. The Contacts application usually prefers to crop, as this seems to look more aesthetically pleasing for typical avatar images.

Note

Usually there is no need to cache the returned GdkPixbuf since the most recently used images are stored in a OssoABookAvatarCache.

avatar : a OssoABookAvatar
width : desired width of the avatar image, or -1
height : desired height of the avatar image, or -1
crop : whether the image should be cropped or downscaled
radius : radius of rounded corners, or -1
border_color : ARGB tuple describing the border color, or NULL
Returns : the avatar image. You should use g_object_unref() after you're done using it.

osso_abook_avatar_get_server_image ()

GdkPixbuf*          osso_abook_avatar_get_server_image  (OssoABookAvatar *avatar);

Retrieves the sever provided avatar image from avatar.

avatar : a OssoABookAvatar
Returns : the sever provided avatar image. The returned GdkPixbuf is owned by the avatar object and should not be modified or freed.

osso_abook_avatar_get_server_image_scaled ()

GdkPixbuf*          osso_abook_avatar_get_server_image_scaled
                                                        (OssoABookAvatar *avatar,
                                                         int width,
                                                         int height,
                                                         gboolean crop);

Retrieves the server provided avatar image from avatar. If width and height are -1, the full image is returned; otherwise, the image will be scaled to the desired size.

See documentation of osso_abook_avatar_get_image_scaled() for full explaination of the crop argument.

avatar : a OssoABookAvatar
width : desired width of the avatar image, or -1
height : desired height of the avatar image, or -1
crop : whether the image should be cropped or downscaled
Returns : the server provided avatar image. You should use g_object_unref() after you're done using it.

osso_abook_avatar_get_fallback_icon_name ()

const char*         osso_abook_avatar_get_fallback_icon_name
                                                        (OssoABookAvatar *avatar);

Gets the stock icon name to use when avatar does not have an image set.

avatar : a OssoABookAvatar
Returns : the fallback icon name, owned by avatar

osso_abook_avatar_is_user_selected ()

gboolean            osso_abook_avatar_is_user_selected  (OssoABookAvatar *avatar);

Returns whether the OssoABookAvatar was set by the user. Note that a return value of FALSE doesn't necessarily mean that there is no avatar set if this OssoABookAvatar is also a master OssoABookContact.

avatar : a OssoABookAvatar
Returns : TRUE if the avatar was selected by the user.

osso_abook_avatar_is_done_loading ()

gboolean            osso_abook_avatar_is_done_loading   (OssoABookAvatar *avatar);

Returns whether the OssoABookAvatar object has finished loading the image for the avatar.

avatar : a OssoABookAvatar
Returns : TRUE if the avatar has successfully loaded the image.

Property Details

The "avatar-image" property

  "avatar-image"             GdkPixbuf*            : Read

This property contains the avatar's image. Connect to ":avatar-image" to watch this property.


The "avatar-user-selected" property

  "avatar-user-selected"     gboolean              : Read

This property indicates whether the avatar was selected by the user. Connect to ":avatar-user-selected" to watch this property.

Default value: FALSE


The "done-loading" property

  "done-loading"             gboolean              : Read

This property indicates whether the avatar has been loaded. Connect to ":done-loading" to watch this property.

Default value: FALSE


The "server-image" property

  "server-image"             GdkPixbuf*            : Read

This property contains the avatar's server provided image. Connect to ":server-image" to watch this property.

Signal Details

The "load-error" signal

void                user_function                      (OssoABookAvatar *avatar,
                                                        gpointer         error,
                                                        gpointer         user_data)      : Run Last

This signal is emitted if an error occurs when loading the avatar's image.

avatar : a OssoABookAvatar
error : the GError
user_data : user data set when the signal handler was connected.