#!/bin/sh
#2007 Lesser GPL licence v2 (http://www.fsf.org/licensing/licenses/lgpl.html)
#gtk theme selector

#/etc/gtk/ has gtkrc, which has the current theme.
#this folder has other themes, the files are named
#gtkrc.something.

CURRENTTHEME="`cat /etc/gtk/current-theme`"

STATUSORIGINAL="off"
STATUSBASIC="off"
STATUSNOTIF2="off"
STATUSQUIET="off"
STATUSFOREST="off"
STATUSPEACH="off"
STATUSWEARY="off"
STATUSGREY="off"
STATUSREDBLUE="off"
STATUSCUSTARD="off"
STATUSXP="off"
STATUSBLUEX="off"
STATUSSTARDUST="off"

if [ "$CURRENTTHEME" = "original" ];then
 STATUSORIGINAL="on"
fi
if [ "$CURRENTTHEME" = "basic" ];then
 STATUSBASIC="on"
fi
if [ "$CURRENTTHEME" = "notif2" ];then
 STATUSNOTIF2="on"
fi
if [ "$CURRENTTHEME" = "quiet" ];then
 STATUSQUIET="on"
fi
if [ "$CURRENTTHEME" = "forest" ];then
 STATUSFOREST="on"
fi
if [ "$CURRENTTHEME" = "peach" ];then
 STATUSPEACH="on"
fi
if [ "$CURRENTTHEME" = "weary" ];then
 STATUSWEARY="on"
fi
if [ "$CURRENTTHEME" = "grey" ];then
 STATUSGREY="on"
fi
if [ "$CURRENTTHEME" = "redblue" ];then
 STATUSREDBLUE="on"
fi
if [ "$CURRENTTHEME" = "custard" ];then
 STATUSCUSTARD="on"
fi
if [ "$CURRENTTHEME" = "xp" ];then
 STATUSXP="on"
fi
if [ "$CURRENTTHEME" = "blueX" ];then
 STATUSBLUEX="on"
fi
[ "$CURRENTTHEME" = "stardust" ] && STATUSSTARDUST="on"

RESULTOK="`Xdialog --wmclass "gtktheme" --title "GTK theme selector" --no-tags --stdout \
 --icon /usr/share/images/themesthumbs.xpm  \
 --radiolist "" 39 34 10 \
 "original" "Default（デフォルト）" $STATUSORIGINAL \
 "basic"   "Basic（ベーシック）"   $STATUSBASIC   \
 "notif2"  "Notif 2（Motif風）" $STATUSNOTIF2  \
 "quiet"   "Quiet（ライトグレー）"   $STATUSQUIET   \
 "grey"    "Gray（ダークグレー）" $STATUSGREY  \
 "peach"   "Peach（パステルピーチ）"   $STATUSPEACH   \
 "weary"   "Weary（ダークブルー）"  $STATUSWEARY  \
 "redblue" "RedBlue（赤と青）" $STATUSREDBLUE  \
 "xp"   "XP（WindowsXP風）" $STATUSXP  \
 "custard" "Custard（ライトグリーン）" $STATUSCUSTARD  \
 "forest"  "Forest（フォレストグリーン）" $STATUSFOREST \
 "blueX"   "blueX（ブルー）" $STATUSBLUEX \
 "stardust" "Stardust（グレーブルー3D）" $STATUSSTARDUST 2> /dev/null `"

STATUSRET=$?

if [ ! $STATUSRET -eq 0 ];then
 exit
fi

#v2.15 some themes (stardust) are for gtk2 only...
if [ -f /etc/gtk-2.0/gtkrc.$RESULTOK ];then
 cp -f /etc/gtk-2.0/gtkrc.$RESULTOK /etc/gtk-2.0/gtkrc
 cp -f /etc/gtk/gtkrc.original /etc/gtk/gtkrc
else
 cp /etc/gtk/gtkrc.$RESULTOK /etc/gtk/gtkrc
 cat /etc/gtk/gtkrc.$RESULTOK | sed -e 's/# font_name/  font_name/g' > /etc/gtk-2.0/gtkrc
fi

echo -n $RESULTOK > /etc/gtk/current-theme
sync
####END####
