#alternate user interface designed by zigbert.
#120203 rodin.s: internationalized.
#120224 more gettext's required. icons were missing.
#120224 handle translated help.htm
#120225 fix for translated categories.
#120504 some files moved into /tmp/petget
#120508 01micko: bugfix. ref: http://murga-linux.com/puppy/viewtopic.php?p=625843#625843
#120515 calls to /tmp/petget/filterpkgs.results.postfilter.sh replace by /usr/local/petget/postfilterpkgs.sh.
#120529 app icons in tree. variable FLG_APPICONS created in pkg_chooser.sh
#120811 category field now supports sub-category |category;subcategory|, use as icon in ppm main window.
#130330 GUI filter. see also filterpkgs.sh, pkg_chooser.sh, ui_Ziggy.
#130331 more GUI filter options.

export TEXTDOMAIN=petget___ui_Ziggy
export OUTPUT_CHARSET=UTF-8

ALLITEM='' ; ALLSTOCK='' ; CATHEIGHT='100' ; WINHEIGHT='380'
if [ "$ALLCATEGORY" != "" ];then
 ALLITEM="<item stock=\"gtk-ALL\">$(gettext 'ALL')</item>"
 ALLSTOCK='stock["gtk-ALL"] = {{ "pet24.png", *, *, *}}'
 CATHEIGHT='112'
 WINHEIGHT='388'
fi

##120529
#if [ "$FLG_APPICONS" = "true" ];then
# APPICONXMLINSERT=' icon-column="0"'
#else
# APPICONXMLINSERT=''
#fi
APPICONXMLINSERT=' icon-column="1"' #120811 each line is format: abiword0-1.2.3|subcategory|description of abiword|stuff

#120224 handle translated help.htm
LANG1="${LANG%_*}" #ex: de
HELPFILE="/usr/local/petget/help.htm"
[ -f /usr/local/petget/help-${LANG1}.htm ] && HELPFILE="/usr/local/petget/help-${LANG1}.htm"

#120225 fix translated categories...
CATTRANSTABLE="Desktop:$(gettext 'Desktop') 
System:$(gettext 'System')
Setup:$(gettext 'Setup')
Utility:$(gettext 'Utility')
Filesystem:$(gettext 'Filesystem')
Graphic:$(gettext 'Graphic')
Document:$(gettext 'Document')
Business:$(gettext 'Business')
Personal:$(gettext 'Personal')
Network:$(gettext 'Network')
Internet:$(gettext 'Internet')
Multimedia:$(gettext 'Multimedia')
Fun:$(gettext 'Fun')
ALL:$(gettext 'ALL')"
echo "#!/bin/sh
CATTRANSTABLE='${CATTRANSTABLE}'" > /tmp/ppm-ui-ziggy-fix
echo 'CATEGORY="`echo "$CATTRANSTABLE" | grep "$1" | head -n 1 | cut -f 1 -d ':'`"
[ ! "$CATEGORY" ] && CATEGORY="Desktop"
echo "$CATEGORY"
' >> /tmp/ppm-ui-ziggy-fix
chmod 755 /tmp/ppm-ui-ziggy-fix

DEFGUIFILTER="$(cat /var/local/petget/gui_filter)" #130330 see pkg_chooser.sh, and below.

#130330 $GUIONLYSTR $ANYTYPESTR are exported from pkg_chooser.sh.  130331 also $GUIEXCSTR $NONGUISTR
export MAIN_DIALOG="<window title=\"$(gettext 'Puppy Package Manager')\" icon-name=\"gtk-about\" default_height=\"${WINHEIGHT}\" default_width=\"680\">
<hbox>
 <vbox>
  <hbox>
   <button tooltip-text=\"$(gettext 'Uninstall packages')\">
    <label>$(gettext 'Uninstall')</label>
    <input file icon=\"mini-trash\"></input>
    <action>launch:INSTALLED_DIALOG</action>
   </button>
   <button tooltip-text=\"$(gettext 'Configure package manager')\">
    <input file icon=\"gtk-preferences\"></input>
    <action>/usr/local/petget/configure.sh</action>
    <action>/usr/local/petget/filterpkgs.sh</action>
    <action>refresh:TREE1</action>
   </button>
   <button tooltip-text=\"$(gettext 'Help')\">
    <input file>/usr/local/lib/X11/pixmaps/help24.png</input>
    <action>defaulthtmlviewer file://${HELPFILE} & </action>
   </button>
   <button type=\"exit\"  tooltip-text=\"$(gettext 'Quit package manager')\">
    <input file>/usr/local/lib/X11/pixmaps/shutdown24.png</input>
   </button>
   </hbox>


 <frame $(gettext 'Repositories')>
 <vbox>
  ${DB_ORDERED}
 </vbox>
 </frame>
 
   
 <frame $(gettext 'package types')>
 <hbox>
  <vbox>
   <checkbox>
    <default>${DEF_CHK_EXE}</default>
    <label>EXE</label>
    <variable>CHK_EXE</variable>
    <action>/usr/local/petget/postfilterpkgs.sh EXE \$CHK_EXE</action>
    <action>refresh:TREE1</action>
   </checkbox>
   <checkbox>
    <default>${DEF_CHK_DEV}</default>
    <label>DEV</label>
    <variable>CHK_DEV</variable>
    <action>/usr/local/petget/postfilterpkgs.sh DEV \$CHK_DEV</action>
    <action>refresh:TREE1</action>
   </checkbox>
   <checkbox>
    <default>${DEF_CHK_DOC}</default>
    <label>DOC</label>
    <variable>CHK_DOC</variable>
    <action>/usr/local/petget/postfilterpkgs.sh DOC \$CHK_DOC</action>
    <action>refresh:TREE1</action>
   </checkbox>
   <checkbox>
    <default>${DEF_CHK_NLS}</default>
    <label>NLS</label>
    <variable>CHK_NLS</variable>
    <action>/usr/local/petget/postfilterpkgs.sh NLS \$CHK_NLS</action>
    <action>refresh:TREE1</action>
   </checkbox>
  </vbox>
  <vbox>
   <comboboxtext width-request=\"140\">
    <variable>FILTERCOMBOBOX</variable>
    <default>$DEFGUIFILTER</default>
    <item>$ANYTYPESTR</item>
    <item>$GUIONLYSTR</item>
    <item>GTK+2 $GUIONLYSTR</item>
    <item>GTK+3 $GUIONLYSTR</item>
    <item>Qt4 $GUIONLYSTR</item>
    <item>Qt4 $GUIEXCSTR KDE</item>
    <item>Qt5 $GUIONLYSTR</item>
    <item>Qt5 $GUIEXCSTR KDE</item>
    <item>$NONGUISTR</item>
    <action>echo -n \"\$FILTERCOMBOBOX\" > /var/local/petget/gui_filter</action>
    <action>/usr/local/petget/filterpkgs.sh</action>
    <action>refresh:TREE1</action>
   </comboboxtext>
  </vbox>
 </hbox> 
 </frame>

  <hbox width-request=\"100\">
   <text><label>$(gettext 'Find:')</label></text>
   <entry activates-default=\"true\">
    <variable>ENTRY1</variable>
   </entry>
   <button can-default=\"true\" has-default=\"true\" use-stock=\"true\">
    <label>$(gettext 'Go')</label>
    <action>/usr/local/petget/findnames.sh</action>
    <action>refresh:TREE1</action>
    <action>/usr/local/petget/show_installed_version_diffs.sh & </action>
   </button>
  </hbox>
</vbox>  
  
<vbox>
   <tree>
   <label>$(gettext 'Category')</label>
   <variable>CATEGORY</variable>
   <item stock=\"gtk-Desktop\">$(gettext 'Desktop')</item>
   <item stock=\"gtk-System\">$(gettext 'System')</item>
   <item stock=\"gtk-Setup\">$(gettext 'Setup')</item>
   <item stock=\"gtk-Utility\">$(gettext 'Utility')</item>
   <item stock=\"gtk-Filesystem\">$(gettext 'Filesystem')</item>
   <item stock=\"gtk-Graphic\">$(gettext 'Graphic')</item>
   <item stock=\"gtk-Document\">$(gettext 'Document')</item>
   <item stock=\"gtk-Business\">$(gettext 'Business')</item>
   <item stock=\"gtk-Personal\">$(gettext 'Personal')</item>
   <item stock=\"gtk-Network\">$(gettext 'Network')</item>
   <item stock=\"gtk-Internet\">$(gettext 'Internet')</item>
   <item stock=\"gtk-Multimedia\">$(gettext 'Multimedia')</item>
   <item stock=\"gtk-Fun\">$(gettext 'Fun')</item>
   ${ALLITEM}
   <width>140</width><height>${CATHEIGHT}</height>
   <action signal=\"button-release-event\">/tmp/ppm-ui-ziggy-fix \$CATEGORY | xargs -I CATINSERT /usr/local/petget/filterpkgs.sh CATINSERT</action>
   <action signal=\"button-release-event\">refresh:TREE1</action>
  </tree>
</vbox>
  <tree>
    <label>$(gettext 'Package|Description')</label>
    <variable>TREE1</variable>
    <input${APPICONXMLINSERT}>cat /tmp/petget/filterpkgs.results.post</input>
    <action signal=\"button-release-event\">/usr/local/petget/installpreview.sh</action>
    <action signal=\"button-release-event\">/usr/local/petget/finduserinstalledpkgs.sh</action>
    <action signal=\"button-release-event\">refresh:TREE2</action>
  </tree>

</hbox>
</window>"

export INSTALLED_DIALOG='<window title="'$(gettext 'Uninstall Puppy Package')'" icon-name="gtk-about" default_height="380" default_width="450">
 <vbox>
  <text><label>'$(gettext 'Click on an item in the list to uninstall package')'</label></text>  
  <tree>
    <label>'$(gettext 'Installed Package|Description')'</label>
    <variable>TREE2</variable>
    <input'${APPICONXMLINSERT}'>cat /tmp/petget/installedpkgs.results.post</input>
    <action signal="button-release-event">/usr/local/petget/removepreview.sh</action>
    <action signal="button-release-event">/usr/local/petget/finduserinstalledpkgs.sh</action>
    <action signal="button-release-event">refresh:TREE2</action>
  </tree>
  </vbox>
</window>' 

mkdir -p /tmp/puppy_package_manager
ln -s /usr/local/lib/X11/pixmaps/*24.png /tmp/puppy_package_manager 2>/dev/null
echo 'style "icon-style" {
	stock["gtk-Desktop"] = {{ "x24.png", *, *, *}}
	stock["gtk-System"]	= {{ "pc24.png", *, *, *}}
	stock["gtk-Setup"] = {{ "configuration24.png", *, *, *}}
	stock["gtk-Utility"] = {{ "utility24.png", *, *, *}}
	stock["gtk-Filesystem"] = {{ "folder24.png", *, *, *}}
	stock["gtk-Graphic"] = {{ "paint24.png", *, *, *}}
	stock["gtk-Document"] = {{ "word24.png", *, *, *}}
	stock["gtk-Business"] = {{ "spread24.png", *, *, *}}
	stock["gtk-Personal"] = {{ "date24.png", *, *, *}}
	stock["gtk-Network"] = {{ "connect24.png", *, *, *}}
	stock["gtk-Internet"] = {{ "www24.png", *, *, *}}
	stock["gtk-Multimedia"] = {{ "multimedia24.png", *, *, *}}
	stock["gtk-Fun"] = {{ "games24.png", *, *, *}}
	'${ALLSTOCK}'}
class "GtkWidget" style "icon-style"' > /tmp/puppy_package_manager/gtkrc_ppm

export GTK2_RC_FILES=/root/.gtkrc-2.0:/tmp/puppy_package_manager/gtkrc_ppm

export TEXTDOMAIN=petget___pkg_chooser.sh
