The time now is Sat 21 Apr 2018, 04:11
All times are UTC - 4 |
Page 45 of 56 [833 Posts] |
Goto page: Previous 1, 2, 3, ..., 43, 44, 45, 46, 47, ..., 54, 55, 56 Next |
Author |
Message |
zigbert

Joined: 29 Mar 2006 Posts: 6541 Location: Valåmoen, Norway
|
Posted: Tue 27 Nov 2012, 19:59 Post subject:
|
|
Thunor
r480 Works!!!
But if function_is_true(argument) should be if command_is_true(argument) - at least in my case.
Sigmund
_________________ Stardust resources
|
Back to top
|
|
 |
thunor

Joined: 14 Oct 2010 Posts: 350 Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
|
Posted: Wed 28 Nov 2012, 08:03 Post subject:
|
|
zigbert wrote: | ... But if function_is_true(argument) should be if command_is_true(argument) - at least in my case. ... |
Yeah, I'm working on the wiki at the moment which I haven't committed yet, but you've got a choice of these:
Code: | +------------------------------+-------------------------------+---------------+
| Type | Description | Argument |
+------------------------------+-------------------------------+---------------+
| active_is_true(argument) | Active state of toggle widget | Variable name |
| active_is_false(argument) | Active state of toggle widget | Variable name |
| command_is_true(argument) | Output of shell command | Shell command |
| command_is_false(argument) | Output of shell command | Shell command |
| file_is_true(argument) | Contents of a file | Filename |
| file_is_false(argument) | Contents of a file | Filename |
| sensitive_is_true(argument) | Sensitive state of widget | Variable name |
| sensitive_is_false(argument) | Sensitive state of widget | Variable name |
| visible_is_true(argument) | Visible state of widget | Variable name |
| visible_is_false(argument) | Visible state of widget | Variable name |
+------------------------------+-------------------------------+---------------+ |
With command_is_true/false() the widget variables are placed into the shell which is not necessary for the other functions. Other than file_is_true/false(), the rest are simple widget property reads.
Regards,
Thunor
|
Back to top
|
|
 |
thunor

Joined: 14 Oct 2010 Posts: 350 Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
|
Posted: Thu 29 Nov 2012, 08:10 Post subject:
|
|
The action directive's documented type="function" attribute I've renamed function="type" so that we now have:
Code: | <action signal="type" function="type" condition="type">parameter</action> |
The docs and examples have been updated and of course type="function" is still supported (it was really type="type" but I think it's pretty obvious why it wasn't documented as such).
I'm not sure if anyone is aware of the fact that it is possible to use all of the action's attributes together as shown above which isn't obvious from the wiki/docs or examples therefore you'd never need to use the shortcut function:parameter because you can always move the function into its own function="type" attribute.
|
Back to top
|
|
 |
zigbert

Joined: 29 Mar 2006 Posts: 6541 Location: Valåmoen, Norway
|
Posted: Thu 29 Nov 2012, 19:21 Post subject:
|
|
Yes, I am boring you - I know.....
I have tried so many times to get the reorderable attribute to work properly. - Not in an example, but in real code. With that I mean to update the <input> after each move. - Else the inputfile are not the same as the outputfile. So my simple test code looks like this, but it does not work. There MUST be a way .... ???
Code: | #!/bin/sh
echo "gtk-ok|row1
|row2
|row3
" > /tmp/inputfile
echo '
<window>
<vbox>
<tree reorderable="true">
<label>A|B</label>
<variable>tree</variable>
<height>150</height>
<input file stock-column="0">/tmp/inputfile</input>
<output file>/tmp/outputfile</output>
<action signal="button-release-event">save:tree</action>
<action signal="button-release-event">cut -d"|" -f2- /tmp/outputfile > /tmp/inputfile</action>
<action signal="button-release-event">refresh:tree</action>
</tree>
</vbox>
</window>
' | gtkdialog -s |
Thanks for any help
Sigmund
_________________ Stardust resources
|
Back to top
|
|
 |
zigbert

Joined: 29 Mar 2006 Posts: 6541 Location: Valåmoen, Norway
|
Posted: Sat 01 Dec 2012, 18:19 Post subject:
|
|
Thunor
I think there is a minor bug in r483.
condition="command_is_true()" does not work, but using if as earlier versions, it works. command_is_false works.
This is how I set it to work
Code: | <action signal="button-release-event" condition="command_is_false([ $COPY_FORMAT != flac ] && echo false)">enable:VBOX_CONVERT1</action>
<action signal="button-release-event" condition="if command_is_true([ $COPY_FORMAT = flac ] && echo true)">disable:VBOX_CONVERT1</action> |
Sigmund
_________________ Stardust resources
|
Back to top
|
|
 |
thunor

Joined: 14 Oct 2010 Posts: 350 Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
|
Posted: Sat 01 Dec 2012, 23:14 Post subject:
|
|
zigbert wrote: | ...
Code: | <action signal="button-release-event" condition="if command_is_true([ $COPY_FORMAT = flac ] && echo true)">disable:VBOX_CONVERT1</action> |
... |
Check the terminal: if a condition is not recognised then it is ignored and you'll see "Unkown expression...", therefore it won't stop the execution of the action because it's not valid.
"if command_is_true(...)" will result in "Unkown expression..." and it'll be ignored.
Try playing with examples/miscellaneous/conditional_actions in r484 and see if you can break it because it's working for me.
|
Back to top
|
|
 |
thunor

Joined: 14 Oct 2010 Posts: 350 Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
|
Posted: Sat 01 Dec 2012, 23:45 Post subject:
|
|
I really should turn my laptop off as it's approaching 4am, but just place <action signal="button-release-event">echo COPY_FORMAT=$COPY_FORMAT</action> above your problematic line and then you'll know what the outcome should be.
Goodnight and god morgen
|
Back to top
|
|
 |
zigbert

Joined: 29 Mar 2006 Posts: 6541 Location: Valåmoen, Norway
|
Posted: Sun 02 Dec 2012, 05:28 Post subject:
|
|
What an idiot I met in the mirror this morning.....
It is all clear now (command_is_true). The major bug is between the keyboard and the chair. For pMusic testing I have made a gtkdialog5 symlink to gtkdialog-0.8.2 which is preferred by pMusic if exist. There was no chance for the new code to work.
Sorry for bothering you.
Sigmund
Code: | Goodnight and god morgen | Det er faktisk en vidunderlig morgen!
Kan vi fortsette å skrive på norsk. Det går veldig mye fortere for meg....
_________________ Stardust resources
|
Back to top
|
|
 |
EDDIE_THE_HEAD

Joined: 02 Dec 2012 Posts: 15 Location: Córdoba, Argentina
|
Posted: Sun 02 Dec 2012, 22:48 Post subject:
HELP!!! |
|
Hi there! I am new to the forum, and I come seeking for help
A couple of days ago I came across gtkdialog and I found it quite interesting. While tampering with it I encountered some trouble regarding variables and functions.
Take this code, for example:
Code: |
#!/bin/bash
now () {
date > /tmp/date
}
export -f now
export script='
<vbox>
<entry>
<variable>ENTRY_DATE</variable>
<input>cat /tmp/date</input>
</entry>
<button>
<label>Refresh</label>
<action>now</action>
<action>refresh:ENTRY_DATE</action>
</button>
</vbox>'
gtkdialog -p script
|
(It belongs to one of the examples in zigbert's tips).
When I run it and click the 'Refresh' button, it seems that the dialog doesn't recognize the function 'now', for I get the following error:
Code: | sh: 1: now: not found |
As you see, the function was exported to the environment so this shouldn't be happening. Any ideas?
As far as variables are concerned, I haven't been able to figure out how to assign new values to pre-declared variables inside the action tags, for example:
Code: |
#!/bin/bash
MY_VAR="DEFAULT VALUE"
export script='
<vbox>
<entry>
<variable>ENTRY</variable>
<input>echo '"$MY_VAR"'</input>
</entry>
<button>
<label>Change</label>
<action>MY_VAR="NEW VALUE"</action>
<action>refresh:ENTRY</action>
</button>
</vbox>'
gtkdialog -p script
|
My intention here is to change the value of the entry field by clicking a button, though I click it and nothing happens. I have tried exporting MY_VAR, but still nothing.
I appreciate any help you can provide!!
|
Back to top
|
|
 |
thunor

Joined: 14 Oct 2010 Posts: 350 Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
|
Posted: Mon 03 Dec 2012, 10:20 Post subject:
Re: HELP!!! |
|
EDDIE_THE_HEAD wrote: | ...
Code: | #!/bin/bash
...
<action>now</action>
... |
...
Code: | ...
<action>MY_VAR="NEW VALUE"</action>
... |
... |
Welcome EDDIE_THE_HEAD
Exporting functions is a bashism and since you do indeed have /bin/bash at the top of your script, everything would appear to be fine but the contents of the action will be executed as /bin/sh -c now because gtkdialog was written with C and the C library uses /bin/sh, so I'll hazard a guess that you are using Ubuntu and your /bin/sh is a symlink to dash which doesn't support exported functions.
The easy way to deal with this is to use <action>/bin/bash -c now</action> which gtkdialog will ultimately execute as /bin/sh -c /bin/bash -c now.
You could not use bashisms and instead write portable script:
Code: | #!/bin/sh
## Create the function as a file somewhere (/tmp will do for this).
echo "funcNow() {
date > /tmp/date
}" > /tmp/funcNow
## The action below will first include the function (known as sourcing)
## and then execute it.
script='
<vbox>
<entry>
<variable>ENTRY_DATE</variable>
<input>cat /tmp/date</input>
</entry>
<button>
<label>Refresh</label>
<action>. /tmp/funcNow; funcNow</action>
<action>refresh:ENTRY_DATE</action>
</button>
</vbox>'
export script
gtkdialog -p script |
export script= is a bashism too which is why I modified it.
Widget variables (the ones that you have created and named yourself) will be placed into the shell when an action executes so that you can read the contents of widgets, but you can't change the contents of widgets by modifying their variables -- you'll likely want something like this:
Code: | <entry>
<variable>ENTRY</variable>
<input file>/tmp/inputfile</input>
</entry>
<button>
<label>Change</label>
<action>echo "NEW VALUE" > /tmp/inputfile</action>
<action>refresh:ENTRY</action>
</button> |
Regards,
Thunor
|
Back to top
|
|
 |
EDDIE_THE_HEAD

Joined: 02 Dec 2012 Posts: 15 Location: Córdoba, Argentina
|
Posted: Mon 03 Dec 2012, 14:08 Post subject:
Re: HELP!!! |
|
thunor wrote: |
Regards,
Thunor |
Thanks a lot Thunor!! You were right, I am using Ubuntu and that was exactly the problem.
One last question (for now ): I understand that you can't change the content of a widget by assigning new values to their variables, but say you wanna change the content of a variable (not related to a widget) by clicking a button or with any other signal, how can you do it? For example:
Code: |
#!/bin/bash
MY_VAR="DEFAULT VALUE"
export script='
<vbox>
<button>
<label>Change</label>
# What should I put here to assign another value to MY_VAR??
<action></action>
</button>
</vbox>'
gtkdialog -p script
echo MY_VAR
|
I've tried many things but no matter what the last line keeps printing "DEFAULT VALUE". Perhaps storing the variable in another file??
|
Back to top
|
|
 |
thunor

Joined: 14 Oct 2010 Posts: 350 Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
|
Posted: Mon 03 Dec 2012, 21:09 Post subject:
Re: HELP!!! |
|
EDDIE_THE_HEAD wrote: | ... I've tried many things but no matter what the last line keeps printing "DEFAULT VALUE". Perhaps storing the variable in another file?? |
That's exactly what you have to do. You need to maintain variables as files. Anything other than a very simple program will require quite a few variables so I personally create a temporary folder in /tmp and store them in there, then delete the folder on program exit.
For the record, if you want shell variables to be visible to subshells then you have to export them, but any changes that you might make to exported variables will be lost when the subshell exits.
See this page.
I don't know if you have the examples that are included with the source package but you should have a look at them.
Cheers and have fun
Thunor
|
Back to top
|
|
 |
EDDIE_THE_HEAD

Joined: 02 Dec 2012 Posts: 15 Location: Córdoba, Argentina
|
Posted: Mon 03 Dec 2012, 22:46 Post subject:
Re: HELP!!! |
|
thunor wrote: |
Cheers and have fun
|
Thanks again!! Yes, I've had a look at some of the examples but I must confess I rather felt at a loss while trying to analyze them. Now with your explanations everything is starting to add up. I will be playing with gtkdialog for the next few days, working on some project for university. Wish me luck!!
Greetings from Argentina!
|
Back to top
|
|
 |
EDDIE_THE_HEAD

Joined: 02 Dec 2012 Posts: 15 Location: Córdoba, Argentina
|
Posted: Wed 05 Dec 2012, 00:47 Post subject:
|
|
Thunor, me again
So far the only widgets that have given me trouble are the menu, menubar and menuitems. My gtkdialog seems to be ignoring them completely. No matter how I define them, they won't appear in my dialogs.
I've attached a screen capture for you to see. The code belongs to one of your examples.
I am inclined to think that it has something to do with Ubuntu. Or maybe something went wrong during the installation of the package, which would be weird 'cause neither configure nor make install complained...
Any hints??
EDDIE_THE_HEAD a.k.a the BALL BUSTER
Description |
|

Download |
Filename |
screen.jpg |
Filesize |
60.74 KB |
Downloaded |
463 Time(s) |
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 4786 Location: Kingwood, TX
|
Posted: Wed 05 Dec 2012, 02:52 Post subject:
|
|
in ubuntu /bin/sh is dash, so $() does not work, try changing it to backticks or the first line to #!/bin/bash
It looks like Thunor has fixed some bashisms in latest source
_________________ Check out my github repositories. I may eventually get around to updating my blogspot.
|
Back to top
|
|
 |
|
Page 45 of 56 [833 Posts] |
Goto page: Previous 1, 2, 3, ..., 43, 44, 45, 46, 47, ..., 54, 55, 56 Next |
|
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
|