#!/usr/bin/env python3

import os
import glob
import gi

# Some initial requirements so older version don't get loaded.
gi.require_version('Gtk', '3.0')
gi.require_version('Gst', '1.0')

repo = gi._gi.Repository.get_default()

module_names = set([os.path.basename(p[:p.rfind('-')])
                    for p in glob.glob('/usr/lib64/girepository-1.0/*.typelib')])

for modname in module_names:
    try:
        repo.require(modname)
    except Exception as e:
        print(modname, e)
        continue

    for info in repo.get_infos(modname):
        if not isinstance(info, (gi._gi.ObjectInfo, gi._gi.InterfaceInfo)):
            continue

        for signal in info.get_signals():
            for arg in signal.get_arguments():
                type_info = arg.get_type()
                if arg.get_direction() == gi._gi.Direction.OUT and \
                        type_info.get_tag() == gi._gi.TypeTag.INTERFACE and \
                        type_info.get_interface().get_type() in (gi._gi.InfoType.BOXED, gi._gi.InfoType.STRUCT):
                    print('*** %s.%s:%s' % (modname, info.get_name(), signal.get_name()))
                    break
