diff options
Diffstat (limited to 'src/up-device-list.c')
-rw-r--r-- | src/up-device-list.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/up-device-list.c b/src/up-device-list.c index da5555b..b95925a 100644 --- a/src/up-device-list.c +++ b/src/up-device-list.c @@ -130,6 +130,37 @@ up_device_list_remove (UpDeviceList *list, GObject *device) } /** + * up_device_list_remove_cb: + **/ +static gboolean +up_device_list_remove_all_cb (gpointer key, gpointer value, gpointer user_data) +{ + return TRUE; +} + +/** + * up_device_list_clear: + * @list: This class instance + * @unref_it: %TRUE if you own a reference to the objects and want to drop it. + * + * Clear the contents of this list. + **/ +void +up_device_list_clear (UpDeviceList *list, gboolean unref_it) +{ + g_return_if_fail (UP_IS_DEVICE_LIST (list)); + + /* caller owns these objects, but wants to destroy them */ + if (unref_it) + g_ptr_array_foreach (list->priv->array, (GFunc) g_object_unref, NULL); + + /* remove all devices from the db */ + g_hash_table_foreach_remove (list->priv->map_native_path_to_device, + up_device_list_remove_all_cb, NULL); + g_ptr_array_set_size (list->priv->array, 0); +} + +/** * up_device_list_get_array: * * This is quick to iterate when we don't have GObject's to resolve |