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 May 2013, 13:55
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
GtkDialog - tips
Post new topic   Reply to topic View previous topic :: View next topic
Page 6 of 52 [769 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6, 7, 8, ..., 50, 51, 52 Next
Author Message
sunburnt


Joined: 08 Jun 2005
Posts: 4006
Location: Arizona, U.S.A.

PostPosted: Fri 16 Oct 2009, 05:07    Post subject:  

zigbert; I tried various ways of what you suggest and I had no luck.
Could you please give an example of what you`re proposing?
Back to top
View user's profile Send private message 
zigbert


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

PostPosted: Fri 16 Oct 2009, 12:25    Post subject:  

sunburnt
An example will require to build a complete left-pane for the filebrowser. I am in lack of time, but if you have no rush, I will try to make it in a week or 2 ..............


Sigmund

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


Joined: 08 Jun 2005
Posts: 4006
Location: Arizona, U.S.A.

PostPosted: Fri 16 Oct 2009, 12:48    Post subject:  

zigbert; I`m a little unsure of the extent of "build complete".
I don`t want you to spend lots of time on this, it`s not critical.
If it`s possible... Just post examples of tree sub branch control.

If you have to "play" with it for awhile to figure it out, take your time...

Icons would be nice of course, but gtkDialog is not very flexible.
I gather from the discussion that gtkDialog does support some
underlying properties of GTK, but I don`t know how to use them.
Back to top
View user's profile Send private message 
zigbert


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

PostPosted: Fri 16 Oct 2009, 16:56    Post subject:  

sunburnt
What I mean with 'build complete' is that the list must be completely built by bash each time user click on a directory.

This draft only gives a picture how it could be solved.
It is not tested or complete.

1. List directories in <table>.
<table><variable>DIR</variable><labels>"|directory structure"</label><input>cat /tmp/dirs</input>
I would use a command like:
Code:
find "$DIR" -maxdepth 1 -mindepth 1 -type d -follow -printf "  %p|%f/\n" | sort > /tmp/dirs

The trick here is to list full path of directories in first column, and then hide the column with the given <label>.

2. Add a + in front of all directories that includes subdirectories. Others gets a -.
I suggest here to use sed, but since it is a very slow command, you should probably search for a faster solution.
Code:
cut -c 3 /tmp/dirs > /tmp/dirs2 #get rid of spaces added by -printf command
while read I; do
   NAME=`basename "$I"`
   if [ -d "`ls -1 --group-directories-firs "$I" | head -n 1`" ]; then
      sed -i -e "s%|$NAME%|+ $NAME%g" /tmp/dirs
   else
      sed -i -e "s%|$NAME%|- $NAME%g" /tmp/dirs
   fi      
done < /tmp/dirs2


3. User click on a + directory and the list must expand with the given sublevel
Code:
BEFORE="`grep --before-context=1000 -w "$DIR" /tmp/dirs`"
AFTER="`grep --after-context=1000 -w "$DIR" /tmp/dirs`"
SUBLEVEL="`find "$DIR" -maxdepth 1 -mindepth 1 -type d -follow -printf "  %p|    %f/\n" | sort`"
echo -e "$BEFORE\n$DIR\n$SUBLEVEL\$AFTER" >  /tmp/dirs


4. Clear and Refresh <table>

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


Joined: 08 Jun 2005
Posts: 4006
Location: Arizona, U.S.A.

PostPosted: Fri 16 Oct 2009, 17:42    Post subject:  

I found this in the docs.:
But the tree tag "Hover_expand=" doesn`t seem to create sub levels.
Code:
#! /bin/bash
export MAIN_DIALOG='
<vbox>
  <frame Hover Mode>
    <tree hover_expand="true" hover_selection="true">
      <input file>tmp.text</input>
      <label>Device                        | Directory | File</label>
      <item stock="gtk-floppy">Floppy Disk | /floppy/  | ak.tex</item>
      <item stock="gtk-floppy">Floppy Disk | /floppy/  | ak.dvi</item>
      <item stock="gtk-floppy">Floppy Disk | /floppy/  | ak.ps</item>
      <item stock="gtk-floppy">Floppy Disk | /floppy/  | ak.pdf</item>
      <item stock="gtk-cdrom">CD_ROM Drive | /cdrom/   | </item>
      <height>100</height><width>400</width>
      <variable>TREE</variable>
    </tree>
  </frame>
  <hbox>
    <button cancel></button>
    <button ok></button>
  </hbox>
</vbox>
'
gtkdialog --program=MAIN_DIALOG

In fact in none of these examples have the sub triangles like the other example I posted.
For something SO VERY IMPORTANT, it`s hard to believe it`s not in the docs. (intentional).
Back to top
View user's profile Send private message 
Gedrean


Joined: 05 Jun 2009
Posts: 138

PostPosted: Mon 19 Oct 2009, 14:54    Post subject:  

It seems apparent that Laszlo Pere, while making a cool tool, managed to basically abandon it once it was able to create the tool he was actually aiming for, so documenting it was more of an afterthought for him.

Thanks to Zigbert for putting together all these awesome tips and helper notes, they've managed to make it so much easier (even as gtkdialog makes it so much harder) to build a good looking GUI.
Back to top
View user's profile Send private message 
Ale


Joined: 30 Nov 2007
Posts: 34

PostPosted: Tue 20 Oct 2009, 00:52    Post subject:  

I have been working on a gui lately for prboom. Has anyone found a way to make the file select dialogs start in directories other than root?

The only work around I have found is to execute the script in a directory where one wishes to open it. What I am asking is if I can have different file select widgets start in different directories.

Thanks for your time.
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 4006
Location: Arizona, U.S.A.

PostPosted: Tue 20 Oct 2009, 01:49    Post subject:  

Hi Ale; I use the Xdialog file selector for my apps. ( This may be what you ment )
Notice the: /mnt after: --fselect and --dselect? Set the path there...
Code:
FILE=`Xdialog --title "$TITLE" --dselect /mnt 0 0`
echo `Xdialog --title "$TITLE" --fselect /mnt 0 0` > /tmp/$Path-File

Two different ways of getting the /path/file info, a variable or a /tmp file.
The upper one is a directory /path selector and the lower is a /path/file selector.
An Xdialog file selector "bug": You must click on a file or no path is given.
Back to top
View user's profile Send private message 
zigbert


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

PostPosted: Tue 20 Oct 2009, 04:01    Post subject:  

Ale
You can execute 'cd /dir' before opening the fileselect widget.


Sigmund

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


Joined: 30 Nov 2007
Posts: 34

PostPosted: Tue 20 Oct 2009, 12:50    Post subject:  

zigbert wrote:
Ale
You can execute 'cd /dir' before opening the fileselect widget.


Sigmund


That does work quite well. I was using a helper script before to change the directory because I wanted to make it callable from the command line and open in a certain directory.

I wasn't specific enough, but I would like to know if it is possible to allow each file select box to search in separate directories. The first one would search in a directory of IWADs, and the second would be for PWADs, etc.

I used Technosaurus's template to get started and have been essentially working in reverse to learn more gtkdialog and bash.
My current work in progress can be found here:

http://www.murga-linux.com/puppy/viewtopic.php?t=47987
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 4006
Location: Arizona, U.S.A.

PostPosted: Tue 20 Oct 2009, 15:27    Post subject:  

Ale; Both zigbert`s and my examples will open Xdialog or whatever in any dir. you specify.
Just change the parameters for each file browser you want to open.
Code:
cd /(path)/IWADs
IFILE=`Xdialog --title "$TITLE" --fselect 0 0`
cd /(path)/PWADs
PFILE=`Xdialog --title "$TITLE" --fselect 0 0`
Back to top
View user's profile Send private message 
Patriot


Joined: 15 Jan 2009
Posts: 734

PostPosted: Tue 20 Oct 2009, 19:34    Post subject:  

Hmmm .....

@zigbert
I consider you our resident gtkdialog guru (at least so Smile ), so I hope you can help shed some light ... I have completed my service manager script (alpha quality stage) and I'm wondering if its possible to specify specific entry widget width sizes ... I was about to take a whack at gtkdialog sources but I thought I'll ask you first .... Take a peek at the screenshot ... It's the entry widgets that displays either running or stopped messages, I can't seem to control the width (to make the width smaller) ...

Kindly advise.


Best Rgds
svcdialog.png
 Description   
 Filesize   27.3 KB
 Viewed   1088 Time(s)

svcdialog.png

Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 4006
Location: Arizona, U.S.A.

PostPosted: Tue 20 Oct 2009, 20:08    Post subject:  

Just thought I`d pop in here Patriot, did you try the width-height tags?
Code:
<width>60</width><height>30</height>

Also the next frame down with checkboxes is the widest thing on the GUI.
This sets the GUI width and gtkDialog has a tendency to "fill in the spaces".
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 3843

PostPosted: Tue 20 Oct 2009, 20:19    Post subject:  

I haven't used height and width but it looks like it would "fix" itself if you put the Registered services only part on its own line (that line is increasing the width)

vbox
--- Registered services ....
hbox
---next checkbox
---next checkbox
....
/hbox
/vbox

_________________
Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
Patriot


Joined: 15 Jan 2009
Posts: 734

PostPosted: Wed 21 Oct 2009, 00:57    Post subject:  

Hmmm .....

Well, sunburnt, technosaurus ... thanks for your input ...

I've used previously the width/height tags (ie. width-request) but it didn't work as expected. I had already thought about the Registered services line length too and already tested it prior to posting the above question. Moving it onto its own line did not have any effect on the entry widget.

Anyway, after some messing with the tags, I now have an acceptable result. I've specified a longer text widget width and it squashed the entry widgets shorter and yet still retain overall compact window height. Still, there's no direct control over the entry widget widths ...

One thing that I find funny, for the text widget, specifying width-chars tag will make texts center justified within the specified width without being requested ...


Rgds
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 6 of 52 [769 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6, 7, 8, ..., 50, 51, 52 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
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.0853s ][ Queries: 13 (0.0154s) ][ GZIP on ]