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

10. The holy grail


The holy grail is all about combining knowledge. To find spots in your gui where bash can fuel the gtk-theme or svg to push gtkdialog's limitations. Be aware that both gtk-themes and svg images are basically raw text files. Since bash is a great tool for text managing, it is easy to code a text-file depending on user/system input.

The example is taken from the app 'pFind'. The screenshot shows that pFind has detected 419 files with the pattern "puppy". 2 audiofiles, 67 images...
These are <button> widgets with no button decoration (relief="2"), and no <label> defined. The result for the user is a clickable svg that highlights at mouse hovering, and has tooltip text.

screenshot

The svg contains info about
Coding the same functionality with basic gtkdialog widgets would require more widgets, more code, more clutter, and a less userfriendly gui.

<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100" height="30">
  <rect width="80" height="30" style="fill:#ddd; fill-opacity:1; stroke-width:0" />
  <path style="fill:#ddd; fill-opacity:0.8; stroke:none" d="m 80,0 20,15 -20,15 z" />
  <path style="fill:black; stroke:none;" d="m 5,11 0,8 4,0 7,6 0,-20 -7,6 z M 20,9 c -1,-1 -2,1 -1,2 l 0,0 c 1,1 1,3 1,4 0,1 0,3 -1,4 -1,1 0,3 1,2 2,-2 2,-4 2,-6 0,-2 0,-4 -2,-6 z m 4,-3 c -1,-1 -3,-1 -2,1 3,3 3,5 3,8 0,3 0,5 -3,8 -1,2 1,2 2,1 3,-4 3,-6 3,-9 0,-3 0,-5 -3,-9 z"/>
  <text x="75" y="20" style="fill:black; font-family:DejaVu; font-size:14; text-anchor:end;">
	2
  </text>
</svg>


The gtkdialog code for the button is extremly simple. What makes the code long is to refresh all <button> widgets when clicking. We have to rebuild the svg for all of them to make the new active svg/button get the arrow.

<button relief="2" tooltip-text="'$(gettext "Sound files")'">
  <variable>BUTTON_MUSIC</variable>
  <input file>/tmp/pfind_MUSIC.svg</input>
  <action>func_viewMusic</action>
  <action>func_buildSvg</action>
  <action>refresh:TREE</action>
  <action>refresh:BUTTON_ALL</action>
  <action>refresh:BUTTON_MUSIC</action>
  <action>refresh:BUTTON_PIC</action>
  <action>refresh:...</action>
</button>



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