'return the wildcard string for the filesave dialog'

def _get_imagesave_wildcards(self):

    default_filetype = self.get_default_filetype()
    filetypes = self.get_supported_filetypes_grouped()
    sorted_filetypes = sorted(filetypes.items())
    wildcards = []
    extensions = []
    filter_index = 0
    for (i, (name, exts)) in enumerate(sorted_filetypes):
        ext_list = u';'.join([(u'*.%s' % ext) for ext in exts])
        extensions.append(exts[0])
        wildcard = (u'%s    (%s)|%s' % (name, ext_list, ext_list))
        if (default_filetype in exts):
            filter_index = i
        wildcards.append(wildcard)
    wildcards = u'|'.join(wildcards)
    return (wildcards, extensions, filter_index)
