#!/bin/sh
#Barry Kauler 2005 www.puppylinux.com
#2007 Lesser GPL licence v2 (http://www.fsf.org/licensing/licenses/lgpl.html)
#w019 apr2009: updated for woof.
#100215 fixes.
#110807 changed to gtkdialog3.
#111019 screen out Xdialog.
#120203 BK: internationalized.
#131228 zigbert: gui (gtkdialog) improvements.

export TEXTDOMAIN=xserverwizard
export OUTPUT_CHARSET=UTF-8

VIDEOINFO="`cat /proc/pci | grep "VGA" | cut -f 2-4 -d ':'`"
WHATXS="`ls -1 /usr/bin/X?* | grep -v 'Xdialog' | sed -e 's/\/usr\/bin\///g' | tr "\n" " "`"
CURRENTX="`readlink /usr/bin/X`"

XVESATXT=""
if [ -e /usr/bin/Xvesa ];then
 XVESATXT='
 <hbox border-width="2" space-expand="true" space-fill="true">
   <text xalign="0" use-markup="true" space-expand="true" space-fill="true"><label>"'$(gettext '<b>Xvesa Kdrive server</b>. This has been in most live-CDs, and works on the widest range of video hardware. The single biggest disadvantage is that the screen refresh frequency cannot be changed (which does not matter for LCD monitors, it is only a problem for CRT monitors where low frequency causes noticeable flicker).')'"</label></text>
   <vbox space-expand="false" space-fill="false">
     <button space-expand="false" space-fill="false">
       '"`/usr/lib/gtkdialog/xml_button-icon graphics_lowres.svg big`"'
       <action>video-wizard & </action>
       <action type="exit">exited xserver wizard</action>
     </button>
   </vbox>
 </hbox>'
fi

export XserverWizard='
<window title="'$(gettext 'Puppy X server chooser Wizard')'" icon-name="gtk-preferences">
<vbox space-expand="true" space-fill="true">
  '"`/usr/lib/gtkdialog/xml_info fixed "graphics.svg" 60 "$(gettext 'Installed graphical server(s):') <b>${WHATXS}</b>" "$(gettext 'Running graphical server is:') <b>${CURRENTX}</b>"`"' 
  <frame '$(gettext 'Graphical server Wizards')'>
    <vbox space-expand="false" space-fill="false">
      '${XVESATXT}'
      <hbox border-width="2" space-expand="true" space-fill="true">
        <text xalign="0" use-markup="true" space-expand="true" space-fill="true"><label>"'$(gettext '<b>Xorg X server</b>. This is the big fella, large, sophisticated, accelerated rendering, Xinerama, supports many input devices.')'"</label></text>
        <vbox space-expand="false" space-fill="false">
          <button space-expand="false" space-fill="false">
            '"`/usr/lib/gtkdialog/xml_button-icon graphics.svg big`"'
            <action>xorgwizard &</action>
            <action type="exit">exited xserver wizard</action>
          </button>
        </vbox>
      </hbox>
    </vbox>
  </frame>
</vbox>
</window>'

#If only xorg is installed, go straight to xorgwizard
if [ ! "${XVESATXT}" ]; then
	xorgwizard &
else
	. /usr/lib/gtkdialog/xml_info gtk #build bg_pixmap for gtk-theme
	gtkdialog -p XserverWizard
fi
###END###
