AsIcon: AppStream-glib Reference Manual

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

## Stability Level

Stable, unless otherwise indicated

## Functions

AsIcon * | as_icon_new ()
GQuark | as_icon_error_quark ()
const gchar * | as_icon_kind_to_string ()
AsIconKind | as_icon_kind_from_string ()
const gchar * | as_icon_get_name ()
const gchar * | as_icon_get_url ()
const gchar * | as_icon_get_filename ()
const gchar * | as_icon_get_prefix ()
guint | as_icon_get_width ()
guint | as_icon_get_height ()
AsIconKind | as_icon_get_kind ()
GdkPixbuf * | as_icon_get_pixbuf ()
void | as_icon_set_name ()
void | as_icon_set_url ()
void | as_icon_set_filename ()
void | as_icon_set_prefix ()
void | as_icon_set_width ()
void | as_icon_set_height ()
void | as_icon_set_kind ()
void | as_icon_set_pixbuf ()
gboolean | as_icon_load ()
gboolean | as_icon_convert_to_kind ()

## Types and Values

enum | AsIconError
enum | AsIconKind
enum | AsIconLoadFlags
#define | AS_ICON_ERROR

## Object Hierarchy

        GObject
        ╰── AsIcon

## Includes

    #include <appstream-glib.h>

## 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

## Functions

### 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.

#### Parameters

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.

#### Parameters

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"

#### Parameters

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`

#### Parameters

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`

#### Parameters

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.

#### Parameters

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.

#### Parameters

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.

#### Parameters

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.

#### Parameters

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.

#### Parameters

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.

#### Parameters

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.

#### Parameters

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.

#### Parameters

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.

#### Parameters

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.

#### Parameters

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.

#### Parameters

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.

#### Parameters

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.

#### Parameters

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.

#### Parameters

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.

#### Parameters

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

## Types and Values

### enum AsIconError

The error type.

#### Members

AS_ICON_ERROR_FAILED | Generic failure |

### enum AsIconKind

The icon type.

#### Members

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

The flags to use when loading icons.

#### Members

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 ()