Gtkdialog Development

Under development: PCMCIA, wireless, etc.
Message
Author
User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#211 Post by thunor »

Added togglebutton widget

The widget reference is available here.

This widget uses the exact same code (same functions in fact) as the button widget with the following changes:
  • <default>true/false<default> will set the default active state
  • <input>command</input> will set the default active state and again on refresh
  • <action>if true function:parameter</action> conditional action function execution is supported
  • The widget's variable will contain "true" (pressed-in) or "false" (normal)
  • The default signal is "toggled"
  • The save action function will save "true" or "false" to an outputfile
<togglebutton> widget example (attached images required):

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

ln -sf true.svg tgb0.svg; ln -sf false.svg tgb1.svg

export MAIN_DIALOG='
<window title="tgbToggleButton" resizable="false" border-width="0">
	<vbox>
		<menubar>
			<menu use-underline="true">
				<menuitem stock-id="gtk-quit" accel-key="0x51" accel-mods="4">
					<action>exit:Quit</action>
				</menuitem>
				<label>"_File"</label>
				<variable>mnuFile</variable>
				<sensitive>false</sensitive>
			</menu>
		</menubar>
		<vbox border-width="20" spacing="20">
			<hbox>
				<togglebutton>
					<default>true</default>
					<label>Toggle</label>
					<variable>tgb0</variable>
					<input file>tgb0.svg</input>
					<action>ln -sf $tgb0.svg tgb0.svg</action>
					<action>refresh:tgb0</action>
					<action>save:tgb0</action>
					<action>refresh:ent0</action>
					<output file>outputfile</output>
				</togglebutton>
				<entry>
					<default>true</default>
					<variable>ent0</variable>
					<input>echo $tgb0</input>
				</entry>
			</hbox>
			<hseparator></hseparator>
			<hbox homogeneous="true">
				<togglebutton>
					<variable>tgb1</variable>
					<height>128</height>
					<width>128</width>
					<input file>tgb1.svg</input>
					<action>ln -sf $tgb1.svg tgb1.svg</action>
					<action>refresh:tgb1</action>
					<action>if true enable:mnuFile</action>
					<action>if false disable:mnuFile</action>
				</togglebutton>
			</hbox>
		</vbox>
	</vbox>
	<action signal="hide">exit:Exit</action>
</window>
'

$GTKDIALOG --center --program=MAIN_DIALOG
Regards,
Thunor
Attachments
true-false.svg.tar.gz
Two SVG images from the Elementary Icons
(1.25 KiB) Downloaded 531 times
Last edited by thunor on Sat 27 Aug 2011, 22:43, edited 1 time in total.

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

#212 Post by zigbert »

More info about the menu-icon issue
I am not sure if this issue should be targeted here, so I will post a link in the Slacko thread as well.

The problem is that icons in the menu shows well in Puppy 5 but not in Slacko. This only happens to some of the builtin icons (like gtk-new, gtk-save, gtk-information). My first thought was that this has to be an gtk issue in Slacko (Puppy 5.xx uses gtk 2.20, Slacko uses gtk 2.24), but programs like Abiword, Gnumeric and Geany does not have this problem with their icons NOT taken from the gtk-stock. It _seems_ to only happen for gtkdialog apps.

In Slacko the Pmusic menu looks like this (gtkdialog-rev224).
Image

In Puppy 511, it appears like it is meant to be (same gtkdialog).
Image

This might be related to an old gtkdialog behavior I have wondered about. Why menuitems does not support gtk-undo, gtk-redo (together with other icons) else using the gtk-stock. That means <menuitem icon="gtk-undo"> fails but setting <menuitem stock="gtk-undo"> will work - but now you are not allowed to give it another label than the stock-label. Even more strange is it that gtk-media-stop works with both icon and stock setting, while gtk-media-play only works with the stock.


Sigmund

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

#213 Post by 01micko »

Hi zigbert, thunor

just some info on Slacko, may or may not be relevant.

*Slacko uses gtk+-2.24.4 version [pkgname: gtk+2-2.24.4-i486-1.txz]

*source and patches

*some icons in gnome-mplayer don't work, so maybe there is a clue there (I suspect other apps too)

*Slackware sources are nearly always patched, they don't care about looks, stability is paramount.

Hope this helps
Puppy Linux Blog - contact me for access

User avatar
ttuuxxx
Posts: 11171
Joined: Sat 05 May 2007, 10:00
Location: Ontario Canada,Sydney Australia
Contact:

#214 Post by ttuuxxx »

hi guys on 2.14X the next version will have gtk+-2.24.5, I just compiled so I installed pmusic and well I only had a total of 4 icons for all three menus combined. But Firefox 6.0 had the regular amount, but pburn had all the menu icons. ?? looks more like a pmusic issue, than gtk2+
http://audio.online-convert.com/ <-- excellent site
http://samples.mplayerhq.hu/A-codecs/ <-- Codec Test Files
http://html5games.com/ <-- excellent HTML5 games :)

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

#215 Post by thunor »

Overhauled the fileselect action function
  • The existing accept="filename/savefilename/directory/newdirectory" custom tag attribute has been deprecated in favour of fs-action="file/newfile/folder/newfolder" which better represents the file chooser dialog actions.
  • Added fs-folder="/path/to/current/folder" custom tag attribute.
  • Added fs-filters="pattern|pattern|..." custom tag attribute.
  • Added fs-filters-mime="mime/type|mime/type|..." custom tag attribute.
  • Added fs-title="File Chooser Dialog Title" custom tag attribute.
Note that this is not the <chooser> widget, it is the fileselect action function type as used in <action>fileselect:ENTRY1</action> and within Gtkdialog they are both seperate entities.

Note too that fs-action="newfolder" (accept="newdirectory") is temperamental and the file chooser dialog will hang if you select nothing other than "OK", and for example going back a level and not selecting a folder and then selecting "OK" will return NULL and therefore not update the entry widget. Since this particular file chooser action only wants the user to create a new folder then fs-action="folder" (accept="directory") will suffice as there's a "Create" folder button anyway.

I did notice that the target widget's <label> directive can be used for the file chooser dialog's title which can be seen in the 16.00-fileselect example, but I'm not sure if this is widely known. Anyway, "fs-title" can be used now which will be documented.

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="gtk-'$2'"></input>
			<action>fileselect:ent'$1'</action>
		</button>'
}

export MAIN_DIALOG='
<window title="Fileselect" resizable="false" width-request="500">
	<vbox>
		<vbox border-width="20" spacing="10">
			<hbox>
				<text label="All defaults" width-request="80"></text>
				<entry>
					<variable>ent0</variable>
				</entry>
				'"$(funcbtnCreate 0 new)"'
			</hbox>
			<hseparator></hseparator>
			<hbox>
				<text label="file" width-request="80"></text>
				<entry fs-action="file" fs-folder="/usr/share/doc"
					fs-filters="*.txt|*.html"
					fs-title="Select an existing file">
					<variable>ent1</variable>
				</entry>
				'"$(funcbtnCreate 1 new)"'
			</hbox>
			<hseparator></hseparator>
			<hbox>
				<text label="newfile" width-request="80"></text>
				<entry fs-action="newfile" fs-folder="'$HOME'"
					fs-filters-mime="text/plain|text/html"
					fs-title="Select an existing file or type in a new filename">
					<variable>ent2</variable>
				</entry>
				'"$(funcbtnCreate 2 new)"'
			</hbox>
			<hseparator></hseparator>
			<hbox>
				<text label="folder" width-request="80"></text>
				<entry fs-title="Select an existing folder" fs-action="folder">
					<variable>ent3</variable>
				</entry>
				'"$(funcbtnCreate 3 open)"'
			</hbox>
			<hseparator></hseparator>
			<hbox>
				<text label="newfolder" width-request="80"></text>
				<entry fs-action="newfolder"
					fs-title="Select an existing folder or type in a new folder name">
					<default>This fileselect action type is temperamental</default>
					<variable>ent4</variable>
				</entry>
				'"$(funcbtnCreate 4 open)"'
			</hbox>
		</vbox>
		<hseparator></hseparator>
		<hbox homogeneous="true">
			<button ok></button>
		</hbox>
	</vbox>
	<action signal="hide">exit:Exit</action>
</window>
'

$GTKDIALOG --center --program=MAIN_DIALOG
Regards,
Thunor

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#216 Post by vovchik »

Dear thunor,

What can I say? FAB...

With thanks and kind regards,
vovchik

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#217 Post by jpeps »

thunor wrote:Overhauled the fileselect action function
Great!!! Will give it a try...Thanks

edit: This works nicely...major addition.

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

#218 Post by thunor »

vovchik and jpeps: cheers for the feedback.

[EDIT] Screenshot below looks cool :)

Regards,
Thunor
Last edited by thunor on Fri 26 Aug 2011, 16:17, edited 1 time in total.

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

New Fileselect Filters

#219 Post by jpeps »

Ah....This is way better!
Attachments
PetCheck-gtk3.png
(99.99 KiB) Downloaded 1865 times

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

#220 Post by thunor »

zigbert, 01micko and ttuuxxx: Ok, where to start with this. I'll list the C code for the widgets that support theme icons:

button widget
pixmap widget
menuitem widget
tree widget (the task is handled by a GTK+ function)

I didn't write the icon theme loading code and I haven't particularly researched it either; it was already there and working and all I've done is make it more robust, but the results within the tree widget are identical to the other widgets so I personally wouldn't focus my attention on the code at this point.

I did very recently modify the menuitem theme icon code to show the missing icon image if it wasn't found and I'm now thinking that it'd be better not to show the image within the menu so I intend to change that.

I should point out too that there's more to theme icons than the gtk-stock-id images we are dealing with here. I recently fixed a few examples within the examples folder that were referencing invalid theme icons and I replaced them with a selection that I know are located within /usr/share/icons and /usr/share/mini-icons, so can everybody see icons from those folders?

Updated 2011-08-27 23:41: You should see all of the icons except for gtk-discard which is a known GTK+ "issue".

Here's an example that attempts to show all the stock images by loading them as theme icons:

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

window_width=800
icon_names=(echo $(<icon-names.txt))
type=icon

mnuCreate() {
	for ((x = 0; x < 7; x++)); do
		echo '<menu label="Menu'$x'" width-request="'$(($window_width/7+1))'">'
		for ((y = 0; y < 15; y++)); do
			i=$((x*15*2+y*2+1))
			echo '<menuitem '$type'="'${icon_names[$i]}'">
					<label>""</label>
				</menuitem>'
		done
		echo '</menu>'
	done
}

pixCreate() {
	for ((x = 0; x < 7; x++)); do
		echo '<vbox spacing="0" scrollable="true">'
		for ((y = 0; y < 15; y++)); do
			i=$((x*15*2+y*2+1))
			echo '<pixmap>
					<input file '$type'="'${icon_names[$i]}'"></input>
				</pixmap>'
		done
		echo '</vbox>'
	done
}

btnCreate() {
	for ((x = 0; x < 7; x++)); do
		echo '<vbox spacing="0" scrollable="true">'
		for ((y = 0; y < 15; y++)); do
			i=$((x*15*2+y*2+1))
			echo '<button>
					<input file '$type'="'${icon_names[$i]}'"></input>
				</button>'
		done
		echo '</vbox>'
	done
}

treCreate() {
	for ((x = 0; x < 3; x++)); do
		echo '<tree>
				<label>Name|GTK+</label>'
		for ((y = 0; y < 35; y++)); do
			i=$((x*35*2+y*2+1))
			echo '<item '$type'="'${icon_names[$i]}'">"'${icon_names[$i]}'|'
			if [ ${icon_names[$(($i+1))]} != 0 ]; then
				echo ${icon_names[$(($i+1))]}
			fi
			echo '"</item>'
		done
		echo '</tree>'
	done
}

export MAIN_DIALOG='
<window title="Theme Icon Test" width-request="'$window_width'"
	border-width="0" resizable="false">
	<vbox spacing="0">
		<menubar>
			'"$(mnuCreate)"'
		</menubar>
		<hbox spacing="0" height-request="200">
			'"$(pixCreate)"'
		</hbox>
		<hbox spacing="0" height-request="200">
			'"$(btnCreate)"'
		</hbox>
		<hbox spacing="0" height-request="200">
			'"$(treCreate)"'
		</hbox>
	</vbox>
	<action signal="hide">exit:Exit</action> 
</window>
'

$GTKDIALOG --center --program=MAIN_DIALOG
Regards,
Thunor
Attachments
icon-names.txt.gz
icon-names.txt required by the example (gunzip it)
(655 Bytes) Downloaded 582 times
Last edited by thunor on Sat 27 Aug 2011, 22:40, edited 1 time 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:

#221 Post by thunor »

zigbert wrote:...<menuitem icon="gtk-undo"> fails but setting <menuitem stock="gtk-undo"> will work - but now you are not allowed to give it another label than the stock-label. Even more strange is it that gtk-media-stop works with both icon and stock setting, while gtk-media-play only works with the stock.
You say "now you are not allowed to give it another label" but I wasn't aware that you could before. If a stock menuitem didn't have the label I wanted I would use a theme icon menuitem with a custom label which is what you've been doing and not having much joy with.

I decided tonight to investigate making the menuitem operate similarly to the button widget whereby you can use a stock icon with a custom label and to my surprise I found that it was already possible! :

Code: Select all

<menuitem stock="gtk-undo" label="_Undo Something"
	use-underline="true" accel-key="0x5a" accel-mods="4">
</menuitem>
This is how it works: Gtkdialog calls the GTK+ function gtk_image_menu_item_new_from_stock() which loads the stock gtk-undo icon and adds the stock "Undo" label, and then later when the widget is realized and the tag attributes that are GTK+ properties are set, GTK+ sets the label again which overwrites the stock "Undo" label with "_Undo Something" :P

This is news to me! I think that I should update my menuitem example and the one in the examples folder so that it's documented.

I'd still like to know though why some stock icons loaded as theme icons don't show. I'm going to see if I can find the answer to that.

Regards,
Thunor

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

#222 Post by zigbert »

Hi Thunor
This is how it looks in Slacko beta 1

Image

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

#223 Post by zigbert »

thunor wrote:I decided tonight to investigate making the menuitem operate similarly to the button widget whereby you can use a stock icon with a custom label and to my surprise I found that it was already possible!
This will help out if your icon-test doesn't lead to an answer. :)


Sigmund

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

#224 Post by 8-bit »

thunor wrote: I'd still like to know though why some stock icons loaded as theme icons don't show. I'm going to see if I can find the answer to that.
Check out 09.03-tree_icon_columns in the examples.
I was able to add the icons that do not show in your theme_icon_example.

I had also noticed missing icons, but after examining the one above, it shed light on things.
Still, it is interesting that some icons show and others do not.

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

#225 Post by zigbert »

.... And this is how it looks in Puppy 5.11

Image

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

#226 Post by 01micko »

Ok, it appears a bug has crept in.. (and got worse?)

Slacko Beta 1 ships with r220 that I compiled. I reverted to the original from the iso and this displays:

Image

Not quite OK, I think.

When I just installed r241 I see what zigbert sees, definitely not OK!.

Hope this helps
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:

#227 Post by thunor »

01micko wrote:Ok, it appears a bug has crept in.. (and got worse?)

Slacko Beta 1 ships with r220 that I compiled. I reverted to the original from the iso and this displays:

[image]

Not quite OK, I think.

When I just installed r241 I see what zigbert sees, definitely not OK!.

Hope this helps
There's no bug and you are essentially seeing the same thing!

In r226 I "modified icon from theme code so that a gtk-missing-image is shown when an image isn't found" (not the tree widget as it's not under my control) so in >= r226 you will see a missing-image icon whereby prior to that you weren't ;)

Look in the column under Menu1 in your screenshot and you can see the compressed buttons that are missing an image but you aren't seeing the missing-image icons, and look at the pixmaps above and you can't immediately tell that they are missing because again you aren't seeing the missing-image icons and the empty pixmaps have no dimension. You could tell though by looking in the tree widgets or in the menus and comparing, and creating a list to check against.

I recommend that you use the latest Gtkdialog (r241) so that we are all testing the same thing and looking at the same thing.

Also when testing it is important to be thorough which is why I compiled a list of the icons that aren't showing.

Anyway, seeing as most stock-icons-loaded-through-the-theme show from Gtkdialog's C code or the tree widget's GTK+ function with identical results , I'm investigating the theme. I'm working on this right now in fact and have some debugging messages dumped to the terminal:

Code: Select all

[root@ese:theme-icon-support]# ./theme-icon-test
widget_button_create(): error='Icon 'gtk-discard' not present in theme'
widget_button_create(): error='Icon 'gtk-goto-first' not present in theme'
widget_button_create(): error='Icon 'gtk-goto-last' not present in theme'
widget_button_create(): error='Icon 'gtk-go-back' not present in theme'
widget_button_create(): error='Icon 'gtk-go-forward' not present in theme'
widget_button_create(): error='Icon 'gtk-indent' not present in theme'
widget_button_create(): error='Icon 'gtk-jump-to' not present in theme'
widget_button_create(): error='Icon 'gtk-media-forward' not present in theme'
widget_button_create(): error='Icon 'gtk-media-next' not present in theme'
widget_button_create(): error='Icon 'gtk-media-play' not present in theme'
widget_button_create(): error='Icon 'gtk-media-previous' not present in theme'
widget_button_create(): error='Icon 'gtk-media-rewind' not present in theme'
widget_button_create(): error='Icon 'gtk-redo' not present in theme'
widget_button_create(): error='Icon 'gtk-revert-to-saved' not present in theme'
widget_button_create(): error='Icon 'gtk-undelete' not present in theme'
widget_button_create(): error='Icon 'gtk-undo' not present in theme'
widget_button_create(): error='Icon 'gtk-unindent' not present in theme'
EXIT="Exit"
[root@ese:theme-icon-support]#
So, GTK+ is telling me that the 17 stock-icons-loaded-through-the-theme that fail to show for me are not present within the theme and therefore I'm going to continue up the theme path, but today is Saturday and the London pubs are calling me :P

Regards,
Thunor

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

#228 Post by zigbert »

but today is Saturday and the London pubs are calling me
that makes sense

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

#229 Post by thunor »

zigbert wrote:that makes sense
:lol: Here's something that makes sense:

The icons are built-in to GTK+ and in most cases the filenames are equivalent to their corresponding stock-ids except for the ones that I've noted as not showing for me in lupu-520 with GTK+ 2.20.0 using the Crux theme:

gtk-discard (this is not built-in, it's a known GTK+ "issue")
gtk-goto-first
gtk-goto-last
gtk-go-back
gtk-go-forward
gtk-indent
gtk-jump-to
gtk-media-forward
gtk-media-next
gtk-media-play
gtk-media-previous
gtk-media-rewind
gtk-redo
gtk-revert-to-saved
gtk-undelete
gtk-undo
gtk-unindent

The solution is to append every one of those stock-ids with "-ltr" or "rtl" which will give you the correct theme icon name. I can now see everything except gtk-discard.

I discovered this by looking at /usr/include/gtk-2.0/gtk/gtkstock.h

Now, I don't know the list of icons that are not showing in Slacko beta 1 because I haven't been given that information, but I can see from your screenshot that you can't see:

gtk-dialog-authentication
gtk-dialog-error
gtk-dialog-info
gtk-dialog-question
gtk-dialog-warning
gtk-discard (this is not built-in, it's a known GTK+ "issue")
gtk-goto-first
gtk-goto-last
gtk-go-back
gtk-info
gtk-jump-to
gtk-new
gtk-undelete
...
etc. etc..

Here's something that doesn't make sense: in Slacko beta 1 you can't see gtk-info, gtk-new or any of the gtk-dialog-* icons!!! In /usr/include/gtk-2.0/gtk/gtkstock.h you should see something like this:

Code: Select all

...
/**
 * GTK_STOCK_NEW:
 *
 * The "New" item.
 * <inlinegraphic fileref="gtk-new.png" format="PNG"></inlinegraphic>
 */
#define GTK_STOCK_NEW              "gtk-new"
...
Therefore the conclusion to this "issue" is that you need to supply the correct theme icon name to icon="" and not the stock-id, and there appears to be some problem accessing some of the built-in images within the version of GTK+ that Slacko beta 1 is using (can you see them using stock="" ?).

I've updated my icon_names.txt list a few posts back so you might want to download it and try the example again.

Regards,
Thunor

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

#230 Post by 01micko »

Hi Thunor... (excuse my dopiness :P, not a programmer at all, just a concreter, I tend to do silly things and ask silly questions)

Ok, (with ltr appended?) these are missing:

gtk-dialog-authentication
gtk-dialog-error
gtk-dialog-info
gtk-dialog-question
gtk-dialog-warning
gtk-disacard (known issue)
gtk-info
gtk-new
gtk-save

They all show ok in example 09.10

What do you think?

If it's a Slacko gtk issue I can certainly try to recompile. I'll go through the patches too. But I won't jump the gun :wink: .

Image

Cheers
Puppy Linux Blog - contact me for access

Post Reply