Gtkdialog Development
- thunor
- Posts: 350
- Joined: Thu 14 Oct 2010, 15:24
- Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
- Contact:
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
Regards,
Thunor
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
Regards,
Thunor
- Dougal
- Posts: 2502
- Joined: Wed 19 Oct 2005, 13:06
- Location: Hell more grotesque than any medieval woodcut
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
Some say your nose
Some say your toes
But I think it's your mind
- Dougal
- Posts: 2502
- Joined: Wed 19 Oct 2005, 13:06
- Location: Hell more grotesque than any medieval woodcut
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.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]".
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind
Some say your nose
Some say your toes
But I think it's your mind
- thunor
- Posts: 350
- Joined: Thu 14 Oct 2010, 15:24
- Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
- Contact:
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):
Regards,
Thunor
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
Regards,
Thunor
Last edited by thunor on Sun 28 Aug 2011, 22:23, edited 2 times in total.
- thunor
- Posts: 350
- Joined: Thu 14 Oct 2010, 15:24
- Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
- Contact:
ExecuteDougal 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.
Code: Select all
find /usr -name "gtk-*[ps][nv]g"
Regards,
Thunor
vovchik told me that ages ago!!! (about 2 years) [doh!]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]
ziggy.... hmmm...
At least this will please your weary eyes (oh yes, Slacko B1 and PM2 [hacked] )
...and thunors example with type=stock [line 13] and all -ltr$ removed from icon-names.txt
Thanks thunor.. and everyone else for sticking with it
Puppy Linux Blog - contact me for access
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?
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?
- Dougal
- Posts: 2502
- Joined: Wed 19 Oct 2005, 13:06
- Location: Hell more grotesque than any medieval woodcut
This was obvious from the names.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.
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...)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.
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 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.
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind
Some say your nose
Some say your toes
But I think it's your mind
Well it's basically what thunor explained.. in 2 previous posts.. and of course vovchik's mention to me awhile ago.. I was just too dense to do it.. until the penny dropped! I do not deserve the kudos!8-bit wrote: Second, that one line change in the gtk theme icons example was great
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: I had found that appending the -ltr to some names in a script worked in some scripts but not others.
I guess once a month when I boot into Slackware I am... [shh... that could get me in trouble around here..]8-bit wrote: Are you going to become a Slacker?
Puppy Linux Blog - contact me for access
Mick, uhhhmmmm.........01micko wrote:vovchik told me that ages ago!!! (about 2 years) [doh!]
ziggy.... hmmm...
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
- thunor
- Posts: 350
- Joined: Thu 14 Oct 2010, 15:24
- Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
- Contact:
Added statusbar widget
<statusbar> widget example:
Regards,
Thunor
- 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
<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
Thunor
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.
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.
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.
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
Doh! yes.. thickness disease..zigbert wrote: Mick, uhhhmmmm.........
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
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
http://murga-linux.com/puppy/viewtopic. ... &start=2148-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.
Thunor.. you just caught me! (off to bed)
here is my hack: (due respect to Sigmund)
Make sense?
Cheers..
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>'
Cheers..
Puppy Linux Blog - contact me for access