'Add an entry to the manifest for a file with the specified name. Returns the manifest id.'

def add_name_to_manifest(self, name, process_manifest_item=None):

    all_ids = {x.get(u'id') for x in self.opf_xpath(u'//*[@id]')}
    c = 0
    item_id = u'id'
    while (item_id in all_ids):
        c += 1
        item_id = (u'id' + (u'%d' % c))
    manifest = self.opf_xpath(u'//opf:manifest')[0]
    href = self.name_to_href(name, self.opf_name)
    item = manifest.makeelement(OPF(u'item'), id=item_id, href=href)
    item.set(u'media-type', self.mime_map[name])
    self.insert_into_xml(manifest, item)
    if (process_manifest_item is not None):
        process_manifest_item(item)
    self.dirty(self.opf_name)
    return item_id
