# -*- python -*-
# encoding: utf-8

import os

def configure(conf):
    conf.env.append_value('MODULES_AVAILABLE', 'matecanvas')
    
    if 'matecanvas' in conf.env['ENABLE_MODULES'] or 'all' in conf.env['ENABLE_MODULES']:
        if conf.pkg_check_modules('MATECANVAS', 'libmatecanvas-2.0 >= 2.8.0 pygobject-2.0 ',
                                  mandatory=False):
            conf.env.append_value('MODULES_TO_BUILD', 'matecanvas')


def build(bld):
    env = bld.env
    if 'matecanvas' in env['MODULES_TO_BUILD']:
        bld.codegen('canvas', local_load_types=['../matecomponent/matecomponent-arg-types.py'],
                    local_register=['../mate/mate-types.defs',
                                    'canvas.defs',
                                    '../matecomponent/matecomponent-types.defs'],
                    register=[os.path.join(env['PYGTK_DEFSDIR'], 'pango-types.defs'),
                              os.path.join(env['PYGTK_DEFSDIR'], 'gdk-types.defs'),
                              os.path.join(env['PYGTK_DEFSDIR'], 'gtk-types.defs')])

        pyext = bld.create_pyext()
        pyext.source = 'canvasmodule.c canvas.c'
        pyext.target = 'matecanvas'
        pyext.uselib = 'MATECANVAS'
        pyext.install_path = '${PYTHONDIR}/gtk-2.0'

        bld.install_files('${DATADIR}/pygtk/2.0/defs',
                          ['canvas.defs'])

