/src/wrappers/gtk/library/gtk_menu_shell.e

http://github.com/tybor/Liberty · Specman e · 355 lines · 120 code · 85 blank · 150 comment · 2 complexity · e1a4eba1d896ae5c5d8ecca7ea901d95 MD5 · raw file

  1. indexing
  2. description: "GtkMenuShell -- A base class for menu objects."
  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. deferred class GTK_MENU_SHELL
  19. -- A GtkMenuShell is the abstract base class used to derive the
  20. -- GtkMenu and GtkMenuBar subclasses.
  21. -- A GtkMenuShell is a container of GtkMenuItem objects arranged in
  22. -- a list which can be navigated, selected, and activated by the
  23. -- user to perform application functions. A GtkMenuItem can have a
  24. -- submenu associated with it, allowing for nested hierarchical
  25. -- menus.
  26. inherit GTK_CONTAINER
  27. -- GtkMenuShell implements AtkImplementorIface Interface
  28. feature -- size
  29. struct_size: INTEGER is
  30. external "C inline use <gtk/gtk.h>"
  31. alias "sizeof(GtkMenuShell)"
  32. end
  33. feature
  34. -- TODO: check if all those `a_child' shall be GTK_MENU_ITEM
  35. -- instead of GTK_WIDGET
  36. append (a_child: GTK_WIDGET) is
  37. -- Adds a new GtkMenuItem to the end of the menu shell's item
  38. -- list.
  39. require widget_not_void: a_child /= Void
  40. do
  41. gtk_menu_shell_append (handle, a_child.handle)
  42. end
  43. prepend (a_child: GTK_WIDGET) is
  44. -- Adds a new GtkMenuItem to the beginning of the menu
  45. -- shell's item list.
  46. require widget_not_void: a_child /= Void
  47. do
  48. gtk_menu_shell_prepend (handle, a_child.handle)
  49. end
  50. insert_child (a_child: GTK_WIDGET; a_position: INTEGER) is
  51. -- Adds a new GtkMenuItem to the menu shell's item list at
  52. -- `a_position'. Positions are numbered from 0 to n-1.
  53. require
  54. widget_not_void: a_child /= Void
  55. valid_position: a_position>=0
  56. do
  57. gtk_menu_shell_insert (handle, a_child.handle, a_position)
  58. end
  59. deactivate is
  60. -- Deactivates the menu shell. Typically this results in the
  61. -- menu shell being erased from the screen.
  62. do
  63. gtk_menu_shell_deactivate (handle)
  64. end
  65. select_item (a_menu_item: GTK_WIDGET) is
  66. -- Selects `a_menu_item' (a GtkMenuItem) from the menu shell.
  67. require item_not_void: a_menu_item /= Void
  68. do
  69. gtk_menu_shell_select_item (handle, a_menu_item.handle)
  70. end
  71. select_first (search_sensitive: BOOLEAN) is
  72. -- Select the first visible or selectable child of the menu
  73. -- shell; don't select tearoff items unless the only item is
  74. -- a tearoff item.
  75. -- `search_sensitive': if TRUE, search for the first
  76. -- selectable menu item, otherwise select nothing if the
  77. -- first item isn't sensitive. This should be FALSE if the
  78. -- menu is being popped up initially.
  79. do
  80. gtk_menu_shell_select_first (handle, search_sensitive.to_integer);
  81. end
  82. deselect is
  83. -- Deselects the currently selected item from the menu shell,
  84. -- if any.
  85. do
  86. gtk_menu_shell_deselect (handle)
  87. end
  88. activate_item (a_menu_item: GTK_WIDGET; force_deactivate: BOOLEAN) is
  89. -- Activates `a_menu_item' within the menu shell. If
  90. -- `force_deactivate' is True, force the deactivation of the
  91. -- menu shell after the menu item is activated.
  92. require item_not_void: a_menu_item /= Void
  93. do
  94. gtk_menu_shell_activate_item (handle, a_menu_item.handle, force_deactivate.to_integer)
  95. end
  96. cancel is
  97. -- Cancels the selection within the menu shell.
  98. do
  99. gtk_menu_shell_cancel (handle)
  100. end
  101. set_take_focus is
  102. -- Makes the menu shell to take the keyboard focus so that it
  103. -- will receive all keyboard events which is needed to enable
  104. -- keyboard navigation in menus.
  105. -- The state of a menu or menu bar is automatically
  106. -- propagated to submenus whenever a submenu is popped up, so
  107. -- you don't have to worry about recursively setting it for
  108. -- your entire menu hierarchy. Only when programmatically
  109. -- picking a submenu and popping it up manually, the
  110. -- take_focus property of the submenu needs to be set
  111. -- explicitely.
  112. -- See also GDK_KEYBOARD.grab
  113. do
  114. gtk_menu_shell_set_take_focus (handle,1)
  115. end
  116. unset_take_focus is
  117. -- This is useful only for special applications like virtual
  118. -- keyboard implementations which should not take keyboard
  119. -- focus.
  120. -- The take_focus state of a menu or menu bar is
  121. -- automatically propagated to submenus whenever a submenu is
  122. -- popped up, so you don't have to worry about recursively
  123. -- setting it for your entire menu hierarchy. Only when
  124. -- programmatically picking a submenu and popping it up
  125. -- manually, the take_focus property of the submenu needs to
  126. -- be set explicitely.
  127. -- Note that this setting has side-effects:
  128. -- If the focus is in some other app, it keeps the focus and
  129. -- keynav in the menu doesn't work. Consequently, keynav on
  130. -- the menu will only work if the focus is on some toplevel
  131. -- owned by the onscreen keyboard.
  132. -- To avoid confusing the user, menus with take_focus set to
  133. -- FALSE should not display mnemonics or accelerators, since
  134. -- it cannot be guaranteed that they will work.
  135. -- See also GDK_KEYBOARD.grab
  136. do
  137. gtk_menu_shell_set_take_focus (handle,0)
  138. end
  139. is_focus_taken: BOOLEAN is
  140. -- Will the menu shell will take the keyboard focus on popup.
  141. do
  142. Result:=(gtk_menu_shell_get_take_focus(handle).to_boolean)
  143. end
  144. feature -- TODO: Properties
  145. -- "take-focus" gboolean : Read / Write
  146. -- Property Details
  147. -- The "take-focus" property
  148. -- "take-focus" gboolean : Read / Write
  149. -- A boolean that determines whether the menu and its submenus grab the
  150. -- keyboard focus. See gtk_menu_shell_set_take_focus() and
  151. -- gtk_menu_shell_get_take_focus().
  152. -- Default value: TRUE
  153. -- Since 2.8
  154. feature -- TODO: Signals
  155. -- "activate-current"
  156. -- void user_function (GtkMenuShell *menushell,
  157. -- gboolean force_hide,
  158. -- gpointer user_data) : Run last / Action
  159. -- "cancel" void user_function (GtkMenuShell *menushell,
  160. -- gpointer user_data) : Run last / Action
  161. -- "cycle-focus"
  162. -- void user_function (GtkMenuShell *menushell,
  163. -- GtkDirectionType *arg1,
  164. -- gpointer user_data) : Run last / Action
  165. -- "deactivate"
  166. -- void user_function (GtkMenuShell *menushell,
  167. -- gpointer user_data) : Run first
  168. -- "move-current"
  169. -- void user_function (GtkMenuShell *menushell,
  170. -- GtkMenuDirectionType direction,
  171. -- gpointer user_data) : Run last / Action
  172. -- "selection-done"
  173. -- void user_function (GtkMenuShell *menushell,
  174. -- gpointer user_data) : Run first
  175. -- Signal Details
  176. -- The "activate-current" signal
  177. -- void user_function (GtkMenuShell *menushell,
  178. -- gboolean force_hide,
  179. -- gpointer user_data) : Run last / Action
  180. -- An action signal that activates the current menu item within the menu
  181. -- shell.
  182. -- menushell : the object which received the signal.
  183. -- force_hide : if TRUE, hide the menu after activating the menu item.
  184. -- user_data : user data set when the signal handler was connected.
  185. -- -----------------------------------------------------------------------
  186. -- The "cancel" signal
  187. -- void user_function (GtkMenuShell *menushell,
  188. -- gpointer user_data) : Run last / Action
  189. -- An action signal which cancels the selection within the menu shell.
  190. -- Causes the GtkMenuShell::selection-done signal to be emitted.
  191. -- menushell : the object which received the signal.
  192. -- user_data : user data set when the signal handler was connected.
  193. -- -----------------------------------------------------------------------
  194. -- The "cycle-focus" signal
  195. -- void user_function (GtkMenuShell *menushell,
  196. -- GtkDirectionType *arg1,
  197. -- gpointer user_data) : Run last / Action
  198. -- menushell : the object which received the signal.
  199. -- arg1 :
  200. -- user_data : user data set when the signal handler was connected.
  201. -- -----------------------------------------------------------------------
  202. -- The "deactivate" signal
  203. -- void user_function (GtkMenuShell *menushell,
  204. -- gpointer user_data) : Run first
  205. -- This signal is emitted when a menu shell is deactivated.
  206. -- menushell : the object which received the signal.
  207. -- user_data : user data set when the signal handler was connected.
  208. -- -----------------------------------------------------------------------
  209. -- The "move-current" signal
  210. -- void user_function (GtkMenuShell *menushell,
  211. -- GtkMenuDirectionType direction,
  212. -- gpointer user_data) : Run last / Action
  213. -- An action signal which moves the current menu item in the direction
  214. -- specified by direction.
  215. -- menushell : the object which received the signal.
  216. -- direction : the direction to move.
  217. -- user_data : user data set when the signal handler was connected.
  218. -- -----------------------------------------------------------------------
  219. -- The "selection-done" signal
  220. -- void user_function (GtkMenuShell *menushell,
  221. -- gpointer user_data) : Run first
  222. -- This signal is emitted when a selection has been completed within a
  223. -- menu shell.
  224. -- menushell : the object which received the signal.
  225. -- user_data : user data set when the signal handler was connected.
  226. feature {} -- External calls
  227. -- GtkMenuShell
  228. -- typedef struct _GtkMenuShell GtkMenuShell;
  229. -- The GtkMenuShell-struct struct contains the following
  230. -- fields. (These fields should be considered read-only. They
  231. -- should never be set by an application.)
  232. -- GList *children; The list of GtkMenuItem objects contained by
  233. -- this GtkMenuShell.
  234. get_children (a_menu_shell: POINTER): POINTER is
  235. external "C struct GtkMenuShell get children use <gtk/gtk.h>"
  236. end
  237. gtk_menu_shell_append (a_menu_shell: POINTER; a_child: POINTER) is
  238. external "C use <gtk/gtk.h>"
  239. end
  240. gtk_menu_shell_prepend (a_menu_shell: POINTER; a_child: POINTER) is
  241. external "C use <gtk/gtk.h>"
  242. end
  243. gtk_menu_shell_insert (a_menu_shell: POINTER; a_child: POINTER; a_position: INTEGER) is
  244. external "C use <gtk/gtk.h>"
  245. end
  246. gtk_menu_shell_deactivate (a_menu_shell: POINTER) is
  247. external "C use <gtk/gtk.h>"
  248. end
  249. gtk_menu_shell_select_item (a_menu_shell: POINTER; a_menu_item: POINTER) is
  250. external "C use <gtk/gtk.h>"
  251. end
  252. gtk_menu_shell_select_first (a_menu_shell: POINTER; search_sensitive: INTEGER) is
  253. external "C use <gtk/gtk.h>"
  254. end
  255. gtk_menu_shell_deselect (a_menu_shell: POINTER) is
  256. external "C use <gtk/gtk.h>"
  257. end
  258. gtk_menu_shell_activate_item (a_menu_shell: POINTER; a_menu_item: POINTER; force_deactivate: INTEGER) is
  259. external "C use <gtk/gtk.h>"
  260. end
  261. gtk_menu_shell_cancel (a_menu_shell: POINTER) is
  262. external "C use <gtk/gtk.h>"
  263. end
  264. gtk_menu_shell_set_take_focus (a_menu_shell: POINTER; take_focus: INTEGER) is
  265. external "C use <gtk/gtk.h>"
  266. end
  267. gtk_menu_shell_get_take_focus (a_menu_shell: POINTER): INTEGER is
  268. external "C use <gtk/gtk.h>"
  269. end
  270. end