GtkDialog - tips

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
pemasu
Posts: 5474
Joined: Wed 08 Jul 2009, 12:26
Location: Finland

#561 Post by pemasu »

Thunor. Thank you of your quick testing, fix and report. I will retest new gtkdialog3 when it is time and will include it to the next version of my puppy. It seems nice way to find some problems and it will benefit all to get them hunted.

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

#562 Post by 01micko »

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 :wink: )
Puppy Linux Blog - contact me for access

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

#563 Post by 8-bit »

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.

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#564 Post by Argolance »

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...

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
... 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!

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

#565 Post by 8-bit »

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.

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#566 Post by Argolance »

Hello 8-bit,
Thanks for your reply.
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.
This is probably one of the solutions! :D Please, may I ask you to tell more about or give any link where I could find example or explanations? :oops:

Cordialement.

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

#567 Post by 8-bit »

Argolance nad others,
If you want to see my solution to the drag example list disappearing, go
HERE.

It may not be the best, but it works.
And by the way, I found all I needed on this forum! :) :)

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#568 Post by Argolance »

Thank you a lot! :wink:

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

#569 Post by 8-bit »

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?

User avatar
Dave_G
Posts: 453
Joined: Thu 21 Jul 2011, 13:53

#570 Post by Dave_G »

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.

mrd
Posts: 124
Joined: Wed 28 Nov 2007, 02:04

where to find window icons

#571 Post by mrd »

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!

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

#572 Post by 8-bit »

If you click on ROX, the house icon on your desktop and then on Puppy Reference, there will be a number of icon directory links shown.
You can put your icon in any of them although I would suggest /usr/share/mini-icons.
Or you can create a link to it.

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

#573 Post by thunor »

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?
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.
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.
If there's something that you think is lacking in documentation then let me know and I'll address the issue :)

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:

#574 Post by thunor »

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:

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 
Regards,
Thunor

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#575 Post by technosaurus »

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].

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

#576 Post by 8-bit »

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.

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

#577 Post by thunor »

8-bit wrote:...what is it with an included example in gtkdialog/examples/09.12-tree-one-column
Fixed now, and 09.00-tree as well.

They use "ls" to build rows using theme icons but the commands weren't working properly and the icons didn't exist.

Regards,
Thunor

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

#578 Post by 8-bit »

Again, I know it has been said many times, but I will say it again.

Thank you thunor!!!

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#579 Post by jpeps »

Is there any way to add a filter to gtk-open "fileselect" for specific filetypes?

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#580 Post by seaside »

jpeps wrote:Is there any way to add a filter to gtk-open "fileselect" for specific filetypes?
Jpeps,

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.

Post Reply