AsIcon

AsIcon — Object representing a single icon used in a screenshot.

Stability Level

Stable, unless otherwise indicated

Synopsis

#include <appstream-glib.h>

enum                AsIconError;
enum                AsIconKind;
enum                AsIconLoadFlags;
#define             AS_ICON_ERROR
AsIcon *            as_icon_new                         (void);
GQuark              as_icon_error_quark                 (void);
const gchar *       as_icon_kind_to_string              (AsIconKind icon_kind);
AsIconKind          as_icon_kind_from_string            (const gchar *icon_kind);
const gchar *       as_icon_get_name                    (AsIcon *icon);
const gchar *       as_icon_get_url                     (AsIcon *icon);
const gchar *       as_icon_get_filename                (AsIcon *icon);
const gchar *       as_icon_get_prefix                  (AsIcon *icon);
guint               as_icon_get_width                   (AsIcon *icon);
guint               as_icon_get_height                  (AsIcon *icon);
AsIconKind          as_icon_get_kind                    (AsIcon *icon);
GdkPixbuf *         as_icon_get_pixbuf                  (AsIcon *icon);
void                as_icon_set_name                    (AsIcon *icon,
                                                         const gchar *name,
                                                         gssize name_len);
void                as_icon_set_url                     (AsIcon *icon,
                                                         const gchar *url);
void                as_icon_set_filename                (AsIcon *icon,
                                                         const gchar *filename);
void                as_icon_set_prefix                  (AsIcon *icon,
                                                         const gchar *prefix);
void                as_icon_set_width                   (AsIcon *icon,
                                                         guint width);
void                as_icon_set_height                  (AsIcon *icon,
                                                         guint height);
void                as_icon_set_kind                    (AsIcon *icon,
                                                         AsIconKind kind);
void                as_icon_set_pixbuf                  (AsIcon *icon,
                                                         GdkPixbuf *pixbuf);
gboolean            as_icon_load                        (AsIcon *icon,
                                                         AsIconLoadFlags flags,
                                                         GError **error);
gboolean            as_icon_convert_to_kind             (AsIcon *icon,
                                                         AsIconKind kind,
                                                         GError **error);

Description

Screenshot may have multiple versions of an icon in different resolutions or aspect ratios. This object allows access to the location and size of a single icon.

See also: AsScreenshot

Details

enum AsIconError

typedef enum {
	AS_ICON_ERROR_FAILED,
} AsIconError;

The error type.

AS_ICON_ERROR_FAILED

Generic failure

enum AsIconKind

typedef enum {
	AS_ICON_KIND_UNKNOWN,		/* Since: 0.1.0 */
	AS_ICON_KIND_STOCK,		/* Since: 0.1.0 */
	AS_ICON_KIND_CACHED,		/* Since: 0.1.0 */
	AS_ICON_KIND_REMOTE,		/* Since: 0.1.0 */
	AS_ICON_KIND_EMBEDDED,		/* Since: 0.3.1 */
	AS_ICON_KIND_LOCAL,		/* Since: 0.3.1 */
} AsIconKind;

The icon type.

AS_ICON_KIND_UNKNOWN

Type invalid or not known

AS_ICON_KIND_STOCK

Stock icon or present in the generic icon theme

AS_ICON_KIND_CACHED

An icon shipped with the AppStream metadata

AS_ICON_KIND_REMOTE

An icon referenced by a remote URL

AS_ICON_KIND_EMBEDDED

An embedded Base64 icon

AS_ICON_KIND_LOCAL

An icon with absolute path and filename

enum AsIconLoadFlags

typedef enum {
	AS_ICON_LOAD_FLAG_NONE			= 0, /* Since: 0.3.1 */
	AS_ICON_LOAD_FLAG_SEARCH_SIZE		= 1, /* Since: 0.3.1 */
} AsIconLoadFlags;

The flags to use when loading icons.

AS_ICON_LOAD_FLAG_NONE

No extra flags to use

AS_ICON_LOAD_FLAG_SEARCH_SIZE

Search first in a size-specific directory

AS_ICON_ERROR

#define AS_ICON_ERROR				as_icon_error_quark ()

as_icon_new ()

AsIcon *            as_icon_new                         (void);

Creates a new AsIcon.

Returns :

a AsIcon. [transfer full]

Since 0.3.1


as_icon_error_quark ()

GQuark              as_icon_error_quark                 (void);

Returns :

An error quark.

Since 0.3.1


as_icon_kind_to_string ()

const gchar *       as_icon_kind_to_string              (AsIconKind icon_kind);

Converts the enumerated value to an text representation.

icon_kind :

the AsIconKind.

Returns :

string version of icon_kind

Since 0.1.0


as_icon_kind_from_string ()

AsIconKind          as_icon_kind_from_string            (const gchar *icon_kind);

Converts the text representation to an enumerated value.

icon_kind :

the string.

Returns :

a AsIconKind or AS_ICON_KIND_UNKNOWN for unknown

Since 0.1.0


as_icon_get_name ()

const gchar *       as_icon_get_name                    (AsIcon *icon);

Gets the name of the icon, e.g. "epiphany.png"

icon :

a AsIcon instance.

Returns :

the basename of the icon

Since 0.3.1


as_icon_get_url ()

const gchar *       as_icon_get_url                     (AsIcon *icon);

Gets the full qualified URL for the icon, usually pointing at some mirror. NOTE: This is only set for icons of type AS_ICON_KIND_REMOTE

icon :

a AsIcon instance.

Returns :

the fully qualified URL

Since 0.3.2


as_icon_get_filename ()

const gchar *       as_icon_get_filename                (AsIcon *icon);

Gets the absolute path on disk of the icon. NOTE: This is only set for icons of type AS_ICON_KIND_LOCAL

icon :

a AsIcon instance.

Returns :

the absolute filename on disk

Since 0.3.2


as_icon_get_prefix ()

const gchar *       as_icon_get_prefix                  (AsIcon *icon);

Gets the suggested prefix of the icon.

icon :

a AsIcon instance.

Returns :

filename

Since 0.1.6


as_icon_get_width ()

guint               as_icon_get_width                   (AsIcon *icon);

Gets the icon width.

icon :

a AsIcon instance.

Returns :

width in pixels

Since 0.3.1


as_icon_get_height ()

guint               as_icon_get_height                  (AsIcon *icon);

Gets the icon height.

icon :

a AsIcon instance.

Returns :

height in pixels

Since 0.3.1


as_icon_get_kind ()

AsIconKind          as_icon_get_kind                    (AsIcon *icon);

Gets the icon kind.

icon :

a AsIcon instance.

Returns :

the AsIconKind

Since 0.3.1


as_icon_get_pixbuf ()

GdkPixbuf *         as_icon_get_pixbuf                  (AsIcon *icon);

Gets the icon pixbuf if set.

icon :

a AsIcon instance.

Returns :

the GdkPixbuf, or NULL. [transfer none]

Since 0.3.1


as_icon_set_name ()

void                as_icon_set_name                    (AsIcon *icon,
                                                         const gchar *name,
                                                         gssize name_len);

Sets the basename to use for the icon.

icon :

a AsIcon instance.

name :

the icon name, e.g. "gimp.png"

name_len :

the size of name, or -1 if NULL-terminated.

Since 0.3.1


as_icon_set_url ()

void                as_icon_set_url                     (AsIcon *icon,
                                                         const gchar *url);

Sets the icon URL.

icon :

a AsIcon instance.

url :

the new icon URL.

Since 0.3.2


as_icon_set_filename ()

void                as_icon_set_filename                (AsIcon *icon,
                                                         const gchar *filename);

Sets the icon absolute filename.

icon :

a AsIcon instance.

filename :

the new icon URL.

Since 0.3.2


as_icon_set_prefix ()

void                as_icon_set_prefix                  (AsIcon *icon,
                                                         const gchar *prefix);

Sets the icon prefix filename.

icon :

a AsIcon instance.

prefix :

the new filename prefix.

Since 0.1.6


as_icon_set_width ()

void                as_icon_set_width                   (AsIcon *icon,
                                                         guint width);

Sets the icon width.

icon :

a AsIcon instance.

width :

the width in pixels.

Since 0.3.1


as_icon_set_height ()

void                as_icon_set_height                  (AsIcon *icon,
                                                         guint height);

Sets the icon height.

icon :

a AsIcon instance.

height :

the height in pixels.

Since 0.3.1


as_icon_set_kind ()

void                as_icon_set_kind                    (AsIcon *icon,
                                                         AsIconKind kind);

Sets the icon kind.

icon :

a AsIcon instance.

kind :

the AsIconKind, e.g. AS_ICON_KIND_STOCK.

Since 0.3.1


as_icon_set_pixbuf ()

void                as_icon_set_pixbuf                  (AsIcon *icon,
                                                         GdkPixbuf *pixbuf);

Sets the icon pixbuf.

icon :

a AsIcon instance.

pixbuf :

the GdkPixbuf, or NULL

Since 0.3.1


as_icon_load ()

gboolean            as_icon_load                        (AsIcon *icon,
                                                         AsIconLoadFlags flags,
                                                         GError **error);

Loads the icon into a local pixbuf.

icon :

a AsIcon instance.

flags :

a AsIconLoadFlags, e.g. AS_ICON_LOAD_FLAG_SEARCH_SIZE

error :

A GError or NULL.

Returns :

TRUE for success

Since 0.3.1


as_icon_convert_to_kind ()

gboolean            as_icon_convert_to_kind             (AsIcon *icon,
                                                         AsIconKind kind,
                                                         GError **error);

Converts the icon from one kind to another.

icon :

a AsIcon instance.

kind :

a AsIconKind, e.g. AS_ICON_KIND_EMBEDDED

error :

A GError or NULL.

Returns :

TRUE for success

Since 0.3.1