added eugtk examples
This commit is contained in:
83
eugtk/examples/test63.ex
Normal file
83
eugtk/examples/test63.ex
Normal file
@@ -0,0 +1,83 @@
|
||||
|
||||
------------------------------------------------------------------------
|
||||
--# GtkTreeStore
|
||||
------------------------------------------------------------------------
|
||||
-- Hard to understand, difficult to make it easy to use.
|
||||
-- However, this does work for nested sequences
|
||||
-- up to a point, as long as the data is all strings.
|
||||
------------------------------------------------------------------------
|
||||
|
||||
include GtkEngine.e
|
||||
|
||||
|
||||
object store = create(GtkTreeStore,{gSTR,gSTR})
|
||||
|
||||
sequence os = {
|
||||
{"Windows","An Operating? System",
|
||||
{"Bill Gates"}},
|
||||
{"Linux","An Operating! System",
|
||||
{"Linus Torvalds"}},
|
||||
{"Mac","A Religion",
|
||||
{"Steve Jobs",
|
||||
"The Woz",
|
||||
{"Billy (the kid)",
|
||||
{"Bowser","Fido"},
|
||||
"Susan (the other kid)",
|
||||
{"Grumpy Cat"}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
set(store,"data",os)
|
||||
|
||||
constant
|
||||
col1 = create(GtkColumn,"title=OS,type=text,markup=1,sort_column_id=1"),
|
||||
col2 = create(GtkColumn,"title=Notes,type=text,markup=2,sort_column_id=2")
|
||||
|
||||
constant tv = create(GtkTreeView,{
|
||||
{"model",store},
|
||||
{"append columns",{col1,col2}},
|
||||
{"enable tree lines",TRUE},
|
||||
{"rules hint",TRUE},
|
||||
-- {"hover expand",TRUE},
|
||||
-- {"expand all"},
|
||||
$})
|
||||
|
||||
-- Note: you can set a search column, and then ctl-f will pop up a search box,
|
||||
-- or you can just start typing, and best match will be highlighted,
|
||||
-- but the view must be expanded for this to work.
|
||||
set(tv,"search column",1)
|
||||
|
||||
constant selection = get(tv,"selection")
|
||||
|
||||
constant win = create(GtkWindow,
|
||||
"title=`Tree View`,size=250x400,border_width=10,position=1,$destroy=Quit")
|
||||
|
||||
constant panel = create(GtkBox,VERTICAL)
|
||||
add(win,panel)
|
||||
|
||||
pack(panel,tv,TRUE,TRUE,5)
|
||||
|
||||
constant btn2 = create(GtkToggleButton,"gtk-ok#Expand",_("Expand"))
|
||||
constant btn1 = create(GtkButton,"gtk-quit","Quit")
|
||||
constant box = create(GtkButtonBox)
|
||||
add(box,{btn1,btn2})
|
||||
pack(panel,-box)
|
||||
|
||||
show_all(win)
|
||||
main()
|
||||
|
||||
------------------------
|
||||
function Expand()
|
||||
------------------------
|
||||
if get(btn2,"active") then
|
||||
set(tv,"expand all")
|
||||
else
|
||||
set(tv,"collapse all")
|
||||
end if
|
||||
return 1
|
||||
end function
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user