Gtkdialog Development

Under development: PCMCIA, wireless, etc.
Message
Author
User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#376 Post by technosaurus »

it would be nice to allow

Code: Select all

<!-- comments -->
as with other xml implementations

in the mean time

Code: Select all

#!/usr/sbin/gtkdialog -e

function print_this() {
  echo "print: $1"
}

COMMENT=" "

export MAIN_DIALOG='
<vbox>
  <button>
    <label>function</label>
    <action>print_this button</action>
  </button>
'${COMMENT:- this is a comment}'
  <button>
    <label>Exit</label>
  </button>
</vbox>
'
edit:
Note that the COMMENT variable is initialized to " " (a space ... or a tab), the single quote immediately before the $ and after the } and the ":-" following COMMENT (this is necessary)

also for _some_ tags you can just add
comment="your comment here"
ex:

Code: Select all

<button comment="this button is useless">
this method doesn't work for label and probably some others though
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].

SK7000
Posts: 4
Joined: Wed 12 Oct 2011, 18:54

Re: gtkComboboxText improvements

#377 Post by SK7000 »

thunor wrote: This behaviour must be coded so you'll find it wherever a developer has implemented it. I agree that it would be a welcome feauture so I'll create a feature request for it.
Thanks! That's good enough.

Something else that I noticed, which should be very easy (I think) to add. I am using GtkDialog 0.8.0, and technically, if this is a dialog I am creating, why I can't dismiss it by pressing "Escape"? Is it because the top level markup is a "window", thus creating a gtkWindow rather than a gtkDialog?

I wonder if there's already example code for this, because I haven't found it yet (I can't see any GtkWindow binding to intercept keys pressed), maybe a way to use a GtkDialog rather than a GtkWindow for the top level object?

Thanks in advance for any thoughts on the matter.

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#378 Post by thunor »

@technosaurus

That's quite ingenious :) Much better in fact than messing about with ## and sed.

Or in place of your COMMENT you could use:

Code: Select all

rem() { true; }

...
	</but'$(rem this is a comment)'ton>
'$(rem this is a comment)'
	<button>'$(rem this is a comment)'
...
technosaurus wrote:

Code: Select all

<button comment="this button is useless">
this method doesn't work for label and probably some others though
Yeah, not all widget tags support tag attributes and these will be stored as name-value pairs attached to the widget consuming memory.

Regards,
Thunor

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

#379 Post by technosaurus »

thunor wrote:@technosaurus

That's quite ingenious :) Much better in fact than messing about with ## and sed.

Or in place of your COMMENT you could use:

Code: Select all

rem() { true; }

...
	</but'$(rem this is a comment)'ton>
'$(rem this is a comment)'
	<button>'$(rem this is a comment)'
...
Regards,
Thunor
Your method would be less likely to be misinterpreted ... I could foresee people trying to set the variable, because few people use/understand these variable operations, (I use them frequently for setting defaults.)
Though $(command) is much more readable, it doesn't work in ash ... backticks are more portable (though not nestable and less readable)
It is also fairly portable to use a ":" (colon) in place of true.
[/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].

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

#380 Post by 8-bit »

technosaurus,
I must be missing something here.
Your example worked just fine for me. But I tried to modify it to use thunor's snip-its and failed.
I kept getting errors of gtkdialog environment not found among others.
An example of thunor's method would be very helpful in being able to use comments/rem in a gtkdialog script.

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

#381 Post by 8-bit »

As a followup I tried to create a script using thunor's snip-its.

Code: Select all

#!/usr/sbin/gtkdialog -e

function print_this() {
  echo "print: $1"
}

rem() { true; }
export MAIN_DIALOG='
<vbox>
  <button>
    <label>function</label>
    <action>print_this button</action>
  </button>
'$(rem this is a comment)'
  <button>
    <label>Exit</label>
        <action type="exit">exit 0</action>
  </button>
   <button>'$(rem this is a comment)'
    <label>T2</label>
   </button>
  <button>
    <label>T1</label>
   </but'$(rem this is a comment)'ton>
  </vbox>
'

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

#382 Post by technosaurus »

I prefer to use ash for my shell, because scripts run generally faster, but not being able to export functions requires using an --include file with the functions (so they get loaded twice and I have a rather large number of functions)

here is a partial solution, I am sure there could be some more case statements that would improve it:

Code: Select all

gtkdialog --program=MAIN_DIALOG | while read A; do
	case "$A" in
		*=*)eval $A #evaluates all the variables on exit
		*)$A #execute function, command, etc...
	esac
done
now you can just echo your functions (it probably won't work with those that need to make changes to the gui itself though)
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
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#383 Post by BarryK »

Hi,
I'm using gtkdialog 0.8.0, in Wary with GTK 2.24.5, and I am having problems with the dimensions of windows created by gtkdialog. That is, either too high or too wide, or both.

For example, this is a simple window with vbox tags and a single text tag with markup, and one button. See the big gap at the bottom:
Attachments
gtkdialog-too-high.png
(17.95 KiB) Downloaded 1000 times
[url]https://bkhome.org/news/[/url]

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#384 Post by BarryK »

Here is another example. For this app I am being forced to use 'width-request' in the window tag -- without that, it looks like the attachment.

The window is simple structure:

Code: Select all

<window title=\"${WINTITLE}\" window_position=\"1\" icon-name=\"${WINICON}\" ${WINWIDTHPARAM}>
<vbox>
  ${BACKTITLEXML}
  <hbox>
    ${COUNTRYXML}
    ${XXML}
  </hbox>
  <hbox>
    <text><label>${M_exit}</label></text>
    <button><label>${B_ok}</label><input file>/usr/local/lib/X11/mini-icons/mini-tick.xpm</input><action>EXIT:OK</action></button>
  </hbox>
</vbox>
</window>"
Attachments
gtkdialog-too-wide.png
(6.59 KiB) Downloaded 1248 times
[url]https://bkhome.org/news/[/url]

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

#385 Post by zigbert »

BarryK
Be aware that most widgets supports space-expand="true/false" and space-fill="true/false". They have become handy to get better control over the window scaling. In you example I would think it is the <text> widget which is the troublemaker. I Think it would be a good idea to place it inside a <hbox>

Code: Select all

<window title=\"${WINTITLE}\" window_position=\"1\" icon-name=\"${WINICON}\" ${WINWIDTHPARAM}>
<vbox>
  <hbox space-expand="false" space-fill="false" (and maybe a width-request="xxx")>
    ${BACKTITLEXML}
  </hbox>
  <hbox>
    ${COUNTRYXML}
    ${XXML}
  </hbox> 
Another simple solution that has worked for me is to request a size of main window that is below the required space.

Code: Select all

<window title=\"${WINTITLE}\" window_position=\"1\" icon-name=\"${WINICON}\" ${WINWIDTHPARAM} default_height="100" default_width="100">
Sigmund

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#386 Post by BarryK »

zigbert,
Thanks for the feedback, but none of those suggestions fix it. They made no difference at all.

If anyone with more knowledge about gtkdialog would like to help me to fix this, here are some of the dialogs attached:
Attachments
quicksetup-too-wide.gz
(5.54 KiB) Downloaded 358 times
quickcountry-too-wide.gz
(5.07 KiB) Downloaded 326 times
[url]https://bkhome.org/news/[/url]

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#387 Post by 01micko »

ok, rough I guess but it works .. the roughness is the flicker
Attachments
quicksetup-was-too-wide.gz
(5.61 KiB) Downloaded 336 times
quickcountry-was-too-wide.gz
(5.12 KiB) Downloaded 332 times
Puppy Linux Blog - contact me for access

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#388 Post by thunor »

Adding resizable="false" to both window tags is the solution.

In quicksetup within the text widget at the top with the markup, Gtkdialog enables wrapping by default so you might want to set wrap="false" since you can easily accommodate it within the bounds of the window.

Regards,
Thunor

User avatar
miriam
Posts: 373
Joined: Wed 06 Dec 2006, 23:46
Location: Queensland, Australia
Contact:

setting checkboxes from actions

#389 Post by miriam »

I haven't been able to find any way to set checkboxes from other widgets. I can clear them okay (<action>if false clear:chkbx2</action>), but can't set them.

I have an interface with 19 checkboxes. They divide naturally into about 5 groups. I would like to be able to set a group of, say 3 or 6 checkboxes with one click, while still retaining the option of setting/resetting them individually, so I've made 5 other checkboxes of type <checkbox draw_indicator="false"> to work as toggling buttons. Unfortunately I can't find documentation on how to send a signal to the various normal checkboxes to set them. As I said, I can clear them easily with <action>if false clear:chkbx8</action>, but not set them.

The only actions I can find are:
closewindow:NAME
launch:NAME
disable:NAME
enable:NAME
refresh:NAME
save:NAME
fileselect:WIDGET
clear:WIDGET
removeSelected:WIDGET

Anybody got any ideas? I've tried every term that I could think of (set, active, select, etc), hoping that it just hasn't made its way into the docs yet, but without any luck...
[color=blue]A life! Cool! Where can I download one of those from?[/color]

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#390 Post by BarryK »

BarryK wrote:zigbert,
Thanks for the feedback, but none of those suggestions fix it. They made no difference at all.

If anyone with more knowledge about gtkdialog would like to help me to fix this, here are some of the dialogs attached:
Ha ha, I just now reread what I posted, and it sure can be misunderstood! What I meant was:

If anyone with more knowledge about gtkdialog than me would like to help me to fix this, here are some of the dialogs attached

Anyway, thunor, thanks for the solution, greatly appreciated!
[url]https://bkhome.org/news/[/url]

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

Re: setting checkboxes from actions

#391 Post by thunor »

Hi Miriam

This is how you get data into a widget (many widgets support <input file> but the checkbox doesn't [yet] so we can use <input> instead):

Code: Select all

#!/bin/sh

GTKDIALOG=gtkdialog

inputfile1=`mktemp`
inputfile2=`mktemp`
inputfile3=`mktemp`
inputfile4=`mktemp`

echo true > $inputfile1
echo false > $inputfile2
echo true > $inputfile3
echo false > $inputfile4

export MAIN_DIALOG='
<window title="Miriam - CheckBox Setting States" resizable="false">
	<vbox>
		<hbox>
			<frame Group 1>
				<checkbox>
					<variable>chkGroup1CheckBox1</variable>
					<label>CheckBox 1</label>
					<input>cat '$inputfile1'</input>
				</checkbox>
				<checkbox>
					<variable>chkGroup1CheckBox2</variable>
					<label>CheckBox 2</label>
					<input>cat '$inputfile2'</input>
				</checkbox>
				<checkbox>
					<variable>chkGroup1CheckBox3</variable>
					<label>CheckBox 3</label>
					<input>cat '$inputfile3'</input>
				</checkbox>
				<checkbox>
					<variable>chkGroup1CheckBox4</variable>
					<label>CheckBox 4</label>
					<input>cat '$inputfile4'</input>
				</checkbox>
				<hseparator></hseparator>
				<togglebutton>
					<variable>tgbGroup1</variable>
					<label>Toggle All</label>
					<action>echo $tgbGroup1 > '$inputfile1'</action>
					<action>echo $tgbGroup1 > '$inputfile2'</action>
					<action>echo $tgbGroup1 > '$inputfile3'</action>
					<action>echo $tgbGroup1 > '$inputfile4'</action>
					<action>refresh:chkGroup1CheckBox1</action>
					<action>refresh:chkGroup1CheckBox2</action>
					<action>refresh:chkGroup1CheckBox3</action>
					<action>refresh:chkGroup1CheckBox4</action>
				</togglebutton>
			</frame>
		</hbox>
		<hbox homogeneous="true">
			<button ok></button>
		</hbox>
	</vbox>
	<action signal="hide">exit:Exit</action>
</window>
'

$GTKDIALOG --program=MAIN_DIALOG

rm $inputfile1 $inputfile2 $inputfile3 $inputfile4
Regards,
Thunor

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

#392 Post by 8-bit »

BarryK wrote:
BarryK wrote:zigbert,
Thanks for the feedback, but none of those suggestions fix it. They made no difference at all.

If anyone with more knowledge about gtkdialog would like to help me to fix this, here are some of the dialogs attached:
Ha ha, I just now reread what I posted, and it sure can be misunderstood! What I meant was:

If anyone with more knowledge about gtkdialog than me would like to help me to fix this, here are some of the dialogs attached

Anyway, thunor, thanks for the solution, greatly appreciated!
Barry, I just ran both scripts after adding enough to do that.
I made one change and the windows display correctly.
The drop down lists I did nothing with to reduce the height of them.
But for the windows, just add " resizable="false" to the window line like this:
<window title="Quick Setup" window_position="1" icon-name="gtk-preferences" resizable="false" >

That is if I read your post correctly.

One other thing and this is important.
The added line will not work with gtkdialog3!
But if you use thunor's gtkdialog rev8 release, it will.
So change gtkdialog3 to whatever you called thunor's release.

Sometimes, simple solutions pass us by.

User avatar
miriam
Posts: 373
Joined: Wed 06 Dec 2006, 23:46
Location: Queensland, Australia
Contact:

#393 Post by miriam »

Holy cow! Thanks Thunor! I have to admit I was really expecting you to reply with something like, "Sorry, not supported yet, so isn't possible."

I'm rapt! And thank you so much for the beautiful example. :)

Ummm... I'm going to sound like I'm looking a gift-horse in the mouth here, but with all the wonderful work you've been doing on bringing gtkdialog back to life you might know if there is some way to use a monospaced font for the text in an edit pane. That would be extremely useful for a lot of data that uses character-spacing to output tables or ASCII-art.

And here is a really big ask: markup too? Like in some other parts of gtkdialog.
[color=blue]A life! Cool! Where can I download one of those from?[/color]

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#394 Post by thunor »

Hi Miriam

The edit widget doesn't support markup, but the text widget does. Anyway, you can use styles to change widgets like this (see here for a great theme tutorial):

Code: Select all

#!/bin/sh

GTKDIALOG=gtkdialog

## Create a custom style.
funcgtkrcCreate() {
	echo '
style "styleGtkEditFontMonospace" {
	text[NORMAL] = "#ffffff"
	base[NORMAL] = "#000000"
	font_name = "monospace 16"
}
widget "*GtkEditFontMonospace" style "styleGtkEditFontMonospace"
' > $TEMP_DIR/gtkrc
	GTK2_RC_FILES=$TEMP_DIR/gtkrc:~/.gtkrc-2.0
}

## Create a temporary directory.
TEMP_DIR=$(mktemp -d)
if [ $? -ne 0 ]; then
	echo "Error: Couldn't create temporary directory."
	exit 1
fi

## Create a custom style.
funcgtkrcCreate
export GTK2_RC_FILES

## Create some ASCII art.
cat > $TEMP_DIR/asciiart <<EOF
Font: chunky
 _______ __   __       __ __         __              
|     __|  |_|  |--.--|  |__|.---.-.|  |.-----.-----.
|    |  |   _|    <|  _  |  ||  _  ||  ||  _  |  _  |
|_______|____|__|__|_____|__||___._||__||_____|___  |
                                              |_____|

Font: graffiti
  ________ __   __       .___.__       .__                 
 /  _____//  |_|  | __ __| _/|__|____  |  |   ____   ____  
/   \  __\   __\  |/ // __ | |  \__  \ |  |  /  _ \ / ___\ 
\    \_\  \  | |    </ /_/ | |  |/ __ \|  |_(  <_> ) /_/  >
 \______  /__| |__|_ \____ | |__(____  /____/\____/\___  / 
        \/          \/    \/         \/           /_____/  

Font: rectangles
 _____ _   _     _ _     _         
|   __| |_| |_ _| |_|___| |___ ___ 
|  |  |  _| '_| . | | .'| | . | . |
|_____|_| |_,_|___|_|__,|_|___|_  |
                              |___|

http://www.network-science.de/ascii/
EOF

echo '
<window title="Miriam - Edit Font" resizable="false">
	<vbox>
		<edit name="GtkEditFontMonospace" editable="false">
			<width>600</width>
			<height>400</height>
			<input file>'$TEMP_DIR'/asciiart</input>
		</edit>
		<hbox homogeneous="true">
			<button ok></button>
		</hbox>
	</vbox>
	<action signal="hide">exit:Exit</action>
</window>
' > $TEMP_DIR/dialog_main

## Run the main application.
$GTKDIALOG -f $TEMP_DIR/dialog_main

## Remove the temporary files.
rm -rf $TEMP_DIR
Regards,
Thunor

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

#395 Post by 8-bit »

thunor,
In the scripts Barry provided, the size of the window is figured out now.
The dropdown in the quick-country-too-wide script is long.
But is there a way to limit the height of the item drop down selection popup window when the down arrow is clicked?
Try it and you will see what I mean.
Barry did not comment on that one, but if it was doable, it would help.

Post Reply