#!/bin/bash
# timewizard
# called by wizardwizard

export TEXTDOMAIN=timewizard
export OUTPUT_CHARSET=UTF-8

export ICONDIR=/usr/share/pixmaps/puppy

# set icon-name
[ ! -f /usr/share/icons/hicolor/48x48/apps/connect.svg ] && \
ln -sf $ICONDIR/connect.svg /usr/share/icons/hicolor/48x48/apps && gtk-update-icon-cache -f -i /usr/share/icons/hicolor 2>/dev/null

# define button commands
[ -f /usr/sbin/sfwbar-clockset ] && clock_cmd=sfwbar-clockset || clock_cmd=PupClockset
[ -f /usr/local/jwmdesk/psync ] && psync_cmd=/usr/local/jwmdesk/psync || psync_cmd=psync

# define header text
MSG_1="<b><span size='"'x-large'"'>$(gettext "Time Wizard")</span></b>"
MSG_2="<b>$(gettext "Date and time configuration")</b>"

# main dialog
export TimeWizard='
<window title="'$(gettext "Time Wizard")'" icon-name="connect" window-position="1" resizable="false">
 <vbox space-expand="true" space-fill="true">
  <vbox margin="2">
  '"`/usr/lib/gtkdialog/xml_info fixed clock_digital.svg 60 "$MSG_1" "$MSG_2"`"'
  </vbox>
  <vbox margin="2" spacing="10" space-expand="true" space-fill="true">

    <hbox spacing="10" homogeneous="true" space-expand="true" space-fill="true">
      <button image-position="2" tooltip-text=" '$(gettext 'Set date and time')' ">
        <label>'$(gettext 'Date & Time')'</label>
        <input file>'$ICONDIR'/date_time.svg</input><height>42</height><width>42</width>
        <action>set-time-for-puppy &</action>
      </button>
      <button image-position="2" tooltip-text=" '$(gettext 'Set timezone')' ">
        <label>'$(gettext 'Timezone')'</label>
        <input file>'$ICONDIR'/country_timezone.svg</input><height>42</height><width>42</width>
        <action>timezone-set &</action>
      </button>
    </hbox>

    <hbox spacing="10" homogeneous="true" space-expand="true" space-fill="true">
      <button image-position="2" tooltip-text=" '$(gettext 'Set hardware-clock type')' ">
        <label>'$(gettext 'Hardware Clock')'</label>
        <input file>'$ICONDIR'/clock.svg</input><height>42</height><width>42</width>
        <action>set_hwclock_type &</action>
      </button>
      <button image-position="2" tooltip-text=" '$(gettext 'Set tray-clock format')' ">
        <label>'$(gettext 'Tray Clock')'</label>
        <input file>'$ICONDIR'/clock_digital.svg</input><height>42</height><width>42</width>
        <action>'$clock_cmd' &</action>
      </button>
    </hbox>

    <hbox spacing="10" homogeneous="true" space-expand="true" space-fill="true">
      <button image-position="2" tooltip-text=" '$(gettext 'Syncronize with time-server')' ">
        <label>'$(gettext 'Sync')'</label>
        <input file>'$ICONDIR'/clock_countdown.svg</input><height>42</height><width>42</width>
        <action>'$psync_cmd' &</action>
      </button>
      <button image-position="2" tooltip-text=" '$(gettext 'Task scheduler')' ">
        <sensitive>'$(which pschedule 2>/dev/null && echo true || echo false)'</sensitive>
        <label>'$(gettext 'Schedule')'</label>
        <input file>'$ICONDIR'/execute_interval.svg</input><height>42</height><width>42</width>
        <action>pschedule &</action>
      </button>
    </hbox>

  </vbox>
 </vbox>
</window>'

gtkdialog -p TimeWizard --styles=/tmp/gtkrc_xml_info.css

unset TimeWizard
