[gnome-software] Add the gs_app_remove_category function



commit b75e337f17df10ed45236f675bed819c6fb1a3bc
Author: Joaquim Rocha <jrocha endlessm com>
Date:   Fri Nov 18 10:38:44 2016 +0100

    Add the gs_app_remove_category function

 src/gs-app.c |   30 ++++++++++++++++++++++++++++++
 src/gs-app.h |    2 ++
 2 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-app.c b/src/gs-app.c
index 89b6b01..f7d503c 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -2939,6 +2939,36 @@ gs_app_add_category (GsApp *app, const gchar *category)
 }
 
 /**
+ * gs_app_remove_category:
+ * @app: a #GsApp
+ * @category: a category ID, e.g. "AudioVideo"
+ *
+ * Removes an category ID from an application, it exists.
+ *
+ * Returns: %TRUE for success
+ *
+ * Since: 3.24
+ **/
+gboolean
+gs_app_remove_category (GsApp *app, const gchar *category)
+{
+       const gchar *tmp;
+       guint i;
+
+       g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&app->mutex);
+       g_return_val_if_fail (GS_IS_APP (app), FALSE);
+
+       for (i = 0; i < app->categories->len; i++) {
+               tmp = g_ptr_array_index (app->categories, i);
+               if (g_strcmp0 (tmp, category) != 0)
+                       continue;
+               g_ptr_array_remove_index_fast (app->categories, i);
+               return TRUE;
+       }
+       return FALSE;
+}
+
+/**
  * gs_app_get_key_colors:
  * @app: a #GsApp
  *
diff --git a/src/gs-app.h b/src/gs-app.h
index 3e3cc22..35a0599 100644
--- a/src/gs-app.h
+++ b/src/gs-app.h
@@ -261,6 +261,8 @@ gboolean     gs_app_has_category            (GsApp          *app,
                                                 const gchar    *category);
 void            gs_app_add_category            (GsApp          *app,
                                                 const gchar    *category);
+gboolean        gs_app_remove_category         (GsApp          *app,
+                                                const gchar    *category);
 GPtrArray      *gs_app_get_keywords            (GsApp          *app);
 void            gs_app_set_keywords            (GsApp          *app,
                                                 GPtrArray      *keywords);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]