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