#!/bin/sh
# test we are root
if [ "$USER" != "root" ] ; then
   echo "Run as root please, exiting." 
   exit 1                                                      
fi

export CFLAGS="-mtune=generic -Os -pipe"
export CXX="g++ -flto -fuse-linker-plugin -mtune=generic -Os -pipe "

P=xfce4-panel
V=4.13.2
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc exo-dev libwnck-dev "
for Z in $LIST 
    do 
    su -c "tce-load -i $Z" $USER
done

cd /tmp
su -c "/usr/local/bin/wget -nc --no-check-certificate \
https://mirror.vinahost.vn/xfce/src/xfce/$P/4.13/$P-$V.tar.bz2 " $USER
mkdir $P
tar jxvf $P*bz2
cd $P-$V 
./configure --disable-debug --enable-gio-unix \
--enable-introspection=no  
#  Build Configuration:#####################
# Debug Support:          no
# GNU Visibility:         yes
# GTK+ 2 Support:         yes
#####################################################
make check
make install-strip DESTDIR=/tmp/$P
cd /tmp

# locale
#########
mkdir -p $P-locale/usr/local/share
mv $P/usr/local/share/locale $P-locale/usr/local/share

# doc
#####
mkdir -p $P-doc/usr/local/share/doc/$P
mv $P/usr/local/share/gtk-doc $P-doc/usr/local/share
cp $P-$V/AUTHORS $P-doc/usr/local/share/doc/$P
cp $P-$V/COPYING $P-doc/usr/local/share/doc/$P

# dev
#####
mkdir -p $P-dev/usr/local/lib/xfce4/panel/plugins
mv $P/usr/local/include $P-dev/usr/local/
mv $P/usr/local/lib/*a $P-dev/usr/local/lib/
mv $P/usr/local/lib/pkgconfig $P-dev/usr/local/lib/
chmod 644 $P-dev/usr/local/lib/*a 
mv $P/usr/local/lib/xfce4/panel/plugins/*a $P-dev/usr/local/lib/xfce4/panel/plugins
chmod 644 $P-dev/usr/local/lib/xfce4/panel/plugins/*a

# main
#####
mkdir -p $P/usr/local/share/doc/$P
echo 'see doc tcz for license' > $P/usr/local/share/doc/$P/COPYING

# desktops only appear in XFCE thru the menu system

# TCZ them
#######
LIST="$P $P-doc $P-dev $P-locale"
for Z in $LIST
do
	mksquashfs $Z $Z.tcz
	md5sum $Z.tcz > $Z.tcz.md5.txt
	cd $Z
	find usr -not -type d > /tmp/$Z.tcz.list
        sed 's|usr|/usr|g' -i /tmp/$Z.tcz.list
	cd /tmp
done

echo 'xfce4-panel.tcz' > $P-locale.tcz.dep

echo 'xfce4-panel.tcz
exo-dev.tcz
libwnck-dev.tcz' > $P-dev.tcz.dep

echo 'libwnck.tcz
exo.tcz 
xfce4-settings.tcz ' > $P.tcz.dep

echo 'Title:          xfce4-panel.tcz  
Description:    xfce panel
Version:        4.13.2
Author:         see doc for authors  
Original-site:  xfce.org
Copying-policy: GPL v2
Size:		
Extension_by:   aus9 at gmx dot com
Tags:           xfce 
Comments:       The panel for XFCE. Runs OK on most other graphical 
                environments. The panel is started by xfce4-session 
                when its running. wbar "can" co-exist when 
                xcfe4-session is running if you have no plans to 
                download more XFCE TCZs. 
                
                If xfce4-session is not loaded, you can start panel by 
                $ xfce4-panel --disable-wm-check &
                (First time use, a popup will offer 2 choices always 
                 choose default config.) 
                You will see numerous GTK warnings.....and ignore them
                as warning are not errors!

                When panel is running, you can click the pulldown for 
                panel 1 for menus. Testing openbox most KB shortcuts 
                still worked

                Panel 2, the bottom one, will over-write the space
                where wbar would normally display. You can move panel 
                2 once you unlock it. It can display vertically or 
                moved left or right of wbar.

                No preferences have been set in panel 2, first time
                you click their launcher icons, a popup can help set them. 
                To reset, if needed, panel 1 ->  Applications -> Settings etc

                It might be prudent for ALL NON-XFCE users to use the fluxbox 
                instructions in case my tests were insufficient.

                fluxbox
                #######
                If you wish to test out this panel, do not use Apps 
                -> onboot but choose download only and test it in 
                your currect session of fluxbox please.

                My test shows panel 2 covers panel 1. YMMV so steps for a 
                RH mouse user to fix are:  
                $ tce-load -i xfce4-panel
                $ xfce4-panel &
                $ xfce4-settings-manager (starts the GUI for changing the settings)
                choose panel to configure
                LH click on panel 1 and select panel 2
                Un-tick the box for lock panel
                To the right of panel 2 LH click the minus (delete) sign
                A new popup will offer 2 choices.....choose remove......
                panel 2 should close, making panel 1 -> Applications clickable

                Compiled for 64 9.x
Change-log:     2018/04/07  First version 
Current:        2018/04/07 ' > $P.tcz.info

echo 'Title:          xfce4-panel-doc.tcz
Description:    docs
Version:        4.13.2
Author:         see doc for authors 
Original-site:  xfce.org
Copying-policy: GPL v2
Size:		
Extension_by:   aus9 at gmx dot com
Tags:           xfce 
Comments:       Some docs

                Compiled for 64 9.x
Change-log:     2018/04/07  First version 
Current:        2018/04/07 ' > $P-doc.tcz.info

echo 'Title:          xfce4-panel-dev.tcz
Description:    dev files for xfce4-panel
Version:        4.13.2
Author:         see doc for authors 
Original-site:  xfce.org
Copying-policy: GPL v2
Size:		
Extension_by:   aus9 at gmx dot com
Tags:           xfce 
Comments:       Development files

                Compiled for 64 9.x
Change-log:     2018/04/07  First version 
Current:        2018/04/07 ' > $P-dev.tcz.info


echo 'Title:          xfce4-panel-locale.tcz
Description:    locales
Version:        4.13.2
Author:         see doc for authors 
Original-site:  xfce.org
Copying-policy: GPL v2
Size:		
Extension_by:   aus9 at gmx dot com
Tags:           xfce 
Comments:       for non-english users untested

                Compiled for 64 9.x
Change-log:     2018/04/07  First version 
Current:        2018/04/07 ' > $P-locale.tcz.info

submitqc --libs
