eumandy/eugtk/examples/test64.ex
2016-11-25 00:33:18 -07:00

69 lines
2.3 KiB
Elixir

-------------------------------------------------------------------------------------
--# Custom Tooltips - routine to build fancier tooltips with images, etc...
-------------------------------------------------------------------------------------
include GtkEngine.e
sequence docs = `
This is just some various stuff stuck into a Window.
Mouse over the Help button to see a <b><u>Custom Tooltip</u></b>.
`
if inet_connected() then -- add optional link to website if connected to internets;
docs &= `In addition, here's a link to <a href="http://gtk.org" title="Click me to visit the GTK website!">gtk.org</a>`
end if
constant txt = {"Click to <b><i>exit</i></b>","Click button to see <b><u>help</u></b>"}
constant img = {
create(GdkPixbuf,"thumbnails/clown.png",80,80,1),
create(GdkPixbuf,"thumbnails/gtk-logo-rgb.gif",80,80,1)}
constant win = create(GtkWindow,
"size=400x400,border_width=10,position=1,$destroy=Quit")
constant panel = create(GtkBox,VERTICAL)
add(win,panel)
constant photo = create(GtkImage,"thumbnails/jeff.jpg")
add(panel,photo)
constant lbl1 = create(GtkLabel)
set(lbl1,"markup",docs)
add(panel,lbl1)
sequence btn = repeat(0,2)
btn[1] = create(GtkButton,"gtk-quit","Quit")
set(btn[1],"has tooltip",TRUE)
connect(btn[1],"query-tooltip","MakeCustomTooltip") -- call custom tip builder func;
btn[2] = create(GtkButton,"gtk-help","Help")
set(btn[2],"has tooltip",TRUE)
connect(btn[2],"query-tooltip","MakeCustomTooltip") -- call custom tip builder func;
constant btnbox = create(GtkButtonBox)
add(btnbox,btn)
pack(panel,-btnbox)
show_all(win)
main()
-- must write a function to build a custom tooltip on 'query-tooltip' signal;
--------------------------------------------------------------------------------
global function MakeCustomTooltip(atom b, integer x, integer y, atom mode, Tooltip tip)
--------------------------------------------------------------------------------
integer n = find(b,btn)
set(tip,"icon",img[n])
set(tip,"markup",txt[n])
return 1
end function
------------------------------------------------------------------------
global function Help()
------------------------------------------------------------------------
return Info(win,"Help","Some help",
"could appear here,\nif I weren't too lazy to type some...",,,img[2])
end function