#!/bin/bash

MY_DIALOG='<window title="Gamma correction utility" resizable="false">
 <vbox>
   <vbox>
     <frame>
       <vbox>
         <frame Red>
           <hscale width-request="800" height-request="80"
             range-min="0.1" range-max="2" range-step="0.05"
             value-pos="2" inverted="false">
             <default>1.0</default>
             <variable>HS_1</variable>
             <item>"0.2 | 3 | 0.2 "</item>
             <item>"0.4 | 3 | 0.4 "</item>
             <item>"0.6 | 3 | 0.6 "</item>
             <item>"0.8 | 3 | 0.8 "</item>
             <item>"1.0 | 3 | 1.0 "</item>
             <item>"1.2 | 3 | 1.2 "</item>
             <item>"1.4 | 3 | 1.4 "</item>
             <item>"1.6 | 3 | 1.6 "</item>
             <item>"1.8 | 3 | 1.8 "</item>
             <item>"2.0 | 3 | 2.0 "</item>
             <output file>/tmp/h1_out</output>
           </hscale>
         </frame>
         <frame Green>
           <hscale width-request="800" height-request="80"
             range-min="0.1" range-max="2" range-step="0.05"
             value-pos="2" inverted="false">
             <default>1.0</default>
             <variable>HS_2</variable>
             <item>"0.2 | 3 | 0.2 "</item>
             <item>"0.4 | 3 | 0.4 "</item>
             <item>"0.6 | 3 | 0.6 "</item>
             <item>"0.8 | 3 | 0.8 "</item>
             <item>"1.0 | 3 | 1.0 "</item>
             <item>"1.2 | 3 | 1.2 "</item>
             <item>"1.4 | 3 | 1.4 "</item>
             <item>"1.6 | 3 | 1.6 "</item>
             <item>"1.8 | 3 | 1.8 "</item>
             <item>"2.0 | 3 | 2.0 "</item>
             <output file>/tmp/h2_out</output>
           </hscale>
         </frame>
         <frame Blue>
           <hscale width-request="800" height-request="80"
             range-min="0.1" range-max="2" range-step="0.05"
             value-pos="2" inverted="false">
             <default>1.0</default>
             <variable>HS_3</variable>
             <item>"0.2 | 3 | 0.2 "</item>
             <item>"0.4 | 3 | 0.4 "</item>
             <item>"0.6 | 3 | 0.6 "</item>
             <item>"0.8 | 3 | 0.8 "</item>
             <item>"1.0 | 3 | 1.0 "</item>
             <item>"1.2 | 3 | 1.2 "</item>
             <item>"1.4 | 3 | 1.4 "</item>
             <item>"1.6 | 3 | 1.6 "</item>
             <item>"1.8 | 3 | 1.8 "</item>
             <item>"2.0 | 3 | 2.0 "</item>
             <output file>/tmp/h3_out</output>
           </hscale>
        </frame>
      </vbox>
    </frame>    
  </vbox>    
  <vbox>
    <frame>
      <hbox homogeneous="true">
        <timer visible="false" interval="200" milliseconds="true">
        <action function="save">HS_1</action>
        <action function="save">HS_2</action>
        <action function="save">HS_3</action>
        <action function="command">xgamma -quiet -rgamma `cat /tmp/h1_out`</action>
        <action function="command">xgamma -quiet -ggamma `cat /tmp/h2_out`</action>
        <action function="command">xgamma -quiet -bgamma `cat /tmp/h3_out`</action>
      </timer>
      <button image-position="2">
        <label>"Done"</label>
        <input file stock="gtk-cancel"></input>
        <action>EXIT:cancel</action>
      </button>
    </hbox>
  </frame>
 </vbox>
</vbox>
</window>'
export MY_GUI="`echo "$MY_DIALOG" | sed 's/##.*//'`"
gtkdialog -p MY_GUI
#rm -f /tmp/h1_out
#rm -f /tmp/h2_out
#rm -f /tmp/h3_out        # I decided to leave these for reference.
