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
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#871 Post by don570 »

Tree widget is a
more powerful version of list widget.

I put a couple of examples of the tree widget in my

gtkdialog tutorial manual under 'refresh'

_____________________________________
Last edited by don570 on Sat 02 Nov 2013, 19:45, edited 1 time in total.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#872 Post by sunburnt »

Hi don570; Thanks for the reply, and thanks for the docs.

I used to work with GtkDialog`s tree, it was a little difficult to control, but it was a "tree".
All the examples I see now are lists. Doesn`t it do a real tree any more?

Hello again SFR; I think you may be right, but as I said above GtkDialog used to have one.
That was probably back in GTK+ 2.


Trying to get GTK widgets to behave is always a struggle. Only the basic level of control.
Like the List, simple 1 click selection is about all there is, as is the case for most widgets.

# I`m using the List as a Tree by indenting the text 2 spaces for each sub dir. level.
It seems the $FOLDER string lags the input. And Buttons 2 and 3 don`t select of course.

Code: Select all

#! /bin/bash

Path='/'
offX=2
offSet=0

ItemList() {
	eq20="===================="						# 20 "=" characters
	Indent=`echo "${eq20:0:$((offX*offSet))}" |sed 's/=/ /g'`	# convert = to space

	FolderList=`find /$1 -maxdepth 1 -type d |sed "1d;s#^.*$1/##" |sort`

	items=$(echo "$FolderList" |while read I
	do
		echo "<item>\"$Indent $I\"</item>"						# make gtkD items
	done)
	echo "$items"
}

ClkList() {

echo -e " |$1|    |$2|"

	LN=`echo "$Items" |grep -n "$1"`
	tmp=`echo "$Items" |head -n ${LN%:*}`				# first part of list
	tmp=$tmp`echo -e "\n`ItemList $1`\n"`				# new sub list
	tmp=$tmp`echo "$Items" |tail -n +$((${LN%:*}))`		# last part of list
echo "$tmp"
exit
	Items=$(echo "$FileList" |while read I
	do
		echo "$Indent<item>$I</item>"

		if [ "$I" = "$1" ];then
			subItems=`ls $1`
			echo "$FileList" |while read I
			do
				echo "$Indent<item>$I</item>"
			done
		fi
	done)
}

export btnFLAG
	
Items=`ItemList`

export Items
export -f ItemList ClkList ClkBtn

export FILER_DIALOG='
  <vbox>
    <list>
      <variable>FOLDER</variable>
      '$Items'
      <action signal="button-press-event">ClkList "$BUTTON" "$FOLDER"</action>
    </list>
    <hbox>
     <button ok></button>
     <button cancel></button>
    </hbox>
  </vbox>
'
gtkdialog --program=FILER_DIALOG

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

GtkDialog doesn`t have "action refresh"?

#873 Post by sunburnt »

I tried it with the combobox and the list, the only widget the docs. show it with is the progressbar.

I want the combobox selection to clear/refresh the list box. Or another combobox.

Code: Select all

export MIRRORS_DLG='
<window title=" Ubuntu Mirrors.">
<vbox>
  <text><label>Set World Region       </label></text>
  <combobox>
    <variable>REGION</variable>
	<item>North America</item>
	<item>Europe</item>
	<item>Asia</item>
	<item>Africa</item>
	<item>Australia</item>
	<item>New Zealand</item>
    <action type="refresh">MIRROR</action>
  </combobox>
  <list>
    <variable>MIRROR</variable>
    <input>'$Path'/mirrors.ubu REGION</input>
  </list>
  <hbox>
   <button ok></button>
   <button cancel></button>
  </hbox>
 </vbox>
</window>
'
gtkdialog --program=MIRRORS_DLG

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#874 Post by don570 »

to sunburnt.....

Your script of nov1 has terminal errors reported..

function ClkBtn not found and head -n is not acceptable option.

___________________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#875 Post by don570 »

To sunburnt ...

your script from yesterday

combobox can't emit a signal. whereas comboboxtext,
comboboxentry,and buttons can emit a signal, so use one of them.

Here's an example of a comboboxtext widget emitting a signal to a tree
widget.

Code: Select all

#!/bin/sh
# Refresh tree example -   comboboxtext  gives signal


function print_selection() {   # show the TREE VALUE
xmessage  "This is selection of TREE  =  $TREE

Note that value is passed 
to functions for further processing."
}
export -f print_selection


export FOLDER=/root/.config  #  must use export to show properly at launch -  not sure if needed??


# comboboxtext emits the refresh signal
export REFRESH_EXAMPLE='
<window title="application">

<hbox> 
    <frame Choose a dotdir in /root>          
             <comboboxtext tooltip-text="List contents of your dotdirs">
             <variable>FOLDER</variable>
             <item>/root/.config</item>
             <item>/root/.cache</item>
             <item>/root/.jwm</item>
             <item>/root/.icons</item>
             <action>refresh:TREE</action> 
             </comboboxtext>           
    </frame>

<hbox>   
<vbox width-request="300"> 
	 <text use-markup="true"><label>"<b>Contents of dotdir</b>"</label></text>
        
             <tree>
             <height>300</height>
             <label>""</label>
             <variable>TREE</variable>
             <input>ls "$FOLDER"</input> 
             </tree>         
    <hbox>
             <button>
             <label>function</label>
             <action>print_selection</action>     
             </button>    
             <button cancel>         
             </button> 
    </hbox> 
</vbox>    
</hbox>    
</hbox>
</window>'

gtkdialog -c  --program REFRESH_EXAMPLE
echo "Program has finished"

Image

________


Here's another example I've just written but it's a comboboxtext widget
refreshing another comboboxtext widget. The interesting thing
is the function that is used. Notice that an action directive
of the first comboboxtext executes the function.


__________
Attachments
comboboxtext_refresh.sh.gz
remove fake extension
(1.23 KiB) Downloaded 396 times

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#876 Post by sunburnt »

Thank you don570; Show me the code as Linus Torvalds says. Very good.!
I`ve never seen the comboboxtext widget before, just the bare combo that`s enabled I think.
I see the "refresh" action line is the older style that I`m use to using, but no "clear" line.

# In your example, the tree is a grid with one column. I need a dir. tree for the left panel.
Xdialog`s tree really is a tree with node branches, but it`s a dialog so it`s not usable.
### Is there a "treebox" or some other widget, or a tree style modifier, or tree actions.?

### Is it possible to get the index of a combo, list, or table? Better than text some times.

I`ve got nearly everything reading and writing files just to get it to work.
# Figured out the returned GtkDialog variables: eval `/path/gtkApp`
Thanks again... Terry B.
Attachments
mirrorGUItable.png
New GUI with Table. Much nicer.
(19.01 KiB) Downloaded 735 times
mirrorGUI.png
As you can see, I need a grid to line up the bps speeds... Maybe a GridListBox.?
(9.93 KiB) Downloaded 795 times

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#877 Post by don570 »

To get gtkdialog to work with the official Ubuntu distro
you should go to launchpad.net and search for 'gtkdialog'

For instance here is a package I got for Precise....

https://launchpad.net/~dnjl/+archive/bu ... ld/4306078

___________________________________________________

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#878 Post by sunburnt »

Thanks again Don; Dnld the GtkDialog, will see what it`s got to offer.

### Is there a "treebox" or some other widget, or a tree style modifier, or tree actions.?

There are now 2 combo widgets, are there other trees or how to control sub nodes?


### Is it possible to get the index of a combo, list, or table? Better than text some times.
.

afifio
Posts: 19
Joined: Sat 26 Oct 2013, 16:57

Anyone want to test gmould ?

#879 Post by afifio »

Anyone want to test buggy gmould ? :)
Its not finish or anywhere near complete but...as is basis,
just to check out whats available :):):)

http://murga-linux.com/puppy/viewtopic.php?p=736697 - Thread
http://gmould.blogspot.com/ - Blog

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#880 Post by sunburnt »

I already don`t like GtkDialog, but it`s what Puppy`s got, so...
Too bad it wasn`t made on top of GTK+ instead. Why go through GtkDialog?
But there`s Glade, so talk about reinventing your wheels. Could improve on it.

afifio
Posts: 19
Joined: Sat 26 Oct 2013, 16:57

#881 Post by afifio »

Yep, its reinventing the wheel if compared to glade.
But why not, gtkdialog can call glade file, true, but look in the last 10 pages. We can count how many thats glade generated, pretty low
or is it people who use glade did not have issues with gtkdialog ? :o

I wonder why the whole Gnome community miss gtkdialog. It can be much more if people give it a thought and help extend it. Declarative programming is the future and people still stuck with C and C++.

Anyway since its backend is mostly bash/sh powered, we cant achieve much I guess. But the real problem is the widget, its quite primitive.

Yeah, I too looking for a real tree. gtkdialog treeview is NOT a tree, so frustrating.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#882 Post by sunburnt »

It use to have one, but I don`t know how to make it work anymore.
As technosaurus blogged, GTK sucks. My take... It sucks badly.
XML syntax is another suck arse item. It`s a crappy way to describe anything.

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

#883 Post by disciple »

It use to have one
Are you sure you're not mixing gtkdialog up with something else? I don't think I've ever seen one.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#884 Post by SFR »

disciple wrote:
It use to have one
Are you sure you're not mixing gtkdialog up with something else? I don't think I've ever seen one.
Maybe it was Xdialog..?

Code: Select all

Xdialog --treeview "A tree" 0 0 5 tag1 item1 on 0 tag2 item2 on 1 tag3 item3 on 2
Greetings!
Attachments
Screenshot.png
(11.28 KiB) Downloaded 614 times
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
CatDude
Posts: 1563
Joined: Wed 03 Jan 2007, 17:49
Location: UK

#885 Post by CatDude »

Hi

Widget Reference
Examples

If it's not what you are talking about, then please ignore.

CatDude
.
[img]http://www.smokey01.com/CatDude/.temp/sigs/acer-futile.gif[/img]

afifio
Posts: 19
Joined: Sat 26 Oct 2013, 16:57

#886 Post by afifio »

sunburnt wrote:XML syntax is another suck arse item. It`s a crappy way to describe anything.
I believe you got it a bit wrong there. XML is THE WAY to describe anything, that is the current common popular belief and practiced successfully almost everywhere. View source of this page and bam, its XML. Even MS in drawn to create XAML.

What interesting about gtkdialog is - the ability to define actions to perform. Most XML dont have this or in limited style using CDATA.

gtkdialog takes the pain away from GTK using XML and I'm trying to take the pain away from XML using gmould. In future, your grandchild might have <make><coffee type=latte></coffee></make> button, and guess what it do ? :lol: :lol: :lol:

Of course, there are other way to describe things, but I think they introduce more complexity.

About GTK sucks, I cant comment, I dont code in it. I never code in GTK, not yet, even its just C. Why bother when you can use XML. Notice that I dont know GTK but still able to build gtk app ? Thats the power of XML.

I believe you can accept these stuff as a game challenge, its more fun that way.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#887 Post by sunburnt »

Just because it`s popular doesn`t mean it`s better in any way.
Obtuse syntax and too much typing to describe the items.
xml and html just use more text to describe less data and control.

Example`s easier to read, understand, type, and is smaller.
Less typing means fewer errors, people make mistakes.
Easy to read and understand means quicker to find the errors.

Code: Select all

gui='title Example
list
	var LIST
	file /path/file
	click script1
button
	text Do Something
	click script2
button
	cancel'

User avatar
Moose On The Loose
Posts: 965
Joined: Thu 24 Feb 2011, 14:54

#888 Post by Moose On The Loose »

sunburnt wrote:Just because it`s popular doesn`t mean it`s better in any way.
Obtuse syntax and too much typing to describe the items.
xml and html just use more text to describe less data and control.

Example`s easier to read, understand, type, and is smaller.
Less typing means fewer errors, people make mistakes.
Easy to read and understand means quicker to find the errors.

Code: Select all

gui='title Example
list
	var LIST
	file /path/file
	click script1
button
	text Do Something
	click script2
button
	cancel'
Are you suggesting that a fixed indenting system would be the way to make clear what is going on.

BTW: Languages with default types and no need to explicitly define variables are the source of massive numbers of hard to find errors. They do require less typing but at least they don't lose space craft because of a mistyped "do".

My method of doing gtkdialog scripts is to make functions for the fragments and test them one by one and then combine fragments to make the whole GUI. It is easy to do and does not lead to errors. The only downside is that I have to do just a little more typing. The functions just echo to stdout.

The final mainline code looks a little like this:

Code: Select all

function MakeGUI() {
  Fragment1
  Fragment2
  SomeButtons
  }

DIA=$( MakeGUI )
gtkdialog3 -p DIA
Its all very easy to trouble shoot

afifio
Posts: 19
Joined: Sat 26 Oct 2013, 16:57

#889 Post by afifio »

sunburnt wrote:Just because it`s popular doesn`t mean it`s better in any way.
Obtuse syntax and too much typing to describe the items.
xml and html just use more text to describe less data and control.

Code: Select all

gui='title Example
list
	var LIST
	file /path/file
	click script1
button
	text Do Something
	click script2
button
	cancel'
Correct, its more typing, but its the most simplest of code I guess. IMO, XML lose only to direct variable assignment.

Code: Select all

<button>blue</button> vs
button=blue
....but then XML add more flexibility. Flexibility always come with complexity.

Code: Select all

<button align="right">
<text align="left" style="underline">blue</text>
</button>
Now how do you do that in your algo ? even with python style indentation its quite hard to explain I think.

Anyway, want gmould ? (my shameless promo)
It save you from typing :lol: :lol: :lol:
its still in dev but pretty usable now.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#890 Post by sunburnt »

It`s just an example, there are as many ways to do things as the imagination can muster.
And it is easier on the eyes ( many claim otherwise...), and it`ll do anything xml will do.

Code: Select all

button
   align right
   text blue
   text align left
   text style underline
afifio; I don`t write apps much, a Filer is needed to replace Rox is my only use here.
If time permits I`ll look at it, I`m looking at RSH`s Modularity package at the moment.

Moose; Yes, my dynamic menu loops to make the buttons from lists or files.
Each loop creates code for a complete button. I wrote one in BaCon also.
But it needs to be compiled to work on different Puppies. Too much effort...
GtkDialog`s one saving grace, as only it needs compiling because it reads script.
.
Last edited by sunburnt on Sat 23 Nov 2013, 19:49, edited 1 time in total.

Post Reply