gs-category: GNOME Software Reference Manual

## gs-category gs-category — An category that contains applications |

## Functions

GsCategory * | gs_category_new ()
const gchar * | gs_category_get_id ()
GsCategory * | gs_category_get_parent ()
const gchar * | gs_category_get_name ()
void | gs_category_set_name ()
const gchar * | gs_category_get_icon ()
void | gs_category_set_icon ()
gint | gs_category_get_score ()
void | gs_category_set_score ()
GPtrArray * | gs_category_get_key_colors ()
void | gs_category_add_key_color ()
GPtrArray * | gs_category_get_desktop_groups ()
gboolean | gs_category_has_desktop_group ()
void | gs_category_add_desktop_group ()
GsCategory * | gs_category_find_child ()
GPtrArray * | gs_category_get_children ()
void | gs_category_add_child ()
guint | gs_category_get_size ()
void | gs_category_increment_size ()

## Types and Values

#define | GS_TYPE_CATEGORY
| GsCategory

## Object Hierarchy

        GObject
        ╰── GsCategory

## Description

This object provides functionality that allows a plugin to create a tree structure of categories that each contain GsApp's.

## Functions

### gs_category_new ()

    GsCategory *
    gs_category_new (const gchar *id);

Creates a new category object.

#### Parameters

id | an ID, e.g. "all" |
name | a localised name |

#### Returns

the new GsCategory

Since: 3.22

### gs_category_get_id ()

    const gchar *
    gs_category_get_id (GsCategory *category);

Gets the category ID.

#### Parameters

category | a GsCategory |

#### Returns

the string, e.g. "other"

Since: 3.22

### gs_category_get_parent ()

    GsCategory *
    gs_category_get_parent (GsCategory *category);

Gets the parent category.

#### Parameters

category | a GsCategory |

#### Returns

the GsCategory or `NULL`

Since: 3.22

### gs_category_get_name ()

    const gchar *
    gs_category_get_name (GsCategory *category);

Gets the category name.

#### Parameters

category | a GsCategory |

#### Returns

the string, or `NULL`

Since: 3.22

### gs_category_set_name ()

    void
    gs_category_set_name (GsCategory *category,
                          const gchar *name);

Sets the category name.

#### Parameters

category | a GsCategory |
name | a category name, or `NULL` |

Since: 3.22

### gs_category_get_icon ()

    const gchar *
    gs_category_get_icon (GsCategory *category);

Gets the category icon.

#### Parameters

category | a GsCategory |

#### Returns

the string, or `NULL`

Since: 3.22

### gs_category_set_icon ()

    void
    gs_category_set_icon (GsCategory *category,
                          const gchar *icon);

Sets the category icon.

#### Parameters

category | a GsCategory |
icon | a category icon, or `NULL` |

Since: 3.22

### gs_category_get_score ()

    gint
    gs_category_get_score (GsCategory *category);

Gets if the category score. Important categories may be shown before other categories, or tagged in a different way, for example with color or in a different section.

#### Parameters

category | a GsCategory |

#### Returns

the string, or `NULL`

Since: 3.22

### gs_category_set_score ()

    void
    gs_category_set_score (GsCategory *category,
                           gint score);

Sets the category score, where larger numbers get sorted before lower numbers.

#### Parameters

category | a GsCategory |
score | a category score, or `NULL` |

Since: 3.22

### gs_category_get_key_colors ()

    GPtrArray *
    gs_category_get_key_colors (GsCategory *category);

Gets the list of key colors for the category.

#### Parameters

category | a GsCategory |

#### Returns

An array.

[element-type GdkRGBA][transfer none]

Since: 3.22

### gs_category_add_key_color ()

    void
    gs_category_add_key_color (GsCategory *category,
                               const GdkRGBA *key_color);

Adds a key color to the category.

#### Parameters

category | a GsCategory |
key_color | a GdkRGBA |

Since: 3.22

### gs_category_get_desktop_groups ()

    GPtrArray *
    gs_category_get_desktop_groups (GsCategory *category);

Gets the list of AppStream groups for the category.

#### Parameters

category | a GsCategory |

#### Returns

An array.

[element-type utf8][transfer none]

Since: 3.22

### gs_category_has_desktop_group ()

    gboolean
    gs_category_has_desktop_group (GsCategory *category,
                                   const gchar *desktop_group);

Finds out if the category has the specific AppStream desktop group.

#### Parameters

category | a GsCategory |
desktop_group | a group of categories found in AppStream, e.g. "AudioVisual::Player" |

#### Returns

`TRUE` if found, `FALSE` otherwise

Since: 3.22

### gs_category_add_desktop_group ()

    void
    gs_category_add_desktop_group (GsCategory *category,
                                   const gchar *desktop_group);

Adds a desktop group to the category. A desktop group is a set of category strings that all must exist.

#### Parameters

category | a GsCategory |
desktop_group | a group of categories found in AppStream, e.g. "AudioVisual::Player" |

Since: 3.22

### gs_category_find_child ()

    GsCategory *
    gs_category_find_child (GsCategory *category,
                            const gchar *id);

Find a child category with a specific ID.

#### Parameters

category | a GsCategory |
id | a category ID, e.g. "other" |

#### Returns

the GsCategory, or `NULL`.

[transfer none]

Since: 3.22

### gs_category_get_children ()

    GPtrArray *
    gs_category_get_children (GsCategory *category);

Gets the list if children for a category.

#### Parameters

category | a GsCategory |

#### Returns

A list of children.

[element-type GsApp][transfer none]

Since: 3.22

### gs_category_add_child ()

    void
    gs_category_add_child (GsCategory *category,
                           GsCategory *subcategory);

Adds a child category to a parent category.

#### Parameters

category | a GsCategory |
subcategory | a GsCategory |

Since: 3.22

### gs_category_get_size ()

    guint
    gs_category_get_size (GsCategory *category);

Returns how many applications the category could contain.

NOTE: This may over-estimate the number if duplicate applications are filtered or core applications are not shown.

#### Parameters

category | a GsCategory |

#### Returns

the number of apps in the category

Since: 3.22

### gs_category_increment_size ()

    void
    gs_category_increment_size (GsCategory *category);

Adds one to the size count if an application is available

#### Parameters

category | a GsCategory |

Since: 3.22

## Types and Values

### GS_TYPE_CATEGORY

    #define GS_TYPE_CATEGORY (gs_category_get_type ())

### GsCategory

    typedef struct _GsCategory GsCategory;