Blame Scripts/Functions/Render/Backends/Svg/svg_convertPngToDm.sh

ae8a10
#!/bin/bash
ae8a10
#
40f83f
# svg_convertPngToDm.sh -- This function standardize production of
40f83f
# display managers (e.g., Gdm and Kdm). This function copies all files
40f83f
# needed into a temporal directory, realize expansion of translation
40f83f
# markers and packs all the files into a tar.gz package that is used
40f83f
# for installation. This function must be used as last-rendition
40f83f
# action for Gdm and Kdm directory specific base-rendition actions.
ae8a10
#
3b0984
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
fa95b1
#
fa95b1
# This program is free software; you can redistribute it and/or modify
fa95b1
# it under the terms of the GNU General Public License as published by
dcd347
# the Free Software Foundation; either version 2 of the License, or (at
dcd347
# your option) any later version.
fa95b1
#
74a058
# This program is distributed in the hope that it will be useful, but
74a058
# WITHOUT ANY WARRANTY; without even the implied warranty of
ae8a10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ae8a10
# General Public License for more details.
ae8a10
#
ae8a10
# You should have received a copy of the GNU General Public License
ae8a10
# along with this program; if not, write to the Free Software
dcd347
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
7ac5a5
#
ae8a10
# ----------------------------------------------------------------------
ae8a10
# $Id$
ae8a10
# ----------------------------------------------------------------------
ae8a10
40f83f
function svg_convertPngToDm {
ae8a10
8af4d8
    # Print separator line.
0ff158
    cli_printMessage '-' --as-separator-line
8af4d8
44b2ba
    # Initialize source and destination local variables.
44b2ba
    local SRC=''
44b2ba
    local DST=''
ae8a10
44b2ba
    # Initialize display manager type.
44b2ba
    local DM=$(render_getConfigOption "${ACTION}" '2')
ae8a10
40f83f
    # Initialize screen resolutions used by display manager theme.
40f83f
    # These are the different screen resolutions a display manager
40f83f
    # theme is built for. The amount of screen resolution a display
40f83f
    # manager theme can be built for is limited to the amount of
40f83f
    # background files provided by the artistic motif used to build
40f83f
    # the display manager theme.
44b2ba
    local RESOLUTION=''
44b2ba
    local RESOLUTIONS=$(render_getConfigOption "${ACTION}" '3')
ae8a10
44b2ba
    # Verify screen resolutions. We cannot produce display manager
44b2ba
    # theme if no screen resolution has been specified.
44b2ba
    if [[ "$RESOLUTIONS" == '' ]];then
44b2ba
        cli_printMessage "`gettext "There is no resolution information to process."`" --as-error-line
44b2ba
    fi
ae8a10
44b2ba
    # Initialize theme information we are going to build the display
44b2ba
    # manager theme for.
334459
    local THEME=$(cli_getPathComponent $ACTIONVAL --motif)
334459
    local THEME_NAME=$(cli_getPathComponent $ACTIONVAL --motif-name)
44b2ba
44b2ba
    # Initialize temporal directory where we collect all files needed
44b2ba
    # in order to create the tar.gz file. This intermediate step is
44b2ba
    # also needed in order to expand translation markers from XML and
44b2ba
    # Desktop definitions.
44b2ba
    local TMPDIR=$(cli_getTemporalFile 'dm')
44b2ba
44b2ba
    # Initialize source location for brands. This is the place where
40f83f
    # brand information, needed to build the display manager theme, is
44b2ba
    # retrived from.
44b2ba
    local BRANDS=$(cli_getRepoTLDir)/Identity/Images/Brands
44b2ba
40f83f
    # Initialize source location for artistic motif's backgrounds.
40f83f
    # This is the place where background information needed to ubild
40f83f
    # the display manager theme is retrived from. 
44b2ba
    local BGS=$(cli_getRepoTLDir)/Identity/Images/Themes/${THEME}/Backgrounds/Img/Png
44b2ba
44b2ba
    # Initialize file variables. File variables are used build and
44b2ba
    # process the file relation between source and target locations. 
44b2ba
    local FILE=''
44b2ba
    local FILES=''
44b2ba
44b2ba
    # Define file relation between source and target locations, based
40f83f
    # on whether we are producing GDM or KDM. Use the colon character
40f83f
    # (`:') as separator; on the left side we put the file's source
40f83f
    # location and in the right side the file's target location.
40f83f
    # Presently, both GDM and KDM are very similar on files with the
40f83f
    # exception that GDM does use icons near actions buttons (e.g.,
40f83f
    # shutdown, reboot, session, language) and KDM doesn't.
44b2ba
    case ${DM} in
44b2ba
44b2ba
        Gdm )
44b2ba
            FILES="\
40f83f
            ${BRANDS}/Symbols/centos-48.png:centos-symbol.png
44b2ba
            ${OUTPUT}/release.png:centos-release.png
44b2ba
            ${OUTPUT}/screenshot.png:screenshot.png
44b2ba
            $(dirname $TEMPLATE)/GdmGreeterTheme.xml:${THEME_NAME}.xml
44b2ba
            $(dirname $TEMPLATE)/GdmGreeterTheme.desktop:GdmGreeterTheme.desktop
44b2ba
            $(dirname $TEMPLATE)/icon-language.png:icon-language.png
44b2ba
            $(dirname $TEMPLATE)/icon-reboot.png:icon-reboot.png
44b2ba
            $(dirname $TEMPLATE)/icon-session.png:icon-session.png
44b2ba
            $(dirname $TEMPLATE)/icon-shutdown.png:icon-shutdown.png
44b2ba
            "
44b2ba
            ;;
44b2ba
            
44b2ba
        Kdm )
44b2ba
            FILES="\
f2b5b4
            ${BRANDS}/Symbols/centos-48.png:centos-symbol.png
44b2ba
            ${OUTPUT}/release.png:centos-release.png
44b2ba
            ${OUTPUT}/screenshot.png:screenshot.png
44b2ba
            $(dirname $TEMPLATE)/GdmGreeterTheme.xml:${THEME_NAME}.xml
44b2ba
            $(dirname $TEMPLATE)/GdmGreeterTheme.desktop:GdmGreeterTheme.desktop
44b2ba
            "
44b2ba
            ;;
44b2ba
44b2ba
        * )
44b2ba
            cli_printMessage "`eval_gettext "The \\\"\\\$DM\\\" display manager is not supported yet."`" --as-error-line
44b2ba
            ;;
44b2ba
    esac
44b2ba
44b2ba
    for FILE in $FILES;do
44b2ba
44b2ba
        # Define source location.
44b2ba
        SRC=$(echo $FILE | cut -d: -f1)
44b2ba
44b2ba
        # Define target location.
44b2ba
        DST=${TMPDIR}/${THEME_NAME}/$(echo $FILE | cut -d: -f2)
44b2ba
44b2ba
        # Verify source files.
44b2ba
        cli_checkFiles $SRC
44b2ba
44b2ba
        # Verify parent directory for target file.
44b2ba
        if [[ ! -d $(dirname $DST) ]];then
44b2ba
            mkdir -p $(dirname $DST)
44b2ba
        fi
eb0e14
44b2ba
        # Copy files from source to target location.
44b2ba
        cp ${SRC} ${DST}
ae8a10
44b2ba
        # Expand translation markers.
44b2ba
        if [[ ${DST} =~ "\.(xml|desktop)$"  ]];then
44b2ba
            cli_replaceTMarkers "${DST}"
44b2ba
        fi
ae8a10
44b2ba
    done
ae8a10
44b2ba
    # Move into temporal directory.
44b2ba
    pushd $TMPDIR > /dev/null
ae8a10
44b2ba
    for RESOLUTION in $RESOLUTIONS;do
ae8a10
44b2ba
        # Verify background information. If it doesn't exist go on
44b2ba
        # with the next one in the list.
44b2ba
        if [[ ! -f $BGS/${RESOLUTION}-final.png ]];then
44b2ba
            continue
44b2ba
        fi
ae8a10
643925
        # Print action message.
44b2ba
        if [[ -f ${RESOLUTION}.tar.gz ]];then
0ff158
            cli_printMessage "${OUTPUT}/${RESOLUTION}.tar.gz" --as-updating-line
0ff158
        else
0ff158
            cli_printMessage "${OUTPUT}/${RESOLUTION}.tar.gz" --as-creating-line
0ff158
        fi
ae8a10
44b2ba
        # Copy background information.
44b2ba
        cp $BGS/${RESOLUTION}-final.png ${THEME_NAME}/background.png
ae8a10
44b2ba
        # Create tar.gz file.
44b2ba
        tar -czf ${RESOLUTION}.tar.gz ${THEME_NAME}
ae8a10
44b2ba
        # Move from temporal directory to its final location.
44b2ba
        mv ${RESOLUTION}.tar.gz ${OUTPUT}
ae8a10
44b2ba
    done
ec641d
d856c1
    # Return to where we were initially.
d856c1
    popd > /dev/null
d856c1
44b2ba
    # Remove temporal directory.
44b2ba
    rm -r ${TMPDIR}
44b2ba
ae8a10
}