# -*- 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

PortSystem          1.0
PortGroup           meson 1.0

name                gedit-plugins
version             44.2
revision            1
license             GPL-2+
set branch          [lindex [split ${version} .] 0]
description         Plug-ins for GEdit
long_description    Various additional plug-ins for GEdit
maintainers         nomaintainer
categories          gnome editors
homepage            https://wiki.gnome.org/Apps/Gedit
master_sites        gnome:sources/${name}/${branch}/

use_xz              yes

# Disable unexpected download of subprojects
meson.wrap_mode     nodownload

checksums           rmd160  674349ae4e74199bc224c6f60ae81cd7e016074a \
                    sha256  8c59b8e9fac0525f24d3757689b69a34f85df27190ba6a758b038849919df755 \
                    size    915256

depends_build-append \
                    port:pkgconfig \
                    port:appstream-glib \
                    port:gettext \
                    port:itstool \
                    path:bin/vala:vala

depends_lib         port:gedit \
                    port:gettext-runtime \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    path:lib/pkgconfig/gobject-introspection-1.0.pc:gobject-introspection \
                    path:lib/pkgconfig/gtk+-3.0.pc:gtk3 \
                    port:gtksourceview4 \
                    port:libpeas1

patchfiles          patch-python3-bin.diff

post-patch {
    reinplace "s|@@PYTHON3_BIN@@|${configure.python}|" \
        ${worksrcpath}/meson.build
    reinplace "s|^#!.*|#!${configure.python}|" \
        ${worksrcpath}/build-aux/meson/post_install.py
}

# Enabled plugins:
#     bookmarks
#     bracketcompletion
#     codecomment
#     colorpicker
#     colorschemer
#     commander
#     drawspaces
#     findinfiles
#     joinlines
#     multiedit
#     sessionsaver
#     smartspaces
#     textsize
#     translate
#     wordcompletion
#
# disabled plugins, enabled via variant:
#     charmap
#     git
#     synctex
#     terminal

# require C11 compiler
compiler.c_standard   2011

configure.args      -Dplugin_charmap=false \
                    -Dplugin_git=false \
                    -Dplugin_synctex=false \
                    -Dplugin_terminal=false

variant charmap description {Insert special characters just by clicking on them} {
    depends_run-append  port:gucharmap

    configure.args-delete -Dplugin_charmap=false
}

variant git description {Highlight lines that have been changed since the last commit} {
    depends_run-append  port:libgit2-glib

    configure.args-delete -Dplugin_git=false
}

variant synctex description {Quickly switch from an opened TeX source file in gedit to a PDF document opened in evince and vice versa} {
    depends_run-append  port:evince

    configure.args-delete -Dplugin_synctex=false
}

variant terminal description {Embed a GNOME terminal in the bottom panel of the gedit window} {
    depends_run-append  port:vte

    configure.args-delete -Dplugin_terminal=false
}

variant python310 conflicts python313 description {Plugins use Python 3.10} {
    depends_lib-append  port:py310-gobject3 \
                        port:dbus-python310

    configure.python    ${prefix}/bin/python3.10
}

variant python313 conflicts python310 description {Plugins use Python 3.13} {
    depends_lib-append  port:py313-gobject3 \
                        port:dbus-python313

    configure.python    ${prefix}/bin/python3.13
}

if {![variant_isset python310] && \
    ![variant_isset python313]} {
    default_variants +python313
}

# libpeas expects plugin modules with .so extensions
# make .so symlink for each plugin module built as .dylib
post-destroot {
    set plugindir lib/gedit/plugins
    foreach pluginlib {libbookmarks libdrawspaces libfindinfiles libwordcompletion} {
        ln -s ${prefix}/${plugindir}/${pluginlib}.dylib ${destroot}${prefix}/${plugindir}/${pluginlib}.so
    }
}

post-activate {
    system "${prefix}/bin/glib-compile-schemas ${prefix}/share/glib-2.0/schemas"
}

livecheck.type      gnome
