#!/bin/bash 
# -*- coding:Utf-8 -*- 
# L'encodage Utf-8 sera a joindre dans tous les fichiers, sinon bug d'accents...

# Copyright (C) 2007 Pâris Quentin

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 

if [ "$PLAYONLINUX" = "" ]
then
exit 0
fi
source "$PLAYONLINUX/lib/sources"

default()
{
	echo '[-HKEY_CURRENT_USER\Control Panel\Colors]
[-HKEY_CURRENT_USER\Control Panel\Desktop]
[HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics]' > $REPERTOIRE/tmp/theme.reg
	
}
cd $REPERTOIRE/wineprefix/
POL_SetupWindow_Init
POL_SetupWindow_free_presentation "Wine Look" "This plugin will permit you to change a theme for your wine applications"
POL_SetupWindow_games "Choose an application" "Wine Look"
prefixe=$(detect_wineprefix "$APP_ANSWER")

echo "Using $prefixe"

#reponse=$(menu "Choisissez un préfixe de wine" "$(ls -1)" "Choisissez un préfixe" 1 2 1 "" --cut-line)
#if [ "$reponse" = "" ]
#then
#	exit
#fi
#select_prefixe "$REPERTOIRE/wineprefix/$reponse"
select_prefixe "$prefixe"
cd "$REPERTOIRE/plugins/Wine Look/themes"
FICHIERS=""
for file in *
do
	if [ ! "$FICHIERS" = "" ]
	then
		FICHIERS+="~"
	fi
	FICHIERS+="$file"
done
FICHIERS+="~Default"
POL_SetupWindow_menu "Choose a theme to apply" "Wine Look" "$FICHIERS~Import colors from gnome theme" "~"
theme="$APP_ANSWER"

default
regedit $REPERTOIRE/tmp/theme.reg
if [ "$theme" = "Import colors from gnome theme" ]
then
	cd "$REPERTOIRE/plugins/Wine Look/scripts"
	python wine_colors_from_gnome.py
else
	if [ ! "$theme" = "Default" ]
	then
		regedit "$theme"
	fi
fi

POL_SetupWindow_message "Your theme has been applied" "Wine Look"
POL_SetupWindow_Close
