gtkdialog1-1.4

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#151 Post by goingnuts »

Another demo: gtkmplayer - very simple frontend for mplayer.
Contains also code for some more advanced functions (select audio and video driver + set audio speed) - change flag in gtkmplayer source to view.
Using "mplayer -slave" and fifo /tmp/mplayer-control to pass commands from gtk-frontend to mplayer.
Attachments
gtkmplayer-0.1.pet
demo for gtkdialog1 - simple frontend for mplayer
(11.59 KiB) Downloaded 697 times

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#152 Post by goingnuts »

Yet another demo - backport/hack of SNS - Simple Network Setup - to use Gtkdialog1. Based on SNS from Puplite 5.0 kindly supplied by starhawk.
Attached pet is the first try and may not work and be buggy.
A bunch of helping progs attached as well, everything put in /bin to give preference for these applications and ease removal...
You will need Gtkdialog1 - get it in the first post.
Attachments
snap0008.png
(19.95 KiB) Downloaded 1402 times

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

Re: Backport gtkdialog 0.59.8 to use gtk1/gtk2: gtkdialog1-1.0

#153 Post by technosaurus »

goingnuts wrote:TODOS:
* <text> accept <input>command
* quotes in <action>command
* combobox <default>, accept <action append> and fill with command
* checkboxes: set value from variable/script[/url][/url]
* revise help text for --geometry
just checking on the TODOS
* quotes in <action>command
g_strescape(); ?
* revise help text for --geometry
from wary's gtkdialogX
Usage:
gtkdialog [OPTION...]
Create dialog boxes and windows according to the given dialog description.For more information try 'info gtkdialog'.

Help Options:
-h, --help Show help options
--help-all Show all help options
--help-gtk Show GTK+ Options

GTK+ Options
--class=CLASS Program class as used by the window manager
--name=NAME Program name as used by the window manager
--screen=SCREEN X screen to use
--sync Make X calls synchronous
--gtk-module=MODULES Load additional GTK+ modules
--g-fatal-warnings Make all warnings fatal

Application Options:
-v, --version Print version information and exit.
-d, --debug Debug mode prints the processed characters.
-p, --program=variable Get the GUI description from the environment.
-g, --glade-xml=filename Get the GUI description from this Glade file.
-f, --file=filename Get the GUI description from a regular file.
-i, --include=filename Include the given file when executing.
-e, --event-driven=filename Execute the file as an event driven program.
-s, --stdin Get the GUI description from standard input.
-w, --no-warning Suppress warning messages.
-G, --geometry=[XxY][+W+H] The placement and the size of the window.
-c, --center Center the windows on the screen.
--print-ir Print the internal representation and exit.
--space-expand=state The "expand" state for packing all widgets.
--space-fill=state The "fill" state for packing all widgets.
--display=DISPLAY X display to use
thats the lowest hanging fruit, for the rest I'd have to compare Xdialog (the unpatched gtk1 version) and gtkdialog2-4 (my sdialog program may help too)
another TODO?
SVG capability via librsvg's included gdkpixbuf-loader (its one of the only ones that isn't distributed with gdkpixbuf)
SVG would add a ton of capabilities

also I submitted a patch to gtkdialog-trunk that used some gtk2 builtins for refreshing, that Thunor cleaned up, but I had previously used native inotify (may require a kernel update though ... Edit: nope - inotify was introduce in 2.6.13) if anyone is interested in that.
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].

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#154 Post by goingnuts »

Thx for looking at this!
The quotes in <action>command seems to be related to the parser. gtkdialog-0.58.11 accepts

Code: Select all

<action>echo "You pressed the button with the label."</action>
whereas gtkdialog-0.59.8 does not (errors out with "Error in line 6, near token 'quoted string': syntax error").

This might be a nice way to force separation of the gktdialog GUI-code and the shell-code but makes translation of existing scripts somewhat more challenging. Looking into lexer.l and the difference between the two version is still black magic to me...

The

Code: Select all

-g,--geometry                     Set the position and/or size of the
                                   window, [XxY][+W+H].

is wrong for present version as the XxY sets the widthxheight and the +W+H sets position...

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

#155 Post by 8-bit »

How compatible is this version of gtkdialog1 with programs written to use gtkdialog that comes with puppy?
I ask because I tried running a few of the examples that come with gtkdialog by first copying them to a temporary directory and then editing them to use gtkdialog1.
I did not find any that worked.
Most had syntax errors.
So will this fork of gtkdialog be compatible with the gtkdialog scripts that permeate puppy?

And is this mod a matter of lessening CPU load?

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#156 Post by goingnuts »

8-bit wrote:How compatible is this version of gtkdialog1 with programs written to use gtkdialog that comes with puppy?
I ask because I tried running a few of the examples that come with gtkdialog by first copying them to a temporary directory and then editing them to use gtkdialog1.
I did not find any that worked.
Most had syntax errors.
So will this fork of gtkdialog be compatible with the gtkdialog scripts that permeate puppy?

And is this mod a matter of lessening CPU load?
Its quite compatible but most scripts needs "fine tuning". A lot of the formating tags are not supported and one of the main issues is the <window> tag which must be converted to a <wtitle></wtitle> tag and no </window> in the end of script...

The strength is that you can compile for both gtk1 & gtk2 and use the same scripts.

Another advantage is that with gtk1 & tinyxlb & uclibc one can compile a static version at reasonable size. So resource demand is quite low and speed is good.

I haven't seen puppy gtk-scripts that worked out of the box but some of them are easy to "port". Using the -d (debug) switch is a great tool to debug when converting scripts to GtkDialog1.

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

#157 Post by technosaurus »

simple "stocks" stock quote program ported
the un-backslashed quotes was an issue, but I just removed them in my script... seems like g_strescape might fix it or we could just know to backslash them in the script

mostly though just needed to strip most things out of the insides of tags...
stuff like:hover-selection="true", rules_hint="true", tooltip="" ...

remove/replace window tags:
replace '<window title="name">...more tags ...</window>' with:
'<wtitle>name</wtitle>...more tags ...'
Attachments
stocks-0.1.pet
very basic ... could use:
action refresh to update
action launchwindow to change stock symbols
(2.12 KiB) Downloaded 915 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].

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#158 Post by goingnuts »

technosaurus: Added your stock port under examples in first post - thx!

I did a quick test to see if the lexer.l rules could be used to filter out the "future" gtkdialog tags. By adding the following rule it seems that the <window some text> and the </window> can be ignored - but not tested intensively. Might work and be applicable with some of the other tags as well:

Code: Select all

 /* remove </window> future tag */
"</window>".* { ; }
 /* remove <window * > future tag */
"<window".*(.|\n).*">" { ; }

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

#159 Post by technosaurus »

note: the variables don't get set after action completion, and before the next action

ex.
<action fileselection>FILEINFO</action>
<action>echo $FILEINFO</action>

was working on a mupdf gui when I noticed that it does wait for the 1st action to complete but the variable doesn't get set till some time after

tried refresh and Refresh: action in between but nada - any ideas?

(your mplayer frontend selected a file and then plays with a separate button works fine - but I was hoping to do a 1-step process)
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:

#160 Post by technosaurus »

Posted a frontend for mupdf here:
http://www.murga-linux.com/puppy/viewto ... 689#659689

Its a decent example of how to control windows that use keyboard shortcuts

there is a static mupdf too, but it also needs xdotool which I haven't built statically yet
http://code.google.com/p/semicomplete/
(scottman's vlc-gtk uses xdotool too)

EDIT: also notice that the file selection is limited to 32 character long paths - I think it may be using a *tag_attribute (see stringman.c)
I would recommend [80] at least - gcc stores 0-80 length char[] in the same amount of code
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].

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#161 Post by goingnuts »

It might be that chooser acts different than fileselect - not sure and not home atm so cant test...
The fileselect action spawns a new window and all actions after the fileselect does not wait for fileselect to finish - I had same problem when trying to do a text editor with gtkdialog1
I will try later to look at the stringlength in fileselect - haven't tested if spaces are allowed but will test that as well
Looking forward to test your front-end to mupdf - your handling of the different versions of gtkdialog is a nice workaround!

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

#162 Post by technosaurus »

it may have just been spaces in the filenames now that I have looked further
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].

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#163 Post by goingnuts »

Here is a solution to the mupdf-gtk (as gtkdialog1 concerns):

Code: Select all

export MESSAGE_DIALOG='
<vbox>
	<chooser>
		<height>300</height><width>600</width>
		<variable>FILE</variable>
		<default>/</default>
		<action when="file-activated">echo File: $FILE </action>
		<action when="selection-changed">echo Selection: $FILE</action>
		<action when="current-folder-changed">echo Folder: $FILE</action>
		<action>refresh:FILENAME</action>
	</chooser>
	<button>
		<label>OK</label>
		<action>mu_open $FILENAME</action>
		<action>closewindow:MESSAGE_DIALOG</action>
	</button>
</vbox>
'


and then revise the top part (below </menubar>) to:
	<hbox>
	<button>
		<label>Choose File</label>
		<action launchwindow>MESSAGE_DIALOG</action>
	</button>
		<entry>
			<variable>FILENAME</variable>
			<input>echo $FILE</input>
			
		</entry>
	</hbox>


And for the open in the File menu do this:

Code: Select all

<menuitem>
				<label>Open</label>
				#<action type="fileselect">FILENAME</action>
				<action type="launch">MESSAGE_DIALOG</action>
			</menuitem>

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

#164 Post by technosaurus »

that worked, now just need to figure out a gtkdialog4 equivalent
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:

#165 Post by technosaurus »

Any way to make passwords hidden in entry boxes that I am missing? I looked into adding tooltip capabilities, but not sure how to go about it... Mainly the tag part. Tooltips aren't technically an attribute, but they can be applied to any windowed widget (those that don't need an event box to handle events)
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].

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#166 Post by goingnuts »

Code: Select all

<entry>
<variable>ENTRY</variable>
<visible>password</visible>
</entry>
I will look at the possibilities to add tooltips - at least to buttons if possible.
Update: Tooltip is quite easy to implement on buttons, radiobuttons, checkbox and entry. Atm. set for a syntax like:

Code: Select all

<button>
<label>Button with tooltip</label>
<tooltip>gtkdialog1 rocks!</tooltip>
</button>
which seems different from the younger gtkdialog way of doing it...
Present patches for GtkDialog1-1.1 attached:
Added tooltips to entry, button, radiobutton, checkbox and menu.
automaton.c - fix of LABPIX button missing right paddding.
widget.c added default - setting it to be first item in list in
fill_list_by_items
Add 20121027: Working "hard" on making GtkDialog1 more compatible with the other gtkdialog versions. As an example the below action syntax is now supported:

Code: Select all

<action>Enable:ENTRY</action>
<action enable>ENTRY</action>
<action type="enable">ENTRY</action>
which should make more of the script running by default...Attached the present state as static build gtk1.2 - rename to gtkdialog1
Attachments
tooltip.png
(22.69 KiB) Downloaded 965 times

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#167 Post by goingnuts »

While back in GtkDialog1 I found my notes on the swallow widget and decided to give it another try. So attached static gtk1 version accepts the following script:

Code: Select all

#!/bin/sh
#swallow demo for GtkDialog1 - experimental...!
#20121028goingnuts
#launch the app and establish the window ID
APP="${1}"
${1} &
while :; do
	if [ "$(wmctrl -l | grep -i "${APP}" | cut -d " " -f1)" = "" ]; then
		usleep 50
	else
		WINID=$(wmctrl -l | grep -i "${APP}" | cut -d " " -f1)
		break
	fi
done
export MAIN_DIALOG='
<vbox>
	<swallow>
		<label>'${WINID}'</label>
	</swallow>
	<button ok></button>
</vbox>
'
gtkdialog1 --program=MAIN_DIALOG
You will need the wmctrl which is also attached as a static build. It is huge as it needs glib-2 - but we might be able to reduce size by backport to glib-1 or eliminate the need for glib. Note that wmctrl also can show the pid of the windows (wmctrl -l -p) which might be a more secure way of finding the windows ID than the name used in above script (${APP} &) - then get the pid of the process and find the window ID with wmctrl -l -p (+ some grep/cut stuff)...

The widget still need some error checking/fix for resize and might fail to launch some applications. Not sure if it add value to gtkdialog1..
Attachments
snap0010.png
example of running &quot;swallow Links&quot;
(63.32 KiB) Downloaded 902 times

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

#168 Post by technosaurus »

sounds great - what exactly is it that wmctrl does? if it is just getting the window id, xwinifo can do that (IIRC there is also an port to xcb that compiles pretty small statically)

Code: Select all

eval `xwininfo -root -all -int |awk '/'$APPNAME'/{print "WINID="$1 }'`
here is the result from mupdf (just grepping the xwininfo output for mupdf - no awk):

Code: Select all

10485769 "txtbk.pdf - 201/816 (161 dpi)": ("mupdf" "MuPDF")  1274x747+3+22  +3+22
windowID "title bar info" (class? name?) widthxheight+?+? +xoffset+yoffset
(I think the +3+22 has to do with the window border left and top)

later versions of gtkdialog use <TAG tooltip-text="tooltip text here"> though I prefer the <tooltip>tooltip text</tooltip> (seriously why even have an xml format if you aren't going to use it)

your method is much more extensible and readable
<tooltip>
<tooltip-text>.....</tooltip-text>
<tooltip-markup>.....</tooltip-markup>
<tooltip-font>.....</tooltip-font>
... any tags that can affect tooltips
</tooltip>

than trying to fit it all in the same tag and simplifies the parsing
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].

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#169 Post by goingnuts »

I actually planed to do no more with the tooltip-tag...thought that the styling should be done via rcfile:

Code: Select all

style "tooltips"
{
  bg[NORMAL] = "#ffd000"
  fg[NORMAL] = "#000000"
  font = "-adobe-helvetica-medium-r-normal--*-140-*-*-*-*-*-*"
}
widget "gtk-tooltip*" style "tooltips"
...I think the rcfile is like a css-file for the html-files...

wmctrl is used to get the window ID and anything, you can control to give you that, can be used. The swallow widget "only" needs the window ID passed (for now as a label tag).

Add: And the patches leading up to this attached. Found this which might be a solid way to get the window ID.
One problem remains with the swallow widget: Seems that the socket window is always on top - even when the gtkdialog1 window is minimized the swallow-window remains on top. Any solutions to this is very welcome!

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#170 Post by goingnuts »

Guess the swallow widget need some rest - tried a lot without getting one step further...
So started to add "drag-and-drop" support for widget edit, table(=tree) and list (that is dnd TO the gtkdialog widget for a starter). Got the edit working nicely so far...
Target is to get dnd for the relevant widgets without having to add anything in the gtk-dialog-script...

Post Reply