Gtkdialog Development

Under development: PCMCIA, wireless, etc.
Message
Author
User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#141 Post by 8-bit »

thunor,
When I asked the question as to where, scOttman's post read completely different.
He edited it after my reply.

ScOttman,

I have looked at your program and I see what you meant about the play button being grayed out.
If you think that is because of a nonexistent file just search for it differently.

User avatar
sc0ttman
Posts: 2812
Joined: Wed 16 Sep 2009, 05:44
Location: UK

#142 Post by sc0ttman »

8-bit wrote:thunor,
When I asked the question as to where, scOttman's post read completely different.
He edited it after my reply
sorry about that, thought I would dig out the actual code. :oops:
[b][url=https://bit.ly/2KjtxoD]Pkg[/url], [url=https://bit.ly/2U6dzxV]mdsh[/url], [url=https://bit.ly/2G49OE8]Woofy[/url], [url=http://goo.gl/bzBU1]Akita[/url], [url=http://goo.gl/SO5ug]VLC-GTK[/url], [url=https://tiny.cc/c2hnfz]Search[/url][/b]

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

#143 Post by thunor »

sc0ttman wrote:...but there seems to be a slight lack of consistency

- Some options are allowed here, but not there..
- options seem to take xxx="yes/no", others xxx="true/false" or maybe xxx="0/1"

For example, I often wonder why "width-request" and "height-request" are allowed in some widgets, but are NOT allowed in others..
I have noticed too whilst travelling through the code that some consistency is required with regards accepting values. I have made a feature request within the issue tracker so that it gets dealt with.

GTK+ widgets have an ancestry, so that they inherit from their ancestors. "width-request" and "height-request" are properties of GtkWidget which everything is a descendant of, therefore you should be able to apply these to any Gtkdialog widget.
sc0ttman wrote:Open VLC-GTK, and drag the window away from the centre of the screen.
Then click on the 'Streams' tab.. The sizing make the window move..
The same thing happens with the 'General Settings' tab at the bottom.
GTK initialises some widgets the first time that they are shown and this can make applications spring back to the middle of the screen if Gtkdialog's "--center" option is used -- I've noticed this whilst working on the menu system -- and a remedy for this is to use a "width-request" somewhere, likely on the window if there are multiple causes.

Regards,
Thunor

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

#144 Post by disciple »

Just FYI, it looks like Flash has got around to making the package collections/repositories section publicly visible, so everyone should be able to see the "Index of programs using gtkdialog" now :)

Thanks Flash - I was starting to worry this was becoming like the Ubuntu forum, where you seem to need to be logged in to read half the pages, or download attachments, or whatever...
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

User avatar
Dougal
Posts: 2502
Joined: Wed 19 Oct 2005, 13:06
Location: Hell more grotesque than any medieval woodcut

#145 Post by Dougal »

thunor wrote:I want to add new widgets, overhaul existing widgets, implement missing action functions, finish the wiki, write some more examples, even restructure the code so that one widget is in one file with everything in a consistent order so that I don't have to keep searching the entire session to find things. These things to me will improve Gtkdialog.
Doesn't it make more sense to start with the refactoring? that way you have less to refactor and it makes it easier to do the other work...
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind

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

#146 Post by thunor »

Overhauled the menu and menuitem widgets - final

The widget reference is available here.

Updated 2011-08-07 22:11 to include a theme icon menuitem with a requested size of 32 (value goes into either the width or height directives and you'll get that size if it's available).
  • Added support for submenus by nesting the existing menu widget.
  • The menu widget -- being essentially a menuitem with a submenu -- now supports the same tag attributes and directives as the menuitem widget.
  • Added support for images from files via the "image-name" custom tag attribute (scaling works too).
  • The image from file menuitem widget supports the disable, enable and refresh action functions.
  • Created a new name for the existing separator widget: menuitemseparator.
  • Added checkbox and radiobutton menuitem support via the "checkbox" and "radiobutton" custom tag attributes.
  • The checkbox and radiobutton menuitem widgets support the disable, enable, refresh and save action functions.
  • The theme icon menuitem widget now supports using the height or width directives to override the default theme icon size of 16.
Please note that I can't complement the existing "stock" and "icon" custom tag attribute names with "image" as it's a GTK+ property, and "file" is meaningless so I've created "image-name". The tree widget also accepts the extended names "stock-id" and "icon-name" so "image-name" is consistent with these, there's just no short version.

<menu> and <menuitem> widgets example:

Code: Select all

#!/bin/sh

# NOTE: This example requires at least gtkdialog-0.7.21 (please visit
# http://code.google.com/p/gtkdialog/). Additionally if you are using
# Puppy Linux then you may find that an historical version of gtkdialog
# already exists in /usr/sbin, and if that is the case then you should
# modify the shell variable below to point to the new gtkdialog binary.

GTKDIALOG=gtkdialog

function funcmuiCreate() {
	echo '<variable>'$1'</variable>'
	if [ $2 = 1 ]; then echo '<label>"'"$3"'"</label>'; fi
	echo '<action>echo "'"$1 ($3) action for default signal triggered"'"</action>'
	if [ ${1:0:3} = "mnu" ]; then echo '</menu>'; else echo '</menuitem>'; fi
}

function funcimageCreate() {
	local -a colours=("d0d0d0" "a0a0a0" "707070" "404040" "f0d0d0" "c0a0a0" "907070" "604040"
		"d0f0d0" "a0c0a0" "709070" "406040" "d0d0f0" "a0a0c0" "707090" "404060")
	echo '
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
	<rect x="0" y="0" height="16" width="16" fill="#000000"/>
	<rect x="1" y="1" height="14" width="14" fill="#ffffff"/>
	<rect x="8" y="8" height="6" width="6" fill="#'${colours[$(($1 * 4 + 0))]}'"/>
	<rect x="2" y="8" height="6" width="6" fill="#'${colours[$(($1 * 4 + 1))]}'"/>
	<rect x="2" y="2" height="6" width="6" fill="#'${colours[$(($1 * 4 + 2))]}'"/>
	<rect x="8" y="2" height="6" width="6" fill="#'${colours[$(($1 * 4 + 3))]}'"/>
	<rect x="9" y="9" height="2" width="2" fill="#ffffff"/>
	<rect x="11" y="9" height="2" width="2" fill="#'${colours[$(($1 * 4 + 1))]}'"/>
	<rect x="11" y="11" height="2" width="2" fill="#'${colours[$(($1 * 4 + 2))]}'"/>
	<rect x="9" y="11" height="2" width="2" fill="#'${colours[$(($1 * 4 + 3))]}'"/>
</svg>' > image.svg
}; export -f funcimageCreate

funcimageCreate 1

echo -n > inoutfile

export MAIN_DIALOG='
<window title="muiMenuItem" resizable="false" width-request="360" height-request="240" border-width="0">
	<vbox spacing="0">
		<menubar>
			<menu label="_File" use-underline="true">
				<menuitem stock-id="gtk-new" accel-key="0x4e" accel-mods="4">
					<action>clear</action>
					'"$(funcmuiCreate mui00.00 0 "New")"'
				<menuitemseparator></menuitemseparator>
				<menuitem stock-id="gtk-quit" accel-key="0x51" accel-mods="4">
					<action>exit:Quit</action>
					'"$(funcmuiCreate mui00.01 0 "Quit")"'
				'"$(funcmuiCreate mnu00 0 "File")"'
			<menu use-underline="true">
				<menuitem stock-id="gtk-network"
					tooltip-text="Stock image gtk-network">
					'"$(funcmuiCreate mui01.00 0 "Stock Image")"'
				<menuitem icon-name="gnumeric" use-underline="true"
					tooltip-markup="<span fgcolor='"'darkred'"'><b>Theme</b></span> <i>image</i> gnumeric">
					'"$(funcmuiCreate mui01.01 1 "_Theme Image")"'
				<menuitem icon-name="gnumeric" use-underline="true">
					<width>32</width>
					'"$(funcmuiCreate mui01.02 1 "_Theme Image Size 32")"'
				<menuitem image-name="image.svg" use-underline="true"
					tooltip-markup="<span fgcolor='"'darkgreen'"'><i>File</i></span> <b>image</b> image.svg">
					'"$(funcmuiCreate mui01.03 1 "_File Image")"'
				<menuitem image-name="image.svg" use-underline="true">
					<width>64</width>
					'"$(funcmuiCreate mui01.04 1 "File Image _Scaled 64")"'
				'"$(funcmuiCreate mnu01 1 "_Image")"'
			<menu label="_Checkbox" use-underline="true">
				<menuitem checkbox="true" use-underline="true" accel-key="0x31" accel-mods="4">
					<action>if true enable:mui00.01</action>
					<action>if false disable:mui00.01</action>
					'"$(funcmuiCreate mui02.00 1 "Enable _Quit")"'
				<menuitem checkbox="yes" use-underline="true" accel-key="0x32" accel-mods="4">
					<action>if true enable:mnu01</action>
					<action>if false disable:mnu01</action>
					'"$(funcmuiCreate mui02.01 1 "Enable _Image")"'
				<menuitem checkbox="yes" use-underline="true" accel-key="0x33" accel-mods="4">
					<action>if true enable:mnu03.00</action>
					<action>if false disable:mnu03.00</action>
					'"$(funcmuiCreate mui02.02 1 "Enable _Color")"'
				'"$(funcmuiCreate mnu02 0 "Checkbox")"'
			<menu use-underline="true">
				<menu use-stock="true" label="gtk-select-color">
					<menuitem radiobutton="true" use-underline="true" accel-key="0xffbf" accel-mods="0">
						<action>if true funcimageCreate 1</action>
						<action>refresh:mui01.04</action>
						'"$(funcmuiCreate mui03.00.00 1 "File Image Scaled _Red")"'
					<menuitem radiobutton="false" use-underline="true" accel-key="0xffc0" accel-mods="0">
						<action>if true funcimageCreate 2</action>
						<action>refresh:mui01.04</action>
						'"$(funcmuiCreate mui03.00.01 1 "File Image Scaled _Green")"'
					<menuitem radiobutton="no" use-underline="true" accel-key="0xffc1" accel-mods="">
						<action>if true funcimageCreate 3</action>
						<action>refresh:mui01.04</action>
						'"$(funcmuiCreate mui03.00.02 1 "File Image Scaled _Blue")"'
					'"$(funcmuiCreate mnu03.00 0 "Select Colour")"'
				'"$(funcmuiCreate mnu03 1 "_Radiobutton")"'
		</menubar>
	</vbox>
	<action signal="hide">exit:Exit</action>
</window>
'

$GTKDIALOG --center --program=MAIN_DIALOG
Regards,
Thunor
Last edited by thunor on Fri 12 Aug 2011, 13:35, edited 10 times in total.

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

#147 Post by thunor »

disciple wrote:Just FYI, it looks like Flash has got around to making the package collections/repositories section publicly visible, so everyone should be able to see the "Index of programs using gtkdialog" now :)
Yay :D
Dougal wrote:Doesn't it make more sense to start with the refactoring? that way you have less to refactor and it makes it easier to do the other work...
I'm going to have a think about it now as I need to do something different.

Regards,
Thunor

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

#148 Post by BarryK »

thunor wrote: Retrieving and Testing Against Gtkdialog's Version
The fact that Gtkdialog went from 0.59.8 to 0.6.0 in 2006 slightly complicates the process of checking the version number, but the following code does the trick (on Puppy Linux you will get "5908" for gtkdialog2, "7020" for gtkdialog3 and "7021" and upwards for gtkdialog):

Code: Select all

GTKDIALOG=gtkdialog

function funcGTKDVGet() {
	GTKDV=( $($GTKDIALOG -v) )
	GTKDV=${GTKDV[2]}
	echo "Gtkdialog version: $GTKDV"
	GTKDV=( ${GTKDV//./ } )
	if [ ${GTKDV[1]} -lt 10 ]; then GTKDV[1]=${GTKDV[1]}0; fi
	if [ ${GTKDV[2]} -lt 10 ]; then GTKDV[2]=0${GTKDV[2]}; fi
}; funcGTKDVGet

if [ ${GTKDV[1]}${GTKDV[2]} -lt "7021" ]; then
   echo "This application requires at least gtkdialog-0.7.21"
   exit
fi
Comparing dotted version numbers is now easy. Woof as from April 2011 has 'vercmp' which will be in all Puppy builds, both in the initramfs and in /bin. See my blog post:

http://bkhome.org/blog/?viewDetailed=02226

Example:

Code: Select all

VER1=0.7.21
if vercmp $VER1 gt 0.7.20 ; then
 echo 'greater than 0.7.20'
fi
...returns 0 if true.
[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:

#149 Post by thunor »

BarryK wrote:Comparing dotted version numbers is now easy. Woof as from April 2011 has 'vercmp' which will be in all Puppy builds, both in the initramfs and in /bin. See my blog post:

http://bkhome.org/blog/?viewDetailed=02226

Example:

Code: Select all

VER1=0.7.21
if vercmp $VER1 gt 0.7.20 ; then
 echo 'greater than 0.7.20'
fi
...returns 0 if true.
Hi Barry

I'll update my main post with this information :)

BTW I've gone through the examples within the repository and fixed-up the quirky ones and commented within the broken ones. I know you said that you were putting together a collection of new examples so why don't I give you developer access and you can do it all in the repository. Then if you want to change all the "GTKDIALOG=gtkdialog" to "GTKDIALOG=gtkdialog3" then you can do it with "sed" on a local copy before you create your pet. Let me know if you're interested.

Regards,
Thunor

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

#150 Post by thunor »

Improved the theme icon support

The menuitem widget reference is available here.
The button widget reference is available here.
The pixmap widget reference is available here.

I've updated the menuitem, button and pixmap widgets to support using the height or width directives to override the default theme icon sizes of 16, 20 and 32 respectively.

If you want to know a bit more about what's going on here, theme icons are loaded using the GTK+ gtk_icon_theme_load_icon function and one of its parameters is "size", so if you declare something within the height or width directives then that's what I'm setting "size" to, else I use a default. Note that "the resulting icon may not be exactly this size".

Example:

Code: Select all

#!/bin/sh

# NOTE: This example requires at least gtkdialog-0.7.21 (please visit
# http://code.google.com/p/gtkdialog/). Additionally if you are using
# Puppy Linux then you may find that an historical version of gtkdialog
# already exists in /usr/sbin, and if that is the case then you should
# modify the shell variable below to point to the new gtkdialog binary.

GTKDIALOG=gtkdialog

export MAIN_DIALOG='
<window title="Theme Icon Support" resizable="false" border-width="0">
	<vbox spacing="0">
		<menubar>
			<menu label="_File" use-underline="true">
				<menuitem stock-id="gtk-quit" accel-key="0x51" accel-mods="4">
					<action>exit:Quit</action>
				</menuitem>
			</menu>
			<menu label="_Image" use-underline="true">
				<menuitem icon-name="gimp">
					<label>gimp - Size 16 (Default)</label>
				</menuitem>
				<menuitem icon-name="glade-3">
					<label>glade-3 - Size 32</label>
					<width>32</width>
				</menuitem>
				<menuitem icon-name="gnome-mplayer">
					<label>gnome-mplayer - Size 64</label>
					<width>64</width>
				</menuitem>
			</menu>
		</menubar>
		<vbox border-width="20">
			<pixmap tooltip-text="gnumeric - Size 256">
				<width>256</width>
				<input file icon="gnumeric"></input>
			</pixmap>
			<button image-position="2">
				<label>extension - Size 48</label>
				<width>48</width>
				<input file icon="extension"></input>
				<action>""</action>
			</button>
		</vbox>
	</vbox>
	<action signal="hide">exit:Exit</action> 
</window>
'

$GTKDIALOG --center --program=MAIN_DIALOG
Regards,
Thunor
Last edited by thunor on Fri 12 Aug 2011, 14:17, edited 2 times in total.

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

#151 Post by thunor »

Whilst working on the new spinbutton widget I unearthed a bug in the tag_attributes.c:try_set_property function, the function that is responsible for passing tag attributes that are GTK+ widget properties on to GTK+ to set. The part that was responsible for converting char strings to unsigned integer values wasn't converting to anything, so that's why the "border_width" GTK+ property always appeared to be around 50 -- "0" being ASCII 48, "1" being ASCII "49", "2" being ASCII 50 etc. etc. ;) Therefore the GTK+ "border_width" property now works as expected and this affects quite a few Gtkdialog widgets descended from the GtkContainer class. A short while ago I created the h/vbox and window "margin" custom tag attribute to compensate for this problem but it would appear to be redundant now (I'll leave it in though as it might be being used, but I'll remove it from the documentation).

Regards,
Thunor

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

#152 Post by zigbert »

thunor
Pmusic 2 is taking advantage of your wonderful work. Of course I meet some challenges, and I thought I would share some of them.

1.) H O T K E Y S
If I use <menuitem visible="false" accel-key="0xff52" accel-mods="4"> the hotkey won't work - because visible is set to false. Is this defined by purpose? I see it as a nice way to include hotkeys for other functions than I would like to include to the menus. In this example I want CTRL+up to increase volume level, but find it unlogical to include a menultem as the <hscale> works very well as the gui-alternative for setting volume level.

2.) P R O G R E S S B A R
Pmusic is getting more complex, and some parts of gtkdialog is not friendly to projects like Pmusic. - i.e. I let the main <progressbar> handle the refreshing of
- position of progress <hscale>
- album art for playing song
- play or pause icon in button
- playlist content - to show new items added from external source (like filemanager and external Music-source-window)

The problem is that <hscale> preferable should be updated each second. But this will deselect whatever the user has selected in the playlist <tree>, and that is rather anoying. The best solution for the <tree> would be to refresh only when the user actually adds something, but this won't move the progress <hscale> very often. A solution would of course be to use a unique <progressbar> for the refreshing of the playlist <tree>, but this would steal cpu, and Pmusic is aready using enough cpu-power.

The idea to solve this is hopefully simple:
<input file> is not in use by <progressbar> and could contain a value used in <action>if value refresh:PLAYLIST</action>. In other words; if <input file> contains 'refreshplaylist' (or whatever value) the playlist should be refreshed. Like this one progressbar could be used as a refresh-hub, and gtkdialog would be useful for BIG projects.

The very best would be if the <input file> could hold several values and the <action> activates if one of the values matches. This would make it possible to refresh several widgets, - or just one of them...

3.) C H E C K B O X
Pmusic 2 is close to beta-stage, but still there is one thing that is holding me back from freezing the new graphical theme-standard. You have worked alot with improving the pixmaps in gtkdialog. Still, I am not able to use the <draw-indicator="false"> for <checkbox> with only showing a pixmap (no label). Most audio-players uses only icons on the checkboxes for 'loop' and 'shuffle'. This is not a big thing for me, but I have to decide before I announce the grapical theme-standard for Pmusic 2 as final.


Thanks a lot for you work
Sigmund

taca0
Posts: 123
Joined: Thu 07 May 2009, 00:57

#153 Post by taca0 »

Maybe this its not the best place to ask , But I want to know how I make that all the windows that I open fits on my 640x480 resolution??

Thanks!

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

#154 Post by 8-bit »

Taca0,
I wish I could give you better news, but any applications that have big windows cannot magically be resized for smaller screen resolution.

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

#155 Post by disciple »

There are a number of ways to move windows though, which might improve your experience a little
http://www.murga-linux.com/puppy/viewto ... 059#169059
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

radky
Posts: 977
Joined: Mon 03 May 2010, 03:13

#156 Post by radky »

A quick question about the GtkDialog <notebook> widget.

I see multiple entries in xerrs.log when using the mouse wheel to switch between tabs of a gtkdialog GUI constructed with the <notebook> widget.

For example, using the mouse wheel to switch tabs in 'Puppy Event Manager' will quickly fill xerrs.log with the following:

Code: Select all

(gtkdialog3:3333): Gtk-CRITICAL **: gtk_widget_is_ancestor: assertion `ancestor != NULL' failed

(gtkdialog3:3333): Gtk-CRITICAL **: gtk_widget_is_ancestor: assertion `ancestor != NULL' failed

(gtkdialog3:3333): Gtk-CRITICAL **: gtk_widget_is_ancestor: assertion `ancestor != NULL' failed

(gtkdialog3:3333): Gtk-CRITICAL **: gtk_widget_is_ancestor: assertion `ancestor != NULL' failed

(gtkdialog3:3333): Gtk-CRITICAL **: gtk_widget_is_ancestor: assertion `ancestor != NULL' failed

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

#157 Post by thunor »

Hi Sigmund

1.) H O T K E Y S
GTK+ disables the accelerator with the menuitem.

2.) P R O G R E S S B A R
Sounds to me like you need a proper timer widget like the one described here -> http://code.google.com/p/gtkdialog/issues/detail?id=15. I'm working on the spinbutton widget at the moment but I can add the timer widget pretty easily if you want me to.

3.) C H E C K B O X
I can add one of these (togglebutton widget) equivalent to our existing button i.e. with label/stock/icon/pixmap but it'll toggle. If you need this widget as soon as possible then it could be done by the weekend.

@radky: I get that too. Just note if for the moment.

Regards,
Thunor

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

#158 Post by zigbert »

thunor wrote:2.) P R O G R E S S B A R
Sounds to me like you need a proper timer widget like the one described here -> http://code.google.com/p/gtkdialog/issues/detail?id=15. I'm working on the spinbutton widget at the moment but I can add the timer widget pretty easily if you want me to.
If the timer widget will use less cpu than than a <progressbar> it could be a solution.
thunor wrote:3.) C H E C K B O X
I can add one of these (togglebutton widget) equivalent to our existing button i.e. with label/stock/icon/pixmap but it'll toggle. If you need this widget as soon as possible then it could be done by the weekend.
In the Puppy world we should never rush :) . Please consider it as a suggestion, and do what you feel like. I will sure use a toggle-button if it exist. - If not, I will use the already working checkbox. I can release the Pmusic beta and make a note about the not finished theme-standard.


Sigmund

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

#159 Post by thunor »

Added spinbutton widget

The widget reference is available here.

Updated 2011-08-10 16:34 to illustrate that it's effectively an entry widget with an attached h/vscale widget.
  • The default signal is "value-changed", emitted when the range value changes.
  • The "changed" signal is emitted when typing into the entry.
  • The "activate" signal is emitted when the user activates the entry with the Enter key.
  • "range-min", "range-max", "range-step" and "range-value" are custom tag attributes that accept double precision floating point numbers (the GTK+ "digits" property specifies the number of decimal places that are displayed within the value).
  • Use either the "range-value" custom tag attribute, the <default> directive, the <input> directive or the <input file> directive to set the spinbutton's value.
  • Use the custom tag attribute block-function-signals/block_function_signals="true/yes/1" if you want to isolate signals originating from user widget manipulation from the refresh function.
There are no GTK+ version requirements for this spinbutton widget but there are for some of the entry properties, therefore you should see this post regarding those.

You can see in the terminal that spb1 executes action functions at start-up and this is due to GTK+ emitting both "changed" and "value-changed" signals on application of the "digits" property. Just to note that it's GTK+ doing this on widget realization and not Gtkdialog so I'm not in a position to do anything about it.

<spinbutton> widget example:

Code: Select all

#!/bin/sh

# NOTE: This example requires at least gtkdialog-0.7.21 (please visit
# http://code.google.com/p/gtkdialog/). Additionally if you are using
# Puppy Linux then you may find that an historical version of gtkdialog
# already exists in /usr/sbin, and if that is the case then you should
# modify the shell variable below to point to the new gtkdialog binary.

GTKDIALOG=gtkdialog

function funcbtnCreate() {
	echo '<button>
			<input file stock="'$2'"></input>
			<action>echo "'"$4"' spb'$1'"</action>
			<action type="'"$3"'">spb'$1'</action>
		</button>'
}

function funcspbCreate() {
	echo '<variable>spb'$1'</variable>
			<visible>enabled</visible>
			<output file>outputfile</output>
			<action>echo "spb'$1' action for default signal triggered"</action>
			<action signal="value-changed">echo "spb'$1' changed to $spb'$1'"</action>
			<action signal="changed">echo "spb'$1' typing within the entry detected"</action>
			<action signal="activate">echo "spb'$1' Enter key-press detected"</action>
			<action signal="primary-icon-press">echo "spb'$1' primary icon press detected"</action>
			<action signal="primary-icon-release">echo "spb'$1' primary icon release detected"</action>
			<action signal="secondary-icon-press">echo "spb'$1' secondary icon press detected"</action>
			<action signal="secondary-icon-release">echo "spb'$1' secondary icon release detected"</action>
		</spinbutton>'
}

if [ ! -f inputfile ]; then echo "0.9881" > inputfile; fi

export MAIN_DIALOG='
<window title="spbSpinButton" resizable="false">
	<vbox>
		<frame spinbutton widget>
			<hbox border-width="20" spacing="20">
				<vbox>
					<spinbutton update-policy="1" wrap="true">
						<default>20</default>
						<input>echo 4</input>
						'"$(funcspbCreate 0)"'
					<hbox>
						'"$(funcbtnCreate 0 gtk-no disable Disabling)"'
						'"$(funcbtnCreate 0 gtk-yes enable Enabling)"'
						'"$(funcbtnCreate 0 gtk-refresh refresh Reloading)"'
						'"$(funcbtnCreate 0 gtk-save save Saving)"'
					</hbox>
					<hseparator></hseparator>
					<spinbutton block-function-signals="true" digits="4"
						range-min="0" range-max="1" range-step="0.01"
						tooltip-text="block-function-signals='"'true'"'">
						<input file>inputfile</input>
						'"$(funcspbCreate 1)"'
					<hbox>
						'"$(funcbtnCreate 1 gtk-no disable Disabling)"'
						'"$(funcbtnCreate 1 gtk-yes enable Enabling)"'
						'"$(funcbtnCreate 1 gtk-refresh refresh Reloading)"'
						'"$(funcbtnCreate 1 gtk-save save Saving)"'
					</hbox>
				</vbox>
				<vseparator></vseparator>
				<vbox width-request="100">
					<spinbutton range-value="44" editable="false">
						'"$(funcspbCreate 2)"'
					<hseparator></hseparator>
					<spinbutton range-value="33" xalign="1" primary-icon-name="gnumeric"
						primary-icon-tooltip-markup="<span fgcolor='"'darkred'"'><b>primary-icon</b></span>-<i>tooltip</i>-<u>markup</u>">
						'"$(funcspbCreate 3)"'
					<hseparator></hseparator>
					<spinbutton range-value="56" secondary-icon-stock="gtk-about"
						secondary-icon-tooltip-markup="<span fgcolor='"'darkblue'"'><b>secondary-icon</b></span>-<i>tooltip</i>-<u>markup</u>">
						'"$(funcspbCreate 4)"'
					<hseparator></hseparator>
					<spinbutton range-min="0" range-max="255" range-step="8" range-value="123"
						xalign="0.5" max-length="3" progress-fraction="0.6">
						'"$(funcspbCreate 5)"'
				</vbox>
			</hbox>
		</frame>
		<hbox homogeneous="true">
			<button ok></button>
		</hbox>
	</vbox>
	<action signal="hide">exit:Exit</action> 
</window>
'

$GTKDIALOG --center --program=MAIN_DIALOG
Regards,
Thunor
Last edited by thunor on Fri 12 Aug 2011, 13:34, edited 6 times in total.

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

#160 Post by 8-bit »

I am picturing spinbutton used in combination with toggle.

Instead of 4 buttons of "Enable", "Disable", "Refresh", and "Save",
there would be 3 buttons.
The "Disable" button with icon would be shown and when clicked on besides disabling the entry box, would change to a "Enable button with icon".
Each time it was clicked that button would change to it's opposite button and also change to enable or disable the entry box.
It would allow making a smaller application window that still functioned as it should.

Post Reply