#!/bin/bash

# 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

create_shortcut()
{
	POL_SetupWindow_question "Would you like to add a shortcut ?" "Wine Import"
	if [ "$APP_ANSWER" = "TRUE" ]
	then
		cd $REPERTOIRE/wineprefix/wine/drive_c/
		POL_SetupWindow_browse "Choose a program to add in PlayOnLinux" "Wine Import"
		EXEC="$APP_ANSWER"
		ProgName=$(basename "$EXEC")

		POL_SetupWindow_textbox "Choose the name of your new shortcut" "Wine Import"
		LAUNCHER="$APP_ANSWER"
		if [ ! "$LAUNCHER" = "" ]
		then
			echo "$ProgName"
			POL_SetupWindow_auto_shortcut "wine" "$ProgName" "wine.png" "$LAUNCHER" 
		fi
		create_shortcut
	fi
}

source "$PLAYONLINUX/lib/sources"

POL_SetupWindow_Init "$REPERTOIRE/plugins/Wine Import/setup/top.jpg" "$REPERTOIRE/plugins/Wine Import/setup/left.jpg"
POL_SetupWindow_free_presentation "Wine Import" "This plugin will help you to import your windows programs in PlayOnLinux\n\nBe carefull, PlayOnLinux tools will be able to modify the default wine prefix"
cp "$REPERTOIRE/plugins/Wine Import/wine.png" "$REPERTOIRE/icones"
cd ~/.PlayOnLinux/wineprefix/
ln -s ~/.wine
mv ./.wine ./wine

select_prefix "wine"
POL_SetupWindow_message "Wine prefix ~/.wine linked" "Wine Import"
create_shortcut
POL_SetupWindow_Close
