# Maintainer (Arch): Daniel Micay <danielmicay@gmail.com>
# Contributor (Arch): Elia Notarangelo <elia.notarangelo AT gmail DOT com>
# Contributor (Arch): Frikilinux <frikilinux at frikilinux.com.ar>
# Contributor (Arch): graysky <graysky AT archlinux DOT us>
# Contributor (Arch): Samsagax <samsagax AT gmail DOT com>
# Contributor (Arch): simongmzlj <simongmzlj AT gmail DOT com>
# Maintainer: André Silva <emulatorman@hyperbola.info>
# Contributor: Jorge Araya Navarro <elcorreo@deshackra.com>
# Contributor: Márcio Silva <coadde@hyperbola.info>

pkgname=faenza-icon-theme
pkgver=1.3.1
pkgrel=5
pkgrel+=.par1
pkgdesc='Icon theme designed for Equinox GTK theme'
pkgdesc+=', without nonfree distros and application icons (Parabola rebranded)'
url='http://gnome-look.org/content/show.php/Faenza?content=128143'
license=('GPL3')
arch=('any')
replaces=(${pkgname}-libre)
conflicts=(${pkgname}-libre)
makedepends=('librsvg')
options=(!strip)
source=("http://ppa.launchpad.net/tiheum/equinox/ubuntu/pool/main/f/$pkgname/${pkgname}_${pkgver}.tar.gz"
        'distributor-logo-parabola.svg'
        'start-here-parabola-symbolic.svg')
sha512sums=('0c017ddbaa2dba485341d3bb1e321fafad026aafc893fa2519ddfd3fe0475fc8d011c99ce3de581c9b1c6aa7d250312673dda7c10bb12783db2d45816646ddc9'
            'a6efee8dc521c3975033185eb8a7bf5d89e9a5a157f0f22e2cdee32d631bcaf0930e3a55dbfaf7e7ae2b5249d28895bd06c8957eb6139544b807e8494e601a41'
            '8bcc02e44606af66908b8c377965f1df36341e7991544c7c89375dfa19d05abb8055280a8ec8038e889ba18aa3dd9ab8e5292c9c7c83fec8fac46bebedc3415e')

prepare() {
 cd "$srcdir/$pkgname-1.3"
 rm -rv debian

 # remove nonfree distros and application logos
 for nonfree in archlinux debian fedora frugalware gentoo linux-mint mandriva opensuse redhat slackware ubuntu flash rpmdrake novell skype; do
  find -name *$nonfree* -delete
 done

  # add the Parabola GNU/Linux-libre logos to the source code
  cp -a "$srcdir/distributor-logo-parabola.svg" Faenza/places/scalable
  cp -a "$srcdir/distributor-logo-parabola.svg" Faenza/places/scalable/start-here-parabola.svg
  cp -a "$srcdir/start-here-parabola-symbolic.svg" Faenza/places/scalable

  for size in 22 24 32 48 64 96; do
   rsvg-convert -w $size -h $size -o Faenza/places/$size/distributor-logo-parabola.png "$srcdir/distributor-logo-parabola.svg"
   rsvg-convert -w $size -h $size -o Faenza/places/$size/start-here-parabola.png "$srcdir/distributor-logo-parabola.svg"
   rsvg-convert -w $size -h $size -o Faenza/places/$size/start-here-parabola-symbolic.png "$srcdir/start-here-parabola-symbolic.svg"

   ln -sf Faenza/places/$size/distributor-logo-parabola.png Faenza/places/$size/parabola-logo.png
   ln -sf Faenza/places/scalable/distributor-logo-parabola.svg parabola-logo.svg
   ln -sf Faenza/places/scalable/start-here-parabola.svg Faenza-Dark/places/scalable/start-here-parabola.svg
   ln -sf Faenza/places/scalable/start-here-parabola-symbolic.svg  Faenza-Dark/places/scalable/start-here-parabola-symbolic.svg
  done
}

package() {
  cd $pkgname-1.3
  mkdir -p "$pkgdir/usr/share/icons" "$pkgdir/usr/lib" "$pkgdir/usr/share"

  cp -rf Faenza{,-Dark,-Darkest,-Darker,-Ambiance,-Radiance} "$pkgdir/usr/share/icons/"
  cp -rf rhythmbox "$pkgdir/usr/lib/"
  cp -rf emesene "$pkgdir/usr/share/"

  # set the Parabola GNU/Linux-libre Distributor and start menu logo
  for theme in Faenza{,-Dark}; do
    for size in 22 24 32 48 64 96; do
      cd "$pkgdir/usr/share/icons/$theme/places/$size/"
      # no distributor-logo for Faenza-Dark
      [[ $theme == Faenza ]] && ln -sf distributor-logo{-parabola,}.png
      ln -sf start-here{-parabola,}.png
    done
    cd "$pkgdir/usr/share/icons/$theme/places/scalable/"
    # no distributor-logo for Faenza-Dark
    [[ $theme == Faenza ]] && ln -sf distributor-logo{-parabola,}.svg
    ln -sf start-here{-parabola,}.svg
    ln -sf start-here{-parabola-symbolic,-symbolic}.svg
  done

  for theme in Faenza{,-Dark}; do
    cd "$pkgdir/usr/share/icons/$theme/apps/scalable/"
    ln -sf gnome-session-reboot.svg system-reboot.svg
    for size in 16 22 24 32 48 64 96; do
      cd "$pkgdir/usr/share/icons/$theme/apps/$size/"
      ln -sf gnome-session-reboot.png system-reboot.png
    done
  done
}
