Page 41 of 42

Line continuation within tags

Posted: Sun 19 May 2013, 20:21
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

Posted: Tue 11 Jun 2013, 00:08
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
__________________________________________________

Posted: Tue 11 Jun 2013, 02:41
by scsijon
@don570, same result with the latest wary and racy. (Extra box appearing.)

Posted: Tue 11 Jun 2013, 20:38
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.

________________________________________

Posted: Wed 12 Jun 2013, 09:59
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

Posted: Wed 12 Jun 2013, 23:31
by don570
I tested on wary 5.4.9 and it's fine.
(see image)

That's why I think pwidgets is involved.

Image

__________________________________________

Posted: Thu 13 Jun 2013, 05:27
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.

Posted: Fri 14 Jun 2013, 08:34
by simargl
.

GtkDialog Variables

Posted: Sat 27 Jul 2013, 17:10
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!

Posted: Wed 21 Aug 2013, 09:25
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.

Posted: Wed 21 Aug 2013, 19:45
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

Posted: Sat 19 Oct 2013, 09:29
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.

Posted: Sat 19 Oct 2013, 20:06
by don570
Thunor has looked into a GTK3 version but he
doesn't seem to feel there's a high priority.

________________________________________-

memory leak?

Posted: Fri 15 Nov 2013, 21:47
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.

Posted: Sat 16 Nov 2013, 20:49
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

________________________________________

hide and show

Posted: Wed 12 Feb 2014, 12:57
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>

Posted: Wed 12 Feb 2014, 13:04
by dejan555
Did you try: <button visible="false"> ?

Posted: Wed 12 Feb 2014, 13:09
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.

Posted: Wed 12 Feb 2014, 13:17
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>

Posted: Wed 12 Feb 2014, 13:51
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?