Problem with gtkdialog timer widget
I have been struggling with the GUI interface of BluePup not
performing as I want, then this morning discovered that the timers are
not working. There are three of them, which is probably not very
efficient, but anyway, here is one of them:
<timer visible="false" file-monitor="true" interval="1">
<variable>TIMERNEW</variable>
<input file>/tmp/bluepup/found-new-devices</input>
<action signal="file-changed">clear:BTNEWDEVICE</action>
<action signal="file-changed">refresh:BTNEWDEVICE</action>
<action signal="file-changed">clear:BTREGDEVICE</action>
<action signal="file-changed">refresh:BTREGDEVICE</action>
</timer>
What is weird is that the action tags only execute once. That's it,
after that, changing /tmp/bluepup/found-new-devices does nothing. I
verified by putting in an action to write to a file. The file gets
written once, after that, nothing.
Hmmm. Using gtkdialog 0.8.4 pre-release, r514. Well, I can probably
design the XML differently, so don't use timers. The timer seemed
convenient, so that a separate script can write to that file and update
things in the GUI. Oh, and when exit, the variable TIMERNEW is set to
"true", meaning that the timer was still running, right up to
exiting.
EDIT, simple timer works:
Forum member MochiMoppel posted a simple example, that works:
http://murga-linux.com/puppy/viewtopic.php?t=38608&start=1425
...and, as he observed, clicking the button
outputs "working signal" twice. Yes, I remember that behaviour, it is
dangerous, can cause unexpected consequences in a gtkdialog GUI. The
button action needs to specify some condition, such as "button release
event" (whatever the correct name is).
Doing this from another terminal "echo
abc > /tmp/myfile" causes one "working signal", repeat, again works.
Writing the same data to the file is fine, it works on file modify date,
not the content. However, "touch /myfile" does not work!
I will take another look at my code. I have
three timers. One of them is a "one shot", performs some actions when
the GUI starts, then disables itself -- maybe that brings down the
others also? Or, maybe gtkdialog chokes on three timers?
EDIT, fixed:
The above "EDIT" gave me the hint, that "touch <file>" does not
work, have to actually write to the file, even if the same content as
before. So, I modified my code:
#touch /tmp/bluepup/found-new-devices
#...that doesn't work, have to write to it...
cp -f /tmp/bluepup/found-new-devices /tmp/bluepup/found-new-devicesBAK
cat /tmp/bluepup/found-new-devicesBAK > /tmp/bluepup/found-new-devices
...that did the trick!
Tags: easy