# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=geany-plugins
pkgver=2.0
pkgrel=1
pkgdesc="Plugins for Geany"
url="https://plugins.geany.org/"
arch="all"
license="GPL-3.0-or-later"
makedepends="
	bash
	enchant2-dev
	geany-dev
	gpgme-dev
	gtkspell-dev
	intltool
	libsoup-dev
	libxml2-dev
	lua-dev
	python3-dev
	vala
	vte3-dev
	"
subpackages="$pkgname-dev $pkgname-doc
	$pkgname-addons
	$pkgname-autoclose
	$pkgname-automark
	$pkgname-codenav
	$pkgname-commander
	$pkgname-defineformat
	$pkgname-geanyctags
	$pkgname-geanydoc
	$pkgname-geanyextrasel
	$pkgname-geanyinsertnum
	$pkgname-latex
	$pkgname-geanylua
	$pkgname-geanymacro
	$pkgname-geanyminiscript
	$pkgname-geanynumberedbookmarks
	$pkgname-geanypg
	$pkgname-geanyprj
	$pkgname-geanyvc
	$pkgname-geniuspaste
	$pkgname-lineoperations
	$pkgname-lipsum
	$pkgname-overview
	$pkgname-pairtaghighlighter
	$pkgname-pohelper
	$pkgname-pretty-printer:pretty_printer
	$pkgname-projectorganizer
	$pkgname-sendmail
	$pkgname-shiftcolumn
	$pkgname-spellcheck
	$pkgname-tableconvert
	$pkgname-treebrowser
	$pkgname-updatechecker
	$pkgname-vimode
	$pkgname-xmlsnippets
	$pkgname-keyrecord
	$pkgname-utils
	$pkgname-scope
	$pkgname-lang
	"
source="https://plugins.geany.org/geany-plugins/geany-plugins-$pkgver.tar.bz2
	gcc14.patch
	"

build() {
	./configure --prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		--with-lua-pkg=lua \
		--disable-debugger
	make
}

package() {
	make DESTDIR="$pkgdir" install
}

utils() {
	pkgdesc="Reusable shared library used by geany-plugins"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libgeanypluginutils.so* \
		"$subpkgdir"/usr/lib/
}

_plugin() {
	pkgdesc="$2"
	local _d
	mkdir -p "$subpkgdir"/usr/lib/geany
	mv "$pkgdir"/usr/lib/geany/$1.so "$subpkgdir"/usr/lib/geany/
	cd "$pkgdir"
	for _d in usr/*/geany-plugins/"$1"; do
		if [ -d "$_d" ]; then
			mkdir -p "$subpkgdir"/${_d%/*}
			mv "$pkgdir"/$_d "$subpkgdir"/$_d
			rmdir "$pkgdir"/${_d%/*} || true
		fi
	done
}

addons() { _plugin addons "Miscellaneous Addons for Geany"; }
autoclose() { _plugin autoclose "Auto-closing features for Geany"; }
automark() { _plugin automark "Highlights all words that match current word"; }
codenav() { _plugin codenav "Navigate through your source code easily"; }
commander() { _plugin commander "Control Geany using commands from a command panel"; }
defineformat() { _plugin defineformat "Plugin to write multiline defines with aligned backslash"; }
geanyctags() { _plugin geanyctags "Generate and query ctags files for a Geany project"; }
geanydoc() { _plugin geanydoc "Call documentation from within Geany"; }
geanyextrasel() { _plugin geanyextrasel "Additional features for selecting code"; }
geanyinsertnum() { _plugin geanyinsertnum "Insert huge number ranges with small efforts"; }
latex() { _plugin latex "LaTeX support for Geany"; }
geanylua() { _plugin geanylua "Lua Scripting for Geany"; }
geanymacro() { _plugin geanymacro "User defined Macros for Geany"; }
geanyminiscript() { _plugin geanyminiscript "Geany Mini-Script filter plugin"; }
geanynumberedbookmarks() { _plugin geanynumberedbookmarks "Provide users 10 numbered Bookmarks"; }
geanypg() { _plugin geanypg "A plugin for Geany that allows the user to encrypt, decrypt and verify signatures with GnuPG"; }
geanypy() { _plugin geanypy "Provides Python3 bindings for Geany";
	# Currently missing. Requires GTK+2.0
	mv "$pkgdir"/usr/lib/geany/geanypy \
		"$pkgdir"/usr/lib/geany/*.py \
		"$subpkgdir"/usr/lib/geany/
}
geanyprj() { _plugin geanyprj "Alternate project management tool for Geany"; }
geanyvc() { _plugin geanyvc "Version Control for Geany"; }
geniuspaste() { _plugin geniuspaste "A plugin to paste the code from Geany into different pastebins"; }
multiterm() {
	# Currently missing. Requires GTK2.0
	_plugin multiterm "Multiple terminals inside of Geany";
}
lineoperations() { _plugin lineoperations "Assortment of simple line functions that can be applied to an open file"; }
lipsum() { _plugin lipsum "Lorem Ipsum generator for Inserting Placeholder Text"; }
overview() { _plugin overview "Overview over the code in a sidebar"; }
pairtaghighlighter() { _plugin pairtaghighlighter "Finds and highlights matching HTML tag"; }
pohelper() { _plugin pohelper "A plugin for Geany that improves the support for GetText translation files"; }
pretty_printer() { _plugin pretty-printer "XML pretty printing plugin for Geany"; }
projectorganizer() { _plugin projectorganizer "Extension of Geany's project management"; }
sendmail() { _plugin sendmail "Send E-Mails from within Geany"; }
shiftcolumn() { _plugin shiftcolumn "Move Blocks of Text horizontally"; }
spellcheck() { _plugin spellcheck "Spellcheck text in Geany"; }
tableconvert() { _plugin tableconvert "Helps on converting a tabulator separated selection into a table"; }
treebrowser() { _plugin treebrowser "Alternate file browser plugin"; }
updatechecker() { _plugin updatechecker "A plugin to check whether there is a more recent version of Geany available"; }
vimode() { _plugin vimode "A Vim mode for Geany"; }
xmlsnippets() { _plugin xmlsnippets "Extends XML/HTML tag autocompletion provided by Geany"; }
keyrecord() { _plugin keyrecord "Record a sequence of keystrokes and replay it"; }
scope() { _plugin scope "Graphical GDB front-end"; }

sha512sums="
48d575459e5c9f905b8809796ea89a05f6e082a1bb1d29c9f44dd5de607a64ad65a27d18348312702d25cfbb80ea0348b9e806f8c0fe649ea558b5b4ccd84818  geany-plugins-2.0.tar.bz2
640bd2255eb02d0384b1c3e1078d534ff37fdf4efa403e7ceebd2c26c12f5e637715d9beda71f0df435b6190c571b02e576a7a1ed677734ffd121e1a744ef9d4  gcc14.patch
"
