#!/bin/bash
#
# File: deepin-sailsh
# Version: 1.11.01-1
# Description: Howto install development environment tools on ubuntu with zenity and shell.
#
# Created Date: January 25th, 2011
# Last Motified: January 29th, 2011
#
# Author: mutse <yyhoo2.young@gmail.com>
# History:
#         Author       Date      Version
#         mutse      01/29/2011   1.11.01-1
#
# (C) 2010-2011 Linux Deepin & Chin Foundry. All Rights Reserved.
#
CXX="C++ programming language"
GTK="Gtk+ programming language with GUI"
GTKMM="Gtkmm programming language with GUI"
WXWIDGET="wxWidget programming language with GUI"
MOTIF="Motif programming language with GUI"
OPENGL="OpenGL programming language with GUI"
GNOME="Gnome programming language with GUI"
JAVA="Java programming language"
OBJC="Objective-C programming language"

# install c++ development
function cpp_install
{
OPTION=`zenity --entry --text="Are you sure to install C++?[y/n]" --title "development tool"`
  case $OPTION in
    y) gksudo "apt-get -y install g++ build-essential";;
    n) echo;;
    *) zenity --error --text="error option!";;
  esac
}

# install gtk+ development
function gtk_install
{
OPTION=`zenity --entry --text="Are you sure to install gtk+?[y/n]" --title "development tool"`
  case $OPTION in
    y) gksudo "apt-get -y install libgtk2.0-dev";;
    n) echo;;
    *) zenity --error --text="error option!";;
  esac
}

# install gtkmm development
function gtkmm_install
{
OPTION=`zenity --entry --text="Are you sure to install gtkmm?[y/n]" --title "development tool"`
  case $OPTION in
    y) gksudo "apt-get -y install g++ build-essential libgtkmm-2.4-dev";;
    n) echo;;
    *) zenity --error --text="error option!";;
  esac
}

# install wxWidget development
function wxWidget_install
{
OPTION=`zenity --entry --text="Are you sure to install wxWidget?[y/n]" --title "development tool"`
  case $OPTION in
    y) gksudo "apt-get -y install g++ build-essential libwxgtk2.8-dev";;
    n) echo;;
    *) zenity --error --text="error option!";;
  esac
}

# install motif development
function motif_install
{
OPTION=`zenity --entry --text="Are you sure to install motif?[y/n]" --title "development tool"`
  case $OPTION in
    y) gksudo "apt-get -y install libmotif-dev libmotif3 motif-clients x11proto-print-dev libxt-dev";;
    n) echo;;
    *) zenity --error --text="error option!";;
  esac
}

# install openGL development
function opengl_install
{
OPTION=`zenity --entry --text="Are you sure to install openGL?[y/n]" --title "development tool"`
  case $OPTION in
    y) gksudo "apt-get -y install libgl1-mesa-dev libglu1-mesa-dev libglut3-dev";;
    n) echo;;
    *) zenity --error --text="error option!";;
  esac
}

# install gnome development
function gnome_install
{
OPTION=`zenity --entry --text="Are you sure to install gnome?[y/n]" --title "development tool"`
  case $OPTION in
    y) gksudo "apt-get -y install gnome-common gnome-devel gnome-core-devel";;
    n) echo;;
    *) zenity --error --text="error option!";;
  esac
}

# install java development
function java_install
{
   gksudo "add-apt-repository ppa:sun-java-community-team/sun-java6"
   gksudo "apt-get update"
   
OPTION=`zenity --entry --text="Are you sure to install Java?[y/n]" --title "development tool"`
  case $OPTION in
    y) gksudo "apt-get -y install sun-java6-jre sun-java6-jdk";;
    n) echo;;
    *) zenity --error --text="error option!";;
  esac
}

# install objc development
function objc_install
{
OPTION=`zenity --entry --text="Are you sure to install Objective-C?[y/n]" --title "development tool"`
  case $OPTION in
    y) gksudo "apt-get -y install build-essential gnustep gobjc gnustep-make libgnustep-base-dev gnustep-devel";;
    n) echo;;
    *) zenity --error --text="error option!";;
  esac

cd
echo "#set GNUstep" >> .bashrc
echo "GNUSTEP_ROOT=/usr/share/GNUstep" >> .bashrc
echo "export GNUSTEP_ROOT" >> .bashrc
echo "source /usr/share/GNUstep/Makefiles/GNUstep.sh" >> .bashrc
source ~/.bashrc
}

# main process
while [ 0 ]
  do
export SELECTION=`zenity --list --radiolist \
  --title="Deepin-Sailfish" \
  --width=300 \
  --height=320 \
  --column="" --column="Language Description" \
  True "$CXX" \
  False "$GTK" \
  False "$GTKMM" \
  False "$WXWIDGET" \
  False "$MOTIF" \
  False "$OPENGL" \
  False "$GNOME" \
  False "$JAVA" \
  False "$OBJC"`

if [ -z "$SELECTION" ]
  then
    exit 0
fi

if [ "$SELECTION" = "$CXX" ]
  then
    cpp_install
elif [ "$SELECTION" = "$GTK" ]
  then
    gtk_install
elif [ "$SELECTION" = "$GTKMM" ]
  then
    gtkmm_install
elif [ "$SELECTION" = "$WXWIDGET" ]
  then
    wxWidget_install
elif [ "$SELECTION" = "$MOTIF" ]
  then
    motif_install
elif [ "$SELECTION" = "$OPENGL" ]
  then
    opengl_install
elif [ "$SELECTION" = "$GNOME" ]
  then
    gnome_install
elif [ "$SELECTION" = "$JAVA" ]
  then
    java_install
elif [ "$SELECTION" = "$OBJC" ]
  then
    objc_install
fi
done
