#
# $Id: Jamfile 3305 2012-05-17 13:31:34Z karijes $
#
# Part of Equinox Desktop Environment (EDE).
# Copyright (c) 2000-2007 EDE Authors.
#
# This program is licensed under terms of the 
# GNU General Public License version 2 or newer.
# See COPYING for details.

SubDir TOP data icon-themes ;

# ConvertIconTheme [icon-theme-name] : [icon-sizes] : [icon-categories] ;
# Mass conversion of scalable (.svg) icon theme to .png one. Make sure directory
# that will be converted contains 'scalable' directory with .svg icons
rule ConvertIconTheme 
{
	local size category ;
	for size in $(2) {
		local sname = "$(size)x$(size)" ;
		for category in $(3) {
			SvgToPngDirectory [ FDirName $(1) $(sname) $(category) ] : [ FDirName $(1) scalable $(category) ] : $(size) ;
		}

		# let 'jam clean' removes created directories since SvgToPngDirectory will remove
		# only deepest, e.g. '16/actions' will be removed only 'actions'; here '16' will be removed too
		CleandirSafe clean : [ FDirName $(1) $(sname) ] ;
	}
}

# InstallIconTheme [icon-theme-name] : [icon-sizes] : [icon-categories] ;
# Installs icon theme
rule InstallIconTheme
{
	local size category icon_list directory ;

	for size in $(2) {
		local sname = "$(size)x$(size)" ;
		for category in $(3) {
			directory = [ FDirName $(1) $(sname) $(category) ] ;
			icon_list = [ Wildcard $(directory) : *.png : $(directory) ] ;
			InstallEdeIcons $(directory) : $(icon_list) ;
		}
	}

	# install index.theme
	InstallData [ FDirName $(EDE_ICON_DIR) $(1) ] : [ FFileName $(1) index.theme ] ;
}

ICON_SIZES = 16 22 32 48 64 128 ;
ICON_CATEGORIES = actions apps categories devices emblems mimetypes places status ;

# only convert them when jam -sBUILD_ICON_THEMES=1 is given
# this will reduce jam's startup time
if $(BUILD_ICON_THEMES) = 1 {
	ConvertIconTheme "edeneu" : $(ICON_SIZES) : $(ICON_CATEGORIES) ;
	InstallIconTheme "edeneu" : $(ICON_SIZES) : $(ICON_CATEGORIES) ;
}

if $(INSTALL_ICON_THEMES) = 1 {
	InstallIconTheme "edeneu" : $(ICON_SIZES) : $(ICON_CATEGORIES) ;
}

# install kbflags icons
KBFLAGS_ICONS_DIR = [ FDirName "kbflags" "21x14" ] ;
KBFLAGS_ICONS     = [ Wildcard $(KBFLAGS_ICONS_DIR) : *.png : $(KBFLAGS_ICONS_DIR) ] ;

InstallEdeIcons $(KBFLAGS_ICONS_DIR) : $(KBFLAGS_ICONS) ;
