GtkDialog - tips

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#391 Post by disciple »

There's this page that was linked to earlier in the thread http://tadeboro.blogspot.com/2009/04/gt ... art-2.html

And I was directed to this thread a while back http://www.pclinuxos.com/forum/index.ph ... 050.0.html
But IIRC the goblinx thread linked to there was actually better... but its gone now :(

----
No. From what I can see the goblinx page was a series of tutorials not using glade.
http://gigablast.com/get?q=gtkdialog+si ... 655&cnsp=0
http://gigablast.com/get?q=gtkdialog+si ... 281&cnsp=0
I'm sure I saw another page somewhere with glade examples...

But I guess what neurino posted might be all you want.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

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

#392 Post by zigbert »

An interesting question is; Will gtkdialog allow use of more widgets (like slider, knobs, dynamic image rendering...)?

Another question is about the use of the glade-builder (the user-interface to build guis); Is this so powerful that it can build complex guis, or is it meant for less complex windows/boxes as shown in examples?

A working (tiny) example would be preferable.

What exactly will be the extra dependencies?


Sigmund

User avatar
neurino
Posts: 362
Joined: Thu 15 Oct 2009, 13:08

#393 Post by neurino »

zigbert wrote:is about the use of the glade-builder (the user-interface to build guis); Is this so powerful that it can build complex guis, or is it meant for less complex windows/boxes as shown in examples?
the second option

if you select liblade you'll see a lot of widget / options not available. Morover in my Wary's Glade crashes while using some widgets like the spin button.

It's quick, no more I guess.

About an example I'm not at home now to get some to post.
Anyway it's easier for you to build one by yourself in a minute and make it run like I posted before, I didn't go much more further.

I learned commands to put in signals by your tutorial, like EXIT:sure and others.

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

#394 Post by disciple »

What exactly will be the extra dependencies?
Sorry, no, I'm talking nonsense. At the moment there are no extra dependencies as gtkdialog normally depends on libglade.
But it is extremely easy to hack gtkdialog so that it doesn't depend on libglade, which we were discussing because libglade is becoming obsolete. IIRC someone said that gtkdialog is the only program in Puppy that still depends on it... or was there one other program?
So if we start writing gtkdialog+glade programs we just won't have the option of removing glade support.
If glade makes development easier, or allows gtkdialog to do more tricks, go ahead and use it :)
Another question is about the use of the glade-builder (the user-interface to build guis); Is this so powerful that it can build complex guis
Yes, it should be... although I guess I guess maybe you should define what you mean by complex guis :)
An interesting question is; Will gtkdialog allow use of more widgets (like slider, knobs, dynamic image rendering...)?
I guess we either need to experiment and see, or have another look at the gtkdialog source. I think the answer is no, but I'm not certain.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

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

#395 Post by technosaurus »

someone might be able to remove even the libglade dependency and use gtk-builder-convert to convert the .glade files into .ui files that can be used internally by gtk+-2.12 and later. The same options and more should be available through gtkbuilder. There is a vala .ui example here:
http://live.gnome.org/Vala/GTKSample#Lo ... m_XML_File

there are examples in the devx in /usr/share/doc/gtkdialog3/examples/ (don't forget to edit the script to change gtkdialog to gtkdialog3 or make a symlink from gtkdialog3 for gtkdialog in /usr/sbin)

(Note: you only have to delete /usr/lib/pkgconfig/libglade-2.0.pc to compile without glade)
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
Patriot
Posts: 733
Joined: Thu 15 Jan 2009, 19:04

#396 Post by Patriot »

Hmmm .....
zigbert wrote:An interesting question is; Will gtkdialog allow use of more widgets (like slider, knobs, dynamic image rendering...)?
Widgets creation/usage is limited to only what is defined/supported internally to gtkdialog. If a widget is not defined, no amount of coaxing will either ...
zigbert wrote:Another question is about the use of the glade-builder (the user-interface to build guis); Is this so powerful that it can build complex guis, or is it meant for less complex windows/boxes as shown in examples?
Glade-builder is quite powerful and useful. However, IMHO, there are two good enuff reasons to stick with gtkdialog XML constructs:

1. Since gtkdialog widgets set is fixed,you will end up with a much bigger UI script to do exactly the same thing in glade when compared to standard gtkdialog definitions.

2. glade does gives you finer controls over the widgets but unless you are familiar with gtk+ glade constructs then these finer points can be confusing to use. Example, assigning a simple and meaningful exit action is enough to drive first time users to the wall.


Rgds

User avatar
neurino
Posts: 362
Joined: Thu 15 Oct 2009, 13:08

#397 Post by neurino »

As I already wrote also libglade-related files are plain XML, just a little more verbose but always easy to read.

What I do is, in the case of a Gmail notifier GUI, create with glade the XML mockup then cut and paste glade code in bash like you normally do with your xml, only I can get a working xml faster...

You guys also say the Glade-builder is powerful but I assert again that using libglade a lot of widgets and options are disabled while are active using, in preferences, the other lib.

So maybe it would be nice to understand how to use Glade-builder without libglade and having all the things enabled.

I tried something but had no luck except with the actions I wrote above using libglade. Maybe you can have better luck.

Last thing the "simple and meaningful exit action" is the only way, at the moment, I got the control over user action so no difference with it...
___________________

A little example attached, don't know if you can view the settings.glade file in Glade since on my Wary 030 spin button widget makes the app crash so I had to add it by hand, after founding one (and only one) sample online.

If someone knows where to find all glade XML tags and attributes...
Attachments
settings.tar.gz
little example using libglade
(2 KiB) Downloaded 476 times

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

#398 Post by technosaurus »

This is more of a bash trick, but it could be expanded into a full blown menu if other parts of the .desktop files are parsed. Right now it just pulls out all of the executables from the .desktop files so that I don't have to try to figure out where it is in the menu.

Code: Select all

#!/bin/sh
for x in `ls /usr/share/applications/*.desktop`; do I=$I"<item>""`grep "^Exec=" $x |cut -d = -f 2`""</item>"; done
export D="<vbox><combobox><variable>C</variable>"$I"</combobox><button ok></button></vbox>" && eval `gtkdialog3 --program=D` && $C
Here it is with an entry box in case you want to enter it manually

Code: Select all

#!/bin/sh
for x in `ls /usr/share/applications/*.desktop`; do I=$I"<item>""`grep "^Exec=" $x |cut -d = -f 2`""</item>"; done
export D="<vbox><entry editable=\"true\"><variable>E</variable></entry>
<combobox><variable>C</variable>"$I"</combobox><button ok></button></vbox>"
eval `gtkdialog3 --program=D` && [ "$E" == "" ] && $C || $E
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
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#399 Post by 01micko »

techno 8) 8) 8)

Do you mind if I add this to my 'tools' page? Full credit to you of course.

I should have made something like this, I use a similar loop to detect browsers and choose the default in Lupu. I don't know how many times I have open either the /root/.jwmrc or /root/icewm/menu file just to look up an executable (and path if needed) :lol: Thanks

Cheers
Puppy Linux Blog - contact me for access

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

#400 Post by technosaurus »

By all means.

I was initially planning to build a menu program that could be used with any light weight window manager... lost interest after this part though.

p.s. - it runs a bit faster if the top line has /bin/ash instead of /bin/sh
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
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#401 Post by technosaurus »

This scripts worked after deleting the ayttm desktop entry that contains / as separators - needs a workaround - my version of gtkdialog doesn't find pixmaps in the standard directories and sh: locate: command not found is emitted from running in rxvt - is there a way to make icons work without hacking the full icon paths

Edit: it wasn't the / in the Name= field... it was " (double quotes) in the Comment= field that caused the problem - .desktop files shouldn't contain quotes anyways AFAIK - I just fixed ayttm.desktop and all is well

the icons should be found if you have puppy 44a or stardust with updatedb and locate commands

This is not by any means a finished product - just a starting point that should be easily tweakable to your liking using other tips from this thread. I have it set up for right-handed touchscreen mode (everything on the right side) but it could still use a lot of formatting for appearance and speed. (ex. for faster start after first run you could write DLG to a file and use it if available)

Code: Select all

#!/bin/ash
# can't use entries with " (double quote) in the comment section maybe others - Ayttm is one example
for x in `ls /usr/share/applications/*.desktop`; do
	EXE="`grep "^Exec=" $x |cut -d = -f 2`"
	CAT="`grep "^Categories=" $x |cut -d = -f 2`"
	NAM="`grep "^Name=" $x |cut -d = -f 2`"
	ICO="`grep "^Icon=" $x |cut -d = -f 2`"
	##needs full path to icon - will rework later
	COM="`grep "^Comment=" $x |cut -d = -f 2`"
	NEW="<hbox tooltip-text=\"$COM\"><button><label>$NAM</label><input file>$ICO</input><action>$EXE &</action></button></hbox>"
	case $CAT in
		*alculat*|*inance|*heet|ProjectManagement)	BUS=$BUS$NEW;;
		*eskto*|*creensave*|*ccessib*)	DSK=$DSK$NEW;;
		*ocumen*|*ordProcessor|*ebDevelo*)	DOC=$DOC$NEW;;
		*ile*)	FIL=$FIL$NEW;;
		*Game|*olePla*|*imulation|*musement)	FUN=$FUN$NEW;;
		*raphics|*hotography|*resent*|*art)	GFX=$GFX$NEW;;
		*udio*|*ideo*|*layer|*ecorder|*usic|*idi|*ixer|*equencer|*uner|TV|*iskBurning)	MED=$MED$NEW;;
		Dialup|Network|HamRadio|RemoteAccess)	NET=$NET$NEW;;
		X-PersonalUtility|X-Personal|Calendar|ContactManagement)	PER=$PER$NEW;;
		*etup*|PackageManager)	SET=$SET$NEW;;
		*onitor|*ecurity|*ardware*|*ore|*ystem)	SYS=$SYS$NEW;;
		Utility|Viewer|Development|Building|Debugger|IDE|Profiling|Translation|GUIDesigner|Archiving|TerminalEmulator|Shell)	UTL=$UTL$NEW;;
		*nternet|*rowser|*mail|*ews|*essaging|*elephony|*lient|*ransfer|P2P)	WEB=$WEB$NEW;;
		*) MSC=$MSC$NEW;;
	esac
	
done
DLG="<notebook page=\"0\" tab-pos=\"1\" enable-popup=\"true\" labels=\"Business|Desktop|Document|File|Fun|Graphics|Media|Network|Personal|Setup|System|Utility|Web|Miscellaneous\">
<frame Business>$BUS</frame>
<frame Desktop>$DSK</frame>
<frame Document>$DOC</frame>
<frame File>$FIL</frame>
<frame Fun>$FUN</frame>
<frame Graphics>$GFX</frame>
<frame Media>$MED</frame>
<frame Network>$NET</frame>
<frame Personal>$PER</frame>
<frame Setup>$SET</frame>
<frame System>$SYS</frame>
<frame Utility>$UTL</frame>
<frame Web>$WEB</frame>
<frame Misc>$MSC</frame>
</notebook>"

export DLG
gtkdialog3 --program=DLG
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
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#402 Post by technosaurus »

this is a line of code that will set up your locatedb if needed so that your icons will be found

Code: Select all

[ -f /var/locatedb ] && echo file database detected, skipping updatedb for finding of icons || updatedb --localpaths=/usr
I also reworked the menu script for this (and ability to use a menu file if it exists) if you want an example it is also attached
Attachments
pgtkmenu.gz
(1.2 KiB) Downloaded 555 times
findutils-4.2.33-i486.pet
gtkdialog needs findutils - otherwise you may need to specify the full path for icons
(59.84 KiB) Downloaded 480 times
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].

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

#403 Post by jpeps »

I haven't found much regarding use of variables. For example, how do I:

1. Create or change a new or existing variable from an <action> command?
example: <action>export MyVariable="new value"</action> (doesn't work)

2. Use existing variables, like changing default entry from say a checkbox or button action command.
example: <action>ENTRY1="$NewVal"</action> (doesn't work)

edit: One other thing: I can't get bash functions to work from an action command. (think I tried an example somewhere that didn't work)
function MyFunction() {
rxvt -e echo "Hello World"
}

example <action>MyFunction</action> (doesn't work)


Thanks

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

#404 Post by seaside »

jpeps wrote:I haven't found much regarding use of variables.
jpeps,

You can't make dynamic variables as in Items 1 and 2.
When you invoke a subshell (<action>something<action>), variables created here are not visible to the parent.

The work-around is to make "tmp" files to store variable info.

As far as the function not working - did you "export -f MyFunction"?

Cheers,
s

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

#405 Post by jpeps »

seaside wrote:
The work-around is to make "tmp" files to store variable info.
That's what I've been doing; thought I might have missed something.
..be nice if a "set" command was included.
As far as the function not working - did you "export -f MyFunction"?
,
Ah....that works. Thanks!

User avatar
neurino
Posts: 362
Joined: Thu 15 Oct 2009, 13:08

#406 Post by neurino »

This is a libglade-related question but maybe gtkdialod works the same with the syntax explained here...

I want my dialog to commit an action then close itself after a certain button is pressed so I put two actions (signals for libglade) in sequence:

Code: Select all

<signal name="clicked" handler="my_function"/>
<signal name="clicked" handler="EXIT:OK"/>
but the dialog exits before my_function gets executed, I know it because if I remove the EXIT:OK part the function executes flawlessly.

Does this happen with <action>s too?
Is there a turnaround or something for this?


Thanks

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

#407 Post by zigbert »

<actions> is executed in the order you put them into your code, so it would execute my_function and then exit. It seems that signals have an internal order.....


Sigmund

User avatar
neurino
Posts: 362
Joined: Thu 15 Oct 2009, 13:08

#408 Post by neurino »

sob, unluckily this is not in glade code, I put my_func tag before EXIT but it's not enough

Any ideas or link to refer?

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

#409 Post by technosaurus »

I don't know if it will work but if you just need them in order maybe something like?
my_function1 && my_function2 && ...
or possibly
`my_function1 && my_function2 && ...`
or
'`my_function1 && my_function2 && ...`'
or
"`my_function1 && my_function2 && ...`"
(depending on how you write the code quotes may need a "\" before them as well)

hopefully one of those works
(if they don't need to be completed in order, just started in order use a single & instead of the double &&)
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
neurino
Posts: 362
Joined: Thu 15 Oct 2009, 13:08

#410 Post by neurino »

technosaurus wrote:I don't know if it will work but if you just need them in order maybe something like?
my_function1 && my_function2 && ...
Ok but I don't need 2 functions but a function THEN EXIT:

Code: Select all

my_func && EXIT:OK
sadly won't work... :?

Post Reply