g_get_nth_available_path() function searches for the first non-existing path available according to the given pattern. For instance,
g_get_nth_available_path("my_document", ".txt", " (", ")", 1, false) first checks whether "my_document.txt" exists; if yes, "my_document (2).txt" will be checked, and so on until a non-existing path is reached.
P.S. I have tried my best to follow GLib coding standard, but it is not my usual style and I might not have got everything right, so feel free to adjust it as you wish. Especially the documentation style needs a supervision.