# Maintainer: Balló György <ballogyor+arch at gmail dot com>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: Angel Velasquez <angvp@archlinux.org> 
# Contributor: Geoffroy Carrier <geoffroy.carrier@koon.fr>

pkgbase=gpicview
pkgname=(gpicview gpicview-gtk3)
pkgver=0.2.5
pkgrel=4
pkgdesc='Lightweight image viewer'
arch=('x86_64')
license=('GPL2')
url='https://lxde.org/'
depends=('gtk2' 'gtk3')
makedepends=('intltool')
source=(https://downloads.sourceforge.net/lxde/$pkgbase-$pkgver.tar.xz
        0001-Fix-displaying-images-with-GTK3.patch)
sha256sums=('38466058e53702450e5899193c4b264339959b563dd5cd81f6f690de32d82942'
            'f597fa7d5e8537665ea7bdf7bfffebaa32046e8feb4866866bfb64c219d8ea6d')

prepare() {
  cd $pkgbase-$pkgver

  # Fix displaying images with GTK3
  # https://sourceforge.net/p/lxde/patches/542/
  patch -Np1 -i ../0001-Fix-displaying-images-with-GTK3.patch

  # Apply only one main category
  sed -i '/^Categories=/ s/Utility;//' gpicview.desktop.in
}

build() {
  # GTK+ 2 version
  [ -d gtk2 ] || cp -r $pkgbase-$pkgver gtk2
  cd gtk2
  ./configure --sysconfdir=/etc --prefix=/usr
  make

  cd "$srcdir"
  # GTK+ 3 version
  [ -d gtk3 ] || cp -r $pkgbase-$pkgver gtk3
  cd gtk3
  ./configure --sysconfdir=/etc --prefix=/usr --enable-gtk3
  make
}

package_gpicview() {
  groups=('lxde')
  depends=('gtk2')

  cd gtk2
  make DESTDIR="$pkgdir" install
}

package_gpicview-gtk3() {
  groups=('lxde-gtk3')
  pkgdesc+=' (GTK+ 3 version)'
  depends=('gtk3')
  conflicts=('gpicview')

  cd gtk3
  make DESTDIR="$pkgdir" install
}
