The time now is Sun 08 Dec 2019, 21:21
All times are UTC - 4 |
Page 15 of 56 [839 Posts] |
Goto page: Previous 1, 2, 3, ..., 13, 14, 15, 16, 17, ..., 54, 55, 56 Next |
Author |
Message |
thunor

Joined: 14 Oct 2010 Posts: 350 Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
|
Posted: Tue 23 Aug 2011, 12:10 Post subject:
|
|
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: | #!/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
Description |
Two SVG images from the Elementary Icons
|

Download |
Filename |
true-false.svg.tar.gz |
Filesize |
1.25 KB |
Downloaded |
487 Time(s) |
Last edited by thunor on Sat 27 Aug 2011, 18:43; edited 1 time in total
|
Back to top
|
|
 |
zigbert

Joined: 29 Mar 2006 Posts: 6608 Location: Valåmoen, Norway
|
Posted: Thu 25 Aug 2011, 02:48 Post subject:
|
|
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).
In Puppy 511, it appears like it is meant to be (same gtkdialog).
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
_________________ Stardust resources
|
Back to top
|
|
 |
01micko

Joined: 11 Oct 2008 Posts: 8739 Location: qld
|
Posted: Thu 25 Aug 2011, 04:02 Post subject:
|
|
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
|
Back to top
|
|
 |
ttuuxxx

Joined: 05 May 2007 Posts: 11240 Location: Ontario Canada,Sydney Australia
|
Posted: Thu 25 Aug 2011, 04:53 Post subject:
|
|
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 
|
Back to top
|
|
 |
thunor

Joined: 14 Oct 2010 Posts: 350 Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
|
Posted: Thu 25 Aug 2011, 12:08 Post subject:
|
|
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: | #!/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
|
Back to top
|
|
 |
vovchik

Joined: 23 Oct 2006 Posts: 1512 Location: Ukraine
|
Posted: Thu 25 Aug 2011, 12:32 Post subject:
|
|
Dear thunor,
What can I say? FAB...
With thanks and kind regards,
vovchik
|
Back to top
|
|
 |
jpeps
Joined: 31 May 2008 Posts: 3217
|
Posted: Thu 25 Aug 2011, 14:33 Post subject:
|
|
thunor wrote: | Overhauled the fileselect action function
|
Great!!! Will give it a try...Thanks
edit: This works nicely...major addition.
|
Back to top
|
|
 |
thunor

Joined: 14 Oct 2010 Posts: 350 Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
|
Posted: Thu 25 Aug 2011, 18:46 Post subject:
|
|
vovchik and jpeps: cheers for the feedback.
[EDIT] Screenshot below looks cool
Regards,
Thunor
Last edited by thunor on Fri 26 Aug 2011, 12:17; edited 1 time in total
|
Back to top
|
|
 |
jpeps
Joined: 31 May 2008 Posts: 3217
|
Posted: Fri 26 Aug 2011, 03:05 Post subject:
New Fileselect Filters |
|
Ah....This is way better!
Description |
|
Filesize |
99.99 KB |
Viewed |
1832 Time(s) |

|
|
Back to top
|
|
 |
thunor

Joined: 14 Oct 2010 Posts: 350 Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
|
Posted: Fri 26 Aug 2011, 12:50 Post subject:
|
|
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: | #!/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
Description |
icon-names.txt required by the example (gunzip it)
|

Download |
Filename |
icon-names.txt.gz |
Filesize |
655 Bytes |
Downloaded |
519 Time(s) |
Last edited by thunor on Sat 27 Aug 2011, 18:40; edited 1 time in total
|
Back to top
|
|
 |
thunor

Joined: 14 Oct 2010 Posts: 350 Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
|
Posted: Fri 26 Aug 2011, 19:00 Post subject:
|
|
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: | <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"
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
|
Back to top
|
|
 |
zigbert

Joined: 29 Mar 2006 Posts: 6608 Location: Valåmoen, Norway
|
Posted: Sat 27 Aug 2011, 02:21 Post subject:
|
|
Hi Thunor
This is how it looks in Slacko beta 1
_________________ Stardust resources
|
Back to top
|
|
 |
zigbert

Joined: 29 Mar 2006 Posts: 6608 Location: Valåmoen, Norway
|
Posted: Sat 27 Aug 2011, 02:23 Post subject:
|
|
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
_________________ Stardust resources
|
Back to top
|
|
 |
8-bit

Joined: 03 Apr 2007 Posts: 3425 Location: Oregon
|
Posted: Sat 27 Aug 2011, 02:45 Post subject:
|
|
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.
|
Back to top
|
|
 |
zigbert

Joined: 29 Mar 2006 Posts: 6608 Location: Valåmoen, Norway
|
Posted: Sat 27 Aug 2011, 04:51 Post subject:
|
|
.... And this is how it looks in Puppy 5.11
_________________ Stardust resources
|
Back to top
|
|
 |
|
Page 15 of 56 [839 Posts] |
Goto page: Previous 1, 2, 3, ..., 13, 14, 15, 16, 17, ..., 54, 55, 56 Next |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|