################################################################################
#
# pygtk.cygclass - functions for building PyGTK and Gnome-Python packages
#
# Part of cygport - Cygwin packaging application
# Copyright (C) 2006-2015 Yaakov Selkowitz
# Provided by the Cygwin Ports project <http://sourceware.org/cygwinports/>
#
# cygport is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cygport is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cygport.  If not, see <http://www.gnu.org/licenses/>.
#
################################################################################

#****h* Cygclasses/pygtk.cygclass
#  SYNOPSIS
#  inherit pygtk
#  DESCRIPTION
#  The PyGTK project provides a series of bindings for the GTK+ and GNOME
#  libraries.  APIs are defined in .defs files, from which C binding code
#  is generated with PYGTK_CODEGEN.  These bindings allow full-featured
#  GNOME programs to be written in the Python language, and are among one
#  of the most commonly used GNOME language bindings.
#
#  This package provides definitions and functions for building PyGTK bindings.
#  INHERITS
#  gnome.org.cygclass (unless mate.cygclass has been inherit()ed), python.cygclass
#****

case ${PN#python-} in
	${PN})
		# for packages which provide pygtk bindings together with the C lib.
		pygtk_mod=${PN}
		;;
	gnome-python|nautilus-python)
		pygtk_mod=${PN/-python}
		ORIG_PN=${PN}
		;;
	gnome-python-desktop|gnome-python-extras)
		pygtk_mod=${PN/-python-/ }
		ORIG_PN=${PN}
		;;
	gst0.10)
		pygtk_mod="gstreamer 0.10"
		ORIG_PN="gst-python"
		;;
	mate*)
		pygtk_mod=${PN#python-}
		ORIG_PN=${ORIG_PN:-${PN}}
		;;
	*)
		pygtk_mod=${PN#python-}
		ORIG_PN=${ORIG_PN:-py${pygtk_mod%2*}}
		;;
esac

inherited mate || inherit gnome.org
inherit python

#****d* pygtk.cygclass/PYGTK_INCLUDEDIR
#  DESCRIPTION
#  Directory containing PyGTK C headers.
#****
PYGTK_INCLUDEDIR="/usr/include/pygtk-2.0"

#****d* pygtk.cygclass/PYGTK_LIBDIR
#  DESCRIPTION
#  Installation path for PyGTK bindings.
#****
PYGTK_LIBDIR="${PYTHON_SITELIB}/gtk-2.0"

#****d* pygtk.cygclass/PYGTK_DATADIR
#  DESCRIPTION
#  Installation path for *.defs and *-arg-types.py API files.
#****
PYGTK_DATADIR="/usr/share/pygtk/2.0"

#****d* pygtk.cygclass/PYGTK_CODEGEN
#  DESCRIPTION
#  Absolute path to the PyGTK C code generator.
#****
if check_prog pygobject-codegen-2.0
then
	export PYGTK_CODEGEN="/usr/bin/pygobject-codegen-2.0"
fi

#****o* pygtk.cygclass/CATEGORY (pygtk)
#  DEFINITION
CATEGORY="Python"
#****
#****o* pygtk.cygclass/SUMMARY (pygtk)
#  DEFINITION
SUMMARY="Python ${pygtk_mod} bindings"
#****
#****o* pygtk.cygclass/HOMEPAGE (pygtk)
#  DEFINITION
HOMEPAGE="http://www.pygtk.org/"
#****

KEEP_LA_FILES="none"

unset pygtk_mod

#****C* pygtk.cygclass/pygtk_compile
#  SYNOPSIS
#  pygtk_compile [OPTIONS]
#  DESCRIPTION
#  Configures the package with cygconf, passing any arguments it receives,
#  then compiles the package with cygmake.
#****
pygtk_compile() {
	if inherited gnome2
	then
		gnome2_configure "${@}"
	else
		cygconf "${@}"
	fi
	cygmake LIBS="-no-undefined ${LIBPYTHON}"
}

#****o* pygtk.cygclass/src_compile (pygtk)
#  DEFINITION
src_compile() {
	cd ${S}
	if [ -d m4 ]
	then
		ACLOCAL_FLAGS='-I m4'
	fi
	if inherited gnome2
	then
		gnome2_autoreconf
	else
		cygautoreconf
	fi
	cd ${B}
	pygtk_compile
}
#****

readonly -f pygtk_compile
