Gtkdialog Development

Under development: PCMCIA, wireless, etc.
Message
Author
simargl

#796 Post by simargl »

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

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

#797 Post by thunor »

This is the eventbox inside another eventbox border trick using some of the code from Sigmund's menu prototype just to illustrate what you can do (it might be of interest to somebody, it might not):

Code: Select all

#!/bin/sh

[ -z $GTKDIALOG ] && GTKDIALOG=gtkdialog

## ---------------------------------------------------------------------
## Local Functions
## ---------------------------------------------------------------------

## Create a custom GTK+ 2 style for specific widgets.
funcgtkrcCreate() {
	echo '
style "styleExterior" {
	bg[NORMAL] = "#000000"
}
widget "*Exterior" style "styleExterior"
' > "$TMPDIR"/.gtkrc-2.0

	GTK2_RC_FILES="$TMPDIR"/.gtkrc-2.0:~/.gtkrc-2.0
	export GTK2_RC_FILES
}

## Create a custom GTK+ 3 style for specific widgets.
funcgtkcssCreate() {
	echo '
#Exterior {
	background-color: #000000
}
#Interior {
	background-color: #ffffff
}
' > "$TMPDIR"/gtk.css

	EXTRA_ARGS="$EXTRA_ARGS --styles $TMPDIR/gtk.css"
}

## ---------------------------------------------------------------------
## Main
## ---------------------------------------------------------------------

TMPDIR=/tmp/gtkdialog/examples/"`basename $0`"
mkdir -p "$TMPDIR"

EXTRA_ARGS=

case `$GTKDIALOG -v` in
	*"GTK+ 3"*) funcgtkcssCreate ;;
	*) funcgtkrcCreate ;;
esac

MAIN_DIALOG='
<window decorated="false" window-position="1">
	<eventbox name="Exterior">
		<eventbox name="Interior" border-width="5">
			<vbox spacing="2">
				<hbox spacing="0">
					<pixmap height-request="20" icon-size="1"
						space-expand="false" space-fill="false">
						<input file stock="gtk-add"></input>
					</pixmap>
					<button height-request="20" xalign="0" can-focus="no" relief="2">
						<label>" This could have been a nice ADD menuitem, but menu is too narrow"</label>
					</button>
				</hbox>
				<hbox spacing="0">
					<pixmap height-request="20" icon-size="1"
						space-expand="false" space-fill="false">
						<input file stock="gtk-add"></input>
					</pixmap>
					<button height-request="20" xalign="0" can-focus="no" relief="2">
						<label>" Another nice ADD menuitem"</label>
					</button>
				</hbox>
			</vbox>
		</eventbox>
	</eventbox>
</window>
'
export MAIN_DIALOG

case $1 in
	-d | --dump) echo "$MAIN_DIALOG" ;;
	*) $GTKDIALOG --space-expand=true --space-fill=true --program=MAIN_DIALOG $EXTRA_ARGS ;;
esac

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

#798 Post by zigbert »

Nifty :D

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

#799 Post by thunor »

zigbert wrote:Nifty :D
Instead of painting the background to a specific colour, you could tile it with a black square 50% opaque so for the most part this would give the impression of a border regardless of theme.

The gtkrc and gtk.css code for bitmaps is:

Code: Select all

GTK+ 2:

pixmap_path "/image/folder"

style "styleBgPixmap" {
	bg_pixmap[NORMAL] = "myblacksquare.png"
}
widget "*BgPixmap" style "styleBgPixmap"

GTK+ 3:

#BgPixmap {
	background-image: url("/image/folder/myblacksquare.png")
}
Anyway, since the eventbox interior in gtk2 appears to be solid by default and in gtk3 transparent by default you might have to override the user's theme.

I'm just throwing stuff in.

guraknugen
Posts: 1
Joined: Sun 19 May 2013, 10:08

Using variables in dialogue

#800 Post by guraknugen »

I am not sure if this is the right place to ask this, but I didn't find anywhere else to go…

Let's say that I create a window with a few items on it. One of them is a text field (I think it's called

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

________________________________________

Post Reply