#!/bin/sh

THISDIR=/media/mmcblk0p1/Programs/_mackxpatch
INSTALLERDIR=/media/mmcblk0p1/Programs/Install
ZENITY=/media/mmcblk0p1/Programs/_base/bin/zenity
MTAG=/media/mmcblk0p1/Programs/_mackxpatch/bin/mtag

cd $THISDIR

$ZENITY --question --title "MackxPatch View" --text "<b>Add View</b>\n\nDo you want to add the MustRead View?"
if [ $? -eq 0 ]; then

    # Adapt gconf to enable the new views
    export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`

    # AnyView View
    /bin/cp -f ./schemas/mustread.schemas /etc/gconf/schemas/mustread.schemas
    gconftool-2 --makefile-install-rule /etc/gconf/schemas/mustread.schemas
    # copy the icons
    /bin/cp -f ./icons/icon-mustread-medium.png /usr/share/ctb/icon-mustread-medium.png
    /bin/cp -f ./icons/icon-mustread-small.png /usr/share/ctb/icon-mustread-small.png
    /bin/chmod a-x /usr/share/ctb/icon-mustread-*

    # Enable the appropriate views
    gconftool-2 --type string --set /apps/er/patch/ctb/views/mustread/mode "enabled"
    gconftool-2 --type string --set /apps/er/patch/ctb/views/mustread/flags "autoremove"

    # Create Backup of dr.ini
    /bin/cp -f /media/mmcblk0p1/System/dr.ini /media/mmcblk0p1/System/dr.patch.ini
    # and save the (just modified) settings to disk
    /usr/bin/erconftool -e /apps/er

    # For the new version to be used, a reset is needed
    $ZENITY --info --title "MackxPatch View" --text "<b>View Installed</b>\n\nPress ok to reboot"
    /sbin/reboot
    sleep 31
fi
