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:

#331 Post by thunor »

Overhauled the widget packing method

From the ChangeLog:
  • Added command-line option --space-expand to set the widget packing expand state at the project level.
  • Added command line option --space-fill to set the widget packing fill state at the project level.
  • Added the "space-expand" custom tag attribute for the h/vbox widgets to set the widget packing expand state at the container level.
  • Added the "space-fill" custom tag attribute for the h/vbox widgets to set the widget packing fill state at the container level.
  • Added the "space-expand" custom tag attribute for all other widgets to set the widget packing expand state at the widget level.
  • Added the "space-fill" custom tag attribute for all other widgets to set the widget packing fill state at the widget level.
  • By default the original quirky widget packing method is used.
  • Project level --space-expand/fill override the original method.
  • Container level "space-expand/fill" override the project level method and the original method.
  • Widget level "space-expand/fill" override the container level method, the project level method and the original method.
Look here for an explanation of expand and fill. An important point to remember is that if expand is false then fill has no effect.

Widgets are packed into containers and they may expand into and fill their allocated space. For Gtkdialog, containers means hbox and vbox but there's one embedded unreachable vbox inside the frame widget which is a pain because it's not possible to add tag attributes to the frame or embedded vbox to set expand and fill at the container level although the widget level and project level are fine. The way around this is to place a vbox inside the frame so that you have control over it. The frame widget really needs to be replaced but that's a job for another day.

The Original Method
It's a bit quirky and possibly there's an error in it but it's the default method and used by every single Gtkdialog application until now.

The frame widget and every widget normally placed inside a default scrolled window (edit, tree, list, table and optionally the h/vbox) are packed with expand and fill set to true, otherwise widgets are packed with expand and fill set to false. The possible error I've found is that the hbox uniquely packs the entry widget by default with expand and fill set to true.

The Project Level Method
The command-line options --space-expand=true/yes/1/false/no/0 and --space-fill=true/yes/1/false/no/0 will override the original method for all widgets at the project (application) level. --space-expand=true is the key to creating resizable applications.

The Container Level Method
The custom tag attributes space-expand="true/yes/1/false/no/0" and space-fill="true/yes/1/false/no/0" will override the original method and the project level method for widgets at the container level i.e. <vbox space-expand="true" space-fill="true"> will set expand and fill to true for all the widgets inside this particular vbox but not recursively into v/hboxes nested within.

The Widget Level Method
The custom tag attributes space-expand="true/yes/1/false/no/0" and space-fill="true/yes/1/false/no/0" will override the original method, the project level method and the container level method for individual widgets.

Example (examples/miscellaneous/expand_and_fill):

Code: Select all

#!/bin/sh

export GTKDIALOG=gtkdialog

funcExampleCreate() {
	if [ $1 = 0 ]; then echo '
<window title="Expand and Fill - Original Method" resizable="true">'
	elif [ $1 = 1 ]; then echo '
<window title="Expand and Fill - --space-expand" resizable="true">'
	elif [ $1 = 2 ]; then echo '
<window title="Expand and Fill - --space-expand + --space-fill" resizable="true">'
	else echo '
<window title="Expand and Fill - --space-expand + --space-fill + tweaks" resizable="true">'
	fi
	echo '
	<vbox>
		<hbox>
			<tree stock-id="gtk-select-color"><item>tree widget</item></tree>
			<vseparator></vseparator>
			<vbox>
				<entry><default>entry widget</default></entry>
				<hseparator></hseparator>
				<text label="text widget"></text>
			</vbox>
		</hbox>
		<hseparator></hseparator>
		<hbox>
			<vbox>
				<spinbutton></spinbutton>
				<hseparator></hseparator>'
	if [ $1 -lt 3 ]; then echo '
				<colorbutton use-alpha="true">'
	else echo '
				<colorbutton space-expand="false" use-alpha="true">'
	fi
	echo '
					<default>#'$(for f in 0 1 2; do printf "%02x" $(($RANDOM % 256)); done)'|43934"</default>
				</colorbutton>
			</vbox>
			<vseparator></vseparator>
			<edit><default>edit widget</default></edit>
		</hbox>
		<hseparator></hseparator>'
	if [ $1 -lt 3 ]; then echo '
		<hbox>'
	else echo '
		<hbox space-expand="false">'
	fi
	echo '
			<button image-position="1">
				<label>Next example</label>
				<input file stock="gtk-go-forward"></input>'
	if [ $1 = 0 ]; then echo '
				<action>$GTKDIALOG --space-expand=true --program=CLI_EXPAND_METHOD &</action>'
	elif [ $1 = 1 ]; then echo '
				<action>$GTKDIALOG --space-expand=true --space-fill=true --program=CLI_EXPAND_PLUS_FILL_METHOD &</action>'
	elif [ $1 = 2 ]; then echo '
				<action>$GTKDIALOG --space-expand=true --space-fill=true --program=CLI_EXPAND_PLUS_FILL_PLUS_TWEAKS_METHOD &</action>'
	else echo '
				<sensitive>false</sensitive>'
	fi
	echo '
			</button>
			<button use-stock="true" label="gtk-ok"></button>
		</hbox>
		<statusbar><label>statusbar widget</label></statusbar>
	</vbox>
	<action signal="hide">exit:Exit</action>
</window>
'
}

export ORIGINAL_METHOD="$(funcExampleCreate 0)"
export CLI_EXPAND_METHOD="$(funcExampleCreate 1)"
export CLI_EXPAND_PLUS_FILL_METHOD="$(funcExampleCreate 2)"
export CLI_EXPAND_PLUS_FILL_PLUS_TWEAKS_METHOD="$(funcExampleCreate 3)"

$GTKDIALOG --program=ORIGINAL_METHOD
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:

#332 Post by thunor »

technosaurus wrote:I know we can use dragndrop from an external programs, but do/could any widgets support it?

If so, there is a tiny file manager in my head just waiting to be freed, and I am certain Zigbert's apps could greatly benefit (though he has made great use of the right click menus).

[sidebar]I am really horrible at leaving code format unreadable from cutting/pasting etc & would love to use xmllint -format on the gtkdialog "xml" code, but certain parts are flagged as "invalid" (which is probably why libxml2 is required vs glib or expat) The biggest one I recall is <input file ...>file</input> (space before but no ="" after file)
IIRC, someone posted a code cleanup script that does work with gtkdialog, but I seem to have lost it.
On the other side of things some tags that _are_ usually considered valid xml aren't accepted by gtkdialog such as <vseparator/> instead of <vseparator></vseparator> (not like you can put anything between it anyways)[/sidebar]
Hi technosaurus

GTK+ supports drag 'n' drop. Widgets currently accept data from various sources but it's always all or nothing. There's no mechanism within Gtkdialog for inserting data from one widget into another at a certain position. Well, actually somebody has started to code an <action>insert:sourcevar,destvar</action> function for win32 only but it appears to be appending rather than inserting. So drag 'n' drop would need to be set-up between the source and target widgets which would emit a signal on drop and then an "insert" action would need to be executed -- a lot of work. The tree widget would be the place to start but as I've mentioned a few times before, it uses the wrong model (TreeStore instead of ListStore) which causes items to get grouped and branches open which the code doesn't support, so a new <listview> widget needs to be written first.

GTK+ depends on libxml2 but Gtkdialog uses Flex (lexical analyser) and Bison (parser generator). Gtkdialog's XML-like syntax is custom. It's not valid XML nor is it XML. The reason why "<vseparator/>" isn't accepted is because Gtkdialog's parser doesn't know what it is.

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:

#333 Post by thunor »

MAXWIDGETS

Last night I committed the expand_and_fill example and I when I was working on the widget packing I noticed that the maximum number of widgets Gtkdialog accepted was 256 (16^) so I've increased it to 529 (23^). Using the expand_and_fill example this takes virtual memory usage from 21MB to 25MB (1024 (32^) widgets would've taken it to 34MB) so I hope this is OK for everyone. Ideally the widget pointer array would increase dynamically but it hasn't been written like that so this increase will do for now.

Regards,
Thunor

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

#334 Post by zigbert »

Scaling is fun :)
...and Pburn will sure benefit of it. Thank you Thunor.
Though there are one irritating issue with the new fill/expand option (I know, I know.... it's just me being a fool - not getting it all, but still irritating.... :D

Here is the case:

Image

Last time I showed a pic of Pmusic it used the scrollable option to keep scaling. It worked fine, but with fill/scale the box-border is gone, and it looks cleaner.

BUT, the pic shows how Pmusic starts even if geometry settings is smaller. There is not defined any space between the back-button and the info-button. It auto-scales at startup to the size it would have had without decreasing the button-area by scaling="0" for all buttons. It seems to me like the hardcoded spacing="5" is overwritten fine in the gui itself, but not for the function that defines the shown size of the window.

No problem for me, - I just return to scrollable, but thought I would mention. If you want more info, I could make a test-script.


Sigmund

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

#335 Post by thunor »

Hi Sigmund

Image Image

I don't know if you've played with the expand_and_fill example or not but GTK+ allocates space completely differently when expand is true. I have offered as many ways as possible to attempt to control the widgets but ultimately GTK+ does things by its rules.

When testing I found once that a button in an hbox with space-expand=false was still expanding in the vertical dimension because they were inside a vbox that had space-expand=true. I stopped this behaviour by wrapping the hbox inside another vbox. I realised then that some work might be required in isolating widgets using different methods.

All I've done is present an interface to the expand and fill parameters of the widget packing functions, but if you want to create an example then I'd be interested in looking at it.

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:

#336 Post by thunor »

I've exported the wiki to html -- look in doc/reference.

Well, it's gone quiet so I'll take that to mean it's time to make a release.

Regards,
Thunor

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

#337 Post by zigbert »

thunor wrote:Well, it's gone quiet so I'll take that to mean it's time to make a release.
:D

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#338 Post by 01micko »

Here's my latest for updating from svn, it gives you a choice at the woof level or the running system level to clobber gtkdialog3 or not, using Xdialog. Now the symlinks are not hard coded. It's not perfect but it suits me, also packages the html reference files.

Code: Select all

#!/bin/sh
#my script to update and package gtkdialog
[ -x src/gtkdialog ] && make clean
svn update
./autogen.sh && make
echo
echo "scroll up to get the svn version number"
echo -en "\033[0;31m""enter version";echo -e "\033[0m"
read VER
cd src
strip --strip-unneeded gtkdialog
mkdir -p $HOME/gtkdialog4-${VER}-s/usr/sbin
cp -af gtkdialog $HOME/gtkdialog4-${VER}-s/usr/sbin
#cd $HOME/gtkdialog4-${VER}-s/usr/sbin
#ln -s gtkdialog gtkdialog3
#ln -s gtkdialog gtkdialog4
#cd -
pwd
cd ..
mkdir -p $HOME/gtkdialog4_DOC-${VER}-s/usr/share/doc/gtkdialog/examples
cp -arf examples/* $HOME/gtkdialog4_DOC-${VER}-s/usr/share/doc/gtkdialog/examples/
cp -arf doc/reference $HOME/gtkdialog4_DOC-${VER}-s/usr/share/doc/gtkdialog/
rm -f $HOME/gtkdialog4_DOC-${VER}-s/usr/share/doc/gtkdialog/examples/Make*
echo '#!/bin/sh
#gtkdialog pinstall.sh
if [ "`pwd`" != "/" ];then
 #woof
 (cd ./usr/sbin ; ln -s gtkdialog gtkdialog4)
 Xdialog --title "gtkdialog3" --yesno "Do you want to link to gtkdialog3?" 0 0
  case $? in
  0) (cd ./usr/sbin ; ln -s gtkdialog gtkdialog3)
  echo "linked to gtkdialog3 and 4" ;;
  *) echo "not linked to gtkdialog3, linked to gtkdialog4" ;;
  esac
 else
#non-woof, running system
 (cd /usr/sbin ; rm -f gtkdialog4)
 (cd /usr/sbin ; ln -s gtkdialog gtkdialog4)
 if [ "$(file /usr/sbin/gtkdialog3|grep -iE "symbolic")" != "" ];then
  (cd /usr/sbin ; rm -f gtkdialog3)
  (cd /usr/sbin ; ln -s gtkdialog gtkdialog3)
  echo "Old gtkdialog3 removed, gtkdialog linked to gtkdialog3 and gtkdialog4"
  else
  Xdialog --title "gtkdialog3" --yesno "Do you want to clobber gtkdialog3?" 0 0
  case $? in
  0) (cd /usr/sbin ; rm -f gtkdialog3)
 (cd /usr/sbin ; ln -s gtkdialog gtkdialog3)
  echo "Old gtkdialog3 removed, gtkdialog linked to gtkdialog3 and gtkdialog4" ;;
  *) echo "not linked to gtkdialog3, linked to gtkdialog4" ;;
  esac
 fi
fi' > $HOME/gtkdialog4-${VER}-s/pinstall.sh
chmod 755 $HOME/gtkdialog4-${VER}-s/pinstall.sh
cd $HOME
dir2pet gtkdialog4-${VER}-s
dir2pet gtkdialog4_DOC-${VER}-s
echo done && exit 0
Puppy Linux Blog - contact me for access

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

#339 Post by thunor »

0.8.0 released.

Cheers to everyone who was involved :)

I have other non-programming things that require my attention now but I'd like to write a simple game using Gtkdialog that I haven't written before.

Cheers,
Thunor

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#340 Post by 01micko »

LOL!!!

And I just was updating to 307.. is it identical?

Thanks!

EDIT: to answer my own Q.. No.. md5sum don't match

Cheers :)
Puppy Linux Blog - contact me for access

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

#341 Post by thunor »

Mick

The gtkdialog-0.8.0 source package is r306 and is for the masses.

You and many people here are checking-out from SVN and you can continue to do that.

I have committed r307 which is a simple version change to 0.8.1 and I did this so that I can reserve even numbers for official source package releases.

[EDIT] I should mention too that the wiki is in the repository and working on that will up the revision. When checking out, if you type "svn log -r n" you'll see the commit message (editing wiki pages through the browser results in a default message containing a line of dashes, otherwise it'll be something I've written).

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:

#342 Post by thunor »

I'm an application developer now 8)

This might be a top tip: I'm using functions in my script to build the XML and I'm creating a game board of varying sizes. Initially I started with an 8x8 board which took 2.5 seconds to appear and when I increased it to 12x12 it took 10.5 seconds! 15x15 jumped to 24 seconds!!! Obviously I'm not going to put anyone through that experience so I thought I'd investigate why it was taking so long. I found that building the XML in a shell variable was the cause and simply echoing the XML to a file and using "gtkdialog --file=filename" instead results in 8x8 loading in about 1s, 12x12 in 1.25s and 15x15 in 1.75s. It really makes that much difference so I recommend trying it.

Regards,
Thunor

User avatar
frafa
Posts: 10
Joined: Thu 04 Aug 2011, 14:48
Location: MONTPELIER
Contact:

#343 Post by frafa »

Yes Thunor kiss smack and more :)
Thank's for gtkdialog --file=filename !!!

for 256 img time load responds
Normal: user 0m2.848s
XML version: user 0m0.712s

Image

Download example: http://liveusb.info/tmp/colorchooser.tar.bz2
1° test ./ColorPicKer.sh
2° test ./ColorPicKe-xml.sh
:)

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

#344 Post by thunor »

Hi frafa

Firstly I had to change ColorPicKe-xml.sh:22 to "gtkdialog --file=ColorPicKe-xml.sh" and then I ran your applications:

PIII 866 MHz

ColorPicKer.sh = 0m25.65s :shock:
ColorPicKe-xml.sh = 0m1.07s

That's a nice application :) You should change

Code: Select all

widget "*Button" style "styleBorderless"
to

Code: Select all

widget "*borderless" style "styleBorderless"
and then in generate.sh:63 add name="borderless" to the button tag because you are applying styleBorderless to all GtkButtons (look at Quitter, it has no border).

Regards,
Thunor
Last edited by thunor on Fri 30 Sep 2011, 11:46, edited 1 time in total.

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#345 Post by 8-bit »

I also have to say a big thank you. The release is very well documented and the inclusion of the Reference directory also helps along with the examples one.

User avatar
frafa
Posts: 10
Joined: Thu 04 Aug 2011, 14:48
Location: MONTPELIER
Contact:

#346 Post by frafa »

Ok modified :)
it's just an example, same adress download ...
if you modify generate.sh
erase all files and folder without generate.sh
run generate.sh all files/folder are regenerate
sorry for my broken English
François

EDIT: must be installed imagemagick to use generate.sh ...

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

#347 Post by thunor »

thunor wrote:MAXWIDGETS

...when I was working on the widget packing I noticed that the maximum number of widgets Gtkdialog accepted was 256 (16^) so I've increased it to 529 (23^)....
I've since realised that MAXWIDGETS is a limit placed upon a container (vbox, hbox, frame), not the entire project, so you can currently have 529 widgets per container which isn't so bad.

The project limit I've just discovered is 2048.

This is just for the record so that everyone is aware of this.

Regards,
Thunor

User avatar
Dougal
Posts: 2502
Joined: Wed 19 Oct 2005, 13:06
Location: Hell more grotesque than any medieval woodcut

#348 Post by Dougal »

Thunor,
I just finished catching up on this thread and it's great what you've done, really excellent work both the features and documentation -- I see you've also added the html docs, which I thought of suggesting (I hope you deleted the old texinfo stuff...).

I do have one nitpick, though: your examples are really good and detailed, but have one problem: readability.
Since you use functions to auto-generate the pseudo-XML code, when an example is run it is not possible to look at the bit of code that produces a certain widget (and copy-paste it...), which I consider to be one of the main points of the examples.

I see two ways to change this:
- just put the static code in the scripts
- make the example scripts support a -d/--dump switch, which will only require a small change from

Code: Select all

$GTKDIALOG --program=MAIN_DIALOG 
to

Code: Select all

case $1 in
-d|--dump) echo "MAIN_DIALOG" ;;
*) $GTKDIALOG --program=MAIN_DIALOG ;;
esac
Other than that, I'll have to wait until the next time I use gtkdialog (and learn all the new widgets...) to see if I have any more suggestions... (but if you get bored and aren't listening to Hell, JWM needs some love!)
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind

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

#349 Post by vovchik »

Dear puppians,

I am wondering whether any of you can show me, in a simple and understandable way, how to display elapsed time in the new statusbar widget (most probably using <timer>). I would like it to update the statusbar display every second and to be able to reset it to 00:00:00 upon a button click.

Thanks in advance.

With kind regards,
vovchik

User avatar
frafa
Posts: 10
Joined: Thu 04 Aug 2011, 14:48
Location: MONTPELIER
Contact:

#350 Post by frafa »

Hello,
in case there is here using Debian or Ubuntu,
know that the last stable verstion gtkdialog 0.8.0 developed by Thunor is available in my deposit.

Code: Select all

## Depôt gtkdialog/multimystem
deb http://liveusb.info/multisystem/depot all main
#deb-src http://liveusb.info/multisystem/depot all main
#wget -q http://liveusb.info/multisystem/depot/multisystem.asc -O- | sudo apt-key add -
I can not thank enough Thunor for all the work done on gtkdialog.
François

Post Reply