/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

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