Page 34 of 76

Posted: Wed 01 Feb 2012, 16:34
by jpeps
zigbert wrote:
jpeps wrote:Wouldn't it be posible to eliminate the timer altoget<action>if true refresh:UPDATE_GUI</action>
her? If something like a new track gets played, an input file gets flagged and the checkbox gets refreshed.
What will make the checkbox reread the inputfile?
I don't know what the user clicks to play a track, but something like: (This is linked to another checkbox).

<action>if true refresh:UPDATE_GUI</action>

I don't know if the refresh could be triggered by some some initiated process. Probably the user would have to click on something.

Posted: Wed 01 Feb 2012, 16:50
by zigbert
jpeps wrote:I don't know what the user clicks to play a track, but something like: (This is linked to another checkbox).

<action>if true refresh:UPDATE_GUI</action>
This would only work for song the user actually clicked on (or selected by keyboard). But what about the next song in the playlist ...

Posted: Wed 01 Feb 2012, 17:30
by jpeps
zigbert wrote:
jpeps wrote:I don't know what the user clicks to play a track, but something like: (This is linked to another checkbox).

<action>if true refresh:UPDATE_GUI</action>
This would only work for song the user actually clicked on (or selected by keyboard). But what about the next song in the playlist ...
I guess flagged processes would need to be handled on the script level, which might include loading a new window.

Posted: Wed 01 Feb 2012, 18:20
by zigbert
jpeps wrote:I guess flagged processes would need to be handled on the script level, which might include loading a new window.
If that was acceptable for the project, it would sure be a working solution.


Sigmund

Posted: Fri 03 Feb 2012, 16:24
by technosaurus
I think there was a partial fix in svn for this already, but for slow to start apps instead of:

Code: Select all

export MAIN='...stuff...'
gtkdialog -p MAIN
Try

Code: Select all

gtkdialog -s <<< '...stuff...'
Or

Code: Select all

gtkdialog -s < /pathto/file
This also works, but will need to make sure previous dialogs are closed before echoing a new one

Code: Select all

#!/bin/sh
mkfifo /tmp/gtkmsg
while ([ -e /tmp/gtkmsg ]) do
gtkdialog -s < /tmp/gtkmsg 2>/dev/null
done &
now you can just echo your dialogs to /tmp/gtkmsg and they will start even faster since gtkdialog is already running

you can still pipe the output of the while loop through a while-read-case like this:

Code: Select all

#!/bin/sh
mkfifo /tmp/gtkmsg
while ([ -e /tmp/gtkmsg ]) do
gtkdialog -s < /tmp/gtkmsg 2>/dev/null |while read LINE || [ "$LINE" ] ;do
  case "$LINE" in
#your case here:
    *=*)eval $LINE;;
    *)echo "$LINE";;
  esac
done &
HTH
-Brad

Edit: forgot to mention, use rm -f /tmp/gtkmsg to stop the gtkdialog daemon process

Posted: Fri 03 Feb 2012, 19:27
by Dougal
zigbert wrote:
jpeps wrote:I don't know what the user clicks to play a track, but something like: (This is linked to another checkbox).

<action>if true refresh:UPDATE_GUI</action>
This would only work for song the user actually clicked on (or selected by keyboard). But what about the next song in the playlist ...
This can be done with a fifo:

Code: Select all

#!/bin/sh
Fifo=/tmp/myfifo
[ -p "$Fifo" ] || mkfifo "$Fifo"

# First process, runs in background with stdout tied to "$Fifo"
for i in $(seq 1 10) ; do
	echo $i
	sleep 1
done > "$Fifo" &

# Second process, event bound (without timer wakeups)
# This loop will terminate when the OTHER END of the pipe is released (by the above process)
while read j ; do
	echo "read $j"
done < "$Fifo"

rm "$Fifo"
Note that you can also use different file descriptors (rather than stdout): my distro-building script has functions that are redirected to/from more than one fifo.
For example:

Code: Select all

#!/bin/sh
Fifo1=/tmp/myfifo1
[ -p "$Fifo1" ] || mkfifo "$Fifo1"
Fifo2=/tmp/myfifo2
[ -p "$Fifo2" ] || mkfifo "$Fifo2"

process1(){
for i in $(seq 1 3) ; do
	echo $i >&3
	sleep 1
	echo $((i*2)) >&4
	sleep 1
done
}

process1 3> "$Fifo1" 4> "$Fifo2" &

while read j ; do
	echo "j=$j"
done < "$Fifo1" &
while read k ; do
	echo "k=$k"
done < "$Fifo2" &

wait

rm "$Fifo1"
rm "$Fifo2"
So maybe have a shell embedded inside a widget that has a loop that reads from a fifo...

Posted: Sat 04 Feb 2012, 23:50
by zigbert
So maybe have a shell embedded inside a widget that has a loop that reads from a fifo...
That is the basic issue with both a progressbar and a timer. It is not the widget itself that uses cpu-power, but the checking loop.


Thank you, I did not know there was something called FIFO!!!
Sigmund

Posted: Sun 05 Feb 2012, 00:23
by jpeps
zigbert wrote:
So maybe have a shell embedded inside a widget that has a loop that reads from a fifo...
That is the basic issue with both a progressbar and a timer. It is not the widget itself that uses cpu-power, but the checking loop.


Thank you, I did not know there was something called FIFO!!!
Sigmund
Interesting thing, you can create chains of them to run at any time. Name the above script FifoScript and:

Code: Select all

mkfifo /tmp/newFifo 

FifoScript >/tmp/newFifo &

while read n; do
echo "in newFifo"
echo "$n"
done < /tmp/newFifo &

wait
rm /tmp/newFifo

Posted: Sun 05 Feb 2012, 01:36
by technosaurus
One other usage for named pipes (a.k.a. fifo) and gtkdialog would be to go ahead and spawn gtkdialog while computing needed data to generate the gui, so that gtkdialog is ready to go as soon as the data is ready.

Another would be to handle child window that you only want open one at a time. You can close the other child window and simply echo the variable(s) containing the child dialog to the pipe.

Note: if you echo something to the fifo while a dialog is already displayed, gtkdialog eats it. If we knew where/why the data goes it could be useful knowledge (such as for interprocess communication for stopping/starting/modifying etc...), but until then we just need to close one before opening another.

Side note: I started learning about named pipes because I was building multicall binaries and wanted to see the difference in resource usage if it just forked /proc/self/exe, so I needed a way to communicate back to the original running program. If you only look at top, it appeared to drastically reduce usage, but I wrote a little C program that gives real memory usage and it turns out that top double dips and will tell you that you have 256Mb used on a 128Mb system if you are running the same program (because the kernel will re-use readonly pages for new instances) so it turned out to be pretty unnecessary except as a useful learning excercise. Maybe not as pointless as my bash html to gtkdialog parser (it was really, really slow to display - now I realize I probably should have just used the -s flag instead of -p and not let it vanish into the ether on a pfix=ram shutdown)

Posted: Mon 06 Feb 2012, 18:43
by Dougal
technosaurus wrote:Note: if you echo something to the fifo while a dialog is already displayed, gtkdialog eats it. If we knew where/why the data goes it could be useful knowledge (such as for interprocess communication for stopping/starting/modifying etc...), but until then we just need to close one before opening another.
You could try looking at the code...
If you only look at top, it appeared to drastically reduce usage, but I wrote a little C program that gives real memory usage and it turns out that top double dips and will tell you that you have 256Mb used on a 128Mb system if you are running the same program (because the kernel will re-use readonly pages for new instances)
No. The programs are the ones who usually ask for more memory than they use, hence the VIR(tual) and RES(ident set size) fields in htop.
The kernel just gives them what they ask for, but it also allows you to use more memory than you actually have (you can control that via /proc/sys/vm/overcommit_memory).

Posted: Mon 06 Feb 2012, 19:55
by vovchik
Dear puppians,

Have a look here http://www.murga-linux.com/puppy/viewtopic.php?t=75778 for something probably relevant to this discussion.

With kind regards,
vovchik

hidden folder select

Posted: Mon 12 Mar 2012, 00:36
by brokenman
<hbox>
<text label="Source: " width-request="80"></text>
<entry editable="false" fs-title="Select an existing folder" fs-action="folder">
<variable>SDIR</variable>
</entry>
<button>
<input file stock="gtk-directory"></input>
<action>fileselect:SDIR</action>
</button>
</hbox>

Is it possible to have the dot folders (hidden folders) visible for selection?

Re: hidden folder select

Posted: Mon 12 Mar 2012, 01:09
by seaside
brokenman wrote:
Is it possible to have the dot folders (hidden folders) visible for selection?
brokenman,

If the dialog is right-clicked, a menu comes up with a "show hidden files" option.

cheers,
s

Posted: Thu 15 Mar 2012, 01:41
by brokenman
Thanks. I guess what i really meant is 'Is it possible to have .dir visible by default?'

Posted: Thu 15 Mar 2012, 08:35
by disciple
Yes, but it applies to all programs using the GTK file selector, not just gtkdialog programs.
I thought it remembered after you changed it by the right-click method... but maybe some programs remember the setting independently rather than using a system wide setting.
If it doesn't change system wide, find a file on your system something like /root/.config/gtk-2.0/gtkfilechooser.ini
In it there is a setting `ShowHidden=false`. Change it to true.

Posted: Fri 16 Mar 2012, 01:00
by brokenman
find a file on your system something like /root/.config/gtk-2.0/gtkfilechooser.ini
In it there is a setting `ShowHidden=false`. Change it to true.
Yes. That's what i was looking for. Thanks very much. I didn't even realize a config file was created!

page full of script examples

Posted: Sat 05 May 2012, 16:33
by don570
There's a single page full of script examples for beginners.
A very convenient resource. HERE

and the user manual is HERE


and stock icons are listed HERE



___________________________________________________

press the Enter key

Posted: Sat 12 May 2012, 19:47
by don570
To explain how it is possible to press the Enter key to
input the data to your program I have written a little script.

Just look at the script and run it and you will
understand the method that Zigbert explains on the first page.

Decompress to obtain script.
_________________________________________________

Posted: Tue 22 May 2012, 13:36
by glene77is
Don 570,
Thanks for the demo script.
Just what I needed to begin with.
Resolved some myterious syntax that was killing my efforts.
Thanks. :D
glene77is

Posted: Sat 26 May 2012, 17:13
by don570
Porteus is getting behind the gtkdialog bandwagen :lol:

http://forum.porteus.org/viewtopic.php?f=94&t=1132

Some examples
http://puppy2.org/slaxer/Porteus/Gtkdia ... color.html

_________________________________________________________