# -*- 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 108079 2013-07-12 18:51:43Z devans@macports.org $

PortSystem      1.0

name            totem
version         2.32.0
revision        2
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 \
                    * Mozilla (Firefox) plugin to view movies inside your \
                      browser (in development) \
                    * Webcam utility (in development)

homepage        http://live.gnome.org/Totem
platforms       darwin
master_sites    gnome:sources/${name}/${branch}/

use_bzip2       yes

checksums       rmd160  5312aa67e3ff611be0626fd72da66e1c26d6eb4d \
                sha256  982d6aaeca3e4844694fc0a2540d792bea753e24b55cf33203188b32b5914f47

patchfiles      patch-Makefile.in.diff \
                patch-configure.diff \
                patch-src-plugins-totem-python-module.c.diff \
                patch-bindings-python-totem.override.diff \
                patch-browser-plugin-totemPlugin.cpp.diff

depends_build   port:pkgconfig \
                port:intltool \
                port:gnome-doc-utils \
                port:gtk-doc

depends_lib     port:desktop-file-utils \
                port:gtk2 \
                port:gconf \
                port:libgdata \
                port:libunique \
                port:totem-pl-parser \
                port:xorg-libXtst \
                port:xorg-libXxf86vm \
                port:gstreamer010-gst-plugins-base \
                port:nautilus \
                port:iso-codes \
                port:gnome-icon-theme

depends_run     port:gnome-settings-daemon \
                port:gstreamer010-gst-plugins-good \
                port:gstreamer010-gst-plugins-bad \
                port:gstreamer010-gst-plugins-ugly

# gst-ffmpeg provides optional decoders, but it is not +universal
if {![variant_isset universal]} {
    depends_run-append port:gstreamer010-gst-ffmpeg
}

configure.args  --with-plugins="thumbnail ontop gromit media-player-keys properties sidebar-test skipto youtube pythonconsole dbus-service" \
                --disable-static \
                --enable-browser-plugins \
                --enable-easy-codec-installation \
                --enable-nautilus \
                --disable-vala \
                --disable-silent-rules \
                --disable-schemas-install \
                --disable-scrollkeeper \
                --x-includes=${prefix}/include \
                --x-libraries=${prefix}/lib \
                BROWSER_PLUGIN_DIR=${prefix}/lib/nsplugins

variant python25 conflicts python26 python27 description {Use python 2.5} {
    configure.python          ${prefix}/bin/python2.5
    depends_lib-append        port:py25-pygtk
    set python_framework      ${frameworks_dir}/Python.framework/Versions/2.5
    configure.pkg_config_path ${python_framework}/lib/pkgconfig
    configure.env              PATH=${python_framework}/bin:$env(PATH)
}

variant python26 conflicts python25 python27 description {Use python 2.6} {
    configure.python          ${prefix}/bin/python2.6
    depends_lib-append        port:py26-pygtk
    set python_framework      ${frameworks_dir}/Python.framework/Versions/2.6
    configure.pkg_config_path ${python_framework}/lib/pkgconfig
    configure.env              PATH=${python_framework}/bin:$env(PATH)
}

variant python27 conflicts python25 python26 description {Use python 2.7} {
    configure.python          ${prefix}/bin/python2.7
    depends_lib-append        port:py27-pygtk
    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)
}

if {![variant_isset python25] && ![variant_isset python26]} {
    default_variants +python27
}

post-patch {
    reinplace "s:libdbus-glib-1.so.2:${prefix}/lib/libdbus-glib-1.2.dylib:" ${worksrcpath}/browser-plugin/totemPluginGlue.cpp
}

post-destroot {
    eval delete [glob "${destroot}${prefix}/lib/nsplugins/*.la"]
}

post-activate {
    system "${prefix}/bin/update-desktop-database ${prefix}/share/applications"
    system "${prefix}/bin/gtk-update-icon-cache -f -t ${prefix}/share/icons/hicolor"
    system "export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source` && \
        gconftool-2 --makefile-install-rule ${prefix}/etc/gconf/schemas/*.schemas"
}

livecheck.type  gnome
