Gtkdialog Development

Under development: PCMCIA, wireless, etc.
Message
Author
User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

Re: Gtkdialog3 problem: Sometimes aborts instead of returning

#646 Post by thunor »

rerwin and peebee:
rerwin wrote:1. Is there a way to add some debug/troubleshooting logging to gtkdialog to help identify where things go awry? Or is there already someplace to find diagnostic info from gtkdialog?

2. Because this seems, to me, to be a case where a data item is tested but is not the expected data, thus producing random results, could you examine the gtkdialog code that handles the "exit" process to look for a possible bug of that sort?
I recommend that you compile gtkdialog yourselves and place some debugging code into it.

Exiting using <action type="exit">Exit-NOW</action> or similar is handled by action_exitprogram()

action_exitprogram() is called by execute_action()

execute_action() for the button clicked signal is called by button_clicked_attr()

I've just tried it myself and you have to echo $RETVALS in the frisbee script and don't forget to rename gtkdialog3 (which I did forget to do) because it's going to be "gtkdialog" wherever you put it.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#647 Post by technosaurus »

Helping other people debug is always difficult because everyone has their own method. I try strace and then pepper the hell out of the code near where strace stops with printfs/echoes of sequential numbers, others use a methodical approach, write test code, step through a debugger/tracer. It all depends on whether you are a programmer, "software engineer" or code hacker... or whatever.

Speaking of compiling gtkdialog, I was contemplating trying to build it for win32, but before I even start I know of at least 1 stumbling block. I don't think windows has popen(), (someone correct me if I am mistaken) but glib has a wrapper that should work on both: g_spawn_command_line_async(s,NULL) or one of its relatives.

Can anyone think of others that may be missing?

@thunor - which version would you recommend git, latest stable or is there a new stable just beyond the horizon?
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].

User avatar
peebee
Posts: 4370
Joined: Sun 21 Sep 2008, 12:31
Location: Worcestershire, UK
Contact:

Re: Gtkdialog3 problem: Sometimes aborts instead of returning

#648 Post by peebee »

[quote="thunor"][/quote]

Hi Thunor

Many, many thanks for your helpful suggestions and patient hand-holding - much appreciated.

With the help of your suggested diagnostic trace outputs and many, many reboots I think I've proved that the problem actually lies in the called Frisbee function "add-profile".

I've generated some diagnostic info from add-profile and sent it off to rerwin - hopefully it will allow him to pinpoint why add-profile in his new version of Frisbee does not return.....

Cheers
peebee
ImageLxPup = Puppy + LXDE
Main version used daily: LxPupSc; Assembler of UPups, ScPup & ScPup64, LxPup, LxPupSc & LxPupSc64

User avatar
rerwin
Posts: 2017
Joined: Wed 24 Aug 2005, 22:50
Location: Maine, USA

#649 Post by rerwin »

thunor, peebee,
I have been away from puppy for almost a full day, so have just now reviewed all that you have accomplished together. Thank you, both, for working the problem. Now it is my turn, to digest the recommendations and evidence, then fix the code.
Richard

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#650 Post by thunor »

peebee and rerwin: A good job done.

technosaurus: I'm just putting the 0.8.3 release together so I can recommend that -- good luck with win32 :)

Cheers,
Thunor

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#651 Post by thunor »

zigbert wrote:...

Code: Select all

<action>[ $FORMAT = flac" ] && disable:BITRATE</action>
or

Code: Select all

<action>[ $FORMAT = flac" ] && <action>disable:BITRATE</action></action>
...
Changes in r476:
  • Added support for:
  • <action>if file(filename) function:parameter</action>
  • <action>if ! file(filename) function:parameter</action>
  • <action>if command(shell command) function:parameter</action>
  • <action>if ! command(shell command) function:parameter</action>
To accommodate different coding styles I have allowed anything between "if !file(filename)" to "if ! file ( filename )" and similarly for command(). Technically speaking I am parsing the start of every action directive so you could do <action>if command(cat /some/file) echo "this is pointless"</action> but it would be two processes instead of one which is indeed pointless.

With command() -- just as with <action>shell command</action> -- the widget variables are placed into the shell therefore you could conditionally execute code based upon the value of other widgets.

Both the file() and command() functions are expecting true/yes/!0 or false/no/0 so a file will require this data to be within it and a command will require this data to be echoed to stdout.

Is it intuitive? Does it make sense? Otherwise let me know.

I'm going to update the wiki and widget reference now and maybe tweak a couple of things before putting together a source code package release.

Regards,
Thunor

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#652 Post by zigbert »

thunor
After a bit testing, this is how I got it working.
Really handy - thanks a lot!!!

Code: Select all

      <comboboxtext width-request="80">
       <variable>COPY_FORMAT</variable>
       <sensitive>'$VISIBLE_CONVERT'</sensitive>
       <item>'$COPY_FORMAT'</item>
  	   <item>aiff</item>
	   <item>asf</item>
	   <item>au</item>
	   <item>flac</item>
	   <item>mp3</item>
	   <item>ogg</item>
	   <item>rm</item>
	   <item>voc</item>
	   <item>wav</item>
       <action>if command([ $COPY_FORMAT = flac ] && echo true) disable:COPY_BITRATE</action>
       <action>if command([ $COPY_FORMAT = flac ] && echo true) disable:TXT_COPY_BITRATE</action>
       <action>if command([ $COPY_FORMAT = flac ] && echo true) disable:COPY_SAMPLE</action>
       <action>if command([ $COPY_FORMAT = flac ] && echo true) disable:TXT_COPY_SAMPLE</action>
       <action>if command([ $COPY_FORMAT = flac ] && echo true) disable:COPY_CHANNEL</action>
       <action>if command([ $COPY_FORMAT = flac ] && echo true) disable:TXT_COPY_CHANNEL</action>
       <action>if command([ $COPY_FORMAT != flac ] && echo false) enable:COPY_BITRATE</action>
       <action>if command([ $COPY_FORMAT != flac ] && echo false) enable:TXT_COPY_BITRATE</action>
       <action>if command([ $COPY_FORMAT != flac ] && echo false) enable:COPY_SAMPLE</action>
       <action>if command([ $COPY_FORMAT != flac ] && echo false) enable:TXT_COPY_SAMPLE</action>
       <action>if command([ $COPY_FORMAT != flac ] && echo false) enable:COPY_CHANNEL</action>
       <action>if command([ $COPY_FORMAT != flac ] && echo false) enable:TXT_COPY_CHANNEL</action>
      </comboboxtext>

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#653 Post by thunor »

zigbert wrote:thunor
After a bit testing, this is how I got it working.
Really handy - thanks a lot!!!

Code: Select all

       <action>if command([ $COPY_FORMAT != flac ] && echo false) enable:COPY_BITRATE</action>
       <action>if command([ $COPY_FORMAT != flac ] && echo false) enable:TXT_COPY_BITRATE</action>
       <action>if command([ $COPY_FORMAT != flac ] && echo false) enable:COPY_SAMPLE</action>
       <action>if command([ $COPY_FORMAT != flac ] && echo false) enable:TXT_COPY_SAMPLE</action>
       <action>if command([ $COPY_FORMAT != flac ] && echo false) enable:COPY_CHANNEL</action>
       <action>if command([ $COPY_FORMAT != flac ] && echo false) enable:TXT_COPY_CHANNEL</action>
      </comboboxtext>
I've just tweaked the code as the "!" not symbol scanning code was not-very-accommodating(tm) so I recommend checking it out (r477).

Which means that the last 6 lines above will correctly be <action>if command([ $COPY_FORMAT != flac ] && echo true) enable: ...

Yeah, this will be handy for lots of things I'm sure. I'm writing an application and I want to do a conditional exit which is now possible, well I guess it was before with the checkbox trick but I think that that laborious trick is now redundant.

Regards,
Thunor

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#654 Post by zigbert »

thunor wrote:I want to do a conditional exit which is now possible, well I guess it was before with the checkbox trick but I think that that laborious trick is now redundant.
As I see it, the checkbox trick is still the best solution where several widgets wants to refresh (parts) of the gui. Ie. in pMusic there are plenty of occasions to update the playlist/window-title/albumart/... (or the trackinfo window that contain heaps of widgets to refresh). Much easier with one checkbox than conditional <action> code in all related widgets.


All good stuff!!!
Sigmund

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#655 Post by thunor »

Regarding the recent conditional execution code, I'm investigating moving it to something like <action condition="if ! command(shellcommand)">function:parameter</action> because it's more integrated into how gtkdialog deals with everything and I'm thinking about the possible expansion of this feature at a later date, so carry on using it but you might have to slightly modify it. Hey, that's what it's like living on the cutting edge :P

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#656 Post by zigbert »

Living on the edge keep me alive

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#657 Post by thunor »

Changes in r479:
  • Moved the action conditions into their own tag attribute belonging to the action directive e.g. <action condition="if file(filename)">...
  • Added support for:
  • condition="if active(varname)",
  • condition="if sensitive(varname)",
  • condition="if visible(varname)" and it's trivial to add more.
I've got some interesting things to say about gtkdialog's parser but I'm off out so I'll post it later tonight.

Cheers,
Thunor

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#658 Post by thunor »

I guess everyone who's written a gtkdialog application will have experienced the following issue although I know that I've become accustomed to working around it -- I'm talking about the escaped double-quotes problem.

When constructing the contents of an action you know that if you wrap the lot in double-quotes then you can't use double-quotes inside unless you escape them, but the escapes (backslashes) remain within the string i.e. there's no processing of these to remove the backslashes from the front of double-quotes so you end up with this:

Code: Select all

<action>"echo \"sometext\""</action>
echoing this:

Code: Select all

"sometext"
The advantage of wrapping the action's contents in double-quotes is that you can split complex actions across multiple lines, but the moment you need to embed double-quotes it all falls apart. The solution to this which most people are aware of is not to wrap everything in double-quotes but to write everything on one long line. Ok, so at least there's a workaround to that problem but it can't be fixed because escaped double-quotes within existing applications should really be escaped escaped double-quotes.

The recently added condition tag attribute belonging to the action directive initially presented me with the problem that the contents of a tag attribute are wrapped in mandatory double-quotes so you can't work around them, but since this is a new feature and would be rather limited if you couldn't properly embed double-quotes, I scan the string and remove the backslash from the front of double-quotes.

So far so good, except that there's some weird stuff going on with backslashes within tag attributes:

Code: Select all

<button>
	<action>echo some\ text</action>
	<action>"echo some\ text"</action>
</button>
The shell correctly removes the escape character from the space in the first action, and the second results in everything up to "text" being cut! I'm sure that the parser rules are responsible for this and fixing it should be achievable, but you should be aware that it exists although if it happens in a condition tag attribute then it'll cut the function name and you'll get a warning message about it being unknown.

Cheers,
Thunor

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#659 Post by zigbert »

r479

I expected this code to work, but the enable-function is not activated.

Code: Select all

       <action condition="if command([ $COPY_FORMAT = flac ] && echo true)">disable:COPY_BITRATE</action>
       <action condition="if command([ $COPY_FORMAT != flac ] && echo false)">enable:COPY_BITRATE</action>
I fixed it like this

Code: Select all

       <action>enable:COPY_BITRATE</action>
       <action condition="if command([ $COPY_FORMAT = flac ] && echo true)">disable:COPY_BITRATE</action>

Great stuff :)
Sigmund

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#660 Post by thunor »

zigbert wrote:...

Code: Select all

<action condition="if command([ $COPY_FORMAT != flac ] && echo false)">enable:COPY_BITRATE</action>
I fixed it like this

Code: Select all

<action condition="if command([ $COPY_FORMAT = flac ] && echo true)">disable:COPY_BITRATE</action>
...
I was a bit ambiguous about what exactly the functions are expecting:

if function(argument) will expect "true", "yes" or a value that isn't zero e.g. "-89" or "18" to evaluate as true else it'll evaluate as false.

if ! function(argument) will expect "false", "no" or "0" to evaluate as true else it'll evaluate as false.

Basically what I'm doing here is if function(argument) = "true" and if function(argument) = "false" but in a simpler way.

It's like the existing prefix "if true function:parameter" and "if false function:parameter" for toggling widgets but I've replaced the true and false with functions. I can see though that people will think that "!" is actually notting.

Ok, maybe I should use if function_is_true(argument) and if function_is_false(argument) which is clearer right? I'm going to think about it.

[EDIT] I'm changing it now...

[EDIT2] Checkout/update to r480 please. It's now "if function_is_true(argument)" and "if function_is_false(argument)" which is much clearer.

Cheers,
Thunor

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#661 Post by zigbert »

Thunor
r480 Works!!!

But if function_is_true(argument) should be if command_is_true(argument) - at least in my case.


Sigmund

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#662 Post by thunor »

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: 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 |
+------------------------------+-------------------------------+---------------+
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

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#663 Post by thunor »

The action directive's documented type="function" attribute I've renamed function="type" so that we now have:

Code: Select all

<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.

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#664 Post by zigbert »

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: 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
Thanks for any help
Sigmund

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#665 Post by zigbert »

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: 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

Post Reply