Gtkdialog Examples
Here is an example to show the placement of two buttons .....
right-side
center
left-side
Notes:
1) I create some text for log window to launch at button click.
2) I create a SVG icon to be used by one button.
3) I make a second window (called log_window ) to be closed at same time as main window.
EDIT: To close both windows at the same time an extra button is needed
Code: Select all
<button cancel> </button>
4) To control the width of window and also some vertical empty space I used ...
Code: Select all
<hbox width-request="300">
<text height-request="10"><label>""</label></text>
</hbox>
Here is script - It must be executable. Run it in terminal.
Code: Select all
#! /bin/bash
echo "This is text" > /tmp/example_text
echo ' <svg version="1.1" width="150" height="150" id="svg1">
id="svg1854"
<defs
id="defs1856" />
id="base" />
<g
id="g863"
transform="matrix(2.548887,0.000000,0.000000,2.401153,-1219.592,-402.1428)"
style="font-size:12;">
<path
fill="#333333"
d="M516.791,176.799l-3.211,6.996c6.373,1.846,11.049,7.724,11.049,14.683 c0,8.435-6.861,15.296-15.294,15.296c-7.314,0-13.438-5.163-14.938-12.034l-7.119,3c2.729,9.624,11.559,16.682,22.057,16.682 c12.669,0,22.942-10.272,22.942-22.944C532.277,188.421,525.797,179.897,516.791,176.799z"
id="path865" />
<g
id="g867">
<path
fill="#333333"
d="M515.889,206.126c-0.555,0-1.111-0.211-1.539-0.633l-7.075-7.015h-16.514 c-1.207,0-2.185-0.978-2.185-2.185c0-1.207,0.978-2.185,2.185-2.185h18.313l8.354,8.281c0.857,0.85,0.863,2.233,0.014,3.091 C517.014,205.911,516.451,206.126,515.889,206.126L515.889,206.126z"
id="path869" />
</g>
</g>
</svg>
' > /root/baconrecorder.svg
#make a second window that closes at same time as main window
log_window='
<window title="Example">
<frame>
<vbox>
<hbox width-request="300">
<text height-request="10"><label>""</label></text>
</hbox>
</vbox>
<text> <label>This is a static text.</label>
<input file>"/tmp/example_text"</input>
</text>
<hbox>
<button>
<label>"'$LOC303'"</label>
<action function="closewindow">log_window</action>
</button>
</hbox>
</frame>
<variable>log_window</variable>
</window>'
export log_window
###############################################
# #
# M A I N G U I #
# #
###############################################
export DIALOG='<window title="Example">
<vbox>
<frame>
<text height-request="20"><label>""</label></text>
<hbox>
<hbox>
<button tooltip-text="A record of the entries"><label>"Log"</label>
<input file stock="gtk-info"></input>
<action>tail_function</action>
<action function="launch">log_window</action>
</button>
<button>
<width>40</width>
<height>30</height>
<input file>"'/root/baconrecorder.svg'"</input>
<label>"Start the alarm clock"</label>
<action type="exit">Exit by button</action>
</button>
</hbox>
</hbox>
<hbox>
<hbox>
<button tooltip-text="A record of the entries"><label>"Log"</label>
<input file stock="gtk-info"></input>
<action>tail_function</action>
<action function="launch">log_window</action>
</button>
<button>
<width>40</width>
<height>30</height>
<input file>"'/root/baconrecorder.svg'"</input>
<label>"Start the alarm clock"</label>
<action type="exit">Exit by button</action>
</button>
</hbox>
<text space-expand="true" space-fill="true">
<label>""</label>
</text>
</hbox>
<hbox homogeneous="true">
<hbox>
<button tooltip-text="A record of the entries is here."><label>"Log"</label>
<input file stock="gtk-info"></input>
<action function="launch">log_window</action>
</button>
<button>
<width>40</width>
<height>30</height>
<input file>"'/root/baconrecorder.svg'"</input>
<label>"Start the alarm clock"</label>
<action type="exit">Exit by button</action>
</button>
</hbox>
<text space-expand="true" space-fill="true">
<label>""</label>
</text>
</hbox>
<text height-request="20"><label>""</label></text>
</frame>
</vbox>
</window>
'
I=$IFS; IFS=""
for STATEMENTS in $(gtkdialog --program=DIALOG); do
eval $STATEMENTS
done