gs-icon

gs-icon — Utilities for handling GIcons

Functions

Description

This file provides several utilities for creating and handling GIcon instances. GIcon is used for representing icon sources throughout gnome-software, as it has low memory overheads, and allows the most appropriate icon data to be loaded when it’s needed to be used in a UI.

gnome-software uses various classes which implement GIcon, mostly the built-in ones provided by GIO, but also GsRemoteIcon. All of them are tagged with width and height metadata (when that data was available at construction time). See gs_icon_get_width().

Functions

gs_icon_get_width ()

guint
gs_icon_get_width (GIcon *icon);

Get the width of an icon, if it was attached as metadata when the GIcon was created from an AsIcon.

Parameters

icon

a GIcon

 

Returns

width of the icon (in device pixels), or 0 if unknown

Since: 40


gs_icon_set_width ()

void
gs_icon_set_width (GIcon *icon,
                   guint width);

Set the width of an icon. See gs_icon_get_width().

Parameters

icon

a GIcon

 

width

width of the icon, in device pixels

 

Since: 40


gs_icon_get_height ()

guint
gs_icon_get_height (GIcon *icon);

Get the height of an icon, if it was attached as metadata when the GIcon was created from an AsIcon.

Parameters

icon

a GIcon

 

Returns

height of the icon (in device pixels), or 0 if unknown

Since: 40


gs_icon_set_height ()

void
gs_icon_set_height (GIcon *icon,
                    guint height);

Set the height of an icon. See gs_icon_get_height().

Parameters

icon

a GIcon

 

height

height of the icon, in device pixels

 

Since: 40


gs_icon_get_scale ()

guint
gs_icon_get_scale (GIcon *icon);

Get the scale of an icon, if it was attached as metadata when the GIcon was created from an AsIcon.

See gtk_widget_get_scale_factor() for more information about scales.

Parameters

icon

a GIcon

 

Returns

scale of the icon, or 1 if unknown; guaranteed to always be greater than or equal to 1

Since: 40


gs_icon_set_scale ()

void
gs_icon_set_scale (GIcon *icon,
                   guint scale);

Set the scale of an icon. See gs_icon_get_scale().

Parameters

icon

a GIcon

 

scale

scale of the icon, which must be greater than or equal to 1

 

Since: 40


gs_icon_new_for_appstream_icon ()

GIcon *
gs_icon_new_for_appstream_icon (AsIcon *appstream_icon);

Create a new GIcon representing the given AsIcon. The actual type of the returned icon will vary depending on the AsIconKind of appstream_icon .

If the width or height of the icon are set on the AsIcon, they are stored as the width and height data associated with the returned object, using g_object_set_data().

This can fail (and return NULL) if the appstream_icon has invalid or missing properties.

Parameters

appstream_icon

an AsIcon

 

Returns

the GIcon, or NULL.

[transfer full][nullable]

Since: 40