Warn user that a feature requires GTKDIALOG update

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

Warn user that a feature requires GTKDIALOG update

#1 Post by don570 »

Warn user that a feature requires GTKDIALOG update

In my latest version of puppy clock I warn the user that
a feature needs an update of GTKDIALOG to work


Image

At the bottom of this page there is a discussion
by Thunor on warning a user that an update is needed.

First of all all scripts should begin with this code to
create a variable GTKDIALOG

Code: Select all

for P in gtkdialog4 gtkdialog3 gtkdialog; do
GTKDIALOG=$(which $P) && break
done

I made a few changes to Thunor's code

Code: Select all

function funcGTKDVGet() {
   GTKDV=( $($GTKDIALOG -v) )
   GTKDV=${GTKDV[2]}
   echo "Gtkdialog version: $GTKDV"
  
}


When the button is clicked( to launch the new feature
i.e. a World Clock) a function is called that has this
if statement to launch a warning message using yaf-spash

Code: Select all

CHECK_VERSION=`funcGTKDVGet | awk  '{ print $3 }'`
if [ ${CHECK_VERSION:2:1} -gt 7 ] ; then
...


else
yaf-splash -bg_gradient false -fontsize large -bg orange -close box -deco "Puppy Clock" -text "

You must update your version of GTKDIALOG
to use the World Clock feature.
" &
fi



The code that thunor gives is better to make the comparison
of versions since I simply check if version 8 has been installed.

Code: Select all

function funcGTKDVGet() {
   GTKDV=( $($GTKDIALOG -v) )
   GTKDV=${GTKDV[2]}
   echo "Gtkdialog version: $GTKDV"
   GTKDV=( ${GTKDV//./ } )
   if [ ${GTKDV[1]} -lt 10 ]; then GTKDV[1]=${GTKDV[1]}0; fi
   if [ ${GTKDV[2]} -lt 10 ]; then GTKDV[2]=0${GTKDV[2]}; fi
}; funcGTKDVGet

if [ ${GTKDV[1]}${GTKDV[2]} -lt "7021" ]; then
   echo "This application requires at least gtkdialog-0.7.21"
   exit
fi 
 

_____________________________________________
Last edited by don570 on Thu 16 Aug 2012, 00:29, edited 2 times in total.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#2 Post by don570 »

Here is a modification of Thunor's code that anyone can put at the
beginning of their script. Codewriters should modify it to meet their
needs.

Note that the variable GTKDV is initially an array with 3 elements
(numbered ----> 0,1,2 )

...but then GTKDV is changed to a different array
a couple of lines further. Thunar states " the following code does the trick
(on Puppy Linux you will get "5908" for gtkdialog2, "7020" for gtkdialog3
and "7021" and upwards for gtkdialog)."

The function then prints to terminal the version
(echo "Gtkdialog version: $GTKDV") which is how I get the
number 8 for recent puppies.

Code: Select all

for P in gtkdialog4 gtkdialog3 gtkdialog; do
GTKDIALOG=$(which $P) && break
done

function funcGTKDVGet() {
   GTKDV=( $($GTKDIALOG -v) )   
   GTKDV=${GTKDV[2]}  
   echo "Gtkdialog version: $GTKDV"
   GTKDV=( ${GTKDV//./ } )   
   if [ ${GTKDV[1]} -lt 10 ]; then GTKDV[1]=${GTKDV[1]}0; fi
   if [ ${GTKDV[2]} -lt 10 ]; then GTKDV[2]=0${GTKDV[2]}; fi
}; funcGTKDVGet

if [ ${GTKDV[1]}${GTKDV[2]} -lt "7021" ]; then
   xmessage "This application requires at least gtkdialog-0.7.21"
   exit
   else
   xmessage "This application is greater than gtkdialog-0.7.20

That is good!!"
fi 


Post Reply