diff options
author | Richard Hughes <richard@hughsie.com> | 2017-05-04 16:09:50 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2017-05-04 16:09:50 +0100 |
commit | a2b0c4e201b78c4a035edf47b8d47a830d2f0977 (patch) | |
tree | afa834fc013cc233aeabf7ad2b2dffb670b63753 | |
parent | 90354f700bd57d887499021fb341f2c6ad2129f0 (diff) | |
download | appstream-glib-a2b0c4e201b78c4a035edf47b8d47a830d2f0977.tar.gz |
Add as_app_remove_category()
This allows us to remove previously-added categories.
-rw-r--r-- | libappstream-glib/as-app.c | 21 | ||||
-rw-r--r-- | libappstream-glib/as-app.h | 2 |
2 files changed, 23 insertions, 0 deletions
diff --git a/libappstream-glib/as-app.c b/libappstream-glib/as-app.c index b4e7ce6..6b60afa 100644 --- a/libappstream-glib/as-app.c +++ b/libappstream-glib/as-app.c @@ -2792,6 +2792,27 @@ as_app_add_category (AsApp *app, const gchar *category) g_ptr_array_add (priv->categories, as_ref_string_new (category)); } +/** + * as_app_remove_category: + * @app: a #AsApp instance. + * @category: the category. + * + * Removed a menu category from the application. + * + * Since: 0.6.13 + **/ +void +as_app_remove_category (AsApp *app, const gchar *category) +{ + AsAppPrivate *priv = GET_PRIVATE (app); + for (guint i = 0; i < priv->categories->len; i++) { + const gchar *tmp = g_ptr_array_index (priv->categories, i); + if (g_strcmp0 (tmp, category) == 0) { + g_ptr_array_remove (priv->categories, (gpointer) tmp); + break; + } + } +} /** * as_app_add_compulsory_for_desktop: diff --git a/libappstream-glib/as-app.h b/libappstream-glib/as-app.h index b1e3707..35c3849 100644 --- a/libappstream-glib/as-app.h +++ b/libappstream-glib/as-app.h @@ -611,6 +611,8 @@ void as_app_set_priority (AsApp *app, gint priority); void as_app_add_category (AsApp *app, const gchar *category); +void as_app_remove_category (AsApp *app, + const gchar *category); void as_app_add_keyword (AsApp *app, const gchar *locale, const gchar *keyword); |