Gtkdialog Development
- thunor
- Posts: 350
- Joined: Thu 14 Oct 2010, 15:24
- Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
- Contact:
Yeah, I'm working on the wiki at the moment which I haven't committed yet, but you've got a choice of these:zigbert wrote:... But if function_is_true(argument) should be if command_is_true(argument) - at least in my case. ...
Code: Select all
+------------------------------+-------------------------------+---------------+
| 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 |
+------------------------------+-------------------------------+---------------+
Regards,
Thunor
- thunor
- Posts: 350
- Joined: Thu 14 Oct 2010, 15:24
- Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
- Contact:
The action directive's documented type="function" attribute I've renamed function="type" so that we now have:
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.
Code: Select all
<action signal="type" function="type" condition="type">parameter</action>
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.
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 .... ???
Thanks for any help
Sigmund
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: Select all
#!/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
Sigmund
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
Sigmund
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: Select all
<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
- thunor
- Posts: 350
- Joined: Thu 14 Oct 2010, 15:24
- Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
- Contact:
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.zigbert wrote:......Code: Select all
<action signal="button-release-event" condition="if command_is_true([ $COPY_FORMAT = flac ] && echo true)">disable:VBOX_CONVERT1</action>
"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.
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
Det er faktisk en vidunderlig morgen!
Kan vi fortsette å skrive på norsk. Det går veldig mye fortere for meg....
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: Select all
Goodnight and god morgen
Kan vi fortsette å skrive på norsk. Det går veldig mye fortere for meg....
- EDDIE_THE_HEAD
- Posts: 15
- Joined: Mon 03 Dec 2012, 02:24
- Location: Córdoba, Argentina
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:
(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:
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:
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!!
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: Select all
#!/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
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: Select all
sh: 1: now: not found
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: Select all
#!/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
I appreciate any help you can provide!!
- thunor
- Posts: 350
- Joined: Thu 14 Oct 2010, 15:24
- Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
- Contact:
Re: HELP!!!
Welcome EDDIE_THE_HEADEDDIE_THE_HEAD wrote:......Code: Select all
#!/bin/bash ... <action>now</action> ...
...Code: Select all
... <action>MY_VAR="NEW VALUE"</action> ...
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: Select all
#!/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
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: Select all
<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>
Thunor
- EDDIE_THE_HEAD
- Posts: 15
- Joined: Mon 03 Dec 2012, 02:24
- Location: Córdoba, Argentina
Re: HELP!!!
Thanks a lot Thunor!! You were right, I am using Ubuntu and that was exactly the problem.thunor wrote: Regards,
Thunor
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: Select all
#!/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
- thunor
- Posts: 350
- Joined: Thu 14 Oct 2010, 15:24
- Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
- Contact:
Re: HELP!!!
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.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??
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
- EDDIE_THE_HEAD
- Posts: 15
- Joined: Mon 03 Dec 2012, 02:24
- Location: Córdoba, Argentina
Re: HELP!!!
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!!thunor wrote: Cheers and have fun
Greetings from Argentina!
- EDDIE_THE_HEAD
- Posts: 15
- Joined: Mon 03 Dec 2012, 02:24
- Location: Córdoba, Argentina
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
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
- Attachments
-
- screen.jpg
- (60.74 KiB) Downloaded 572 times
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
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
It looks like Thunor has fixed some bashisms in latest source
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
- EDDIE_THE_HEAD
- Posts: 15
- Joined: Mon 03 Dec 2012, 02:24
- Location: Córdoba, Argentina
Yes, I get you, but that doesn't seem to be the problem. See this code:technosaurus wrote: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
Code: Select all
#!/bin/bash
DIALOG='
<menubar>
<menu>
<menuitem>
<label>open</label>
</menuitem>
<menuitem>
<label>save</label>
</menuitem>
<menuitem>
<label>quit</label>
<action>EXIT:quit</action>
</menuitem>
<label>File</label>
</menu>
</menubar>'
export DIALOG
gtkdialog -p DIALOG
- EDDIE_THE_HEAD
- Posts: 15
- Joined: Mon 03 Dec 2012, 02:24
- Location: Córdoba, Argentina
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact: