#!/bin/sh
#called from 3builddistro

BI_ITEMS=""
for ONEITEM in `ls -1 rootfs-complete/usr/share/backgrounds | tr '\n' ' '`
do
 BI_ITEMS="${BI_ITEMS}<item>${ONEITEM}</item>"
done

GT_ITEMS=""
for ONEITEM in `ls -1 rootfs-complete/usr/share/themes/*/gtk-2.0 | grep '^rootfs-complete/usr/share/themes' | cut -f 5 -d '/'`
do
 GT_ITEMS="${GT_ITEMS}<item>${ONEITEM}</item>"
done

DI_ITEMS=""
for ONEITEM in `find rootfs-complete/usr/local/lib/X11/themes -maxdepth 1 -mindepth 1 -type d | rev | cut -f 1 -d '/' | rev`
do
 DI_ITEMS="${DI_ITEMS}<item>${ONEITEM}</item>"
done

JT_ITEMS=""
for ONEITEM in `ls -1 rootfs-complete/root/.jwm/themes/*-jwmrc | rev | cut -f 1 -d '/' | cut -f 2-9 -d '-' | rev`
do
 JT_ITEMS="${JT_ITEMS}<item>${ONEITEM}</item>"
done

OB_ITEMS=""
for ONEITEM in `ls -1 rootfs-complete/usr/share/themes | tr '\n' ' '`
do
 [ ! -e rootfs-complete/usr/share/themes/${ONEITEM}/openbox-3 ] && continue
 OB_ITEMS="${OB_ITEMS}<item>${ONEITEM}</item>"
done

export MAIN_DIALOG="
<vbox>
  <text><label>Choose the default themes...</label></text>
  <hbox>
    <text><label>Background image (ref: usr/share/backgrounds):</label></text>
    <combobox>
      <variable>BACKGROUNDIMAGE</variable>
	  ${BI_ITEMS}
    </combobox>
  </hbox>
  <hbox>
    <text><label>GTK theme (ref: usr/share/themes/*/gtk-2.0):</label></text>
    <combobox>
      <variable>GTKTHEME</variable>
	  ${GT_ITEMS}
    </combobox>
  </hbox>
  <hbox>
    <text><label>Desk icons (ref: usr/local/lib/X11/themes):</label></text>
    <combobox>
      <variable>DESKICONS</variable>
	  ${DI_ITEMS}
    </combobox>
  </hbox>
  <hbox>
    <text><label>JWM theme (ref: root/.jwm/themes):</label></text>
    <combobox>
      <variable>JWMTHEME</variable>
	  ${JT_ITEMS}
    </combobox>
  </hbox>
  <hbox>
    <text><label>Openbox theme (ref: usr/share/themes/*/openbox-3):</label></text>
    <combobox>
      <variable>OBTHEME</variable>
	  ${OB_ITEMS}
    </combobox>
  </hbox>
  <hbox>
   <button ok></button>
  </hbox>
 </vbox>
"

gtkdialog3 --center --program=MAIN_DIALOG


