/src/wrappers/gtk/library/gtk_assistant.e

http://github.com/tybor/Liberty · Specman e · 470 lines · 181 code · 112 blank · 177 comment · 4 complexity · f77144e44acb78a6ce42385284169fbe MD5 · raw file

  1. indexing
  2. description: "GtkAssistant -- A widget used to guide users through multi-step."
  3. copyright: "[
  4. Copyright (C) 2006 Paolo Redaelli, 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 hopeOA 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_ASSISTANT
  19. -- A GtkAssistant is a widget used to represent a generally complex
  20. -- operation splitted in several steps, guiding the user through
  21. -- its pages and controlling the page flow to collect the necessary
  22. -- data.
  23. inherit
  24. GTK_WINDOW
  25. undefine
  26. struct_size
  27. redefine
  28. make
  29. end
  30. -- GtkAssistant implements AtkImplementorIface.
  31. CANCEL_SIGNAL_RECEIVER
  32. insert
  33. G_OBJECT_FACTORY [GTK_WIDGET]
  34. GTK_ASSISTANT_EXTERNALS
  35. creation make, from_external_pointer
  36. feature {} -- Creation
  37. make is
  38. -- Creates a new GtkAssistant.
  39. do
  40. from_external_pointer(gtk_assistant_new)
  41. end
  42. feature
  43. current_page: INTEGER is
  44. -- The index (starting from 0) of the current page in the
  45. -- assistant, if the assistant has no pages, it will be -1.
  46. do
  47. Result:=gtk_assistant_get_current_page (handle)
  48. ensure valid: Result >= -1
  49. end
  50. set_current_page (a_page_num: INTEGER) is
  51. -- Switches the page to `a_page_num'. Note that this will
  52. -- only be necessary in custom buttons, as the assistant flow
  53. -- can be set with `set_forward_page_func'.
  54. -- `a_page_num': index of the page to switch to, starting
  55. -- from 0. If negative, the last page will be used. If
  56. -- greater than the number of pages in the assistant, nothing
  57. -- will be done.
  58. do
  59. gtk_assistant_set_current_page (handle, a_page_num)
  60. end
  61. pages_n: INTEGER is
  62. -- The number of pages in the assistant.
  63. do
  64. Result:=gtk_assistant_get_n_pages(handle)
  65. end
  66. item (a_page_num: INTEGER): GTK_WIDGET is
  67. -- The child widget contained in page number `a_page_num';
  68. -- set it to -1 to get the last page; Result is Void
  69. -- `a_page_num' is out of bounds.
  70. local ptr: POINTER
  71. do
  72. ptr:=gtk_assistant_get_nth_page(handle, a_page_num)
  73. if ptr.is_not_null then
  74. Result:=wrapper(ptr)
  75. if Result=Void then
  76. debug
  77. print("Warning: GTK_ASSISTANT.item received a %
  78. %GtkWidget pointer of an unwrapped widget. %
  79. %Since we don't know which the correct effective wrapper %
  80. %class feature Result will be Void.%N")
  81. end
  82. end
  83. end
  84. end
  85. last_inserted_page: INTEGER
  86. -- The index (starting at 0) of the inserted page
  87. prepend (a_page: GTK_WIDGET) is
  88. -- Prepends `a_page' to the assistant. `last_inserted_page'
  89. -- will be updated.
  90. require page_not_void: a_page /= Void
  91. do
  92. last_inserted_page:=gtk_assistant_prepend_page(handle, a_page.handle)
  93. end
  94. append (a_page: GTK_WIDGET) is
  95. -- Appends `a_page' to the assistant. `last_inserted_page'
  96. -- will be updated.
  97. require page_not_void: a_page /= Void
  98. do
  99. last_inserted_page:=gtk_assistant_append_page(handle,a_page.handle)
  100. end
  101. insert_page (a_page: GTK_WIDGET; a_position: INTEGER) is
  102. -- Inserts `a_page' in the assistant at `a_position',
  103. -- starting at 0; -1 to append the page to the assistant.
  104. require page_not_void: a_page /= Void
  105. do
  106. last_inserted_page:=gtk_assistant_insert_page(handle, a_page.handle, a_position)
  107. end
  108. -- GtkAssistantPageFunc ()
  109. -- gint (*GtkAssistantPageFunc) (gint current_page, gpointer data);
  110. -- A function used by gtk_assistant_set_forward_page_func() to know
  111. -- which is the next page given a current one. It's called both for
  112. -- computing the next page when the user presses the "forward"
  113. -- button and for handling the behavior of the "last" button.
  114. -- current_page : The page number used to calculate the next page.
  115. -- data : user data. Returns : The next page number.
  116. -- TODO: set_forward_page (an_agent)
  117. -- void gtk_assistant_set_forward_page_func (GtkAssistant
  118. -- *assistant, GtkAssistantPageFunc page_func, gpointer data,
  119. -- GDestroyNotify destroy);
  120. -- Sets the page forwarding function to be page_func, this function
  121. -- will be used to determine what will be the next page when the
  122. -- user presses the forward button. Setting page_func to NULL will
  123. -- make the assistant to use the default forward function, which
  124. -- just goes to the next visible page.
  125. -- assistant : a GtkAssistant
  126. -- page_func : the GtkAssistantPageFunc, or NULL to use the default one
  127. -- data : user data for page_func
  128. -- destroy : destroy notifier for data
  129. set_page_type (a_page: GTK_WIDGET; a_type: INTEGER) is
  130. -- Sets the page type for `a_page'. The page type determines the
  131. -- page behavior in the assistant.
  132. require
  133. page_not_void: a_page /= Void
  134. valid_page_type: is_valid_gtk_page_type(a_type)
  135. do
  136. gtk_assistant_set_page_type (handle, a_page.handle, a_type)
  137. end
  138. page_type (a_page: GTK_WIDGET): INTEGER is
  139. -- The type of `a_page'.
  140. require page_not_void: a_page /= Void
  141. do
  142. Result := gtk_assistant_get_page_type (handle, a_page.handle)
  143. ensure valid_page_type: is_valid_gtk_page_type(Result)
  144. end
  145. set_page_title (a_page: GTK_WIDGET; a_title: STRING) is
  146. -- Sets `a_title' for `a_page'. The title is displayed in the
  147. -- header area of the assistant when page is the current
  148. -- page.
  149. require
  150. page_not_void: a_page /= Void
  151. title_not_void: a_title/=Void
  152. do
  153. gtk_assistant_set_page_title(handle, a_page.handle, a_title.to_external)
  154. end
  155. page_title (a_page: GTK_WIDGET): STRING is
  156. -- the title for `a_page'.
  157. require page_not_void: a_page /= Void
  158. do
  159. create {CONST_STRING} Result.from_external
  160. (gtk_assistant_get_page_title(handle, a_page.handle))
  161. end
  162. set_page_header_image (a_page: GTK_WIDGET; a_pixbuf: GDK_PIXBUF) is
  163. -- Sets a header image for page. This image is displayed in
  164. -- the header area of the assistant when page is the current
  165. -- page.
  166. require
  167. page_not_void: a_page /= Void
  168. pixbuf_not_void: a_pixbuf /= Void
  169. do
  170. gtk_assistant_set_page_header_image(handle, a_page.handle, a_pixbuf.handle)
  171. end
  172. page_header_image (a_page: GTK_WIDGET): GDK_PIXBUF is
  173. -- The header image for page; Void if there's no header image
  174. -- for the page.
  175. local factory: G_OBJECT_EXPANDED_FACTORY[GDK_PIXBUF]
  176. do
  177. Result := factory.wrapper_or_void
  178. (gtk_assistant_get_page_header_image
  179. (handle, a_page.handle))
  180. end
  181. set_page_side_image (a_page: GTK_WIDGET; a_pixbuf: GDK_PIXBUF) is
  182. -- Sets a header image for `a_page'. This image is displayed
  183. -- in the side area of the assistant when page is the current
  184. -- page.
  185. require
  186. page_not_void: a_page /= Void
  187. pixbuf_not_void: a_pixbuf /= Void
  188. do
  189. gtk_assistant_set_page_side_image(handle, a_page.handle, a_pixbuf.handle)
  190. end
  191. page_side_image (a_page: GTK_WIDGET): GDK_PIXBUF is
  192. -- The side image for page, or Void if there's no side image
  193. -- for the page.
  194. require page_not_void: a_page /= Void
  195. local factory: G_OBJECT_EXPANDED_FACTORY[GDK_PIXBUF]
  196. do
  197. Result:=factory.wrapper_or_void(gtk_assistant_get_page_side_image(handle, a_page.handle))
  198. end
  199. set_page_complete (a_page: GTK_WIDGET; is_complete: BOOLEAN) is
  200. -- Sets whether page contents are complete. This will make
  201. -- assistant update the buttons state to be able to continue
  202. -- the task.
  203. require page_not_void: a_page /= Void
  204. do
  205. gtk_assistant_set_page_complete (handle, a_page.handle, is_complete.to_integer)
  206. end
  207. is_page_complete (a_page: GTK_WIDGET): BOOLEAN is
  208. -- Is `a_page' complete?
  209. require page_not_void: a_page /= Void
  210. do
  211. Result:=(gtk_assistant_get_page_complete (handle,a_page.handle)).to_boolean
  212. end
  213. add_action_widget (a_child: GTK_WIDGET) is
  214. -- Adds `a_child' to the action area of a GtkAssistant.
  215. require child_not_void: a_child /= Void
  216. do
  217. gtk_assistant_add_action_widget (handle, a_child.handle)
  218. end
  219. remove_action_widget (a_child: GTK_WIDGET) is
  220. -- Removes `a_child' from the action area of a GtkAssistant.
  221. require child_not_void: a_child /= Void
  222. do
  223. gtk_assistant_remove_action_widget(handle, a_child.handle)
  224. end
  225. update_buttons_state is
  226. -- Forces assistant to recompute the buttons state. GTK+
  227. -- automatically takes care of this in most situations,
  228. -- e.g. when the user goes to a different page, or when the
  229. -- visibility or completeness of a page changes. One
  230. -- situation where it can be necessary to call this function
  231. -- is when changing a value on the current page affects the
  232. -- future page flow of the assistant.
  233. do
  234. gtk_assistant_update_buttons_state(handle)
  235. end
  236. feature -- Child Properties
  237. -- "complete" gboolean : Read / Write
  238. -- "header-image" GdkPixbuf : Read / Write
  239. -- "page-type" GtkAssistantPageType : Read / Write
  240. -- "sidebar-image" GdkPixbuf : Read / Write
  241. -- "title" gchararray : Read / Write
  242. -- Child Property Details
  243. -- The "complete" child property
  244. -- "complete" gboolean : Read / Write
  245. -- Setting the "complete" child property to TRUE marks a page as complete
  246. -- (i.e.: all the required fields are filled out). GTK+ uses this information
  247. -- to control the sensitivity of the navigation buttons.
  248. -- Default value: FALSE
  249. -- Since 2.10
  250. -- --------------------------------------------------------------------------
  251. -- The "header-image" child property
  252. -- "header-image" GdkPixbuf : Read / Write
  253. -- The image that is displayed next to the page.
  254. -- Set this to NULL to make the sidebar disappear.
  255. -- Since 2.10
  256. -- --------------------------------------------------------------------------
  257. -- The "page-type" child property
  258. -- "page-type" GtkAssistantPageType : Read / Write
  259. -- The type of the assistant page.
  260. -- Default value: GTK_ASSISTANT_PAGE_CONTENT
  261. -- Since 2.10
  262. -- --------------------------------------------------------------------------
  263. -- The "sidebar-image" child property
  264. -- "sidebar-image" GdkPixbuf : Read / Write
  265. -- Sidebar image for the assistant page.
  266. -- --------------------------------------------------------------------------
  267. -- The "title" child property
  268. -- "title" gchararray : Read / Write
  269. -- The title that is displayed in the page header.
  270. -- If title and header-image are both NULL, no header is displayed.
  271. -- Default value: NULL
  272. -- Since 2.10
  273. -- Style Properties
  274. -- "content-padding" gint : Read
  275. -- "header-padding" gint : Read
  276. -- Style Property Details
  277. -- The "content-padding" style property
  278. -- "content-padding" gint : Read
  279. -- Number of pixels around the content pages.
  280. -- Allowed values: >= 0
  281. -- Default value: 1
  282. -- --------------------------------------------------------------------------
  283. -- The "header-padding" style property
  284. -- "header-padding" gint : Read
  285. -- Number of pixels around the header.
  286. -- Allowed values: >= 0
  287. -- Default value: 6
  288. -- Signals
  289. -- "cancel" void user_function (GtkAssistant *assistant,
  290. -- gpointer user_data) : Run last
  291. -- "close" void user_function (GtkAssistant *assistant,
  292. -- gpointer user_data) : Run last
  293. -- "prepare" void user_function (GtkAssistant *assistant,
  294. -- GtkWidget *page,
  295. -- gpointer user_data) : Run last
  296. -- Signal Details
  297. feature -- The "apply" signal
  298. apply_signal_name: STRING is "apply"
  299. enable_on_apply is
  300. -- Connects "apply" signal to `on_apply' feature.
  301. do
  302. connect (Current, apply_signal_name, $on_apply)
  303. end
  304. on_apply is
  305. -- Built-in activate signal handler; empty by design; redefine it.
  306. -- The ::apply signal is emitted when the apply button is
  307. -- clicked. The default behavior of the GtkAssistant is to
  308. -- switch to the page after the current page, unless the
  309. -- current page is the last one.
  310. -- A handler for the ::apply signal should carry out the
  311. -- actions for which the wizard has collected data. If the
  312. -- action takes a long time to complete, you might consider
  313. -- to put a page of type GTK_ASSISTANT_PAGE_PROGRESS after
  314. -- the confirmation page and handle this operation within the
  315. -- ::prepare signal of the progress page.
  316. do
  317. end
  318. connect_agent_to_apply_signal (a_procedure: PROCEDURE [ANY, TUPLE[GTK_ASSISTANT]]) is
  319. require
  320. valid_procedure: a_procedure /= Void
  321. local
  322. apply_callback: APPLY_CALLBACK
  323. do
  324. create apply_callback.make
  325. apply_callback.connect (Current, a_procedure)
  326. end
  327. feature -- The "cancel" signal
  328. -- void user_function (GtkAssistant *assistant, gpointer user_data)
  329. -- : Run last
  330. -- The ::cancel signal is emitted when then the cancel button is
  331. -- clicked.
  332. -- assistant : the GtkAssistant
  333. -- user_data : user data set when the signal handler was connected.
  334. -- Since 2.10
  335. -- --------------------------------------------------------------------------
  336. feature -- The "close" signal
  337. -- void user_function (GtkAssistant *assistant, gpointer user_data)
  338. -- : Run last
  339. -- The ::close signal is emitted either when the close button of a
  340. -- summary page is clicked, or when the apply button in the last
  341. -- page in the flow (of type GTK_ASSISTANT_PAGE_CONFIRM) is
  342. -- clicked.
  343. -- assistant : the GtkAssistant
  344. -- user_data : user data set when the signal handler was connected.
  345. -- Since 2.10
  346. -- --------------------------------------------------------------------------
  347. feature -- The "prepare" signal
  348. -- void user_function (GtkAssistant *assistant, GtkWidget *page,
  349. -- gpointer user_data) : Run last
  350. -- The ::prepared signal is emitted when a new page is set as the
  351. -- assistant's current page, before making the new page visible. A
  352. -- handler for this signal can do any preparation which are
  353. -- necessary before showing page.
  354. -- assistant : the GtkAssistant
  355. -- page : the current page
  356. -- user_data : user data set when the signal handler was connected.
  357. -- Since 2.10
  358. end -- class GTK_ASSISTANT