1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-06-28 14:49:30 +00:00

util: Make position argument in calls_find_store() optional

This commit is contained in:
Evangelos Ribeiro Tzaras 2021-05-30 02:44:34 +02:00
parent 736c17a4bc
commit b550160a0d

View file

@ -166,7 +166,15 @@ calls_number_is_ussd (const char *number)
return FALSE; return FALSE;
} }
/**
* calls_find_in_store:
* @list: A #GListModel
* @item: The #gpointer to find
* @position: (out) (optional): The first position of @item, if it was found.
*
* Returns: Whether @list contains @item. This is mainly a convenience function
* until we no longer support older glib versions.
*/
gboolean gboolean
calls_find_in_store (GListModel *list, calls_find_in_store (GListModel *list,
gpointer item, gpointer item,
@ -183,18 +191,17 @@ calls_find_in_store (GListModel *list,
count = g_list_model_get_n_items (list); count = g_list_model_get_n_items (list);
for (guint i = 0; i < count; i++) for (guint i = 0; i < count; i++) {
{ g_autoptr (GObject) object = NULL;
g_autoptr (GObject) object = NULL;
object = g_list_model_get_item (list, i); object = g_list_model_get_item (list, i);
if (object == item) if (object == item) {
{ if (position)
*position = i; *position = i;
return TRUE; return TRUE;
}
} }
}
return FALSE; return FALSE;
#endif #endif
} }