GtkDialog - tips
Funny that glade bug is not apparent in spup.
Anyway, new spup will be soon and I'll include the latest gtkdialog revision too (and perhaps some other gtkdialog goodies
)


Puppy Linux Blog - contact me for access
I have been playing with the child window that patriot so kindly made work.
I found that by including a text area with a variable for the child process, I could add a child that was a lot more than just a text box.
I then proceeded to add another child process to see if more than one was supported.
It is. But it is a one way thing. The first child process in the script must be launched first or the script will crash.
But after starting both child processes, either can be closed from the main dialog.
It was an interesting experience though.
And for the curious, I actually used one of the gtkdialog examples of tree stock icons as a child process.
Also, the example in usr/share/doc/gtkdialog3/examples/01.02-button_action_types needs the addition of a variable statement to work correctly as to closing the child from the child window.
I found that by including a text area with a variable for the child process, I could add a child that was a lot more than just a text box.
I then proceeded to add another child process to see if more than one was supported.
It is. But it is a one way thing. The first child process in the script must be launched first or the script will crash.
But after starting both child processes, either can be closed from the main dialog.
It was an interesting experience though.
And for the curious, I actually used one of the gtkdialog examples of tree stock icons as a child process.
Also, the example in usr/share/doc/gtkdialog3/examples/01.02-button_action_types needs the addition of a variable statement to work correctly as to closing the child from the child window.
- Argolance
- Posts: 3767
- Joined: Sun 06 Jan 2008, 22:57
- Location: PORT-BRILLET (Mayenne - France)
- Contact:
Hello,
Thank a lot to zigbert for GtkDialog tips which are so clever and... useful!
Question:
In the script showing how to move items in list by drag'n drop...
... I noticed annoying behavior:
When user just clicks any item of the list without dragging it (this may happen!), the list disappears and let just the clicked item inside... Have somebody got any idea about the way to prevent this?
Thanks you a lot for your attention.
Cordialement!
Thank a lot to zigbert for GtkDialog tips which are so clever and... useful!
Question:
In the script showing how to move items in list by drag'n drop...
Code: Select all
#!/bin/sh
move (){
PRESS_EVENT="`cat /tmp/PRESS_EVENT`"
grep -Fv "$PRESS_EVENT" /tmp/list > /tmp/tmp
grep -Fm1 -B500 "$TREE" /tmp/tmp | grep -v "$TREE" > /tmp/tmp1
echo "$PRESS_EVENT" >> /tmp/tmp1
grep -Fm1 -A500 "$TREE" /tmp/tmp >> /tmp/tmp1
mv -f /tmp/tmp1 /tmp/list
}
export -f move
ls -1 /usr/share/backgrounds > /tmp/list
export test="
<tree rules_hint=\"true\" hover-selection=\"true\" tooltip-text=\"Drag'n drop items to move them in list\">
<label>Backgrounds</label>
<input>cat /tmp/list</input>
<variable>TREE</variable>
<height>300</height><width>200</width>
<action signal=\"button-press-event\">echo \$TREE > /tmp/PRESS_EVENT</action>
<action signal=\"button-release-event\">move</action>
<action signal=\"button-release-event\">refresh:TREE</action>
</tree>"
gtkdialog3 --center -p test
When user just clicks any item of the list without dragging it (this may happen!), the list disappears and let just the clicked item inside... Have somebody got any idea about the way to prevent this?
Thanks you a lot for your attention.
Cordialement!
I am not sure how one could code it, but it seems that the button-release-event that calls the move function is not at fault.
Instead, the button-press-event would call another function to note the cursor position in a variable and then the move function would check that variable for a change of cursor position.
If it was the same, the move would be aborted.
Instead, the button-press-event would call another function to note the cursor position in a variable and then the move function would check that variable for a change of cursor position.
If it was the same, the move would be aborted.
- Argolance
- Posts: 3767
- Joined: Sun 06 Jan 2008, 22:57
- Location: PORT-BRILLET (Mayenne - France)
- Contact:
Hello 8-bit,
Thanks for your reply.
Please, may I ask you to tell more about or give any link where I could find example or explanations?
Cordialement.
Thanks for your reply.
This is probably one of the solutions!Instead, the button-press-event would call another function to note the cursor position in a variable and then the move function would check that variable for a change of cursor position.


Cordialement.
where to find window icons
I can't seem to get a window icon to appear on my apps. Can some tell me where the icon image files needs to be located to work on a dialog as below.
<window title=\"NASViewer\" icon-name=\"NASviewer16.xpm\">
I've tried the full path as well and that didn't work.
Thanks!
<window title=\"NASViewer\" icon-name=\"NASviewer16.xpm\">
I've tried the full path as well and that didn't work.
Thanks!
- thunor
- Posts: 350
- Joined: Thu 14 Oct 2010, 15:24
- Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
- Contact:
You create a shell script to construct a Gtkdialog XML-like structure which is stored within a shell variable that's passed to the gtkdialog binary. The variable names that Gtkdialog exports to the shell are those that you've instructed it to use e.g. <variable>LABEL1</variable> (widgets containing multiple items also export additional variables with an "_ALL" suffix on exit). Recently I found within an example a Gtkdialog exported shell variable named BUTTON which holds the mouse button id (if applicable) that triggered an action, but I'm not aware of anything else (I searched the code for "setenv" and "putenv"). Therefore other than MAIN_DIALOG, the <variable> names that you store within the XML and BUTTON that Gtkdialog may export, what else is there to conflict with? If you give me an example I can assist you with it.8-bit wrote:When one is writing a gtkdialog script, there seems to be no reference one can refer to as to words that are reserved for gtkdialog.
A list of those words would be nice so one knows not to use them as variables or other areas where they might conflict with reserved words.
Good idea or bad?
Dave_G wrote:I've just started coding with gtkdialog and have to agree 100% with 8-bit.
Unfortunately this lack of documentation is not unique to gtkdialog, it seems
to be pretty common in the Linux world.
A very big stumbling block for newbies like myself.
Dave.
- Widget Reference - it's not completely populated but it's a good start.
- GTK+ 2 Reference Manual for the GtkEntry Widget - the <entry> widget within Gtkdialog (the GTK+ read/write properties are the Gtkdialog tag attributes).
- Use the GTK+ 2 Reference Manual to find other properties for other widgets or use Gtkdialog's Widget Reference which already includes the links.
- There's a very useful Widget Construction section with links to GTK+ widget properties (tag attributes) within the main post of the Gtkdialog Development thread.
- The same post includes a list of comprehensive examples for the newly added or extended widgets.
- You can browse the original but recently updated examples within the repository or you can checkout the source code; examples included.
- There's a Documentation section on the project page.

Regards,
Thunor
- thunor
- Posts: 350
- Joined: Thu 14 Oct 2010, 15:24
- Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
- Contact:
Issue 8 within the issue tracker (zigberts issues) has a request for "supporting <item stock=gtk-open>coloumn1|coloumn2</item> from an input file". I came across an example named 09.03-tree_icon_columns that supports <input stock_column="0"> which accepts a stock_id as the first column (icon_column="0" also works for theme icons). Therefore the ability to input stock or theme icons into tree rows from a file already exists and you can do it like this:
Regards,
Thunor
Code: Select all
#!/bin/sh
GTKDIALOG=gtkdialog
function inputfile() {
echo "gtk-open | | gtk-open | 2
gtk-about | | gtk-about | 2
gtk-add | | gtk-add | 2
gtk-apply | | gtk-apply | 2
gtk-bold | | gtk-bold | 2
gtk-cancel | | gtk-cancel | 2
gtk-cdrom | | gtk-cdrom | 2
gtk-clear | | gtk-clear | 2
gtk-close | | gtk-close | 2
gtk-color-picker | | gtk-color-picker | 2
gtk-convert | | gtk-convert | 2 " > inputfile
ifs="$IFS"
IFS=
echo $(<inputfile)
IFS="$ifs"
}; export -f inputfile
export MAIN_DIALOG='
<vbox>
<frame Stock icons from file via input command>
<tree>
<variable>TREE1</variable>
<label>0 | 1 | 2</label>
<height>300</height><width>250</width>
<input stock_column="0">inputfile</input>
</tree>
</frame>
<button ok></button>
</vbox>
'
$GTKDIALOG --program=MAIN_DIALOG
Thunor
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
Jwm will automatically look for an icon with the _same_ name as your program in its icon path (name.png or name.xpm) ... no 16, case must match etc...just make a symlink without the description of size etc... most wm's do the same.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
thunor,
Speaking of examples, what is it with an included example in gtkdialog/examples/09.12-tree-one-column
It is written with an incorrect path to gtkdialog and even though the executable property is set on it, it shows the same as a text file would and not an executable script.
It looks like it is supposed to populate itself with files from the working directory, but does not.
Is it a "fix it yourself" example?
I am just curious as to what it is supposed to display.
Also!! Thank you for the references of documentation for gtkdialog.
It all helps as does this offering by seaside.
Speaking of examples, what is it with an included example in gtkdialog/examples/09.12-tree-one-column
It is written with an incorrect path to gtkdialog and even though the executable property is set on it, it shows the same as a text file would and not an executable script.
It looks like it is supposed to populate itself with files from the working directory, but does not.
Is it a "fix it yourself" example?
I am just curious as to what it is supposed to display.
Also!! Thank you for the references of documentation for gtkdialog.
It all helps as does this offering by seaside.
Jpeps,jpeps wrote:Is there any way to add a filter to gtk-open "fileselect" for specific filetypes?
I have not seen any way, although there is the "complete" function, but I don't think it's available.
You could perhaps call Zenity/Yad or maybe Xdialog (not sure about Xdialog) with a "yad --file-selection --file-filter" option.
Regards,
s
EDIT: I suppose you could also do a "ls *.jpg" action to a tmpfile and then pick from there.