Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 24 Oct 2014, 03:15
All times are UTC - 4
 Forum index » Advanced Topics » Cutting edge
Gtkdialog Development
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 23 of 55 [821 Posts]   Goto page: Previous 1, 2, 3, ..., 21, 22, 23, 24, 25, ..., 53, 54, 55 Next
Author Message
thunor


Joined: 14 Oct 2010
Posts: 350
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings

PostPosted: Thu 22 Sep 2011, 13:02    Post subject:  

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:
#!/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
Back to top
View user's profile Send private message Visit poster's website 
thunor


Joined: 14 Oct 2010
Posts: 350
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings

PostPosted: Fri 23 Sep 2011, 05:49    Post subject:  

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
Back to top
View user's profile Send private message Visit poster's website 
thunor


Joined: 14 Oct 2010
Posts: 350
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings

PostPosted: Fri 23 Sep 2011, 06:02    Post subject:  

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
Back to top
View user's profile Send private message Visit poster's website 
zigbert


Joined: 29 Mar 2006
Posts: 5753
Location: Valåmoen, Norway

PostPosted: Fri 23 Sep 2011, 14:21    Post subject:  

Scaling is fun Smile
...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.... Very Happy

Here is the case:



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

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
thunor


Joined: 14 Oct 2010
Posts: 350
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings

PostPosted: Sat 24 Sep 2011, 05:42    Post subject:  

Hi Sigmund



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
Back to top
View user's profile Send private message Visit poster's website 
thunor


Joined: 14 Oct 2010
Posts: 350
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings

PostPosted: Sun 25 Sep 2011, 13:43    Post subject:  

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
Back to top
View user's profile Send private message Visit poster's website 
zigbert


Joined: 29 Mar 2006
Posts: 5753
Location: Valåmoen, Norway

PostPosted: Sun 25 Sep 2011, 13:56    Post subject:  

thunor wrote:
Well, it's gone quiet so I'll take that to mean it's time to make a release.
Very Happy
_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
01micko


Joined: 11 Oct 2008
Posts: 7835
Location: qld

PostPosted: Sun 25 Sep 2011, 20:16    Post subject:  

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:
#!/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

_________________
Woof Mailing List | keep the faith Cool |
Back to top
View user's profile Send private message Visit poster's website 
thunor


Joined: 14 Oct 2010
Posts: 350
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings

PostPosted: Mon 26 Sep 2011, 08:34    Post subject:  

0.8.0 released.

Cheers to everyone who was involved Smile

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
Back to top
View user's profile Send private message Visit poster's website 
01micko


Joined: 11 Oct 2008
Posts: 7835
Location: qld

PostPosted: Mon 26 Sep 2011, 08:42    Post subject:  

LOL!!!

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

Thanks!

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

Cheers Smile

_________________
Woof Mailing List | keep the faith Cool |
Back to top
View user's profile Send private message Visit poster's website 
thunor


Joined: 14 Oct 2010
Posts: 350
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings

PostPosted: Mon 26 Sep 2011, 09:15    Post subject:  

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
Back to top
View user's profile Send private message Visit poster's website 
thunor


Joined: 14 Oct 2010
Posts: 350
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings

PostPosted: Thu 29 Sep 2011, 13:12    Post subject:  

I'm an application developer now Cool

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
Back to top
View user's profile Send private message Visit poster's website 
frafa


Joined: 04 Aug 2011
Posts: 10
Location: MONTPELIER

PostPosted: Thu 29 Sep 2011, 19:57    Post subject:  

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

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



Download example: http://liveusb.info/tmp/colorchooser.tar.bz2
1° test ./ColorPicKer.sh
2° test ./ColorPicKe-xml.sh
Smile
Back to top
View user's profile Send private message Visit poster's website 
thunor


Joined: 14 Oct 2010
Posts: 350
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings

PostPosted: Fri 30 Sep 2011, 07:36    Post subject:  

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 Shocked
ColorPicKe-xml.sh = 0m1.07s

That's a nice application Smile You should change
Code:
widget "*Button" style "styleBorderless"

to
Code:
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, 07:46; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
8-bit


Joined: 03 Apr 2007
Posts: 3382
Location: Oregon

PostPosted: Fri 30 Sep 2011, 07:43    Post subject:  

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.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 23 of 55 [821 Posts]   Goto page: Previous 1, 2, 3, ..., 21, 22, 23, 24, 25, ..., 53, 54, 55 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Cutting edge
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1341s ][ Queries: 13 (0.0171s) ][ GZIP on ]