# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 119568 2014-04-30 16:45:10Z devans@macports.org $

PortSystem      1.0

name            totem
version         3.12.1
set branch      [join [lrange [split ${version} .] 0 1] .]
categories      gnome
# also has an exception allowing use of non-GPL-compatible plugins
license         GPL-2+
maintainers     devans openmaintainer
description     Official movie player of the GNOME desktop environment
long_description \
                Totem is based on GStreamer. It features a \
                playlist, a full-screen mode, seek and volume controls, \
                as well as keyboard navigation. It comes with added \
                functionality such as: \
                    * Video thumbnailer for the file manager \
                    * Nautilus properties tab \
                    * Webcam utility (in development)

homepage        https://wiki.gnome.org/Apps/Videos
platforms       darwin
master_sites    gnome:sources/${name}/${branch}/

use_xz          yes

checksums       rmd160  8accfa8bf40de8483e0dba79b431a722a359619e \
                sha256  dd168cdd4051d01131d47c24fa45bfd08b6ccf45900ac4b64bae47f6f47a35e3

depends_build   port:pkgconfig \
                port:intltool \
                port:itstool \
                port:gnome-common \
                port:yelp-tools \
                port:appdata-tools

depends_lib     port:desktop-file-utils \
                port:gnome-icon-theme \
                port:gnome-icon-theme-symbolic \
                port:gsettings-desktop-schemas \
                port:gtk3 \
                port:gobject-introspection \
                port:grilo-plugins \
                port:gstreamer1-gst-plugins-base \
                port:gstreamer1-gst-plugins-good \
                port:gstreamer1-gst-plugins-bad \
                port:gstreamer1-gst-libav \
                port:clutter \
                port:clutter-gtk \
                port:clutter-gst \
                port:totem-pl-parser \
                port:libpeas \
                port:libxml2 \
                port:shared-mime-info \
                port:dbus \
                port:vala \
                port:zeitgeist \
                port:xorg-libX11 \
                port:xorg-libsm \
                port:xorg-libice

depends_run     port:gnome-settings-daemon \
                port:yelp

patchfiles      patch-vala-cflags.diff

# update m4/intltool.m4 and autoreconf

pre-configure {
    copy -force ${prefix}/share/aclocal/intltool.m4 ${worksrcpath}/m4
}

use_autoreconf  yes
autoreconf.args -fvi

set withplugins apple-trailers,autoload-subtitles,chapters,dbusservice,im-status,gromit,media-player-keys,ontop,opensubtitles,properties,pythonconsole,recent,rotation,screensaver,screenshot,skipto,zeitgeist-dp,vimeo

if {[variant_isset nautilus]} {
    set withplugins [string map {"rotation" "rotation,save-file"} ${withplugins}]
}

configure.args  --with-plugins=${withplugins} \
                --enable-easy-codec-installation \
                --enable-browser-plugins=no \
                --enable-introspection=yes \
                --enable-debug \
                --enable-compile-warnings=minimum \
                --disable-python \
                --enable-vala \
                --disable-nautilus \
                --disable-schemas-compile \
                --disable-silent-rules

# gobject-introspection uses g-ir-scanner, which uses $CC from env
build.args-append       CC="${configure.cc} ${configure.cc_archflags}"
destroot.args-append    CC="${configure.cc} ${configure.cc_archflags}"

variant nautilus description {Build nautilus properties page plugin} {
    configure.args-delete     --disable-nautilus
    depends_lib-append        port:nautilus
}

variant python27 conflicts python32 python33 python34 description {Use python 2.7} {
    configure.python          ${prefix}/bin/python2.7
    depends_lib-append        port:py27-gobject3 port:py27-pylint
    set python_framework      ${frameworks_dir}/Python.framework/Versions/2.7
    configure.pkg_config_path ${python_framework}/lib/pkgconfig
    configure.env              PATH=${python_framework}/bin:$env(PATH)
    configure.args-replace    --disable-python --enable-python
}

variant python32 conflicts python27 python33 python34 description {Use python 3.2} {
    configure.python          ${prefix}/bin/python3.2
    depends_lib-append        port:py32-gobject3 port:py32-pylint
    set python_framework      ${frameworks_dir}/Python.framework/Versions/3.2
    configure.pkg_config_path ${python_framework}/lib/pkgconfig
    configure.env              PATH=${python_framework}/bin:$env(PATH)
    configure.args-replace    --disable-python --enable-python
}

variant python33 conflicts python27 python32 python34 description {Use python 3.3} {
    configure.python          ${prefix}/bin/python3.3
    depends_lib-append        port:py33-gobject3 port:py33-pylint
    set python_framework      ${frameworks_dir}/Python.framework/Versions/3.3
    configure.pkg_config_path ${python_framework}/lib/pkgconfig
    configure.env              PATH=${python_framework}/bin:$env(PATH)
    configure.args-replace    --disable-python --enable-python
}

variant python34 conflicts python27 python32 python33 description {Use python 3.4} {
    configure.python          ${prefix}/bin/python3.4
    depends_lib-append        port:py34-gobject3 port:py34-pylint
    set python_framework      ${frameworks_dir}/Python.framework/Versions/3.4
    configure.pkg_config_path ${python_framework}/lib/pkgconfig
    configure.env              PATH=${python_framework}/bin:$env(PATH)
    configure.args-replace    --disable-python --enable-python
}

if {![variant_isset python27] && ![variant_isset python32] && ![variant_isset python34]} {
    default_variants +python33
}

post-activate {
    system "${prefix}/bin/update-desktop-database ${prefix}/share/applications"
    system "${prefix}/bin/gtk-update-icon-cache-3.0 -f -t ${prefix}/share/icons/hicolor"
    system "${prefix}/bin/glib-compile-schemas ${prefix}/share/glib-2.0/schemas"
}

livecheck.type  gnome
