Revision [33328]

This is an old revision of gtkdialogDocTips8 made by zigbert on 2023-02-24 06:50:33.

 

HomePage > Software Index > Development > gtkdialog > Tips and Tricks

8. Text managing


INDEX
  1. Some options for the <text> widget
  1. Advanced text layout
  1. Scroll text
  1. Strikethrough text
  1. Set font
  1. Hyperlink


8.1
Some options for the <text> widget
See reference guide for basic options.
Here follows undocumented options.

Justify aligment to right (1), center (2), left (3).
<text justify="2">
Angle the text
<text angle="45">
Force one-line text
<text wrap="false">
<text single-line-mode="true">
Set underline pattern
<text label="Underline me with an useless pattern" pattern="__ __ __ __ __ __ _"></text>


8.2
Advanced text layout
underline, italic and Bold.
<text use-markup="true"><label>"<u><i><b>test</b></i></u>"</label></text>
Gtkdialog supports colors and size with the <span> tag. The use-markup="true" must be included.
<text use-markup="true"><label>"<span color='"'#789978'"'>test</span>"</label></text>
Text size is set by the <big> and <small> tags. Repeat (up to 3 times) to increase value.
<text use-markup="true"><label>"<big><big><big>test</big></big></big>"</label></text>
<text use-markup="true"><label>"<small><small><small>test</small></small></small>"</label></text>
Vovchik has made an editor to test advanced text layout,
Check it out at http://www.murga-linux.com/puppy/viewtopic.php?t=40418.


8.3
Scroll text
This example shows scrolling text in a <text> widget. This will work for other widgets as well.

export MSG="This is a test... I repeat: This is a test... "
export GTKBOX='
<vbox width-request="300">
 <text>
  <variable>MSG</variable>
  <input>echo -en "${MSG:2}${MSG:0:2}"</input>
 </text>
 <timer milliseconds="true" interval="200" visible="false">
  <action type="refresh">MSG</action>
 </timer> 
</vbox>'
gtkdialog -p GTKBOX


8.4
Strikethrough text
Strikethrough text is supported by the use-markup="true" option for text widgets.
<text use-markup="true"><label>"<s>test</s>"</label></text>
This example shows strikethrough on request

> /tmp/strikethrough
export DIALOG='
<window title="StrikeThrough" icon-name="gtk-strikethrough">
  <vbox>
	<edit wrap-mode="3">
	  <variable>EDIT</variable>
	  <default>write some text here</default>
	  <height>50</height>
	</edit>
	<edit file-monitor="true" auto-refresh="true" wrap-mode="3" editable="false">
	  <height>50</height>
	  <input file>/tmp/strikethrough</input>
	</edit>
	<hbox homogeneous="true">
	  <button>
		<label>Strikethrough text</label>
		<input file stock="gtk-ok"></input>
		<action>`echo "$EDIT" | sed "s/./&\xCC\xB6/g" > /tmp/strikethrough`</action>
	  </button>
	</hbox>
  </vbox>
</window>'
gtkdialog -p DIALOG


8.5
Set font
This is an example how to use other fonts even if gtkdialog hasn't an option to set this.

Gtkdialog does not support monospace in the <edit> widget, but I can make it work by adding a unique gtk-theme only for my app. The best way to this is to add my new gtk-theme on top of the already existing. Now my gtk-theme can hold ONLY information about monospace, else it will use gtk-settings specified by user.

By giving the text-widget a name (see example), it is possible to have a gtk-theme for only this unique text string. This also works for text in widgets like <entry>.

echo 'style "specialmono"
{
  font_name="Mono 12"
}
widget "*mono" style "specialmono"
class "GtkText*" style "specialmono"' > /tmp/gtkrc_mono

export GTK2_RC_FILES=/tmp/gtkrc_mono:/root/.gtkrc-2.0

export test_app="
<vbox>
  <text name=\"mono\"><label>This text-widget uses monospace font....</label></text>
  <text><label>...while this text-widget don't.</label></text>
  <edit><default>All edit-widgets gets monospace.</default></edit>
</vbox>"
gtkdialog --program=test_app


8.6
Hyperlink
Hyperlink is clickable text, often pointing user to a web page.

<text selectable="true" use-markup="true">
 <input>linkstyle "click here"</input>
 <action signal="button-press-event">defaultbrowser '$LNK'</action>
</text>

Other solutions including <eventbox> is discussed at http://murga-linux.com/puppy/viewtopic.php?t=106458


Categories
CategoryGtkdialog
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki