[gnome-software] trivial: Add gs_app_list_remove_all()



commit d8dab7270027377bc931aee92e205d79c819499f
Author: Richard Hughes <richard hughsie com>
Date:   Tue May 24 10:09:42 2016 +0100

    trivial: Add gs_app_list_remove_all()
    
    This allows us to empty all applications.

 src/gs-app-list-private.h |    1 +
 src/gs-app-list.c         |   17 +++++++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/src/gs-app-list-private.h b/src/gs-app-list-private.h
index 21064ea..5ee70e8 100644
--- a/src/gs-app-list-private.h
+++ b/src/gs-app-list-private.h
@@ -41,6 +41,7 @@ void           gs_app_list_sort               (GsAppList      *list,
                                                 gpointer        user_data);
 void            gs_app_list_filter_duplicates  (GsAppList      *list);
 void            gs_app_list_randomize          (GsAppList      *list);
+void            gs_app_list_remove_all         (GsAppList      *list);
 
 G_END_DECLS
 
diff --git a/src/gs-app-list.c b/src/gs-app-list.c
index e9b5860..e4e269c 100644
--- a/src/gs-app-list.c
+++ b/src/gs-app-list.c
@@ -89,6 +89,19 @@ gs_app_list_length (GsAppList *list)
 }
 
 /**
+ * gs_app_list_randomize:
+ * @list: A #GsAppList
+ *
+ * Removes all applications from the list.
+ **/
+void
+gs_app_list_remove_all (GsAppList *list)
+{
+       g_return_if_fail (GS_IS_APP_LIST (list));
+       g_ptr_array_set_size (list->array, 0);
+}
+
+/**
  * gs_app_list_filter:
  * @list: A #GsAppList
  * @func: A #GsAppListFilterFunc
@@ -108,7 +121,7 @@ gs_app_list_filter (GsAppList *list, GsAppListFilterFunc func, gpointer user_dat
 
        /* deep copy to a temp list and clear the current one */
        old = gs_app_list_copy (list);
-       g_ptr_array_set_size (list->array, 0);
+       gs_app_list_remove_all (list);
 
        /* see if any of the apps need filtering */
        for (i = 0; i < old->array->len; i++) {
@@ -228,7 +241,7 @@ gs_app_list_filter_duplicates (GsAppList *list)
 
        /* deep copy to a temp list and clear the current one */
        old = gs_app_list_copy (list);
-       g_ptr_array_set_size (list->array, 0);
+       gs_app_list_remove_all (list);
 
        /* create a new list with just the unique items */
        hash = g_hash_table_new (g_str_hash, g_str_equal);


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