Gtkdialog Development

Under development: PCMCIA, wireless, etc.
Message
Author
User avatar
DocSalvage
Posts: 11
Joined: Sat 30 Jun 2012, 18:59
Location: Tallahassee, FL, USA
Contact:

Line continuation within tags

#801 Post by DocSalvage »

I've discovered some unexpected behavior. (at least under bash 4.1.0(1) as of gtkdialog 0.8.4 r503M) and am posting for feedback...

PROBLEM
  • In coding GtkDialog, attributes often extend far more than a comfortable screen width.
    Having many attributes off-screen, accessible only by scrolling, is error-prone and the editor's word-wrapping may not improve readability.
    Using the bash backslash (\) for line-continuation introduces perceptional "noise" that some find distracting.
    Using an editor, such as Geany, set to strip trailing spaces leaves no spaces between attributes and thus generates an error. (Indentation tabs and spaces apparently are ignored.)
SOLUTIONS
  • However, experimentation has revealed that there are actually several options for achieving line-continuation in tags.
    As is documented and used in several standard examples, no line-continuation characters are needed for the common case of assigning the string of code to an environment variable as in...

Code: Select all

	export MAIN_DIALOG='
		<entry 
			file-monitor="true"
			fs-action="file"
			fs-folder=""
			fs-filters-mime="text/plain|text/html"
			fs-title="File Select"
			space-expand="true"
			space-fill="true">'
  • However, if the editor is set to strip trailing spaces, echoing the code fails...

Code: Select all

		echo '
			<entry 
				file-monitor="true"
				fs-action="file"
				fs-folder=""
				fs-filters-mime="text/plain|text/html"
				fs-title="File Select"
				space-expand="true"
				space-fill="true">'      >>gtk_code_file
  • ERROR : gtkdialog: Error in line ___, near token 'string': syntax error

• The well-known bash backslash (\) works as expected as long as it is preceded by a space to separate the attributes, as in...

Code: Select all

		echo ' \
			<entry \
				file-monitor="true" \
				fs-action="file" \
				fs-folder="" \
				fs-filters-mime="text/plain|text/html" \
				fs-title="File Select" \
				space-expand="true" \
				space-fill="true">'      >>gtk_code_file
• But experiments reveal that 3-dot-ellipsis (...), comas (,), and probably other characters also work and may be less distracting. It's possible that some extraneous characters are being tolerated and ignored, thus leading to this behavior.

Code: Select all

		echo '<entry ...
				file-monitor="true" ,
				fs-action="file" ,
				fs-folder="" .
				fs-filters-mime="text/plain|text/html" ,
				fs-title="File Select" ,
				space-expand="true" ,
				space-fill="true">'      >>gtk_code_file
• The most portable solution is probably to just turn off the stripping of trailing spaces in the editor and insuring each line ends with at least one space ("_" below indicates the invisible trailing space)...

Code: Select all

		echo '<entry _
				file-monitor="true"_
				fs-action="file"_
				fs-folder=""_
				fs-filters-mime="text/plain|text/html"_
				fs-title="File Select"_
				space-expand="true"_
				space-fill="true">'      >>gtk_code_file
RESOURCES
[i][color=blue]DocSalvager (a.k.a. DocSalvage)[/color][/i]
[url]http://www.docsalvage.info[/url], [url]http://www.softwarerevisions.net[/url]

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#802 Post by don570 »

I have built an app that does a simple right click copy of a
file or folder, but I found a strange bug.

Reference:
copy-fast-1.4.pet

I believe that there is
an incompatibility with pwidgets and 'visible' tag

I use an invisible entry box to form the 'Add' button.
Here is the code. See 'visible="false"'

Image

When I tested on Precise NOP note that the invisible entry box
is visible . The app can still be used.

Image
__________________________________________________

scsijon
Posts: 1596
Joined: Thu 24 May 2007, 03:59
Location: the australian mallee
Contact:

#803 Post by scsijon »

@don570, same result with the latest wary and racy. (Extra box appearing.)

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#804 Post by don570 »

Hmmm, I tested on Wolx which is Wary 5 (I believe) but has the
openbox window manager and it worked. I assumed that there wasn't
a problem with Wary5

Drat! A lot more work.

________________________________________

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#805 Post by vovchik »

Dear Don,

Just so you know. Your v. 1.4 works fine with Lucid and Thunor's latest gtkdialog. No invisible window showing for me, but then my gtk theme fills the background with a stippled pixbuf, so my observation regarding visibility/invisibility may not be too universal.

With thanks and kind regards,
vovchik

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#806 Post by don570 »

I tested on wary 5.4.9 and it's fine.
(see image)

That's why I think pwidgets is involved.

Image

__________________________________________

scsijon
Posts: 1596
Joined: Thu 24 May 2007, 03:59
Location: the australian mallee
Contact:

#807 Post by scsijon »

don570 wrote:I tested on wary 5.4.9 and it's fine.
(see image)

That's why I think pwidgets is involved.


__________________________________________
ahah! and 1.6 is found where please? I was using 1.4, what I thought was the latest in a message just 6 above.

EDIT: just found it, it's in the same topic. I shall download and test.

No, still there. Moving the problem to copyfast thread.

simargl

#808 Post by simargl »

.
Last edited by simargl on Sun 01 Sep 2013, 15:15, edited 1 time in total.

User avatar
DocSalvage
Posts: 11
Joined: Sat 30 Jun 2012, 18:59
Location: Tallahassee, FL, USA
Contact:

GtkDialog Variables

#809 Post by DocSalvage »

Thunor,

I love GtkDialog 0.8.3 and am working on a fairly large conversion application using it.

In the process, I'm putting together documentation regarding variable passing and was hoping you could confirm if the following statement is correct and straighten me me out if not?

"On startup, GtkDialog processes all <input> and <output> directives for all widgets before processing any <action> directives for any widgets."

If this is all covered somewhere, I haven't been a able to find it. It has taken several days of trial and error to reach this point.

Happy Coding!
[i][color=blue]DocSalvager (a.k.a. DocSalvage)[/color][/i]
[url]http://www.docsalvage.info[/url], [url]http://www.softwarerevisions.net[/url]

User avatar
recobayu
Posts: 387
Joined: Wed 15 Sep 2010, 22:48
Location: indonesia

#810 Post by recobayu »

Hi All,
I want to ask a question. Now I make a simple menu, but i have a problem in adding button. Can I add 4 buttons when I input "4" in entrybox and press enter?
Something trick I do is close gtkdialog and then show new window that has 4 buttons. But, do anyone know something better?
Thank you.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#811 Post by don570 »

When you create a button to do an action you can also
set how the exit variable is set. For instance
<action>exit:EXIT</action> sets the exit variable to "EXIT"
When you run your script in the terminal the variable is printed.
(a nice feature of terminal 8) )

Code: Select all

funcbtnType0Create3() { 
   echo '<button image-position="'$1'" use-stock="true"   tooltip-text="'$(gettext 'Relaunch Bulldog Finder')'"> 
         <input file stock="gtk-ok"></input> 
         <label>"'$(gettext 'Relaunch')'"</label> 
          <action>bulldog-finder "$FPATH" &</action> 
          <action>exit:EXIT</action> 
        </button>'
Then after gtkdialog has run you can put a line that can
decide what is done next . Here's an example in my bulldog-finder
program.

Code: Select all

for STATEMENTS in  $($GTKDIALOG -c -p SETTINGS); do
  eval $STATEMENTS
done
IFS=$I

if [ "$EXIT" = "EXIT" ] || [ "$EXIT" = "abort" ];then  # delete temp
rm -rf $TEMPDIR
exit 0
fi
In my example I do a deletion , in your case you would want to launch
gtkdialog again

simargl7

#812 Post by simargl7 »

Will there be stable Gtk3 based version soon?

In Gtk 3.10 icons from menus are removed without option for user to enable them, Gtk.Stock is deprecated. Icons on menus and buttons must be explicitly added by application's developer.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#813 Post by don570 »

Thunor has looked into a GTK3 version but he
doesn't seem to feel there's a high priority.

________________________________________-

jfi
Posts: 1
Joined: Fri 15 Nov 2013, 21:22

memory leak?

#814 Post by jfi »

Am I doing this wrong or is there a memory leak in gtkdialog?

I ran a gtkdialog script that I'm working on for a day. After about 8 hours it ran out of RAM (there wasn't very much available to start with). The script was sitting idle all day only updating clock display twice a second so I tried removing the clock. Gtkdialog process stopped growing.

Then I narrowed it down to this script that just updates date and time:

Code: Select all

    #!/bin/bash
     
    GTKDIALOG=gtkdialog
     
    MAIN_DIALOG='
    <window title="memory leak test">
      <vbox>
        <text use-markup="true">
          <variable>TIMEDISPLAY</variable>
            <input>date +%H:%M:%S</input>
        </text>
        <text>
            <variable>DATEDISPLAY</variable>
            <input>date +%A\ %-d.%m.%Y</input>
        </text>
        <timer milliseconds="true" interval="50" visible="false">
          <action>clear:TIMEDISPLAY</action>
          <action>refresh:TIMEDISPLAY</action>
          <action>clear:DATEDISPLAY</action>
          <action>refresh:DATEDISPLAY</action>
        </timer>
      </vbox>
    </window>
    '
     
    export MAIN_DIALOG
    $GTKDIALOG --program=MAIN_DIALOG
and watched it grow:

Code: Select all

chmod u+x leaktest
./leaktest&
while [ 1 ]; do date; ps -C "gtkdialog" u; sleep 10; done

I tried this under Ubuntu 10.04 Lucid Lynx (x86_64 desktop) and an A13-OLinuXino-WIFI board running Debian Wheezy (armhf). Bash versions are 4.1.5 for the desktop and 4.2.20 for the arm board.
I tried gtkdialog 0.8.3 tarball on both platforms and on desktop I also tried svn rev 514. All kept growing.

P.S. Those "clear" actions were added for testing, it leaks without them as well. The timer was originally 500 ms, I sped it up to maybe get it to leak more.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#815 Post by don570 »

Additional info: Thunor did a timer example. The shell may be important.
Thunor used the bash 3.0 shell.

Ubuntu uses dash.

http://code.google.com/p/gtkdialog/sour ... n493&r=493

________________________________________

brokenman
Posts: 25
Joined: Thu 20 Oct 2011, 23:00

hide and show

#816 Post by brokenman »

I am trying to hide a button on a 'notebook' page when the page is shown. The page has the an entry widget and radiobutton widgets (as well as the button). I can't seem to get the button to hide using signal="show" for any widgets. It hides OK if i put the action into a radiobutton 'if true' action.

Any ideas how I can realize this?

PS: Is there a donation system for gtkdialog?

Code: Select all

<vbox margin="10">
	<hbox>
		<text><label>Select a file: </label></text>
		<entry fs-action="file" editable="false" block-function-signals="true">
			<variable>SELPKG</variable>
		</entry>
		<button>
			<label>Select</label>
			<action function="fileselect">SELPKG</action>
			<action>echo $SELPKG</action>
		</button>
	</hbox>
	<radiobutton>
		<label>Example</label>
	</radiobutton>
	<button>
		<label>Vanish</label>
		<variable>butDownload</variable>
	</button>
</vbox>
Last edited by brokenman on Wed 12 Feb 2014, 13:06, edited 1 time in total.

User avatar
dejan555
Posts: 2798
Joined: Sun 30 Nov 2008, 11:57
Location: Montenegro
Contact:

#817 Post by dejan555 »

Did you try: <button visible="false"> ?
puppy.b0x.me stuff mirrored [url=https://drive.google.com/open?id=0B_Mb589v0iCXNnhSZWRwd3R2UWs]HERE[/url] or [url=http://archive.org/details/Puppy_Linux_puppy.b0x.me_mirror]HERE[/url]

brokenman
Posts: 25
Joined: Thu 20 Oct 2011, 23:00

#818 Post by brokenman »

I want the button to be visible until a certain 'notebook' page is shown. So what I need is something similar to an "onshow" parameter for one of the widgets. When the widget is shown, the button vanishes. The original state of the button should be visible so this attribute is no good for me. Thanks.

Essentially I would like the button in the above code to be invisible when the script is run, but done so without using anything within the button widget itself.

brokenman
Posts: 25
Joined: Thu 20 Oct 2011, 23:00

#819 Post by brokenman »

Ok I got it. Since the button I want to vanish is created after the other widgets, they can't do what I want since the button doesn't exist at the point when they are created. I need to have a widget somewhere in the code AFTER the button I want to vanish. Makes sense.

Code: Select all

<vbox margin="10">
	<hbox>
		<text><label>Select a file: </label></text>
		<entry fs-action="file" editable="false" block-function-signals="true">
			<variable>SELPKG</variable>
		</entry>
		<button>
			<label>Select</label>
			<action function="fileselect">SELPKG</action>
			<action>echo $SELPKG</action>
		</button>
	</hbox>
	<radiobutton>
		<label>Example</label>
		<action>if true show:butDownload</action>
	</radiobutton>
	<radiobutton>
		<label>Example2</label>
		<action>if true hide:butDownload</action>
	</radiobutton>
	<button visible="true">
		<label>Vanish</label>
		<variable>butDownload</variable>
	</button>
<statusbar has-resize-grip="false">
	<variable>stb0</variable>
	<input>echo statusbar</input>
	<action signal="show">hide:butDownload</action>
</statusbar>
</vbox>

User avatar
dejan555
Posts: 2798
Joined: Sun 30 Nov 2008, 11:57
Location: Montenegro
Contact:

#820 Post by dejan555 »

Not sure if I understand but why not put it inside one frame of notebook if that's only where it should be shown instead after notebook code?
puppy.b0x.me stuff mirrored [url=https://drive.google.com/open?id=0B_Mb589v0iCXNnhSZWRwd3R2UWs]HERE[/url] or [url=http://archive.org/details/Puppy_Linux_puppy.b0x.me_mirror]HERE[/url]

Post Reply