/src/wrappers/gtk/library/gtk_combo_box_entry.e

http://github.com/tybor/Liberty · Specman e · 133 lines · 71 code · 23 blank · 39 comment · 3 complexity · 2174073c74669a9f5f0bc74d61069f9e MD5 · raw file

  1. indexing
  2. description: "GtkComboBoxEntry -- A text entry field with a dropdown list."
  3. copyright: "[
  4. Copyright (C) 2006 eiffel-libraries team, GTK+ team
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License
  7. as published by the Free Software Foundation; either version 2.1 of
  8. the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA
  17. ]"
  18. class GTK_COMBO_BOX_ENTRY
  19. --A GtkComboBoxEntry is a widget that allows the user to choose
  20. -- from a list of valid choices or enter a different value. It is
  21. -- very similar to a GtkComboBox, but it displays the selected
  22. -- value in an entry to allow modifying it.
  23. -- In contrast to a GtkComboBox, the underlying model of a
  24. -- GtkComboBoxEntry must always have a text column (see
  25. -- `set_text_column'), and the entry will show the content of the
  26. -- text column in the selected row. To get the text from the entry,
  27. -- use `active_text'.
  28. -- The changed signal will be emitted while typing into a
  29. -- GtkComboBoxEntry, as well as when selecting an item from the
  30. -- GtkComboBoxEntry's list. Use `active_row' or `active_iter' to
  31. -- discover whether an item was actually selected from the list.
  32. -- Connect to the activate signal of the GtkEntry (use `child') to
  33. -- detect when the user actually finishes entering text.
  34. -- The convenience API to construct simple text-only GtkComboBoxes
  35. -- can also be used with GtkComboBoxEntrys which have been
  36. -- constructed with `with_text_only'.
  37. inherit
  38. GTK_COMBO_BOX
  39. rename
  40. with_model as make_combo_box_with_model,
  41. child as entry
  42. export {} make_combo_box_with_model
  43. redefine make, with_text_only, struct_size, entry
  44. end
  45. -- GtkComboBoxEntry implements the same interfaces implemented by
  46. -- GtkComboBox, i.e.: AtkImplementorIface, GtkCellEditable and
  47. -- GtkCellLayout.
  48. insert
  49. GTK_COMBO_BOX_ENTRY_EXTERNALS
  50. creation make, with_model, with_text_only, from_external_pointer
  51. feature {} -- Creation
  52. make is
  53. -- Creates a new GtkComboBoxEntry which has a GtkEntry as
  54. -- child. After construction, you should set a model using
  55. -- `set_model' and a text_column using
  56. -- `set_text_column'.
  57. do
  58. from_external_pointer (gtk_combo_box_entry_new)
  59. end
  60. with_model (a_model: GTK_TREE_MODEL; a_text_column: INTEGER) is
  61. -- Creates a new GtkComboBoxEntry which has a GtkEntry as
  62. -- child and a list of strings as popup. You can get the
  63. -- GtkEntry from a GtkComboBoxEntry using `child'. To add and
  64. -- remove strings from the list, just modify model using its
  65. -- data manipulation API.
  66. do
  67. from_external_pointer (gtk_combo_box_entry_new_with_model (a_model.handle, a_text_column))
  68. end
  69. with_text_only is
  70. -- Convenience function which constructs a new editable text
  71. -- combo box, which is a GtkComboBoxEntry just displaying
  72. -- strings. If you use this function to create a text combo
  73. -- box, you should only manipulate its data source with the
  74. -- following convenience functions: `append_text',
  75. -- `insert_text', `prepend_text' and `remove_text'.
  76. do
  77. from_external_pointer (gtk_combo_box_entry_new_text )
  78. is_text_only:=True
  79. ensure then text_only: is_text_only
  80. end
  81. feature
  82. set_text_column (a_column: INTEGER) is
  83. -- Sets the model column which entry box should use to get
  84. -- strings from to be `a_column'.
  85. require valid_column: a_column >= -1
  86. do
  87. gtk_combo_box_entry_set_text_column (handle, a_column)
  88. end
  89. text_column: INTEGER is
  90. -- The column which entry box is using to get the strings from.
  91. do
  92. Result := gtk_combo_box_entry_get_text_column (handle)
  93. ensure valid: Result >= -1
  94. end
  95. feature
  96. entry: GTK_ENTRY is
  97. do
  98. if hidden_child_wrapper=Void then
  99. create hidden_child_wrapper.from_external_pointer (gtk_bin_get_child(handle))
  100. end
  101. Result := hidden_child_wrapper
  102. end
  103. feature {} -- Implementation
  104. hidden_child_wrapper: GTK_ENTRY
  105. feature -- size
  106. struct_size: INTEGER is
  107. external "C inline use <gtk/gtk.h>"
  108. alias "sizeof(GtkComboBoxEntry)"
  109. end
  110. end