gtkdialog defaults

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
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

gtkdialog defaults

#1 Post by mavrothal »

I'm trying to make PPM install multiple packages simultaneous (don't hold your breath, still way too early).
So package selection in PPM is calling the installwindow.sh instead of installpreview.sh. The user then can select a second package etc.
Then installwindow.sh upon exit calls installpreview.sh.

The problem I have is that all the PPM scripts have dialogs that require user input so there is no real gain if the user must stay there and confirm for every single package what to do.

The question is can you pre-set defaults in gtkdialogs so the process can go on unattended?
The idea is instead of re-writting all the PPM scripts, to have installwindow.sh set some flags that the PPM script can read and proceed unattended.

BTW my current installwindow.sh looks like this

Code: Select all

#!/bin/bash
OLD_DIALOG=$(ps | grep INSTALL_PETS_DIALOG | grep program | cut -f 1 -d ' ')
kill -9 $OLD_DIALOG
export TEXTDOMAIN=petget__installwindow.sh
export OUTPUT_CHARSET=UTF-8

[ "`whoami`" != "root" ] && exec sudo -A ${0} ${@} #110505

[ "$TREE1" != "" ] && echo "$TREE1" >> /tmp/pkgs_to_install || exit 1

install_package () {
 # Should set some flags here for PPM scripts to proceed unattended.
 for LINE in $(cat /tmp/pkgs_to_install)
 do 
  TREE1=$LINE
  /usr/local/petget/installpreview.sh
  [ $? -ne 0 ] && sed -i "/${TREE1}/d" /tmp/pkgs_to_install
 done
 rm /tmp/pkgs_to_install
}
export -f install_package

export INSTALL_PETS_DIALOG='<window title="'$(gettext 'Install Puppy Packages')'" icon-name="gtk-about" default_height="200" default_width="300">
 <vbox>
  <text><label>'$(gettext 'The following packages will be installed')'</label></text>  
  <tree column-resizeable="false">
    <label>'$(gettext 'Packages to install')'</label>
    <variable>TREE2</variable>
    <input'${APPICONXMLINSERT}'>cat /tmp/pkgs_to_install</input>
    <action>refresh:TREE2</action>
    <action signal="button-release-event">refresh:TREE2</action>
  </tree>
  <hbox>
  <button>
   <label>'$(gettext 'Install packages')'</label>
   <action>install_package &</action>
   <action type="exit">echo exiting</action>
  </button> 
  <button>
   <label>'$(gettext 'Cancel')'</label>
   <action>rm /tmp/pkgs_to_install</action>
   <action type="exit">echo exiting</action> 
  </button>
  </hbox>
  </vbox>
</window>' 
gtkdialog --program=INSTALL_PETS_DIALOG
suggestions for improvements on the script are very welcome
(the buttons for example look "ugly" to me but my gtkdialog knowledge is rudimentary :oops: )
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

stemsee

#2 Post by stemsee »

And while you are at it how about making the check for missing dependecies occur only once at the very end, instead of after each package as is now the case, or on next ppm start up.

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#3 Post by mavrothal »

stemsee wrote:And while you are at it how about making the check for missing dependecies occur only once at the very end, instead of after each package as is now the case, or on next ppm start up.
That's way ahead. P
PM is fairly complex and even small functional changes need a lot of work and testing, thus the request to use "defaults" to minimize changes.
If we ever get there then we may consider more. :wink:
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#4 Post by zigbert »

The default value is set static by the <default> tag. ie:

Code: Select all

<checkbox>
 <default>true</default>
 <variable>CHECK</variable>
</checkbox>
This is the easy way. The <default> tag is only read at startup.

The more flexible way is to use the <input> tag. This one can change its status while the gui is up and running by

Code: Select all

<action>refresh:CHECK</action>

Sigmund

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#5 Post by mavrothal »

zigbert wrote:The default value is set static by the <default> tag. ie:

Code: Select all

<checkbox>
 <default>true</default>
 <variable>CHECK</variable>
</checkbox>
This is the easy way. The <default> tag is only read at startup.

The more flexible way is to use the <input> tag. This one can change its status while the gui is up and running by

Code: Select all

<action>refresh:CHECK</action>

Sigmund
OK.
But can you set these flags from another script.
Ideally installwindow.sh could write the flags in a temp file and PPM scripts could get them from there by adding

Code: Select all

. /tmp/ppm_flags
at the top of the scripts.
Is mostly the "install preview", the "examine dependencies" the "trim fat" dialogs and then a bunch of OK buttons to close information windows.
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#6 Post by zigbert »

The easy way (the static way) would be like this:

Code: Select all

#/tmp/ppm_flags
export TRIM_FAT=true

Code: Select all

. /tmp/ppm_flags
export GUI='<checkbox>
 <default>'$TRIM_FAT'</default>
 <variable>TRIM_FAT</variable>
</checkbox>'

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#7 Post by mavrothal »

zigbert wrote:The easy way (the static way) would be like this:

Code: Select all

#/tmp/ppm_flags
export TRIM_FAT=true

Code: Select all

. /tmp/ppm_flags
export GUI='<checkbox>
 <default>'$TRIM_FAT'</default>
 <variable>TRIM_FAT</variable>
</checkbox>'
That's good :D
The only other issue is if a flag is conditional.
Specifically in the installpreview
if there are dependencies the "examine dependencies" button appears and should be default, if not the "install" should be the default.
How one can go about this?
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#8 Post by zigbert »

Code: Select all

#/tmp/ppm_flags
export TRIM_FAT=true
export EXAM_DEP=true

Code: Select all

. /tmp/ppm_flags
export GUI='<button can-default="true" has-default="true">
 <label>Install</label>
 <action>install</action>
</button>
<button visible='$EXAM_DEP' can-default="true" has-default="true">
 <label>examine dependencies</label>
 <action>exam</action>
</button>'
I have not tested this, but I guess the focus code can-default="true" has-default="true" will be overwritten if the exam-button is visible. If not, the focus code can be the content of a variable depending on exam or not.

If you want me to, I can fix alignment, focus and layout later.

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#9 Post by mavrothal »

Is kind of late to get all these but to be specific on our case installpreview.sh has

Code: Select all

  <button>
   <label>$(gettext 'Download-only selected packages')</label>
   <action type=\"exit\">BUTTON_PKGS_DOWNLOADONLY</action>
  </button>
  <button>
   <label>$(gettext 'Download-and-install selected packages')</label>
   <action type=\"exit\">BUTTON_PKGS_INSTALL</action>
  </button>
  <button cancel></button>
### <snip> ###
if [ "`echo "$RETPARAMS" | grep '^EXIT' | grep -E 'BUTTON_PKGS_INSTALL|BUTTON_PKGS_DOWNLOADONLY'`" != "" ];then
How could we default to BUTTON_PKGS_INSTALL ?
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#10 Post by zigbert »

Code: Select all

  <button>
   <label>$(gettext 'Download-only selected packages')</label>
   <action type=\"exit\">BUTTON_PKGS_DOWNLOADONLY</action>
  </button>
  <button can-default=\"true\" has-default=\"true\">
   <label>$(gettext 'Download-and-install selected packages')</label>
   <action type=\"exit\">BUTTON_PKGS_INSTALL</action>
  </button>
  <button cancel></button> 

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#11 Post by mavrothal »

gtkdialog fails with

Code: Select all

ERROR **: gtkdialog: Error in line 38, near token '<button>': syntax error
ie at line

Code: Select all

<button can-default=\"true\" has-default=\"true\"> 
this is either with or without

Code: Select all

export BUTTON_PKGS_INSTALL=true
I'm wondering if predefined defaults are even in the logic of gtkdialog.
Will not be much dialog going on if we succeed implementing this...
Maybe set flags and bypass dialog altogether providing the desired $RETPARAMS directly?

Latter: tried providing $RETPARAMS with a flag. No easy way to bypass the dialogs without major recoding in the dependency check part of installpreview.sh :evil:
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#12 Post by zigbert »

mavrothal
If you want to, please send over the script after you have done your stuff. I can do the gui-code after your specifications.


Sigmund

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#13 Post by mavrothal »

zigbert wrote:mavrothal
If you want to, please send over the script after you have done your stuff. I can do the gui-code after your specifications.
Zigbert
here is a first attempt. The GUI (and the tree refresh codding) in installwindow.sh is really poor...
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
rufwoof
Posts: 3690
Joined: Mon 24 Feb 2014, 17:47

#14 Post by rufwoof »

I have a RoxApp directory from which I can load PET's/SFS's (or run scripts).

As part of that a gtkdialog passes the 'app' name to a loadprog script, which contains multiple case statements, one for each app/function.

I run frugal, with no save file, so I sym link each app's config to outside of puppy space as part of that sfs or pet load (preserve config changes across reboots).

To that end I modified petget to comment out all of the interactions and called that petgetquiet and use that to load pet's (I also have a sfsloadquiet for loading sfs's).

i.e. case statement in loadprog for Skype4 selection

Code: Select all

(Skype4)

   P=`which skype` export P
    if [ "$P" == "" ]; then
      yaf-splash -bg orange -text "Loading Skype" &
      X3PID=$!
      cd ~
      rm -rf /root/.Skype
      ln -s $APP_DIR/root/.Skype .Skype
      cp $APP_DIR/.pulseaudio-2.0.w53.pet /EXTRAS/.
      cp $APP_DIR/.skype-4.3.0.37-w5.pet /EXTRAS/.
      $APP_DIR/.petgetquiet /EXTRAS/.pulseaudio-2.0.w53.pet 
      $APP_DIR/.petgetquiet /EXTRAS/.skype-4.3.0.37-w5.pet 
      kill $X3PID
    else
      yaf-splash -bg orange -text "Skype already installed" &
      X3PID=$!
      sleep 2
      kill $X3PID
    fi
    pulseaudio --start;skype;pulseaudio --kill &
    exit;;
.... where petgetquiet is :

Code: Select all

#!/bin/sh
#(c) Copyright Barry Kauler 2009, puppylinux.com
#2009 Lesser GPL licence v2 (http://www.fsf.org/licensing/licenses/lgpl.html).
#Note: Puppy Package Manager is started from /usr/local/petget/pkg_chooser.sh for the GUI.
#'petget' is for commandline execution, especially from ROX-Filer.
#If passed param is a pkg name preceded by a + to install pkg, - to uninstall pkg.
# example: +xbubble-0.2.4
#For integration with Rox-Filer, commandline is a .pet|.deb|.tgz|.tar,gz with absolute path, install.
# ex: petget /root/xbubble-0.2.4.pet
#For integration with browser, ex: petget http://somewhere.on.internet/xbubble-0.2.4.pet
#Note, petget also get called from /etc/rc.d/rc.update to remove packages. ex:
# petget -xbubble-0.2.4
# ...when X not running, removal will not put up any DLG windows, will remove without question.
#w482 restart jwm immediately to update menu.
#v424 fix .pet in path with space chars.
#100616 add support for .txz slackware pkgs.
#101116 call download_file to download pkg, instead of direct run of wget.
#101221 yaf-splash fix.
#110505 support sudo for non-root user.
#110523 support for rpm pkgs.
#120101 01micko: jwm >=547 has -reload, no screen flicker.
#120116 rev. 514 introduced icon rendering method which broke -reload at 547. fixed at rev. 574.
#120203 BK: internationalized.
#120323 replace 'xmessage' with 'pupmessage'.

export TEXTDOMAIN=petget___petget
export OUTPUT_CHARSET=UTF-8

[ "`whoami`" != "root" ] && exec sudo -A ${0} ${@} #110505

[ ! $1 ] && exit

#export LANG=C
. /etc/DISTRO_SPECS #has DISTRO_BINARY_COMPAT, DISTRO_COMPAT_VERSION

PASSEDPARAM="$1"

if [ "`echo -n "$PASSEDPARAM" | grep '^\\-'`" != "" ];then
 #remove a package...
 PKGNAME="`echo -n "$PASSEDPARAM" | cut -c 2-99`"
 TREE2="$PKGNAME"
 export TREE2
 /usr/local/petget/removepreview.sh
 exit
fi

#want to install a pkg...

COMPAT_EXT=""
case $DISTRO_BINARY_COMPAT in
 slackware)
  COMPAT_EXT=".tgz"
 ;;
 debian|ubuntu)
  COMPAT_EXT=".deb"
 ;;
 arch)
  COMPAT_EXT=".tar.gz"
 ;;
 scientific|redhat|mandriva|mageia) #110523
  COMPAT_EXT=".rpm"
 ;;
esac

#what type is it...
PASSEDBASE="`basename "$PASSEDPARAM"`"
case $PASSEDBASE in
 *.pet)
  EXT=".pet"
 ;;
 *.deb)
  EXT=".deb"
 ;;
 *.tgz)
  EXT=".tgz"
 ;;
 *.txz)
  EXT=".txz"
 ;;
 *.tar.gz)
  EXT=".tar.gz"
 ;;
 *.rpm) #110523
  EXT=".rpm"
 ;;
 *)
  EXT=""
 ;;
esac

#download if required...
PKGNAME=""
if [ "`echo -n "$PASSEDPARAM" | grep -E '^ftp|^http'`" != "" ];then
 cd /root
 #101116 use download_file utility...
 #rxvt -title "Puppy Package Manager: download" -bg orange -geometry 80x10 -e wget "$PASSEDPARAM"
 download_file "$PASSEDPARAM"
 PKGPATH="`dirname "$PASSEDPARAM"`" #really a url.
 FULLPKGNAME="`basename "$PASSEDPARAM"`"
 PKGMAIN="`basename "$PASSEDPARAM" ${EXT}`"
 if [ ! -f "$FULLPKGNAME" ];then
  pupmessage -bg red "$(gettext 'Sorry, failed to download') $FULLPKGNAME"
  exit
 fi
else
 #get rid of any leading '+'...
 PASSEDPARAM="`echo -n "$PASSEDPARAM" | sed -e 's%^+%%'`"
 FIRSTCHAR="`echo -n "$PASSEDPARAM" | cut -c 1`"
 if [ "$FIRSTCHAR" = "/" -o "$FIRSTCHAR" = "." ];then
  PKGPATH="`dirname "$PASSEDPARAM"`"
  FULLPKGNAME="`basename "$PASSEDPARAM"`"
  PKGMAIN="`basename "$PASSEDPARAM" ${EXT}`"
 else
  PKGPATH="`pwd`"
  if [ "$EXT" = "" ];then
   PKGMAIN="$PASSEDPARAM"
   FULLPKGNAME="${PKGMAIN}.pet"
   EXT=".pet"
  else
   FULLPKGNAME="`basename "$PASSEDPARAM"`"
   PKGMAIN="`basename "$PASSEDPARAM" ${EXT}`"
  fi
 fi
 cp -f "${PKGPATH}/${FULLPKGNAME}" /root/ 2>/dev/null #v424 fix if spaces in path.
fi
originPKGPATH="$PKGPATH" #w482
PKGPATH=/root

#split PKGMAIN, ex: FULLPKGNAME=xvidtune-1.0.1-i486-1.tgz has PKGNAME=xvidtune-1.0.1
 case $EXT in
  .deb)
   #deb ex: xsltproc_1.1.24-1ubuntu2_i386.deb  xserver-common_1.5.2-2ubuntu3_all.deb
   DB_nameonly="`echo -n "$PKGMAIN" | cut -f 1 -d '_'`"
   DB_pkgrelease="`echo -n "$PKGMAIN" | rev | cut -f 2 -d '_' | cut -f 1 -d '-' | rev`"
   prPATTERN="s%\\-${DB_pkgrelease}.*%%"
   PKGNAME="`echo -n "$PKGMAIN" | sed -e "$prPATTERN"`"
   DB_version="`echo "$PKGNAME" | cut -f 2 -d '_'`"
  ;;
  .pet)
   PKGNAME="$PKGMAIN"
   DB_version="`echo -n "$PKGNAME" | grep -o '\\-[0-9].*' | sed -e 's%^\-%%'`"
   xDB_version="`echo -n "$DB_version" | sed -e 's%\\-%\\\\-%g' -e 's%\\.%\\\\.%g'`"
   xPATTERN="s%${xDB_version}%%"
   DB_nameonly="`echo -n "$PKGNAME" | sed -e "$xPATTERN" -e 's%\\-$%%'`"
   DB_pkgrelease=""
  ;;
  .tgz|.txz)
   #slack ex: xvidtune-1.0.1-i486-1.tgz  printproto-1.0.4-noarch-1.tgz
   PKGNAME="`echo -n "$PKGMAIN" | sed -e 's%\\-i[3456]86.*%%' -e 's%\\-noarch.*%%'`"
   DB_version="`echo -n "$PKGNAME" | grep -o '\\-[0-9].*' | sed -e 's%^\\-%%'`"
   xDB_version="`echo -n "$DB_version" | sed -e 's%\\-%\\\\-%g' -e 's%\\.%\\\\.%g'`"
   xPATTERN="s%${xDB_version}%%"
   DB_nameonly="`echo -n "$PKGNAME" | sed -e "$xPATTERN" -e 's%\-$%%'`"
   DB_pkgrelease="`echo -n "$PKGMAIN" | sed -e 's%.*\\-i[3456]86%%' -e 's%.*\\-noarch%%' -e 's%^\\-%%'`"
  ;;
  .tar.gz)
   #arch ex: xproto-7.0.14-1-i686.pkg.tar.gz  trapproto-3.4.3-1.pkg.tar.gz
   PKGNAME="`echo -n "$PKGMAIN" | sed -e 's%\\-i[3456]86.*%%' -e 's%\\.pkg$%%' | rev | cut -f 2-9 -d '-' | rev`"
   DB_version="`echo -n "$PKGNAME" | grep -o '\\-[0-9].*' | sed -e 's%^\\-%%'`"
   xDB_version="`echo -n "$DB_version" | sed -e 's%\\-%\\\\-%g' -e 's%\\.%\\\\.%g'`"
   xPATTERN="s%${xDB_version}%%"
   DB_nameonly="`echo -n "$PKGNAME" | sed -e "$xPATTERN" -e 's%\\-$%%'`"
   DB_pkgrelease="`echo -n "$PKGMAIN" | sed -e 's%\\-i[3456]86.*%%' -e 's%\\.pkg$%%' | rev | cut -f 1 -d '-' | rev`"
  ;;
  .rpm) #110523
   #exs: hunspell-fr-3.4-1.1.el6.noarch.rpm
   PKGNAME="$PKGMAIN"
   DB_version="`echo -n "$PKGNAME" | grep -o '\\-[0-9].*' | sed -e 's%^\-%%'`"
   xDB_version="`echo -n "$DB_version" | sed -e 's%\\-%\\\\-%g' -e 's%\\.%\\\\.%g'`"
   xPATTERN="s%${xDB_version}%%"
   DB_nameonly="`echo -n "$PKGNAME" | sed -e "$xPATTERN" -e 's%\\-$%%'`"
   DB_pkgrelease=""
  ;;
 esac

cd "$PKGPATH" #well, this is /root

#confirm want to install...
export INSTALL_DIALOG="<window title=\"$(gettext 'Puppy Package Manager')\" icon-name=\"gtk-about\">
  <vbox>
  <pixmap><input file>/usr/local/lib/X11/pixmaps/question.xpm</input></pixmap>
   <text><label>$(gettext "Click 'OK' button to confirm that you wish to install this package:")</label></text>
   <text use-markup=\"true\"><label>\"<b>${FULLPKGNAME}</b>\"</label></text>
   <hbox>
    <button ok></button>
    <button cancel></button>
   </hbox>
  </vbox>
 </window>" 
### Rufwoof RETPARAMS="`gtkdialog3 --program=INSTALL_DIALOG`"
### Rufwoof eval "$RETPARAMS"
### Rufwoof [ "$EXIT" != "OK" ] && exit

#find entry in databases...
#pkgname|nameonly|version|pkgrelease|category|size|path|fullfilename|dependencies|description|
#optionally on the end: compileddistro|compiledrelease|repo| (fields 11,12,13)
pPATTERN='^'"$PKGNAME"'|'
if [ "$EXT" = ".pet" ];then
 DB_ENTRY="`cat /root/.packages/Packages-puppy-* | grep "$pPATTERN" | sort -r | head -n 1`"
else
 DB_ENTRY="`cat /root/.packages/Packages-${DISTRO_BINARY_COMPAT}-* | grep "$pPATTERN" | head -n 1`"
fi

#w482 doesn't matter if incomplete, installpkg.sh will read .desktop file for description and category...
#also, if .pet pkg has pet.specs, that will get written to /root/.packages/user-packages-installed
if [ "$DB_ENTRY" = "" ];then
 DB_ENTRY="${PKGNAME}|${DB_nameonly}|${DB_version}|${DB_pkgrelease}||||${FULLPKGNAME}|||"
fi

#w482 hack, if pkg was originally at /root then don't delete it...
[ "$originPKGPATH" = "$PKGPATH" ] && cp -f ${PKGPATH}/${FULLPKGNAME} ${PKGPATH}/${FULLPKGNAME}-TEMPBACKUP

#install pkg...
rm -f /tmp/petget_missing_dbentries-Packages-* 2>/dev/null
rm -f /tmp/petget-installed-pkgs-log 2>/dev/null
echo "$DB_ENTRY" > /tmp/petget_missing_dbentries-Packages-alien
/usr/local/petget/installpkg.sh $PKGPATH/$FULLPKGNAME
RETVAL=$?

#installpkg.sh has already done this...
rm -f $PKGPATH/$FULLPKGNAME 2>/dev/null
rm -f $PKGPATH/${PKGNAME}.tar.gz 2>/dev/null

#w482 hack, if pkg was originally at /root then don't delete it...
[ "$originPKGPATH" = "$PKGPATH" ] && mv -f ${PKGPATH}/${FULLPKGNAME}-TEMPBACKUP ${PKGPATH}/${FULLPKGNAME}

#announce result...
if [ $RETVAL -ne 0 -o ! -s /tmp/petget-installed-pkgs-log ];then
 export FAIL_DIALOG="<window title=\"$(gettext 'Puppy Package Manager')\" icon-name=\"gtk-about\">
  <vbox>
  <pixmap><input file>/usr/local/lib/X11/pixmaps/error.xpm</input></pixmap>
   <text use-markup=\"true\"><label>\"<b>$(gettext 'Error, package') ${FULLPKGNAME} $(gettext 'failed to install.')</b>\"</label></text>
   <hbox>
    <button ok></button>
   </hbox>
  </vbox>
 </window>" 
### Rufwoof gtkdialog3 --program=FAIL_DIALOG
 exit
fi

INSTALLEDMSG="`cat /tmp/petget-installed-pkgs-log`"
MENUMSG=""
INSTALLEDCAT="`echo -n "$INSTALLEDMSG" | rev | cut -f 1 -d ' ' | rev`"
if [ "$INSTALLEDCAT" = "none" ];then
 MENUMSG="<text><label>$(gettext '...note, this package does not have a menu entry.')</label></text>"
else
 MENUMSG="<text><label>$(gettext '...look in') '${INSTALLEDCAT}' $(gettext 'in the menu (bottom-left of screen) to run the application.')</label></text>"
fi

#installpkg.sh will have logged to /tmp/petget-installed-pkgs-log
export INSTALL_DIALOG="<window title=\"$(gettext 'Puppy Package Manager')\" icon-name=\"gtk-about\">
 <vbox>
 <pixmap><input file>/usr/local/lib/X11/pixmaps/ok.xpm</input></pixmap>
  <text><label>$(gettext 'The following package has been successfully installed:')</label></text>
  <text use-markup=\"true\"><label>\"<b>${INSTALLEDMSG}</b>\"</label></text>
  ${MENUMSG}
  <hbox>
   <button ok></button>
  </hbox>
 </vbox>
</window>
"
### Rufwoof gtkdialog3 --program=INSTALL_DIALOG

RESTARTMSG="$(gettext 'Please wait, updating help page and menu...')"
if [ "`pidof jwm`" != "" ];then #120101
 JWMVER=`jwm -v|head -n1|cut -d ' ' -f2|cut -d - -f2`
 if vercmp $JWMVER lt 574;then #120116 547 to 574.
  RESTARTMSG="$(gettext 'Please wait, updating help page and menu (the screen will flicker!)...')"
 fi
fi
[ "$INSTALLEDCAT" = "none" ] && RESTARTMSG="$(gettext 'Please wait, updating help page...')"
#/usr/X11R7/bin/yaf-splash -font "8x16" -outline 0 -margin 4 -bg orange -text "${RESTARTMSG}" &
### Rufwoof yaf-splash -bg orange -text "${RESTARTMSG}" &
X3PID=$!

#w0910 update image cache...
if [ -f /root/.packages/${PKGNAME}.files ];then
 if [ "`grep 'usr/share/icons/hicolor' /root/.packages/${PKGNAME}.files`" != "" ];then
### Rufwoof  gtk-update-icon-cache -f /usr/share/icons/hicolor/
 fi
fi

#master help index has to be updated...
/usr/sbin/indexgen.sh
#Reconstruct configuration files for JWM, Fvwm95, IceWM...
if [ "$INSTALLEDCAT" != "none" ];then
 /usr/sbin/fixmenus
 if [ "`pidof jwm`" != "" ];then #120101
  if vercmp $JWMVER lt 574;then #120116 547 to 574.
   jwm -restart #w482
  else
   jwm -reload
  fi
 fi
fi

kill $X3PID

###END###
i.e. in this image the apps icon above the first drive (lower left) when clicked brings up that gtkdialog to allow me to select what to load, which invokes the above script passing for instance Skype4 as a parameter, which uses petgetquiet to load pulseaudio and skype pets in that particular case.
Attachments
pgq.png
(60.13 KiB) Downloaded 251 times

User avatar
rufwoof
Posts: 3690
Joined: Mon 24 Feb 2014, 17:47

#15 Post by rufwoof »

Another method I use is to create a single sfs from multiple sfs's/pet's using createsfs

i.e. one of my build scripts that builds a multi-media single sfs contains

#!/bin/sh
./createsfs -f multimedia xvidcap-1.1.6-i486.pet audacity-1.3.14.pet Blender263.sfs openshot-1.4.0.sfs

which I then load using sfs_load_no copy (my quiet version of sfs_load that doesn't prompt)

Code: Select all

  (Multi-Media)

      # /root/.audacity-data
      # /root/.config/inkscape
      # /root/.openshot
      # /root/.blender ??
      # /root/.xvidcaprc (file)
            
      # Avoid duplicate loading
      P=".mesa_.sfs" export P
      T=0
      [[ `losetup | grep $P` ]] && T=1
      if [ $T -ne 1 ]; then
         yaf-splash -bg orange -text "Loading Mesa" &
         X3PID=$!
         cp $APP_DIR/.mesa_.sfs /EXTRAS/.
         $APP_DIR/.sfs_load_nocopy -c -q /EXTRAS/.mesa_.sfs
         kill $X3PID
      else	 
         yaf-splash -bg orange -text "Mesa already installed" &
         X3PID=$!
         sleep 2
         kill $X3PID
      fi
      P=".MM_.sfs" export P
      T=0
      [[ `losetup | grep $P` ]] && T=1
      if [ $T -ne 1 ]; then
         yaf-splash -bg orange -text "Loading MM SFS" &
         X3PID=$!
         cp $APP_DIR/.MM_.sfs /EXTRAS/.
         $APP_DIR/.sfs_load_nocopy -c -q /EXTRAS/.MM_.sfs
         # believe openshot config directory also as blender config
         cd ~
         rm -rf .openshot
	 rm -rf .audacity-data
         rm -rf .xvidcaprc
         ln -s $APP_DIR/root/.openshot .openshot
         ln -s $APP_DIR/root/.audacity-data .audacity-data
         ln -s $APP_DIR/root/.xvidcaprc .xvidcaprc
         cd .config
         rm -rf inkscape
         ln -s $APP_DIR/root/.config/inkscape inkscape
         kill $X3PID
      else	 
         yaf-splash -bg orange -text "Multi-Media already installed" &
         X3PID=$!
         sleep 2
         kill $X3PID
      fi
      exit;;

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#16 Post by mavrothal »

rufwoof,
these are very interesting however I have a hard time understanding how they address my "problem" ie passing gtkdialog results as defaults without user intervention (without selecting a package or clicking "ok" etc).
Could you point it out if in the above code, if there?

I'm currently implementing this by conditionally providing the parameter values "fished out" from the option source files with various linux-utils, but I'm hopping for a simpler/better method :wink:
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

Post Reply