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

52 lines
1.5 KiB
Elixir

---------------------------------------------------------------------------------------------------
--# GtkToolBar demo
---------------------------------------------------------------------------------------------------
include GtkEngine.e
constant docs = `<u><b>ToolBar</b></u>
demos two different styles of toolbar.
This uses custom icons.
Edit the source to change styles.
`
constant
fish = create(GdkPixbuf,"thumbnails/fish.png",30,30),
fox = create(GdkPixbuf,"thumbnails/fox.png",30,30),
mouse = create(GdkPixbuf,"thumbnails/mouse.png",30,30),
names = {"Fish","Fox","Mouse"},
pix = {fish,fox,mouse}
constant win = create(GtkWindow,"size=400x200,position=1,$destroy=Quit")
constant panel = create(GtkBox,"orientation=VERTICAL")
add(win,panel)
constant toolbar = create(GtkToolbar) -- try one of the following:
-- set(toolbar,"style",GTK_TOOLBAR_BOTH) -- labels and icons
-- set(toolbar,"style",GTK_TOOLBAR_TEXT) -- to show text labels only
-- set(toolbar,"style",GTK_TOOLBAR_ICONS) -- to show icons only, this is the default
add(panel,toolbar)
atom item
for i = 1 to 3 do
item = create(GtkToolButton,create(GtkImage,pix[i]),names[i],_("Foo"),i)
add(toolbar,item)
end for
constant doclbl = create(GtkLabel)
set(doclbl,"markup",docs)
add(panel,doclbl)
show_all(win)
main()
---------------------------------------------
function Foo(atom ctl, integer n)
---------------------------------------------
set(doclbl,"font","Purisa 36")
set(doclbl,"text",names[n])
return 1
end function