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
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#511 Post by thunor »

seaside wrote:There is one item missing from Gtkdialog - the ability to do multiple selection of items.
[EDIT] Updated 20110621-18:38

Hi seaside

Implemented in SVN r12 :)

See this post for syntax and example code.

Regards,
Thunor
Last edited by thunor on Tue 21 Jun 2011, 17:26, edited 1 time in total.

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

no more gif animation

#512 Post by vovchik »

Dear thunor,

I just noticed that the latest patches prevent gtkdialog from showing animated gifs :(. Standard issue does, and I use it to show animations as follows:


Code: Select all

#! /bin/bash

# -----------------
# Functions
# -----------------

# --------------
# get pic info
# --------------
init_vars()
{
mypicsize=`stat --format=%s "$mypic"`
mypicinfo=`nconvert -info -quiet "$mypic"`
mypicinfo=`echo "$mypicinfo" | grep -v Success`
mypicbase=`basename $mypic`
mypicinfo="    Image           : ""$mypicbase""$mypicinfo""
    Size            : $mypicsize"" bytes"
}


# --------------
# make pic gui
# --------------
make_pic_gui()
{

export show_pic='
<window title="PShowPic: '$mypicbase'" icon-name="gtk-refresh">
	<vbox>
		<frame>
			<pixmap>
				<input file>'$mypic'</input>
			</pixmap>
		</frame>
		<hbox>
			<button help>
				<action>launch:show_pic_help</action>
			</button>
		</hbox>
	</vbox>
</window>
'
}

# --------------
# make help gui
# --------------

make_help_gui()
{
export show_pic_help='
<window title="PShowPic Info" icon-name="gtk-about">
	<vbox>
		<frame>
			<text use-markup="true">
				<label>"<tt><b>'$mypicinfo'</b></tt>"</label>
			</text>
		</frame>
		<hbox>
			<button cancel>
				<action>closewindow:show_pic_help</action>
			</button>
		</hbox>
	</vbox>
</window>
'
}

# --------------
# display gui
# --------------

display_gui()
{
	gtkdialog3 --program=show_pic --center 
}

# -----------------
# End Functions
# -----------------

# -----------------
# Main
# -----------------

mypic="$1"
init_vars
make_pic_gui
make_help_gui
display_gui

# -----------------
# End Main
# -----------------
Can anything be done to preserve this ability and still enable scaling? Could be a "trade-off" or a regression error.

With kind regards,
vovchik

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

Re: no more gif animation

#513 Post by thunor »

vovchik wrote:I just noticed that the latest patches prevent gtkdialog from showing animated gifs...
[EDIT] I have modified the code. Therefore [currently] animated gifs will scale but they'll stop animating. Viewnior manages to scale them so I just need to look into it.
01micko wrote:How do we set up a sourceforge or google account for this? It's getting a bit hard to keep up! I compiled thunor's patches in and thought everything was rosy until I realised I forgot the Moose patch!
[EDIT] I have created a project page for gtkdialog and am in the process of setting it up.

Regards,
Thunor

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

#514 Post by 01micko »

Thanks for setting up the project page thunor!

IMHO it assures the continuation of development for gtkdialog. I did a checkout and the animated gifs work fine for me if left unscaled. I'm sure that will please vovchik as well.

_____

OT.. checked out a couple of your games, "pipe panic" is a fun spin on that old dos version :) . I might make a post in the games thread.

Cheers
Puppy Linux Blog - contact me for access

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#515 Post by zigbert »

thunor wrote:I have created a project page for gtkdialog and am in the process of setting it up.
This makes me emotional.

User avatar
sc0ttman
Posts: 2812
Joined: Wed 16 Sep 2009, 05:44
Location: UK

#516 Post by sc0ttman »

zigbert wrote:
thunor wrote:I have created a project page for gtkdialog and am in the process of setting it up.
This makes me emotional.
I love gtkdialog, if it can be extended, I'd love to help (if I can) and would LOVE to see the results :D


Forgive me if this is already a working feature, but I dont know about it:
I'd like to ability to make non-editable comboboxes

<combobox editable="false">

or whatever
[b][url=https://bit.ly/2KjtxoD]Pkg[/url], [url=https://bit.ly/2U6dzxV]mdsh[/url], [url=https://bit.ly/2G49OE8]Woofy[/url], [url=http://goo.gl/bzBU1]Akita[/url], [url=http://goo.gl/SO5ug]VLC-GTK[/url], [url=https://tiny.cc/c2hnfz]Search[/url][/b]

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

#517 Post by thunor »

01micko wrote:Thanks for setting up the project page thunor!

IMHO it assures the continuation of development for gtkdialog. I did a checkout and the animated gifs work fine for me if left unscaled. I'm sure that will please vovchik as well.
You're welcome. Scaling animated gifs and enabling different selection modes in the tree widget I am already tackling.
zigbert wrote:This makes me emotional.
It makes updating and extending it so much more productive. I guess folk [from any distro] didn't have time to set it up before.
sc0ttman wrote:I love gtkdialog, if it can be extended, I'd love to help (if I can) and would LOVE to see the results :D

Forgive me if this is already a working feature, but I dont know about it:
I'd like to ability to make non-editable comboboxes

<combobox editable="false">

or whatever
Hi sc0ttman

Once I've set-up the issue tracking system I'll add some feature requests for the functionality people are requesting :)

This is Gtkdialog's new home: http://code.google.com/p/gtkdialog/

I went through all the patches that I've found and applied them if necessary. I've fixed all the warnings and removed all the auto-generated files. Everything I've done is recorded in the ChangeLog and the SVN logs.

http://code.google.com/p/gtkdialog/source/checkout explains how to check it out. Initially you'll need to run autogen.sh rather than configure because the auto-generated files will require creating. Then type make.

Possibly there are people here who'd like to assist with extending or maintaining the project -- especially since Puppy uses it so extensively -- so if you'd like write access to the repository (project committer in Google parlance) then PM me your Google account email address.

Personally I like to review my changes with "svn status" before committing and keep the version in the repository stable. This means that whoever checks it out (developer or user) can expect it to be in a usable condition.

Regards,
Thunor

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#518 Post by zigbert »

I have updated the main post to reflect the new situation with thunor in the front seat, and added info about how to scale/refresh pixmaps.


Sigmund

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#519 Post by zigbert »

Also made some cleanup for <entry> information.

I have removed the info about patriots fix - Now when this is covered by thunor, this 'tips and tricks' thread is only about features (not bugfixes)


Sigmund

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

#520 Post by thunor »

Added tree widget additional selection modes

Code: Select all

<tree selection_mode="none"> or <tree selection-mode="0">
<tree selection_mode="single"> or <tree selection-mode="1">
<tree selection_mode="browse"> or <tree selection-mode="2">
<tree selection_mode="multiple"> or <tree selection-mode="3">
None mode prevents selection.
Single mode is the default that Gtkdialog already supported.
Browse mode prevents deselection.
Multiple mode allows the user to select multiple rows with the rows being returned seperated by newlines "\n", so if 3 rows were selected in TREE then TREE would return:
"row 1
row 2
row 3"

Here's an example of all modes (run it in a terminal to see the output):

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 funcfiletreCreate() {
	if [ -f $1 ]; then rm $1; fi
	for ((f = 0; f < $2; f++)); do
		echo "#$f This is selection_mode=\"$3\"" >> $1
	done
}

function functreCreate() {
	echo '<tree selection_mode="'$2'">
			<variable>'$1'</variable>
			<label>Items</label>
			<width>300</width><height>200</height>
			<input>cat file'$1'</input>
		</tree>
		<hbox homogeneous="true">
			<button>
				<label>"    Delete    "</label>
				<action>echo "Deleting $'$1'"</action>
				<action type="removeselected">'$1'</action>
			</button>
			<button>
				<label>"    Reload    "</label>
				<action>echo Reloading file'$1'</action>
				<action type="refresh">'$1'</action>
			</button>
		</hbox>'
}

funcfiletreCreate filetreNone 3 none
funcfiletreCreate filetreSingle 3 single
funcfiletreCreate filetreBrowse 3 browse
funcfiletreCreate filetreMultiple 16 multiple

export MAIN_DIALOG='
<window title="treSelectionModes" resizable="false">
	<vbox>
		<frame tree widget selection modes>
			<hbox>
				<vbox>
					'"$(functreCreate treNone none)"'
					'"$(functreCreate treSingle single)"'
				</vbox>
				<vbox>
					'"$(functreCreate treBrowse browse)"'
					'"$(functreCreate treMultiple multiple)"'
				</vbox>
			</hbox>
		</frame>
		<hbox homogeneous="true">
			<button ok></button>
		</hbox>
	</vbox>
	<action signal="hide">exit:Exit</action> 
</window>
'

$GTKDIALOG --center --program=MAIN_DIALOG
[EDIT] Added note about required version.

Regards,
Thunor
Last edited by thunor on Tue 05 Jul 2011, 20:16, edited 4 times in total.

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#521 Post by zigbert »

Hello thunor
It is amazing to see that you are improving the gtkdialog source.
I want to share some thoughts for further improvements.
I don't want to nag about new widgets or heavy new features.
I don't want to focus on 'the look' - like widget-placement, scaling, alignment....
I see it as more important to improve some weak functions. I think some of these thoughts could be easy to add, and give great new developer tools.

1.)
Today gtkdialog supports drag'n drop as explained in my main post.
To build drag'n drop support between <tree> widgets, they must be set to <tree hover-selection="true">. Most common, and most flexible is to use a normal selection mode. The reason why normal selection doesn't support drag'n drop is because <action signal="button-press-event"> is executed before item is selected. If it was the other way around, drag'n drop would be possible.

2.)
Would it be hard to add a right-click-menu:
- First we need the fix mentioned above.
- The <menu> widget must be loadable without a <menubar>.
- Now we could launch a new gui with a <menu> if user right-clicks.
- The launched gui must use <window decorated="false" skip_taskbar_hint="true" window_position="2">.
- This will work, though the window_position=2 (at mouse position) places the mouse-pointer in the middle of the gui, rather than up-left which is normal.

3.)
Click on <table> header doesn't sort.

4.)
I prefer the <tree> widget over the <table> widget because of more options. But it is one thing that <table> does much better than <tree>; rendering of huge lists.
While a gui including a <tree> must load it's content before the gui shows up, a gui with a <table> shows up at once, and _then_ starts rendering the content of the list. If this is possible for the <tree> widget, I see no reason for not doing so.

5.)
Icons in the <tree> widget is working very well as long as these are defined as
<item stock=gtk-open>coloumn1|coloumn2</item>
I wonder if it would be possible to add this feature for an <input file>. With your pixmap-refresh-improvement, I see huge possibilities if icons in <tree> could be refreshed the same way. This requires to work with <input file>, because <items> are statically loaded before gui execution, and can't be refreshed.

6.)
I see on the new gtkdialog homepage that slider widget is on your todo list. Hopefully this includes the possibility to refresh its status, so the slider can move (without user interaction) to show new status in case it has changed.

7.)
I don't know gtk or C, but I find it strange that the existing <menu> widget doesn't support submenus. Not VERY important, but as gtdialog becomes better, we use it for more complex tasks, and then this feature becomes handy.


Best wishes
Sigmund

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

#522 Post by 8-bit »

One thing I am a little concerned about is that Puppy was using gtkdialog3.
And all your scripts show using gtkdialog, which was the starting one and went from it to gtkdialog2 and finally 3.
I realize I can create syslinks for gtkdialog using other version names.
The reason for the syslinks is so existing gtkdialog scripts used in Puppy will still work.

User avatar
sc0ttman
Posts: 2812
Joined: Wed 16 Sep 2009, 05:44
Location: UK

#523 Post by sc0ttman »

zigbert wrote:Hello thunor
It is amazing to see that you are improving the gtkdialog source.
...
I don't want to nag about new widgets or heavy new features.
I would like to see a very high priority put into making backwards compatibility 100% stable..

For example, the IPConfig tool breaks (in Wary, I think) when the new gtkdialog is used, apparently..

I must say, I am not going to try influence this project at all,
as I am not knowledgeable enough about GTKdialog, GTK widgets, etc, etc,...

And Sorry if this is the wrong place to post.. but..

I have heard lots of people prefer Yad to GTK-Dialog..

One reason is that is has mutliple select boxes..
Not sure of any other reasons.. But it got me thinking..

Maybe we could identify (important) things in Yad that are missing in GTKdialog.

Just a thought... I don't know enough to take the thought further - but users on this forum are now creating more and more Yad GUIs, especially Stu90, Vovchik - maybe they could weight in and say what is missing from GTK-Dialog, and why they chose Yad (or even BaCon)..

I'm sure no one would mind if thunor PM'ed a few people with such questions..
And if no one wants to do that, I would be happy to.
[b][url=https://bit.ly/2KjtxoD]Pkg[/url], [url=https://bit.ly/2U6dzxV]mdsh[/url], [url=https://bit.ly/2G49OE8]Woofy[/url], [url=http://goo.gl/bzBU1]Akita[/url], [url=http://goo.gl/SO5ug]VLC-GTK[/url], [url=https://tiny.cc/c2hnfz]Search[/url][/b]

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#524 Post by zigbert »

sc0ttman
What is wrong with using yad, bacon or xdialog?

regarding backwards compatibility, what is the problem with fixing the xml code in IPConfig or other. The big deal about gtkdialog (as I see it) is that
- it is EXTREMELY easy to set up a gui. Probably much easier than refining the gtkdialog source code to be backward comapatible.
- Using bash, the code is very transparent for the community. When a user got trouble with ie. Pburn, I can ask her/him to change line 245 in /usr/local/pburn/func to ...


Sigmund

User avatar
smokey01
Posts: 2813
Joined: Sat 30 Dec 2006, 23:15
Location: South Australia :-(
Contact:

#525 Post by smokey01 »

Hi Thunor, another simple thing that i find annoying is the inability to just press the enter key when entering data. Clicking the OK button works but pressing the enter key is more intuitive.

I'm not suggesting removing the OK button, rather implement the Enter Key = OK button.

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#526 Post by zigbert »

smokey01
This is already supported

Code: Select all

#!/bin/sh

export ok_box='
<window>
 <vbox> 
  <text><label>press _enter_ to activate OK-button</label></text>
  <hbox>
   <button can-default="true" has-default="true" use-stock="true">
    <input file icon="gtk-ok"></input>
    <label>Ok</label>
   </button>
  </hbox>
 </vbox>
</window>'
gtkdialog3 -p ok_box

User avatar
smokey01
Posts: 2813
Joined: Sat 30 Dec 2006, 23:15
Location: South Australia :-(
Contact:

#527 Post by smokey01 »

Thanks Zigbert. I have been trying to find that for ages.

User avatar
sc0ttman
Posts: 2812
Joined: Wed 16 Sep 2009, 05:44
Location: UK

#528 Post by sc0ttman »

zigbert wrote:sc0ttman
What is wrong with using yad, bacon or xdialog?
Nothing, I wasn't saying people should avoid them - I love Xdialog.. Yad is nice too.. Haven't tried bacon, but I bet it's also nice.. But, for example, Yad requires a fairly new GTK, so GTK Dialog will work on systems where Yad does not..

I just think maybe we could ask others, who prefer Yad, what they think is missing in GTK-Dialog ...
Just a suggestion.
zigbert wrote:regarding backwards compatibility, what is the problem with fixing the xml code in IPConfig or other. The big deal about gtkdialog (as I see it) is that
Would just be nice if all the existing scripts we have in Puppy (many of which are no longer maintained by anyone in particular) still work as they are, that's all.
[b][url=https://bit.ly/2KjtxoD]Pkg[/url], [url=https://bit.ly/2U6dzxV]mdsh[/url], [url=https://bit.ly/2G49OE8]Woofy[/url], [url=http://goo.gl/bzBU1]Akita[/url], [url=http://goo.gl/SO5ug]VLC-GTK[/url], [url=https://tiny.cc/c2hnfz]Search[/url][/b]

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#529 Post by zigbert »

smokey01 wrote:Thanks Zigbert. I have been trying to find that for ages.
I have added the tip to the main post

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#530 Post by zigbert »

sc0ttman
Don't get me wrong, I see nothing bad in either extended features or backward compatibility...... But I see thunor in a vulnerable position. He will likely get bombed with requests of new heavy tasks. I think we should motivate and help him instead of asking him to save the world.

I see it often when I ask for help/suggestions that the replies is; 'I would like to see this/that feature'...... instead of actually help out. I don't say that the suggester should implement the feature, but if he really investigated the issue, he probably could be of great help with his new knowledge. Most often, I get a link to a web-page, and the user might think he helped out....... I don't know?


Sigmund

Post Reply