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:

#241 Post by thunor »

I'm currently working towards making a source package release and I'd like to change something I recently added:

I want to change the checkbox and radiobutton menuitems from saving "0/1" to a file to "true/false" to make them consistent with other toggling widgets that save to file.

I'll wait a while before I do it to give people the time to object :P

Regards,
Thunor

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

#242 Post by Dougal »

Here's a modified version of technosaurus's example, which doesn't have the names hardcoded, so it doesn't need updating for different versions of gtk2...

Code: Select all

#!/bin/sh

MAIN_DIALOG='
<vbox><hbox>'

n=0
while read i ; do
	MAIN_DIALOG="$MAIN_DIALOG
<pixmap icon_size=\"6\" tooltip-text=\"$i\"><input file stock=\"$i\"></input></pixmap> "
	n=$((n+1))
	if [ $((n%20)) -eq 0 ] ; then
		MAIN_DIALOG="$MAIN_DIALOG
</hbox><hbox>"
	fi
done <<_EOF
$(grep -F '#define GTK_STOCK' /usr/include/gtk-2.0/gtk/gtkstock.h | cut -d'"' -f2)
_EOF

export MAIN_DIALOG="$MAIN_DIALOG</hbox>
<button cancel></button>
</vbox>
"

gtkdialog3 --program=MAIN_DIALOG
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
Dougal
Posts: 2502
Joined: Wed 19 Oct 2005, 13:06
Location: Hell more grotesque than any medieval woodcut

#243 Post by Dougal »

thunor wrote:Therefore you shouldn't assume that the theme icon name for gtk-dialog-authentication is going to be "gtk-dialog-authentication[.png]" because clearly on Slacko beta 1 it's "dialog-password[.png]".
Isn't the theme supposed to have also a symlink to it, with the proper stock name? Icon-themes are usually full of symlinks, as they don't have unique icons for everything, but need to support all the names.
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:

#244 Post by thunor »

Dougal

I think that there might be some confusion about what stock="" does and what icon="" does so I'll attempt to explain them:

<input file stock="gtk-new"></input> for example would load the image associated with the stock ID "gtk-new". It is a constant or a macro meant to hide the filename and also to deal with left-to-right and right-to-left variations of some images. Importantly the stock IDs do not change, they are not filenames, they are IDs and the images are possibly compiled-in.

<input file icon="gnumeric"></input> for example would load the file "gnumeric.png/svg/etc." from the current icon theme wherever that is located. My GTK+ 2 Crux theme has an IconTheme=Crux set but there's no such set of icons on my computer so GTK+ searches a default set of paths which results in "/usr/share/icons/hicolor/16x16/apps/gnumeric.png" being loaded. Importantly these are filenames minus the path and extension.

There is not going to be an issue using <input file stock="gtk-new"></input> across GTK+ builds because "gtk-new" here is an ID hiding the filename of the originating image, but there will be if you use <input file icon="gtk-new"></input> because in this case "gtk-new" is a filename.

What's been happening is that <input file icon="gtk-new"></input> has been used and it mostly worked because the originating filenames of the built-in images are mostly identical to the stock IDs (GTK+ apparently also counts built-in stock images as theme images) but on Slacko beta 1 the originating filenames of the built-in images are NOT the same as the stock IDs therefore "gtk-new" wouldn't be found as a theme icon UNLESS it does physically exist as a file somewhere within the paths GTK+ searches for theme icons.

Simply put, stock="" is for unchanging stock IDs, icon="" is for filenames [minus the path and extension] representing icons from the current theme and also within the default paths GTK+ searches for theme icons.

For the record, these are the [likely default] paths GTK+ is searching for theme icons on my lupu-520 (gtk_icon_theme_get_search_path() was used):
  • /root/.icons
  • /root/.local/share/icons
  • /usr/share/icons
  • /usr/local/share/icons -> ../lib/X11/mini-icons
  • /usr/share/pixmaps
  • /usr/local/share/pixmaps
See http://developer.gnome.org/gtk/2.24/gtk ... Items.html and http://developer.gnome.org/gtk/2.24/GtkIconTheme.html.

Regards,
Thunor
Last edited by thunor on Sun 28 Aug 2011, 22:23, 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:

#245 Post by thunor »

Dougal wrote:Isn't the theme supposed to have also a symlink to it, with the proper stock name? Icon-themes are usually full of symlinks, as they don't have unique icons for everything, but need to support all the names.
Execute

Code: Select all

find /usr -name "gtk-*[ps][nv]g"
and find out.

Regards,
Thunor

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

#246 Post by zigbert »

Thunor
Thank you for the explanation.


Sigmund

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

#247 Post by 01micko »

thunor wrote:Simply put, stock="" is for unchanging stock IDs, icon="" is for filenames [minus the path and extension] representing icons from the current theme and also within the default paths GTK+ searches for theme icons.

[snip]
vovchik told me that ages ago!!! (about 2 years) [doh!]

ziggy.... hmmm... :lol:

At least this will please your weary eyes :wink: (oh yes, Slacko B1 and PM2 :) [hacked] )

Image


Image

...and thunors example with type=stock [line 13] and all -ltr$ removed from icon-names.txt

Image

Thanks thunor.. and everyone else for sticking with it :wink:
Puppy Linux Blog - contact me for access

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

#248 Post by 8-bit »

01micko,
First, I like your music interests as per the images! :)

Second, that one line change in the gtk theme icons example was great!
With it, the original icon-names.txt file works fine and all displayable stock icons are displayed.
It saves a lot of guesswork as to if an icon will display properly in various puppy versions.
At least I hope it does.

I had found that appending the -ltr to some names in a script worked in some scripts but not others.

So kudos to you.

Just one question.

Are you going to become a Slacker? :lol: :lol: :lol:

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

#249 Post by Dougal »

thunor wrote:I think that there might be some confusion about what stock="" does and what icon="" does so I'll attempt to explain them:

<input file stock="gtk-new"></input> for example would load the image associated with the stock ID "gtk-new". It is a constant or a macro meant to hide the filename and also to deal with left-to-right and right-to-left variations of some images. Importantly the stock IDs do not change, they are not filenames, they are IDs and the images are possibly compiled-in.

<input file icon="gnumeric"></input> for example would load the file "gnumeric.png/svg/etc." from the current icon theme wherever that is located. My GTK+ 2 Crux theme has an IconTheme=Crux set but there's no such set of icons on my computer so GTK+ searches a default set of paths which results in "/usr/share/icons/hicolor/16x16/apps/gnumeric.png" being loaded. Importantly these are filenames minus the path and extension.
This was obvious from the names.
There is not going to be an issue using <input file stock="gtk-new"></input> across GTK+ builds because "gtk-new" here is an ID hiding the filename of the originating image, but there will be if you use <input file icon="gtk-new"></input> because in this case "gtk-new" is a filename.
My point was that new stock items might be added with newer versions of gtk, to accommodate for newer technologies/standards, thus having them hardcoded will need updating. (the problem with my version is that you need the devx, though...)
What's been happening is that <input file icon="gtk-new"></input> has been used and it mostly worked because the originating filenames of the built-in images are mostly identical to the stock IDs (GTK+ apparently also counts built-in stock images as theme images) but on Slacko beta 1 the originating filenames of the built-in images are NOT the same as the stock IDs therefore "gtk-new" wouldn't be found as a theme icon UNLESS it does physically exist as a file somewhere within the paths GTK+ searches for theme icons.
Of course the theme images have the same names: they are intended to override the builtin stock images. (Sure, you could just give them arbitrary names and just define them the right way in the theme index, but that is pointless and not human-friendly)
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
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#250 Post by 01micko »

8-bit wrote: Second, that one line change in the gtk theme icons example was great
Well it's basically what thunor explained.. in 2 previous posts.. and of course vovchik's mention to me awhile ago.. :roll: I was just too dense to do it.. until the penny dropped! I do not deserve the kudos!
8-bit wrote: I had found that appending the -ltr to some names in a script worked in some scripts but not others.
I found that with -ltr not all images displayed for me, (in thunor's menu example) so I removed it and they did.. just trial and error.
8-bit wrote: Are you going to become a Slacker? :lol: :lol: :lol:
I guess once a month when I boot into Slackware I am... [shh... that could get me in trouble around here..]
Puppy Linux Blog - contact me for access

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

#251 Post by 8-bit »

Actually, I was thinking of your latest Puppy effort called "Slacko"
I have to wipe out a bunch of frugal puppy installs to make some room for Slaco so I can check it out.

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

#252 Post by zigbert »

01micko wrote:vovchik told me that ages ago!!! (about 2 years) [doh!]

ziggy.... hmmm... :lol:
Mick, uhhhmmmm......... :lol:
You missed something important. The labels in your screenshot are limited to the gtk-stock labels. ie. Pmusic uses its own definition of 'Undo' --> 'Go back in playlist history'.

All this is of course fixed in Pmusic 2.0.1 :)


Sigmund

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

#253 Post by zigbert »

Image

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

#254 Post by thunor »

Added statusbar widget
  • The <label> or the <default> directives can be used to set an initial message in addition to both <input> and <input file>
  • The widget's variable will contain the current message
  • There is no default signal and the only signal I've found it to emit is "show" at start-up
Just something I've wanted to add for some time now; a simple widget but useful.

<statusbar> 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

funcbtnCreate() {
	echo '<button image-position="'$2'">
			<label>"'"$3"'"</label>
			<input file stock="'$4'"></input>
			<action>echo "'"$5"' '$1'"</action>
			<action type="'"$3"'">'$1'</action>
		</button>'
}

echo "This message originates from an input file" > inputfile

export MAIN_DIALOG='
<window title="stbStatusBar" 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>
		</menubar>
		<hbox border-width="20" spacing="10">
			'"$(funcbtnCreate stb0 2 Disable gtk-no Disabling)"'
			'"$(funcbtnCreate stb0 2 Enable gtk-yes Enabling)"'
			'"$(funcbtnCreate stb0 2 Clear gtk-clear Clearing)"'
			'"$(funcbtnCreate stb0 2 Refresh gtk-refresh Refreshing)"'
			'"$(funcbtnCreate stb0 2 Save gtk-save Saving)"'
			'"$(funcbtnCreate stb0 2 Fileselect gtk-new "Inserting into")"'
		</hbox>
		<statusbar has-resize-grip="false">
			<label>This message originates from the label directive</label>
			<default>This message originates from the default directive</default>
			<variable>stb0</variable>
			<input>echo This message originates from an input command</input>
			<input file>inputfile</input>
			<sensitive>true</sensitive>
			<output file>outputfile</output>
		</statusbar>
	</vbox>
	<action signal="hide">exit:Exit</action> 
</window>
'

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

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

#255 Post by 8-bit »

I would still like to see an example of how to use a mask with chooser or fileselect to show only files that fit that mask.

For example, if I am at a prompt and type "ls *.png" only png type files are shown.
If I instead type "ls c*" only files beginning with c are shown.

If one has a variety of file types in a directory and wants fileselect or chooser to display only certain file types, that is handy.

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

#256 Post by 8-bit »

I did a bit to get this to work.
But It would need two functions to select the directory and the mask to use.

It may already have been done and no one has shown an example using the fileselect widget. When I get the functions competed, I may share it.

Code: Select all

#! /bin/sh
#This is how far I got creating a masked file list.
# If one adds an entry box to select the directory and another to select the mask with variables, they can be 
#passed to a function that writes a masked selection to /tmp/myfiles.txt
#This is only a start, and with a file mask widget, one would not have to jump through hoops to display
# a masked file list.




GTKDIALOG=gtkdialog
cd /root/examples #select the directory
ls t* >/tmp/myfiles.txt #pick mask to use with ls
window_width=300
icon_names=(echo $(</tmp/myfiles.txt))

lstCreate() {
      echo '<list>'
      for ((y = 0; y < 15; y++)); do
         i=$((x*15*2+y*2+1))
         echo '<item>"'${icon_names[$i]}'"</item>'
         
      done
      echo '</list>'
}

export lstCreate
export MAIN_DIALOG='
<window title="File MASK Test" width-request="'$window_width'"
   border-width="0" resizable="false">
   <hbox>
         '"$(lstCreate)"'
   </hbox>
</window>
'
gtkdialog3 -p MAIN_DIALOG

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

#257 Post by 01micko »

zigbert wrote: Mick, uhhhmmmm......... :lol:
You missed something important. The labels in your screenshot are limited to the gtk-stock labels. ie. Pmusic uses its own definition of 'Undo' --> 'Go back in playlist history'.

All this is of course fixed in Pmusic 2.0.1 :)


Sigmund
Doh! yes.. thickness disease.. :P

i got it now though.. this is a case where -ltr is useful ..
Attachments
got-it.png
(6.33 KiB) Downloaded 700 times
Puppy Linux Blog - contact me for access

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

#258 Post by jpeps »

8-bit wrote: It may already have been done and no one has shown an example using the fileselect widget. When I get the functions competed, I may share it.
http://murga-linux.com/puppy/viewtopic. ... &start=214

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

#259 Post by thunor »

01micko wrote:Doh! yes.. thickness disease.. :P

i got it now though.. this is a case where -ltr is useful ..
Mick

Can you show me the code for those two menuitems please. I'm just interested to know what you are doing with "-ltr".

Regards,
Thunor

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

#260 Post by 01micko »

Thunor.. you just caught me! (off to bed)

here is my hack: (due respect to Sigmund)

Code: Select all

<menuitem icon="gtk-undo-ltr" accel-key="0x07a" accel-mods="4">
  <label>'$LOC118'</label>
  <action>. '$APPDIR'/func -undo</action>
  <action>refresh:PLAYLIST</action>
 </menuitem>
 <menuitem icon="gtk-redo-ltr" accel-key="0x079" accel-mods="4">
  <label>'$LOC119'</label>
  <action>. '$APPDIR'/func -redo</action>
  <action>refresh:PLAYLIST</action>
 </menuitem>'
Make sense?

Cheers.. :)
Puppy Linux Blog - contact me for access

Post Reply