GtkDialog - tips

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
Patriot
Posts: 733
Joined: Thu 15 Jan 2009, 19:04

#121 Post by Patriot »

Hmmm .....

zigbert,
zigbert wrote:..... I have to test your workaround more, but it seems to work excellent. .....
Please do all the testing you want. I've tested only the signal events that made sense to me. The window hide signal seems to be the best workaround for the menubar issue ...

Hmmm, the launch/closewindow issue kept cropping up in my head, so I had to do something about it ... I wrote a small utility to close window by id but it's a lame fix .. So, I took another peek (yeah, one last peek and poke) at it and made a quick fix at the sources. I've made several quick tests and I can now launch and close the child window properly. I think since it's just one fix, maybe we should call this gtkdialog3 1/4 ..... :)

So, that's another carrot dangling ... do you want it ?


Some final comments:

1. Drag-n-drop: I believe it's not fully implemented the way you wished for it to be ... This needs a lot of time to sort out ...

2. The right click stuff: It seems to be widget dependent. The code looks like it won't support much ... but I could be incorrect ...

3. "Click on <table> header doesn't sort": No it wont. Currently, I have no idea of the intended behaviour or how this should work in gtkdialog ... Actual GTK2 GtkTable is for widgets, not for spreadsheet-like stuffs ...

4. "Allows user to select multiple items in list, But gtkdialog doesn't output any value": Nope, there's no code to support multi-selected output ... It may multi-select but it doesn't get stored nor printed ... This needs a lot of time to sort out ...

Well, I've only skimmed, peeked and poked at the sources. The launch/closewindow issue doesn't bug me anymore, but I couldn't spend more time on this ... Really zigbert, gtkdialog IS a simple implementation of some GTK2 widgets but looking at how it is implemented, well I guess I know why I get dizzy .....


Rgds

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

#122 Post by zigbert »

Patriot
:D Of course we want it. All fixes are wonderful!

Hopefully, the bugfix will help me with Pmusic.

I have updated main post with the <menubar> workaround. It works great!!!


Thanks a lot
Sigmund

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

#123 Post by technosaurus »

The biggest feedback I get from people trying to learn puppy is that we don't have the mouseover dialogs that give a short explanation of what stuff does. If someone could figure this out there would be a lot of happy Puppy's.

I looked through the source code before but couldn't really follow how the widgets were set up - I last coded in C in 1997. I was hoping for a template for each widget that I could just modify and add. Anyhow mouseover was all I was wanting to do and it didn't seem like a straightforward cut and paste job....
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

#124 Post by Patriot »

Hmmm .....

zigbert,
Ok, you got it ... The sources and pet is attached below ...

To close the child window, we just specify any var name defined in the child script. The recommend method would be to define the same var name as the exported bash var name for easy reference:

Code: Select all

#!/bin/sh
# Requires the fixed gtkdialog3-pe1

export CHILD_DIALOG='
<window title="Separate Child Dialog">
  <vbox width-request="180">
   <frame>
     <text><label> I am coming </label></text>
     <text><label> out to play. </label></text>
     <text><label> But since I have my own PID, I cant act on my parent dialog. </label></text>
   </frame>
   <button><label>increase number</label>
     <action>A=$(cat /tmp/tmp); echo $(($A+1)) > /tmp/tmp</action>
     <action>refresh:TEXT</action>
   </button>
  </vbox>
</window>
'

export LAUNCHED_DIALOG='
<variable>LAUNCHED_DIALOG</variable>
  <vbox>
    <text>
      <label>This is a launched dialog window.</label>
    </text>
    <button><label>increase number</label>
      <action>A=$(cat /tmp/tmp); echo $(($A+1)) > /tmp/tmp</action>
      <action>refresh:TEXT</action>
    </button>
    <button>
      <label>Close me</label>
      <action type="closewindow">LAUNCHED_DIALOG</action>
    </button>
  </vbox>
'

export MAIN_DIALOG='
<window title="Main Dialog" tooltip-text="Copyleft by Patriot and zigbert">
  <vbox width-request="240">
  <text width-chars="40"><label>"Clickity click to open"</label></text>
  <text width-chars="40"><label>"Clickity click to close"</label></text>
  <text width-chars="40"><label>"Clickity click to exit"</label></text>
   <frame>
   <text width-chars="40" height-request="120"><variable>TEXT</variable><input>cat /tmp/tmp</input></text>
   </frame>
   <button><label>Open child dialog with unique PID</label>
     <variable>OCD</variable>
     <action>gtkdialog3 -p CHILD_DIALOG -c &</action>
     <action>echo $(ps ax|awk '"'"'{if (match($7, "CHILD_DIALOG")) print $1}'"'"')>/tmp/child.pid</action>
     <action>enable:CCD</action>
     <action>disable:OCD</action>
   </button>
   <button sensitive="false"><label>close child dialog with unique PID</label>
     <variable>CCD</variable>
     <action>[ -f /tmp/child.pid ] && p=$(cat /tmp/child.pid) && kill $p</action>
     <action>enable:OCD</action>
     <action>disable:CCD</action>
   </button>

   <button><label>launch child dialog</label>
     <action type="launch">LAUNCHED_DIALOG</action>
   </button>
   <button><label>close child dialog (but look what happens)</label>
     <action type="closewindow">LAUNCHED_DIALOG</action>
   </button>

   <button tooltip-text=" Exit? Really? "><label>Exit </label>
   <action>exit:Exit</action>
   </button>
  </vbox>
</window>>
'
echo 1 > /tmp/tmp

# Requires the fixed gtkdialog3-pe1

gtkdialog3 -p MAIN_DIALOG -c
unset CHILD_DIALOG
unset MAIN_DIALOG


technosaurus wrote:The biggest feedback I get from people trying to learn puppy is that we don't have the mouseover dialogs that give a short explanation of what stuff does. ........
Is tooltips the one you're looking for ? If it is, then it's already covered on the main page of this thread. The above code also shows an example of tooltips ..... If you meant having a customized popup dialog, then the signal events allows you to do so ...


Rgds
Attachments
gtkdialog3-0.7.20-pe1-i486.pet
gtkdialog3 pe1 binary only pet. It will overwrite existing gtkdialog3.
(47.23 KiB) Downloaded 636 times

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

#125 Post by technosaurus »

Thanks Patriot,

That is exactly what I needed. I guess it helps to know what you are looking for.
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:

#126 Post by 01micko »

I suppose you can be forgiven for that techno... zigbert only recently discovered native gtkdialog support for tooltips, it is now documented in this thread! Zigbert even wrote his own workaround with 'Ptooltips' but I think 'Potong' pointed out to him the native support.

I have been using tooltips in all my recent work, (um, not that that amounts to much but it is something!).

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:

#127 Post by zigbert »

THANK YOU PATRIOT
I have uploaded your package to puppylinux.asia and made a red note in the main post.


Works great!!!
Sigmund

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

#128 Post by 8-bit »

This is just a thought on exiting a gtkdialog script with cleanup.
See my post on it Here

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

#129 Post by disciple »

I'm not sure if it's already explained in this thread, but Argolance figured out how to escape apostrophes (= figured out how to use them in text in gtkdialog.
http://www.murga-linux.com/puppy/viewto ... 706#355706
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:

#130 Post by technosaurus »

Ultimate GtkDialog Challenge:

Requirements:
1. Knowledge of GtkDialog, sed, grep and bash scripting
2. Time

The challenge.

Phase 1
Write a gtkdialog that lets you select a command line program and it will run <program> --help, parse the options and then build a basic graphical interface to said program.

Phase 2
Add the description of each option to a tooltips description.

Phase 3
Add options to the parser that looks for hints whether an option requires a directory, file etc...

Phase 4
Add a configurable interim GtkDialog that can be tweaked for input types, default values, icons etc... (using phase 3 for default values) This would build the final GUI.

Is anyone up to the challenge?
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:

#131 Post by 01micko »

I am taking that challenge right now.... in the middle of it..
Puppy Linux Blog - contact me for access

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

#132 Post by disciple »

Ummm... is that not what guicompletion (which you mentioned before) does?
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:

#133 Post by technosaurus »

This could be a fairly easy way to omit programs that aren't installed in all versions of Puppy.

Code: Select all

if [ "`which NAME_of_PROGRAM`" != "" ];then
NAME_of_PROGRAM_ENTRY="<hbox>.......
</hbox>"
else
NAME_of_PROGRAM_ENTRY=""
#alternatively we could have a label telling them what is missing and an action button that does `petget <URL> &`
fi
then later in the gtkdialog window just substitute the code with $NAME_of_PROGRAM_ENTRY
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

#134 Post by Patriot »

Hmmm .....

zigbert,

I'm looking for a way for gtkdialog3 to self update without user intervention. For example, a simple entry box that displays updated time every second. Do you know any simple methods? (The method I'm using is a bit too stretched ...)

Kindly please advise ...


Rgds

User avatar
trio
Posts: 2076
Joined: Sun 21 Dec 2008, 15:50
Location: अनà¥￾मोदना

#135 Post by trio »

Patriot

Pls post your script, so it will be easier to get help

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

#136 Post by zigbert »

Patriot
The only way I know to update an entry without actually click on something in the gui is to include a progressbar. At the time the progressbar reach 100% it runs the <actions> defined. This works just fine, but it uses more cpu-power than we want. If there exist a better approach, both Pburn and Pmusic would benefit of it.

Code: Select all

#!/bin/sh

export box="
 <vbox>
  <progressbar>
   <input>"'while [ A != B ]; do sleep 0.5; P=`cat /tmp/p`;	echo $P; echo 100 > /tmp/p; done'"</input>
   <action>refresh:ENTRY</action>
   <action>echo 99 > /tmp/p</action>
  </progressbar>
  <entry>
   <variable>ENTRY</variable>
   <input>date +%H:%M:%S</input>
  </entry>
 </vbox>"

gtkdialog3 -p box

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

#137 Post by zigbert »

How can I know which key(s) user press?

Code: Select all

<window>
  <action signal="key-press-event">echo Window: key-press-event</action>
</window>

Sigmund

User avatar
Patriot
Posts: 733
Joined: Thu 15 Jan 2009, 19:04

#138 Post by Patriot »

Hmmm .....
zigbert wrote:How can I know which key(s) user press? .....
I was wondering about that too ... but haven't figured out how yet ...
zigbert wrote:........ If there exist a better approach, both Pburn and Pmusic would benefit of it.
Ok, see if my klutz method can be of any use to you (xsendkey is in the archive) ...

Code: Select all

#!/bin/sh

borgdir=$(pwd)
export BORG_DIALOG='
<window title="Selfupdate" icon-name="gtk-info">
<vbox>
  <text><label>""</label></text>
  <entry can-focus="no" width-request="200">
	<variable>UPDATE</variable><input>date</input>
  </entry>
  <text><label>""</label></text>

  <hbox>
	<button>
	  <label>Update</label>
	  <variable>bUpdate</variable>
	  <action>refresh:UPDATE</action>
	</button>
	<button>
	  <label>Exit</label>
	  <action>exit:Exit</action>
	</button>
  </hbox>
</vbox>
<action signal="key-press-event">refresh:UPDATE</action>
</window>
'
gtkdialog3 -p BORG_DIALOG -c >$borgdir/borg.$$ &
i=0
while [ $i -le 5 ]
do
  sleep 1
  GtkWID=$(xwininfo -name Selfupdate | grep id: | cut -f4 -d' ')
  [ $GtkWID ] && break
  ((i++))
done
unset BORG_DIALOG

while [ 1 ]
do
  [ "$GtkWID" ] && $borgdir/xsendkey -window $GtkWID A &>/dev/null
  [ "$(cat $borgdir/borg.$$)" ] && break
  sleep 1
done
rm -f $borgdir/borg.$$

Rgds
Attachments
gtk_selfupdate.tar.gz
(6.02 KiB) Downloaded 443 times

ljfr
Posts: 176
Joined: Thu 23 Apr 2009, 08:35

gettext

#139 Post by ljfr »

Hi,
I made an example on xorgwizarg on how to use gettext in scripts,
this is not directly link to GtkDialog, but it works for GtkDialog text too,
see:
http://www.murga-linux.com/puppy/viewtopic.php?t=46829
regards,

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

#140 Post by zigbert »

Patriot
This is interesting! :D
Your example is maybe a bit inflexible, but you show a creative gtkdialog/bash code structure. I am sure we will see more of this.....


Thanks for sharing
Sigmund

Post Reply