#!/bin/bash
#Pprocess - process manager
#Copyright 2007,2008
#Sigmund Berglund

#------------------------------
#This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation version 2.

#This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. <http://www.gnu.org/licenses/>.
#------------------------------

VERSION="0.5"
export PROGPATH="/usr/local/pprocess"
echo "false" > /tmp/pprocess-viewall
echo "false" > /tmp/pprocess-button
TAB120="$PROGPATH""/tab120.png"

. $PROGPATH/func -probe
export PPROCESS="
<window title=\"Pprocess $VERSION - プロセス マネージャ \"icon-name=\"gtk-execute\">
<hbox>
 <tree headers_visible=\"false\" rules_hint=\"true\">
  <label>hei</label>
  <width>520</width><height>200</height>
  <variable>LIST</variable>
  <input>cat /tmp/pprocess-ps</input>
 </tree>
 <vbox>
  <text><label>\"\"</label></text>
  <hbox>
   <button> 
    <label>\"         プロセス終了        \"</label>
    <action>. $PROGPATH/func -kill</action>
    <action>. $PROGPATH/func -refresh</action>
    <action>. $PROGPATH/func -probe</action>
    <action>Refresh:LIST</action>
   </button>
   <vbox>
    <text><label>\"       \"</label></text>
    <text><label>\"\"</label></text>
    <text><label>\"\"</label></text>
    <text><label>\"\"</label></text>
   </vbox>
  </hbox>
  <text><label>\"\"</label></text>
  <pixmap><input file>$TAB120</input></pixmap>
  <notebook labels=\"一般|高度\">
   <vbox>
    <frame CPU 優先度>
     <hbox>
      <text><label>高</label></text>
      <button>
       <input file stock=\"gtk-go-up\"></input>
       <action>. $PROGPATH/func -high</action>
       <action>. $PROGPATH/func -refresh</action>
       <action>. $PROGPATH/func -probe</action>
       <action>Refresh:LIST</action>
      </button>
     </hbox>
     <hbox>
      <text><label>中</label></text>
      <button>
       <input file stock=\"gtk-remove\"></input>
       <action>. $PROGPATH/func -normal</action>
       <action>. $PROGPATH/func -refresh</action>
       <action>. $PROGPATH/func -probe</action>
       <action>Refresh:LIST</action>
      </button>
     </hbox>
     <hbox>
      <text><label>低</label></text>
      <button>
       <input file stock=\"gtk-go-down\"></input>
       <action>. $PROGPATH/func -low</action>
       <action>. $PROGPATH/func -refresh</action>
       <action>. $PROGPATH/func -probe</action>
       <action>Refresh:LIST</action>
      </button>
     </hbox>
    </frame>
    <frame ビュー>
     <hbox>
      <button>
       <input file stock=\"gtk-fullscreen\"></input>
       <label>全て</label>
       <action>echo true > /tmp/pprocess-button</action>
       <action>. $PROGPATH/func -probe</action>
       <action>Refresh:LIST</action>
      </button>
     </hbox>
     <hbox>
      <entry activates-default=\"true\">
       <variable>SEARCHSTRING</variable>
       <input>echo search text</input>
       <width>100</width><height>25</height>
      </entry>
      <button can-default=\"true\" has-default=\"true\" use-stock=\"true\">
       <input file stock=\"gtk-find\"></input>
       <action>. $PROGPATH/func -search</action>
       <action>. $PROGPATH/func -refresh</action>
       <action>Refresh:LIST</action>
      </button>
     </hbox>
    </frame>
   </vbox>
   <vbox>
    <frame 終了信号>
    <combobox>
     <variable>KILL_SIGNAL</variable>
     <item>0 - No signal</item> 
     <item>1 - Hangup</item> 
     <item>2 - Interrupt</item> 
     <item>3 - Quit</item> 
     <item>9 - Kill</item> 
     <item>14 - Alarm</item> 
     <item>15 - Terminate (soft kill)</item> 
     <item>23 - Stop</item> 
     <item>25 - Continue</item> 
    </combobox>
   </frame>
   <frame 監視>
    <tree rules_hint=\"true\" headers_visible=\"false\" exported_column=\"1\">
     <variable>LOG_FILE</variable>
     <label>a|b</label>
     <item>Running pocesses|top</item>
     <item>Kernel messages|/var/log/messages</item>
     <item>Graphic server|/var/log/Xorg.0.log</item>
     <item>Kernel boot|/tmp/bootkernel.log</item>
     <item>Puppy boot|/tmp/bootsysinit.log</item>
     <action>. $PROGPATH/func -logfile</action>
    </tree>
    </frame>  
   </vbox>
  </notebook>
  <hbox>
   <button>
    <input file stock=\"gtk-refresh\"></input>
    <label>更新</label>
    <action>. $PROGPATH/func -refresh</action>
    <action>. $PROGPATH/func -probe</action>
    <action>Refresh:LIST</action>
   </button>
   <button>
    <input file stock=\"gtk-quit\"></input>
    <label>終了</label>
   </button>
  </hbox>
 </vbox>
</hbox>
</window>"
I=$IFS; IFS=""
for STATEMENTS in  $(gtkdialog3 --program=PPROCESS --center); do
	eval $STATEMENTS
done
IFS=$I
case $EXIT in
	*)			exit;;
esac
