### this file is sourced not run
PKGBUILD=1
PKGARCH=noarch

# source: james
# release tarball
PKGVER=1.0
TARBALL=puppy_icon_theme-$PKGVER.tar.gz
MD5SUM=2b5e5f70919de4ae5c1739013d33e184
SRC_URL=https://github.com/puppylinux-woof-CE/puppy_icon_theme/archive/v1.tar.gz
BUNDLE=

# git-master tarball
#PKGVER=
#MD5SUM=
#hash=5b2a4a54759a8081e815453fc5f407ad129d9f43
#hash7=${hash#???????}; hash7=${hash%$hash7}
#TARBALL=puppy_icon_theme-$PKGVER-$hash7.tar.gz
#SRC_URL=https://github.com/puppylinux-woof-CE/puppy_icon_theme/archive/$hash.tar.gz

SLACKREQ=''
SLACKDESC="puppy-icon-theme: puppy-icon-theme $PKGVER (Puppy Standard icon theme)
puppy-icon-theme: 
puppy-icon-theme: The Puppy icon theme contains almost-complete Freedesktop standard 
puppy-icon-theme: scalable icons which is the standard icon for Puppy Linux.
puppy-icon-theme: Icons credits to to zigbert, technosaurus and 01micko.
puppy-icon-theme: 
puppy-icon-theme: This package contains modification to support Fatdog themeing too.
puppy-icon-theme: 
puppy-icon-theme: https://github.com/puppylinux-woof-CE/puppy_icon_theme
puppy-icon-theme: 
puppy-icon-theme: 
"

### default pkg_download
### prepare
pkg_prepare() {
	pkg_prepare_default &&
	cd tmp/puppy_icon_theme* &&
	patch -Np1 -i ../pkg/inode-directory.patch &&
	true
}

### default pkg_package
### build
pkg_build() {
	export THEME=Puppy-Standard
	
	cd /tmp/puppy_icon_theme*
	sed -i -e "s/NAME=.*/NAME=$THEME/" build.conf &&
	sed -i -e 's/^tar/#tar/' build_theme && # don't package
	make && 
	make install &&
	
	# Create Fatdog icon theme symlinks
	THEMEDIR=/usr/share/pixmaps/themes/${THEME}
	ICONDIR=/usr/share/icons/$THEME/scalable
	FALLBACK=/usr/share/pixmaps/themes/puppy48
	SRCDIR=/tmp/puppy_icon_theme*/icons
	install -d m644 $THEMEDIR &&
	cd $THEMEDIR &&
	for p in \
		abc48.png:apps/document.svg \
		archive48.png:mimetypes/application-x-compressed-tar.svg \
		audio48.png:mimetypes/audio.svg \
		bigred48.png:actions/dialog-no.svg \
		bluetooth48.png:devices/bluetooth.svg \
		camera48.png:devices/photocamera.svg \
		card48.png:devices/sdcard.svg \
		chat48.png:apps/chat.svg \
		clipboard48.png:actions/paste.svg \
		clock48.png:clock.svg \
		configuration48.png:categories/preferences.svg \
		connect48.png:actions/refresh.svg \
		console48.png:apps/terminal.svg \
		contact48.png:apps/book_address.svg \
		controlpanel48.png:devices/graphics.svg \
		date48.png:apps/calendar.svg \
		dog48.png:puppy.svg \
		draw48.png:mimetypes/x-office-drawing.svg \
		drive48.png:devices/harddisk.svg \
		drivemounter.png: \
		edit48.png:apps/edit.svg \
		email48.png:apps/mail.svg \
		error.xpm:status/security-low.svg \
		file-manager48.png:apps/file-manager.svg \
		floppy48.png:devices/floppy.svg \
		folder48.png:places/directory.svg \
		games48.png:categories/game_card.svg \
		go48.png:pmusic.svg \
		gparted.png:partition.svg \
		gparted48.png:partition.svg \
		hammer48.png: \
		help48.png:apps/help.svg \
		help48-fatdog.svg:categories/system-help.svg \
		help48-puppy.svg:categories/system-help.svg \
		home48.png:actions/home.svg \
		invisible96x8.png: \
		keyboard48.png:devices/keyboard.svg \
		keyboard+mouse48.png:mouse_keyboard.svg \
		lamp48.png:status/bulb.svg \
		language48.png:country_keyboard.svg \
		lock-screen48.png:actions/screen_lock.svg \
		login48.png:actions/quit.svg \
		module24.xpm:module.svg \
		mouse48.png:devices/mouse.svg \
		multimedia48.png:categories/multimedia.svg \
		network48.png:places/network2.svg \
		ok.xpm:status/security-high.svg \
		optical48.png:devices/dvdrom.svg \
		package48.png:mimetypes/package.svg \
		paint48.png:apps/paint.svg \
		pc2pc48.png:status/network.svg \
		pc48.png:devices/computer.svg \
		penguin48.png: \
		pet48.png:mimetypes/application-pet.svg \
		pet48x.png:mimetypes/application-pet.svg \
		present48.png:presentation.svg \
		printer48.png:devices/print.svg \
		pupnews48.png:puppy_theme.svg \
		puppy-bone48.gif: \
		question.xpm:status/dialog-question.svg \
		save48.png: \
		scanner48.png:devices/scanner.svg \
		shutdown48.png:actions/shutdown.svg \
		speedometer48.png:urgent.svg \
		spread48.png:apps/spreadsheet.svg \
		squashfs-image48.png:mimetypes/application-x-squashfs-image.svg \
		system48.png:categories/application-x-executable.svg \
		system-monitor48.png:apps/system-monitor.svg \
		touchpad48.png:touchpad.svg \
		trashcan_empty48.png:places/trash_empty.svg \
		trashcan_full48.png:status/trash_full.svg \
		tsclient48.png:internet_connect.svg \
		update48.png:apps/software-update.svg \
		usb48.png: \
		usbdrv48.png:devices/disk_usb.svg \
		users48.png:apps/user.svg \
		utility48.png: \
		webedit48.png:apps/edit_html.svg \
		wifi48.png:wireless.svg \
		word48.png:apps/edit.svg \
		www48.png:apps/internet.svg \
		x48.png:apps/x.svg \
		x.png:actions/dialog-no.svg 
	do
		tgt=${p%:*}
		src=${p#*:}
		if [ $src ]; then
			if [ -e $ICONDIR/$src ]; then
				ln -s $ICONDIR/$src $tgt
			else
				cp $SRCDIR/$src $tgt  # not installed, copy over
			fi
		else
			ln -s $FALLBACK/$tgt $tgt # fallback
		fi
	done &&

	# Link missing ROX icon themes
	FALLBACK=/usr/local/apps/ROX-Filer-jun7/ROX/MIME
	ICONDIR=/usr/share/icons/$THEME
	cd $ICONDIR
	for p in \
		application-font-woff:application-x-font.svg \
		application-notecase-enc: \
		application-ogg:audio.svg \
		application-pgp-encrypted:file_lock.svg \
		application-pgp:file_lock.svg \
		application-pgp-signature:file_lock.svg \
		application-pup:application-pet.svg \
		application-sql:text.svg \
		application-vnd.appimage: \
		application-vnd.oasis.opendocument.chart:x-office-drawing.svg \
		application-vnd.oasis.opendocument.image:x-office-drawing.svg \
		application-vnd.oasis.opendocument.presentation:application-vnd.ms-powerpoint.svg \
		application-vnd.oasis.opendocument.presentation-template:application-vnd.ms-powerpoint.svg \
		application-vnd.oasis.opendocument.spreadsheet-template:spread-sheet.svg \
		application-vnd.rar:application-x-compressed.svg \
		application-vnd.rn-realmedia:audio.svg \
		application-vnd.stardivision.writer:application-vnd.ms-office.svg \
		application-vnd.sun.xml.calc:spread-sheet.svg \
		application-vnd.sun.xml.calc.template:spread-sheet.svg \
		application-vnd.sun.xml.draw:x-office-drawing.svg \
		application-vnd.sun.xml.draw.template:x-office-drawing.svg \
		application-vnd.sun.xml.impress:application-vnd.ms-powerpoint.svg \
		application-vnd.sun.xml.impress.template2:application-vnd.ms-powerpoint.svg \
		application-vnd.sun.xml.impress.template:application-vnd.ms-powerpoint.svg \
		application-vnd.sun.xml.writer.global:application-vnd.ms-office.svg \
		application-vnd.sun.xml.writer:application-vnd.ms-office.svg \
		application-vnd.sun.xml.writer.template:application-vnd.ms-office.svg \
		application-x-awk:text-plain.svg \
		application-x-btrfs-image:application-x-raw-disk-image.svg \
		application-x-bzpdf:pdf.svg \
		application-x-core: \
		application-x-dvi:image.svg \
		application-x-font-linux-psf:application-x-font.svg \
		application-x-font-otf:application-x-font.svg \
		application-x-gzpdf:pdf.svg \
		application-xhtml+xml:application-x-xhtml+xml.svg \
		application-x-initrd-compressed:application-initramfs-gz.svg \
		application-x-initrd:application-initramfs-gz.svg \
		application-x-iso9660-appimage: \
		application-x-lz4-compressed-tar:application-x-compressed-tar.svg \
		application-x-lz4:application-x-compressed.svg \
		application-x-lzma-compressed-tar:application-x-compressed-tar.svg \
		application-x-lzma:application-x-compressed.svg \
		application-x-sfe:file_lock.svg \
		application-x-texmacs:text-plain.svg \
		application-x-troff-man-compressed:text-plain.svg \
		application-x-troff-man:text-plain.svg \
		application-x-troff:text-plain.svg \
		application-x-xzpdf:pdf.svg \
		application-zstd:application-x-compressed.svg \
		audio-volume-high: \
		audio-volume-low: \
		audio-volume-medium: \
		audio-volume-muted: \
		audio-x-pn-realaudio:audio.svg \
		font-collection:application-x-font.svg \
		font-otf:application-x-font.svg \
		font-ttf:application-x-font.svg \
		font-woff:application-x-font.svg \
		image-vnd.djvu:image.svg \
		initrd:application-initramfs-gz.svg \
		inode-core: \
		inode-mount-point: \
		message-x-generic: \
		model-x.stl-binary:application-x-generic.svg \
		text-csv:text-plain.svg \
		text-x-readme:text-plain.svg \
		text-x-tcl:text-plain.svg
	do
		tgt=${p%:*}
		src=${p#*:}
		for pp in 16 22 24 32 48 64 scalable
		do
			if [ $src ]; then
				if [ -e $ICONDIR/$pp/mimetypes/$src ]; then
					ln -s $src $pp/mimetypes/$tgt.svg
				else
					cp $SRCDIR/$src $pp/$tgt.svg  # not installed, copy over
				fi
			else
				ln -s $FALLBACK/$tgt.png $pp/mimetypes/$tgt.png # fallback
			fi		
		done
	done &&

	# special fallback (already uses svg)
	for tgt in application-x-xoj.svg text-x-gtkmenuplus-source.svg
	do
		for pp in 16 22 24 32 48 64 scalable
		do
			ln -s $FALLBACK/$tgt $pp/mimetypes/$tgt # fallback
		done
	done &&

	pkg_build_slackdesc
}
 
