Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 21 Aug 2014, 02:31
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Warn user that a feature requires GTKDIALOG update
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [2 Posts]  
Author Message
don570


Joined: 10 Mar 2010
Posts: 3250
Location: Ontario

PostPosted: Tue 14 Aug 2012, 17:39    Post subject:  Warn user that a feature requires GTKDIALOG update  

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




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:
for P in gtkdialog4 gtkdialog3 gtkdialog; do
GTKDIALOG=$(which $P) && break
done



I made a few changes to Thunor's code

Code:
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:
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:
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 Wed 15 Aug 2012, 20:29; edited 2 times in total
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3250
Location: Ontario

PostPosted: Wed 15 Aug 2012, 20:24    Post subject:  

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:

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

Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [2 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0554s ][ Queries: 12 (0.0055s) ][ GZIP on ]