mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-07 12:25:31 +00:00
util: Make position argument in calls_find_store() optional
This commit is contained in:
parent
736c17a4bc
commit
b550160a0d
1 changed files with 17 additions and 10 deletions
27
src/util.c
27
src/util.c
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue