Gtkdialog Development

Under development: PCMCIA, wireless, etc.
Message
Author
disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#166 Post by disciple »

Maybe there's something I'm missing about what you're asking, but Argolance's example I linked to is for a tree widget. Argolance was looking for help because it had a problem if you clicked on an item and didn't drag it, and 8-bit posted a link to a workaround for that problem using getcurpos http://www.murga-linux.com/puppy/viewto ... 651#549651
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#167 Post by disciple »

Ah, sorry - you haven't edited your last post, have you?
I thought you said you were not talking about your example of moving items in a list widget. But you didn't say that - I must have imagined it.
disciple wrote:Maybe there's something I'm missing about what you're asking
I think I was missing this bit:
zigbert wrote:using gtk-options
8-bit's example does not use gtk-options. Unless I'm misunderstanding what "gtk-options" means, of course.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

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

#168 Post by thunor »

zigbert wrote:...moving items inside a <tree> widget...using gtk-options.
The GTK+ property is "reorderable".

Regards,
Thunor

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

#169 Post by seaside »

Ah yes, "reorderable".

I think this operation needs a tooltip to go with it. I remember struggling with trying to move an item up and down a list and constantly ending up with placing it as a subheading instead.

The trick is after highlighting an item, drag it to the right and keeping the mouse button down move the item up and down and watch for a line under the item where you wish it placed.

Regards,
s

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

#170 Post by thunor »

seaside wrote:I remember struggling with trying to move an item up and down a list and constantly ending up with placing it as a subheading instead.
Hi seaside

I researched this a while back and I couldn't stop the branches from appearing when dragging-and-dropping onto existing rows. What I discovered was that Gtkdialog's tree widget is a GtkTreeView using the GtkTreeStore model which is "a tree-like data structure", whereas -- I'm assuming as I haven't tested it yet -- a GtkTreeView using the GtkListStore model implementing "a list-like data structure" may have been more appropriate. Maybe there was a reason why the tree-like structure was chosen over the list-like structure.

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:

#171 Post by thunor »

Added timer widget

The widget reference is available here.
  • The default signal is "tick", emitted when the timer ticks.
  • The default precision is seconds and the default interval is 1s.
  • Use the milliseconds="true/yes/1" custom tag attribute to use milliseconds.
  • Use the interval="value" custom tag attribute to set the interval (unsigned integer).
  • Use the tag attribute (GTK+ property) visible="false" to hide the timer.
  • Disabling the timer pauses it, enabling the timer unpauses it.
The timer is created enabled by default, but if you want it disabled then use the <sensitive>false</sensitive> directive or the sensitive="false" tag attribute.

The timer itself doesn't affect CPU usage (I tested with 255x1s timers) but what the application developer executes on the "tick" signal will.

<timer> widget example:

Code: Select all

#!/bin/sh

# NOTE: This example requires at least gtkdialog-0.7.21 (please visit
# http://code.google.com/p/gtkdialog/). Additionally if you are using
# Puppy Linux then you may find that an historical version of gtkdialog
# already exists in /usr/sbin, and if that is the case then you should
# modify the shell variable below to point to the new gtkdialog binary.

GTKDIALOG=gtkdialog

function funcpixCreate() {
	for f in 0 1 2 3; do
		echo '<pixmap>
				<variable>pix'$1$f'</variable>
				<input file>pix'$f'.svg</input>
			</pixmap>'
	done
}

function funcbtnCreate() {
	echo '<button>
			<input file stock="'$1'"></input>
			<action>'$2':tmr0</action>
			<action>'$2':tmr1</action>
			<action>'$2':tmr2</action>
			<action>'$2':tmr3</action>
		</button>'
}

function functmrCreate() {
	echo '<variable>tmr'$1'</variable>
			<action>funcpixRandomise</action>
			<action>refresh:pix'$1'0</action>
			<action>refresh:pix'$1'1</action>
			<action>refresh:pix'$1'2</action>
			<action>refresh:pix'$1'3</action>
		</timer>'
}

function funcimageCreate() {
	local -a colours=("a00000" "00a000" "0000a0" "ffffff")
	echo '
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
	<rect x="0" y="0" height="64" width="64" fill="#'${colours[$1]}'"/>
</svg>' > image$1.svg
}; export -f funcimageCreate

function funcpixRandomise() {
	local rand=
	for f in 0 1 2 3; do
		rand=$(($RANDOM % 4))
		ln -sf image$rand.svg pix$f.svg
	done
}; export -f funcpixRandomise

if [ ! -f image0.svg ]; then funcimageCreate 0; fi
if [ ! -f image1.svg ]; then funcimageCreate 1; fi
if [ ! -f image2.svg ]; then funcimageCreate 2; fi
if [ ! -f image3.svg ]; then funcimageCreate 3; fi

funcpixRandomise

export MAIN_DIALOG='
<window title="tmrTimer" resizable="false">
	<vbox>
		<frame timer widget>
			<vbox border-width="20">
				<hbox>
					<timer>
						'"$(functmrCreate 0)"'
					'"$(funcpixCreate 0)"'
				</hbox>
				<hbox>
					<timer interval="2">
						'"$(functmrCreate 1)"'
					'"$(funcpixCreate 1)"'
				</hbox>
				<hbox>
					<timer milliseconds="true" visible="false">
						'"$(functmrCreate 2)"'
					'"$(funcpixCreate 2)"'
				</hbox>
				<hbox>
					<timer milliseconds="true" interval="500" visible="false">
						'"$(functmrCreate 3)"'
					'"$(funcpixCreate 3)"'
				</hbox>
			</vbox>
		</frame>
		<hbox>
			'"$(funcbtnCreate gtk-no disable)"'
			'"$(funcbtnCreate gtk-yes enable)"'
			<button ok></button>
		</hbox>
	</vbox>
	<action signal="hide">exit:Exit</action>
</window>
'

$GTKDIALOG --center --program=MAIN_DIALOG
Regards,
Thunor
Last edited by thunor on Fri 12 Aug 2011, 14:41, edited 2 times in total.

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

#172 Post by Geoffrey »

I tried to compile the latest but it seems to have a problem, I don't really know much about this so it could be me.

Here is what I get after running make.

Code: Select all

widget_timer.o: In function `widget_timer_timer_callback':
/root/gtkdialog/src/widget_timer.c:379: undefined reference to `gtk_widget_get_sensitive'
widget_timer.o: In function `widget_timer_envvar_construct':
/root/gtkdialog/src/widget_timer.c:137: undefined reference to `gtk_widget_get_sensitive'
collect2: ld returned 1 exit status
make[3]: *** [gtkdialog] Error 1
make[3]: Leaving directory `/root/gtkdialog/src'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/root/gtkdialog/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/gtkdialog'
make: *** [all] Error 2
The previous version worked fine for me, seems to be the timer widget is the problem.

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

#173 Post by 01micko »

I tried to compile the latest but it seems to have a problem, I don't really know much about this so it could be me.
Working ok in Slacko-312.37

Don't you use quirky-NOP Geoffrey? gtk+ version is old in that.
Puppy Linux Blog - contact me for access

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

#174 Post by Geoffrey »

01micko wrote:
I tried to compile the latest but it seems to have a problem, I don't really know much about this so it could be me.
Working ok in Slacko-312.37

Don't you use quirky-NOP Geoffrey? gtk+ version is old in that.

Yeah, quirky 1.20 NOP, strange though it has worked ok up until now, I may have reached it's limitations, not to worry
I should look at using a newer version of puppy, It's just that I prefer xfce as a window manager.

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#175 Post by disciple »

thunor wrote:
zigbert wrote:...moving items inside a <tree> widget...using gtk-options.
The GTK+ property is "reorderable".

Regards,
Thunor
Ah, that's cool.

An interesting point is that neither method works after you sort the tree by clicking on a column header.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

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

#176 Post by thunor »

Geoffrey wrote:

Code: Select all

...
/root/gtkdialog/src/widget_timer.c:379: undefined reference to `gtk_widget_get_sensitive'
...
Hi Geoffrey

Sorry about that. gtk_widget_get_sensitive requires GTK+ 2.18.0 and I missed it, but thanks for letting me know as there is an older alternative which I've included and committed :)

Interestingly its sister function gtk_widget_set_sensitive already exists within the project and has no version requirements.

Regards,
Thunor
Last edited by thunor on Fri 12 Aug 2011, 10:10, edited 1 time in total.

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#177 Post by disciple »

I don't have the very latest gtkdialog here, but I'm guessing this isn't fixed yet:
seaside wrote:
potong wrote:sunburnt:
Here's a program written in two ways to show the different options.


Secondly --event-driven=filename

Code: Select all

#!/usr/sbin/gtkdialog3 -e
display(){ echo "Display: ${!1}"; }
...............
Just wanted to add that using the "#!/usr/sbin/gtkdialog3" event form requires that gtkdialog3 is symlinked to gtkdialog, otherwise it errs. I ran into this earlier using the "event driven" form of gtkdialog - no matter from a file or on the command line.

Potong, thanks for supplying all this great information on Gtkdialog. It is immensely helpful.

Regards,
s
Can anyone confirm?
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#178 Post by disciple »

In other words, if the executable is named something other than "gtkdialog", then you need to create a link to it named "gtkdialog", to be able to use the event-driven option.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

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

#179 Post by thunor »

disciple wrote:In other words, if the executable is named something other than "gtkdialog", then you need to create a link to it named "gtkdialog", to be able to use the event-driven option.
Well it's fixed now :) The "gtkdialog" binary name was hardcoded.

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:

#180 Post by thunor »

The badly named <visible>disabled </visible> directive has been deprecated in favour of <sensitive>false/no/0</sensitive> which is what it actually is. I'm going to remove <visible> from the wiki so that folk don't use it anymore.

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

#181 Post by Geoffrey »

thunor wrote:
Geoffrey wrote:

Code: Select all

...
/root/gtkdialog/src/widget_timer.c:379: undefined reference to `gtk_widget_get_sensitive'
...
Hi Geoffrey

Sorry about that. gtk_widget_get_sensitive requires GTK+ 2.18.0 and I missed it, but thanks for letting me know as there is an older alternative which I've included and committed :)

Interestingly its sister function gtk_widget_set_sensitive already exists within the project and has no version requirements.

Regards,
Thunor
Thanks it now works

Geoffrey

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

#182 Post by jpeps »

Hi thunor,

Is there no way to add a filter to gtk-open "fileselect" for specific filetypes?
This would really be a huge plus gtkdialog3. Thanks

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

#183 Post by thunor »

jpeps wrote:Is there no way to add a filter to gtk-open "fileselect" for specific filetypes?
Hi jpeps

I'll look into it (issue 23)

Regards,
Thunor

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

#184 Post by jpeps »

thunor wrote: I'll look into it (issue 23)
Great...thanks!

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

#185 Post by thunor »

Overhauled the notebook widget

The widget reference is available here.
  • The page number is now stored within the variable and can be refreshed from a command or a file.
  • Tab labels can be specified with the "tab-labels" custom tag attribute.
  • Tab labels can be generated automatically by using either or both of the "tab-prefix" and "tab-suffix" custom tag attributes.
  • Tab labels will be generated automatically using "Page n" in the absence of any of the above custom tag attributes.
  • The "tab-base-index" custom tag attribute can be used to control the start page number used within the auto-generated labels.
This widget does not accept setting a default page before being shown (there's a note about it here) which will result in <input> and <input file> data being discarded at start-up. This issue can be overcome by using the "page" tag attribute which will be applied after the widget is shown.

<notebook> widget example:

Code: Select all

#!/bin/sh

# NOTE: This example requires at least gtkdialog-0.7.21 (please visit
# http://code.google.com/p/gtkdialog/). Additionally if you are using
# Puppy Linux then you may find that an historical version of gtkdialog
# already exists in /usr/sbin, and if that is the case then you should
# modify the shell variable below to point to the new gtkdialog binary.

GTKDIALOG=gtkdialog

funcnbkCreate() {
	for f in 0 1 2 3 4; do
		echo '<vbox border-width="20">
				<hbox border-width="70">
					<text label="This is page '$f'"></text>
				</hbox>'
		if [ $1 -lt 2 ]; then echo '<hbox homogeneous="true">'; fi
		if [ $1 -eq 0 ]; then
			echo '<button use-stock="true" label="gtk-go-back">'
			if [ $f -eq 0 ]; then
				echo '<sensitive>false</sensitive>'
			else
				echo '<action>echo '$(($f - 1))' > inputfile</action>
					<action>refresh:nbk'$1'</action>'
			fi
			echo '</button>
				<button use-stock="true" label="gtk-go-forward">'
			if [ $f -eq 4 ]; then
				echo '<sensitive>false</sensitive>'
			else
				echo '<action>echo '$(($f + 1))' > inputfile</action>
					<action>refresh:nbk'$1'</action>'
			fi
		elif [ $1 -eq 1 ]; then
			echo '<button use-stock="true" label="gtk-refresh">
					<action>refresh:nbk'$1'</action>'
		fi
		if [ $1 -lt 2 ]; then
			echo '</button>
				</hbox>'
		fi
		echo '</vbox>'
	done
	echo '<variable>nbk'$1'</variable>'
	if [ $1 -eq 0 -o $1 -eq 2 ]; then
		echo '<input file>inputfile</input>'
	elif [ $1 -eq 1 ]; then
		echo '<input>echo $(($RANDOM % 4))</input>'
	elif [ $1 -eq 3 ]; then
		echo '<input>"if [ $(<inputfile) -eq 4 ]; then echo 0 > inputfile
			else echo $(($(<inputfile) + 1)) > inputfile; fi
			echo $(<inputfile)"</input>'
	fi
}

funcnbkMainCreate() {
	for f in 0 1 2 3; do
		echo '<vbox>
				<vbox homogeneous="true" height-request="300">
					<hbox homogeneous="true" width-request="500">'
		if [ $f -eq 0 ]; then
			echo '<notebook>
					'"$(funcnbkCreate $f)"'
				</notebook>'
		elif [ $f -eq 1 ]; then
			echo '<notebook tab-labels="One|Two|Three|Four|Five"
					page="04" tab-vborder="12" tab-pos="0">
					'"$(funcnbkCreate $f)"'
				</notebook>'
		elif [ $f -eq 2 ]; then
			echo '<vbox>
					<hscale range-min="0" range-max="4" value-pos="0">
						<variable>hsc0</variable>
						<action>save:hsc0</action>
						<action>refresh:nbk'$f'</action>
						<output file>inputfile</output>
					</hscale>
					<notebook show-tabs="false">
						'"$(funcnbkCreate $f)"'
					</notebook>
				</vbox>'
		elif [ $f -eq 3 ]; then
			echo '<vbox>
					<timer visible="false">
						<action>refresh:nbk'$f'</action>
					</timer>
					<notebook show-tabs="false" show-border="false">
						'"$(funcnbkCreate $f)"'
					</notebook>
				</vbox>'
		fi
		echo '</hbox>
			</vbox>
			<hseparator></hseparator>
			<hbox>
				<button use-stock="true" label="gtk-go-back">'
		if [ $f -eq 0 ]; then
			echo '<sensitive>false</sensitive>
					<action>""</action>'
		else
			echo '<action>echo '$(($f - 1))' > inputfile</action>
					<action>refresh:nbkMain</action>'
		fi
		echo '</button>
				<button use-stock="true" label="gtk-go-forward">'
		if [ $f -eq 3 ]; then
			echo '<sensitive>false</sensitive>
					<action>""</action>'
		else
			echo '<action>echo '$(($f + 1))' > inputfile</action>
					<action>refresh:nbkMain</action>'
		fi
		echo '</button>
				<button ok></button>
			</hbox>
		</vbox>'
	done
}

echo 0 > inputfile

export MAIN_DIALOG='
<window title="nbkNotebook" resizable="false">
	<vbox>
		<notebook show-tabs="false" show-border="false">
			'"$(funcnbkMainCreate)"'
			<variable>nbkMain</variable>
			<input file>inputfile</input>
		</notebook>
    </vbox>
	<action signal="hide">exit:Exit</action>
</window>
'
# Uncomment the following line to dump MAIN_DIALOG to a file:
# ifs=$IFS; IFS=; echo $MAIN_DIALOG > nbkNotebook.txt; IFS=$ifs

$GTKDIALOG --center --program=MAIN_DIALOG
Regards,
Thunor
Last edited by thunor on Sat 20 Aug 2011, 10:16, edited 3 times in total.

Post Reply