48 lines
1.3 KiB
Elixir
Raw Permalink Normal View History

2016-11-25 00:33:18 -07:00
----------------------------------------------------------------
--# GtkCombo with model, cell renderers and bitmaps
----------------------------------------------------------------
include GtkEngine.e
sequence desserts = {
{"thumbnails/cake.png","Strawberry Cake"},
{"thumbnails/pie.png","Pecan Pie"},
{"thumbnails/BabyTux.png","Pickled Herring"}
}
for i = 1 to length(desserts) do -- convert name to pointer to pixbuf;
desserts[i][1] = create(GdkPixbuf,desserts[i][1],30,30,1)
end for
constant win = create(GtkWindow,
"title=Bitmap Demo,border=10,icon=./thumbnails/cake.png,$destroy=Quit")
constant panel = create(GtkGrid)
add(win,panel)
constant lbl = create(GtkLabel,"Choose a dessert from the drop-down list below:")
set(panel,"attach",lbl,1,1,5,1)
constant combo = create(GtkComboBox)
set(panel,"attach",combo,3,2,1,1)
constant mdl = create(GtkListStore,{gPIX,gSTR})
set(combo,"model",mdl)
set(mdl,"data",desserts)
constant pixrend = create(GtkCellRendererPixbuf)
constant txtrend = create(GtkCellRendererText)
CellArea cell_area = get(combo,"property","cell-area")
set(cell_area,{
{"add",pixrend},
{"add",txtrend},
{"attribute connect",pixrend,"pixbuf",1},
{"attribute connect",txtrend,"text",2}})
show_all(win)
main()