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
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#1381 Post by MochiMoppel »

disciple wrote:It seems the solution doesn't work if I try to use it with xdg-open
Works perfectly here.
Please check your xdg-open script. Mine accepts only 1 argument ($1), which in your case would be the URL..

[Edit]: Hmm..I tried to let xdg-open accept '>/dev/null' as an argument and trigger your error message. No success. Whatever I do your code just works :cry:
I don't think that bash would treat any redirection operator as a command argument (unless you pass is literally as a string).

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

#1382 Post by disciple »

Ah, sorry, my mistake. It didn't just affect xdg-open - I'd got my test system mixed up and was using the early version of gtkwialog, which didn't have gtkdialog compatibility.

But thanks for testing, and would you be able to confirm whether you have a Puppy xdg-open or the "real" freedesktop.org version? I don't have the Puppy version here, and I'm keen to be sure I'm compatible with it!

Thanks.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#1383 Post by MochiMoppel »

Puppy xdg-open

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#1384 Post by wiak »

disciple wrote:Ah, sorry, my mistake. It didn't just affect xdg-open - I'd got my test system mixed up and was using the early version of gtkwialog, which didn't have gtkdialog compatibility.
Yes, I thought you must be using gtkwialog (in -a or -b mode) rather than legacy gtkdialog. And, yes, with newest gtkwialog it will work with your example without any changes (since in legacy gtkdialog mode by default).

Should you be using either gtkwialog -a or -b modes, you have to remember no /bin/sh (or any other shell) is being used to execute the command (which is instead being fork/exec more directly), which means neither redirection nor job control with & will be in operation since these facilities are provided by a shell. So if you want redirection and job control you either have to use gtkwialog in default legacy gtkdialog mode or if using -a or -b modes, you need to start up a shell to process your command as follows (note that I prefer turning off stdout rather than just redirecting to /dev/null device since the latter is less efficient):

Code: Select all

#!/bin/sh

export HELP_DIALOG="
<window>
<vbox>
  <button>
   <label>Open murga link in browser</label>
   <action>sh -c "xdg-open http://www.murga-linux.com/puppy/viewtopic.php?p=149208#149208 1>&- &"</action>
  </button>
  <button ok>
  </button>
</vbox>
</window>
"

MAINGUI="`gtkwialog -b -p HELP_DIALOG`"

echo "hello"

gtkwialog -b -p HELP_DIALOG

echo "goodbye"

exit 0
wiak

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

#1385 Post by disciple »

Thanks guys, I switched the latest version of gtkwialog back in when I realised.
I think gtkwialog is great, but I'm still writing for gtkdialog, as that is what everybody has at the moment.
BTW, are you still going to release the gtkwialog source?
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#1386 Post by wiak »

disciple wrote:Thanks guys, I switched the latest version of gtkwialog back in when I realised.
I think gtkwialog is great, but I'm still writing for gtkdialog, as that is what everybody has at the moment.
BTW, are you still going to release the gtkwialog source?
Yes, as I have stated, I will be releasing the gtkwialog source code. It will be guaranteed kept backwards compatible with legacy gtkdialog and also with its existing -a and -b alternative modes. However, as mentioned in its new dev thread, I am currently adding some further functionality on top of these and, following the forum issues I ran into the last time when I put up a for-testing-only-binary (which I have lost permission to delete), the newest version won't be released until I have fully tested it by myself. Thereafter, which may take quite a while, it will be published to DebianDog Organisation gtkwialog repository (not as a test binary only, but, yes, with GPL source). I don't work from the github repository, however, so nothing will appear there until my testing is complete. I'm enjoying programming it though since system level C program was always my own favorite computing pastime! :-)

EDIT: Whether anyone is actually planning to adopt it, I'm not sure, and it doesn't matter (other than I'm in no hurry when no-one but myself may use it anyway!) - I will be using it myself from now on though since my own legacy gtkdialog apps need converted for use under dash system shells too and I find this by far the easiest way with my own programs in practice and I'll also be able to add in some new InterProcessComms optional functionality (simple without adding any detrimental bloat really), which I've long wished was available.

wiak

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

#1387 Post by smokey01 »

Is it possible to limit the list displayed by a combobox? See screeny. I would like to only display about 10 items.

Is there a better way to do this in gtkdialog, maybe with another widget?

Thanks
Attachments
combobox.jpg
(70.03 KiB) Downloaded 330 times

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

#1388 Post by don570 »

Is it possible to limit the list displayed by a combobox?
A programmer made a patch that allows a search in comboboxtext and
comboboxentry
https://github.com/oshazard/gtkdialog/issues/43
comboboxtext:
User presses a key, the next item that begins with that case insensitive char
is selected and it'll wrap back to the first.
_____________________________________________

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

#1389 Post by SFR »

smokey01 wrote:Is it possible to limit the list displayed by a combobox? See screeny. I would like to only display about 10 items.

Is there a better way to do this in gtkdialog, maybe with another widget?

Thanks
Hey Smokey

The closest thing I've found is wrap-width property for comboboxtext, with which you can at least use multiple columns.

Greetings!
Attachments
wrap-width.jpg
(38.08 KiB) Downloaded 258 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
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#1390 Post by technosaurus »

smokey01 wrote:Is it possible to limit the list displayed by a combobox? See screeny. I would like to only display about 10 items.

Is there a better way to do this in gtkdialog, maybe with another widget?

Thanks
You can always use programming to limit the entries to X and have an additional entry for next X and/or previous X.
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].

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

#1391 Post by seaside »

smokey01 ,

You might consider List -

Code: Select all

	<list  vscrollbar-policy="0">
This would not be a dropdown, but would prevent the choice items from dropping below the window.

Cheers,
s

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

#1392 Post by smokey01 »

don570 wrote:A programmer made a patch that allows a search in comboboxtext and
comboboxentry
https://github.com/oshazard/gtkdialog/issues/43
comboboxtext:
User presses a key, the next item that begins with that case insensitive char
is selected and it'll wrap back to the first.
_____________________________________________
Thanks don570 but I'm not sure how this will help if everyone's system is not patched. Not sure if this will do what I want.

Cheers

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

#1393 Post by smokey01 »

SFR wrote:
smokey01 wrote:Is it possible to limit the list displayed by a combobox? See screeny. I would like to only display about 10 items.

Is there a better way to do this in gtkdialog, maybe with another widget?

Thanks
Hey Smokey

The closest thing I've found is wrap-width property for comboboxtext, with which you can at least use multiple columns.

Greetings!
Thanks. Probably a good method to remember for future activities but not ideal for my situation.

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

#1394 Post by smokey01 »

technosaurus wrote:
smokey01 wrote:Is it possible to limit the list displayed by a combobox? See screeny. I would like to only display about 10 items.

Is there a better way to do this in gtkdialog, maybe with another widget?

Thanks
You can always use programming to limit the entries to X and have an additional entry for next X and/or previous X.
@technosaurus, sounds very interesting. Can you provide a working example so I can see what you mean.

Thanks

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

#1395 Post by smokey01 »

seaside wrote:smokey01 ,

You might consider List -

Code: Select all

	<list  vscrollbar-policy="0">
This would not be a dropdown, but would prevent the choice items from dropping below the window.

Cheers,
s
The combobox will keep the list contained within the height of screen where the comboboxtext over shoots the screen and looks quite untidy.

I am considering a tree widget as it is quite neat which I guess is similar to the list widget. The only problem with tree and list widgets they take up a lot of real estate. My issue with the combobox is people can edit the selected data which can break things.

See attached for a sneak preview of what I'm working on. It will be in the August newsletter.
Attachments
vlc-rec-gui.png
(101.08 KiB) Downloaded 226 times

User avatar
misko_2083
Posts: 114
Joined: Tue 08 Nov 2016, 13:42

#1396 Post by misko_2083 »

smokey01 wrote:
seaside wrote:smokey01 ,

You might consider List -

Code: Select all

	<list  vscrollbar-policy="0">
This would not be a dropdown, but would prevent the choice items from dropping below the window.

Cheers,
s
The combobox will keep the list contained within the height of screen where the comboboxtext over shoots the screen and looks quite untidy.

I am considering a tree widget as it is quite neat which I guess is similar to the list widget. The only problem with tree and list widgets they take up a lot of real estate. My issue with the combobox is people can edit the selected data which can break things.

See attached for a sneak preview of what I'm working on. It will be in the August newsletter.
Well, I would try with the button that launches the window.
That window would have a list widget (or any other widget, buttons, notebook...) and make it close when it loses the focus.

This is a quick hack with xdotool.

Code: Select all

#!/bin/sh

eval $(xdotool getmouselocation --shell)

[ -z $GTKDIALOG ] && GTKDIALOG=gtkdialog

TMPDIR=/tmp/gtkdialog/examples/"`basename $0`"
mkdir -p "$TMPDIR"

printf "First item\nSecond item\nThird item\nSmokey item\nWiak's Vodka\nNice Weather\nPuppy Linux\nLast Item" > "$TMPDIR"/inputfile

MAIN_DIALOG='
<window window_position="2" skip_taskbar_hint="true" decorated="false">
	<vbox>
		<list vscrollbar-policy="0">
			<variable>LIST</variable>
			<width>350</width>
			<height>150</height>
			<input file>'"$TMPDIR"'/inputfile</input>
			<output file>'"$TMPDIR"'/outputfile</output>
			<action>echo "The chosen item is "$LIST""</action>
		</list>
	</vbox>
</window>
'
export MAIN_DIALOG

case $1 in
	-d | --dump) echo "$MAIN_DIALOG" ;;
	*) $GTKDIALOG --class smokey --space-expand=true --space-fill=true --program=MAIN_DIALOG 2>/dev/null & gtkdiag_pid=$! ;;
esac

until win_id=$(xdotool search --onlyvisible --class smokey 2>/dev/null); do
	sleep .1
done

xdotool windowmove $win_id $X $Y

xdotool search --onlyvisible --class smokey  behave %@ blur windowkill & xdo_pid=$!

wait $gtkdiag_pid

kill $xdo_pid
exit 0
Maybe instead of moving the window xdotool windowmove $win_id $X $Y , when it's maped, gtkdialog --geometry would be better.

The trick is to position the window as close to the button as possible.

User avatar
misko_2083
Posts: 114
Joined: Tue 08 Nov 2016, 13:42

#1397 Post by misko_2083 »

^This window can be used as a stand-alone menu.

The window placement with window_position="2" is centered on the mouse position.

Code: Select all

#!/bin/sh

[ -z $GTKDIALOG ] && GTKDIALOG=gtkdialog

TMPDIR=/tmp/gtkdialog/examples/"`basename $0`"
mkdir -p "$TMPDIR"

printf "First item\nSecond item\nThird item\nSmokey item\nWiak's Vodka\nNice Weather\nPuppy Linux\nLast Item" > "$TMPDIR"/inputfile

MAIN_DIALOG='
<window window_position="2" skip_taskbar_hint="true" decorated="false">
	<vbox>
		<list vscrollbar-policy="0">
			<variable>LIST</variable>
			<width>350</width>
			<height>150</height>
			<input file>'"$TMPDIR"'/inputfile</input>
			<output file>'"$TMPDIR"'/outputfile</output>
			<action>echo "The chosen item is \"$LIST\""</action>
			<action>EXIT:0</action>
		</list>
	</vbox>
</window>
'
export MAIN_DIALOG

case $1 in
	-d | --dump) echo "$MAIN_DIALOG" ;;
	*) $GTKDIALOG --class smokey --space-expand=true --space-fill=true --program=MAIN_DIALOG 2>/dev/null & gtkdiag_pid=$! ;;
esac

until win_id=$(xdotool search --onlyvisible --class smokey 2>/dev/null); do
	sleep .1
done

xdotool search --onlyvisible --class smokey  behave %@ blur windowkill 2>/dev/null & xdo_pid=$!

wait $gtkdiag_pid

kill $xdo_pid 2>/dev/null
exit 0
I could try to calculate the relative position of the mouse pointer and based on that try to find the best position. But not sure if it's, as Americans say, "worth the trouble". :)

Image

slippery60
Posts: 5
Joined: Mon 18 Dec 2017, 20:31
Location: Fairmont, WV

gtkdialog - tips

#1398 Post by slippery60 »

I am trying to write a menu system that will execute various cli programs. Many of the programs need a variable like "output directory" or 'out_dir".

So in their frame I include a variable "out_dir". I would like to propagate the answer to any one of the "out_dir" entries to all of them.

I thought that if is use just 1 variable "out_dir". After the first entry, a refresh would fix all of the "out_dir" variables and the user would not have to entry the variable again. But that didn't work.

Can this be done? and how?

Thanks

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

#1399 Post by smokey01 »

Thanks misko_2083. I have settled with the tree widget.

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

Re: gtkdialog - tips

#1400 Post by MochiMoppel »

slippery60 wrote:I thought that if is use just 1 variable "out_dir". After the first entry, a refresh would fix all of the "out_dir" variables and the user would not have to entry the variable again. But that didn't work.
Can this be done? and how?
Certainly possible but it depends on how you set and store your variable.
I find it hard to grasp your problem from your description. A simple example would help. Or post the code that "didn't work".

Post Reply