PageRenderTime 23ms CodeModel.GetById 18ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/wrappers/gtk/examples/entry_completion/programmers_entry.e

http://github.com/tybor/Liberty
Specman e | 69 lines | 50 code | 11 blank | 8 comment | 0 complexity | 00b9175e1dbe910c61b60be6986298cc MD5 | raw file
 1indexing
 2	description: "."
 3	copyright: "(C) 2006 Paolo Redaelli "
 4	license: "LGPL v2 or later"
 5	date: "$Date:$"
 6	revision: "$Revision:$"
 7
 8class PROGRAMMERS_ENTRY
 9inherit GTK_COMBO_BOX_ENTRY redefine make end 
10insert G_TYPES
11	-- TODO: This insertion is necessary when creating the programmers,
12	-- since it requires explicit reference to g_type_*; it's ugly, or
13	-- better it feels mostly unEiffelish to me. Paolo 2006-05-30
14	
15creation make
16
17feature 
18	make is
19		do
20			with_model (programmers, name_column_n)
21			create completion.make 
22			completion.set_model (programmers)
23			completion.set_text_column (name_column_n)
24			completion.set_inline_completion(True)
25			entry.set_completion (completion)
26		end
27
28feature -- Programmers' model columns
29	name_column_n: INTEGER is 0
30	proficiency_column_n: INTEGER is 1
31	columns_n: INTEGER is 2
32
33feature  {} -- Implementation
34	completion: GTK_ENTRY_COMPLETION
35
36	programmers_array: FAST_ARRAY[TUPLE[STRING,INTEGER]] is
37			-- Programmers name and Eiffelliness level
38		do
39			Result:= ( { FAST_ARRAY[TUPLE[STRING,INTEGER]]
40							 << [ "Jose Bollo", {INTEGER_32 95} ],
41								 [ "Oliver Elphick", {INTEGER_32 95} ],
42								 [ "Raphael Mack", {INTEGER_32 95} ],
43								 [ "Paolo Redaelli", {INTEGER_32 12} ],
44								 [ "Dominique Colnet", {INTEGER_32 100} ] >> } )
45		end
46							  
47	
48	programmers: GTK_LIST_STORE is
49			-- tree model with some data set
50		local iter: GTK_TREE_ITER; i:INTEGER
51		once 
52			create Result.make (<<g_type_string, g_type_uint>>)
53			-- TODO: change design to remove explicit reference to g_type_*; it's
54			-- ugly, or better it feels mostly unEiffelish to me. Paolo 2006-05-28
55			
56			-- Append three rows and fill in some data
57			create iter.make_from_model (Result)
58			iter.start
59
60			from i:=programmers_array.lower until i>=programmers_array.upper
61			loop
62				Result.append (iter)
63				Result.set_string (iter, name_column_n, programmers_array.item(i).item_1)
64				Result.set_natural (iter, proficiency_column_n, programmers_array.item(i).item_2)
65				i:=i+1
66			end
67		end
68
69end