gtkdialog problem

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
ITSMERSH

gtkdialog problem

#1 Post by ITSMERSH »

Hi.

I have a list in a gui to choose exclusive selections by radio buttons.

But I would like to have something like toggle button, as this can have an icon, which looks much nicer.
I tried to use toggle button combined with

<input file>PathToFileContainingStoredOption<input>
plus
<input file icon="myicon"><input>

though, this doesn't work.

I don't get the stored option from the file that way. Even the use of

file-monitor="true" auto-refresh="true"

doesn't change anything. It still refuses to work.

So, my question: is it possible to have radio buttons showing an icon and being auto refreshed from option stored into a file?


Just hope my problem's explained clear enough to understand...

ITSMERSH

#2 Post by ITSMERSH »

Ok.

At least

<default>'$(cat $APPDIR/data/useqtractoropt)'</default>

will give the stored option to the toggle button.

So, I think I can solve this temporarily by adding this line to all the toggle buttons.

Then: if a toggle button is selected (true) echoing "false" to the options-files of all the rest of the toggle buttons.

<action>if true echo "false" > $APPDIR/data/userosegardenopt</action>

Then: refreshing all the toggle buttons

<action>refresh:THEBUTTON</action>

However: still would be cool to have radio buttons with icons.

ITSMERSH

#3 Post by ITSMERSH »

This <action>refresh:THEBUTTON</action> still won't work! :?

No matter what I've tried. It won't refresh the button...

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#4 Post by wiak »

ITSMERSH wrote: <default>'$(cat $APPDIR/data/useqtractoropt)'</default>

will give the stored option to the toggle button.
I haven't as yet tried this (or looked at the relevant gtkdialog source code for this to see what's there), but wonder if <input> construct rather than <default> is what you are meaning in what your wish?

<input>'$(cat $APPDIR/data/useqtractoropt)'</input>

EDIT: or maybe just

<input>cat $APPDIR/data/useqtractoropt</input>



Hoping REFRESH toggle button will re-input as above (but maybe it doesn't?...). Since you seem to have tried many things, I guess you've already tried that and it doesn't work as you intend. I can only suggest you provide an actual complete small program to show what you want and see if someone knows off the top of their head.

wiak

ITSMERSH

#5 Post by ITSMERSH »

No,

<input>'$(cat $APPDIR/data/useqtractoropt)'</input>

doesn't get the stored option from file (note: it's only true or false stored in such file) as <input> from file needs <input file> or for an (gtk cached) icon <input file icon="qtractor"> or even for the stock icons <input file stock="gtk-edit">.

For the toggle button <input file> seems to be reserved for the icon only, as the icon disappears when echoing true or false into that option file.

I will write a small program with two toggle buttons to show what I want to achieve.

ITSMERSH

#6 Post by ITSMERSH »

Ok,

here it is.

Code: Select all

#!/bin/sh
#------------------------------------------------------------------------------

[ ! -f $HOME/useprog1opt ] && echo "true" > $HOME/useprog1opt
[ ! -f $HOME/useprog2opt ] && echo "false" > $HOME/useprog2opt
[ ! -f $HOME/useprog3opt ] && echo "false" > $HOME/useprog3opt

# Simple GUI
ESCAPEGUIPART='<action signal="key-press-event" condition="command_is_true( [ $KEY_SYM = Escape ] && echo true )">exit:QUIT</action>'
TOGGLEBTNGUI='<window title="Toggle Button Test" icon-name="'$ICONONLY'" height-request="'$MIN_WINHGT'" default-height="'$WIN_HGT'" width-request="'$MIN_WINWTH'" default-width="'$WIN_WTH'">
<vbox>
	'"$GUIHEAD"'
	<vbox space-fill="true" space-expand="true">
		<togglebutton tooltip-text="  When clicking this button (Program 1 exclusive) the other buttons (Program 2 exclusive, Program 3 exclusive) should un-select automatically - just like the radio buttons do. The options are stored properly, though the GUI does not refresh.">
			<label>"Program 1 exclusive "</label>
			<input file icon="www48"></input>
			<default>'$(cat $HOME/useprog1opt)'</default>
			<variable>RUNPROG1OPT</variable>
			<action>if true echo "true" >'$HOME'/useprog1opt</action>
			<action>if false echo "false" >'$HOME'/useprog1opt</action>
			<action>if true echo "false" >'$HOME'/useprog2opt</action>
			<action>if true echo "false" >'$HOME'/useprog3opt</action>
			<action>refresh:RUNPROG1OPT</action>
			<action>refresh:RUNPROG2OPT</action>
			<action>refresh:RUNPROG3OPT</action>
		</togglebutton>
		<togglebutton tooltip-text="  When clicking this button (Program 2 exclusive) the other button (Program 1 exclusive, Program 3 exclusive) should un-select automatically - just like the radio buttons do. The options are stored properly, though the GUI does not refresh.">
			<label>"Program 2 exclusive "</label>
			<input file icon="edit48"></input>
			<default>'$(cat $HOME/useprog2opt)'</default>
			<variable>RUNPROG2OPT</variable>
			<action>if true echo "false" >'$HOME'/useprog1opt</action>
			<action>if true echo "true" >'$HOME'/useprog2opt</action>
			<action>if false echo "false" >'$HOME'/useprog2opt</action>
			<action>if true echo "false" >'$HOME'/useprog3opt</action>
			<action>refresh:RUNPROG1OPT</action>
			<action>refresh:RUNPROG2OPT</action>
			<action>refresh:RUNPROG3OPT</action>
		</togglebutton>
		<togglebutton tooltip-text="  When clicking this button (Program 3 exclusive) the other button (Program 1 exclusive, Program 2 exclusive) should un-select automatically - just like the radio buttons do. The options are stored properly, though the GUI does not refresh.">
			<label>"Program 3 exclusive "</label>
			<input file icon="archive48"></input>
			<default>'$(cat $HOME/useprog3opt)'</default>
			<variable>RUNPROG2OPT</variable>
			<action>if true echo "false" >'$HOME'/useprog1opt</action>
			<action>if true echo "false" >'$HOME'/useprog2opt</action>
			<action>if true echo "true" >'$HOME'/useprog3opt</action>
			<action>if false echo "false" >'$HOME'/useprog3opt</action>
			<action>refresh:RUNPROG1OPT</action>
			<action>refresh:RUNPROG2OPT</action>
			<action>refresh:RUNPROG3OPT</action>
		</togglebutton>
	</vbox>
</vbox>
'$ESCAPEGUIPART'
</window>'

export TOGGLEBTNGUI=$(echo "$TOGGLEBTNGUI" | sed 's/#[#~].*$//') # Strip comments
gtkdialog4 --class=TOGGLEBTNGUI -p TOGGLEBTNGUI --center >/dev/null

unset TOGGLEBTNGUI
When clicking a button (e.g. Program 3 exclusive) the other buttons (e.g Program 1 exclusive, Program 2 exclusive) should un-select automatically - just like the radio buttons do.

The options are stored properly, though the GUI refuses to refresh.

EDIT:

Sorry, there was a typo --> if fatruelse <-- fixed. :roll:

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#7 Post by wiak »

Is this not what you want? (though I guess you can have a <default> start up value as well but below starts up with previous results anyway; I'm actually using XenialDog with gtkwialog, but should be the same in Pup with gtkdialog I expect).

Code: Select all

#!/bin/sh
#------------------------------------------------------------------------------

[ ! -f $HOME/useprog1opt ] && echo "true" > $HOME/useprog1opt
[ ! -f $HOME/useprog2opt ] && echo "false" > $HOME/useprog2opt
[ ! -f $HOME/useprog3opt ] && echo "false" > $HOME/useprog3opt

# Simple GUI
ESCAPEGUIPART='<action signal="key-press-event" condition="command_is_true( [ $KEY_SYM = Escape ] && echo true )">exit:QUIT</action>'
TOGGLEBTNGUI='<window title="Toggle Button Test" icon-name="'$ICONONLY'" height-request="'$MIN_WINHGT'" default-height="'$WIN_HGT'" width-request="'$MIN_WINWTH'" default-width="'$WIN_WTH'">
<vbox>
   '"$GUIHEAD"'
   <vbox space-fill="true" space-expand="true">
      <togglebutton tooltip-text="  When clicking this button (Program 1 exclusive) the other buttons (Program 2 exclusive, Program 3 exclusive) should un-select automatically - just like the radio buttons do. The options are stored properly, though the GUI does not refresh.">
         <label>"Program 1 exclusive "</label>
         <input file icon="www48"></input>
         <input>cat $HOME/useprog1opt</input>
         <variable>RUNPROG1OPT</variable>
         <action>if true echo "true" >'$HOME'/useprog1opt</action>
         <action>if false echo "false" >'$HOME'/useprog1opt</action>
         <action>if true echo "false" >'$HOME'/useprog2opt</action>
         <action>if true echo "false" >'$HOME'/useprog3opt</action>
         <action>refresh:RUNPROG1OPT</action>
         <action>refresh:RUNPROG2OPT</action>
         <action>refresh:RUNPROG3OPT</action>
      </togglebutton>
      <togglebutton tooltip-text="  When clicking this button (Program 2 exclusive) the other button (Program 1 exclusive, Program 3 exclusive) should un-select automatically - just like the radio buttons do. The options are stored properly, though the GUI does not refresh.">
         <label>"Program 2 exclusive "</label>
         <input file icon="edit48"></input>
         <input>cat $HOME/useprog2opt</input>
         <variable>RUNPROG2OPT</variable>
         <action>if true echo "false" >'$HOME'/useprog1opt</action>
         <action>if true echo "true" >'$HOME'/useprog2opt</action>
         <action>if false echo "false" >'$HOME'/useprog2opt</action>
         <action>if true echo "false" >'$HOME'/useprog3opt</action>
         <action>refresh:RUNPROG1OPT</action>
         <action>refresh:RUNPROG2OPT</action>
         <action>refresh:RUNPROG3OPT</action>
      </togglebutton>
      <togglebutton tooltip-text="  When clicking this button (Program 3 exclusive) the other button (Program 1 exclusive, Program 2 exclusive) should un-select automatically - just like the radio buttons do. The options are stored properly, though the GUI does not refresh.">
         <label>"Program 3 exclusive "</label>
         <input file icon="archive48"></input>
         <input>cat $HOME/useprog3opt</input>
         <variable>RUNPROG3OPT</variable>
         <action>if true echo "false" >'$HOME'/useprog1opt</action>
         <action>if true echo "false" >'$HOME'/useprog2opt</action>
         <action>if true echo "true" >'$HOME'/useprog3opt</action>
         <action>if false echo "false" >'$HOME'/useprog3opt</action>
         <action>refresh:RUNPROG1OPT</action>
         <action>refresh:RUNPROG2OPT</action>
         <action>refresh:RUNPROG3OPT</action>
      </togglebutton>
   </vbox>
</vbox>
'$ESCAPEGUIPART'
</window>'

export TOGGLEBTNGUI=$(echo "$TOGGLEBTNGUI" | sed 's/#[#~].*$//') # Strip comments
gtkdialog4 --class=TOGGLEBTNGUI -p TOGGLEBTNGUI --center >/dev/null

unset TOGGLEBTNGUI

ITSMERSH

#8 Post by ITSMERSH »

What a difference...

Code: Select all

<input>cat $HOME/useprog2opt</input>
a day makes...

Code: Select all

<input>'$(cat $HOME/useprog2opt)</input>
This <input>cat $HOME/useprog2opt</input> seems to work as expected! 8)

Thanks! :D

Edit:

Applied to my Program and all works as expected and wanted out of the box!

Thanks again!

Post Reply