/src/wrappers/gtk/library/gtk_dialog.e

http://github.com/tybor/Liberty · Specman e · 735 lines · 207 code · 144 blank · 384 comment · 4 complexity · 8926cbb5049d0e0279a2e1f08f03c094 MD5 · raw file

  1. indexing
  2. description: "GtkDialog -- Create popup windows."
  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. date: "$Date:$"
  19. revision: "$Revision:$"
  20. class GTK_DIALOG
  21. -- Dialog boxes are a convenient way to prompt the user for a small amount of
  22. -- input, e.g. to display a message, ask a question, or anything else that
  23. -- does not require extensive effort on the user's part.
  24. -- GTK+ treats a dialog as a window split vertically. The top section is a
  25. -- GtkVBox, and is where widgets such as a GtkLabel or a GtkEntry should be
  26. -- packed. The bottom area is known as the action_area. This is generally
  27. -- used for packing buttons into the dialog which may perform functions such
  28. -- as cancel, ok, or apply. The two areas are separated by a GtkHSeparator.
  29. -- GtkDialog boxes are created with a call to `make' or
  30. -- gtk_dialog_new_with_buttons(). gtk_dialog_new_with_buttons() is
  31. -- recommended; it allows you to set the dialog title, some convenient flags,
  32. -- and add simple buttons.
  33. -- If 'dialog' is a newly created dialog, the two primary
  34. -- areas of the window can be accessed as
  35. -- GTK_DIALOG(dialog)->vbox and
  36. -- GTK_DIALOG(dialog)->action_area, as can be seen from the
  37. -- example, below.
  38. -- A 'modal' dialog (that is, one which freezes the rest of
  39. -- the application from user input), can be created by
  40. -- calling gtk_window_set_modal() on the dialog. Use the
  41. -- GTK_WINDOW() macro to cast the widget returned from
  42. -- gtk_dialog_new() into a GtkWindow. When using
  43. -- gtk_dialog_new_with_buttons() you can also pass the
  44. -- GTK_DIALOG_MODAL flag to make a dialog modal.
  45. -- If you add buttons to GtkDialog using
  46. -- gtk_dialog_new_with_buttons(), gtk_dialog_add_button(),
  47. -- gtk_dialog_add_buttons(), or
  48. -- gtk_dialog_add_action_widget(), clicking the button will
  49. -- emit a signal called "response" with a response ID that
  50. -- you specified. GTK+ will never assign a meaning to
  51. -- positive response IDs; these are entirely
  52. -- user-defined. But for convenience, you can use the
  53. -- response IDs in the GtkResponseType enumeration (these all
  54. -- have values less than zero). If a dialog receives a delete
  55. -- event, the "response" signal will be emitted with a
  56. -- response ID of GTK_RESPONSE_DELETE_EVENT.
  57. -- If you want to block waiting for a dialog to return before
  58. -- returning control flow to your code, you can call
  59. -- gtk_dialog_run(). This function enters a recursive main
  60. -- loop and waits for the user to respond to the dialog,
  61. -- returning the response ID corresponding to the button the
  62. -- user clicked.
  63. -- For the simple dialog in the following example, in reality
  64. -- you'd probably use GtkMessageDialog to save yourself some
  65. -- effort. But you'd need to create the dialog contents
  66. -- manually if you had more than a simple message in the
  67. -- dialog.
  68. -- Example 1. Simple GtkDialog usage.
  69. -- /* Function to open a dialog box displaying the message provided. */
  70. -- void quick_message (gchar *message) {
  71. -- GtkWidget *dialog, *label;
  72. -- /* Create the widgets */
  73. -- dialog = gtk_dialog_new_with_buttons ("Message",
  74. -- main_application_window, GTK_DIALOG_DESTROY_WITH_PARENT,
  75. -- GTK_STOCK_OK, GTK_RESPONSE_NONE, NULL); -- label =
  76. -- gtk_label_new (message);
  77. -- /* Ensure that the dialog box is destroyed when the user
  78. -- responds. */
  79. -- g_signal_connect_swapped (dialog,
  80. -- "response",
  81. -- G_CALLBACK (gtk_widget_destroy),
  82. -- dialog);
  83. -- /* Add the label, and show everything we've added to the dialog. */
  84. -- gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox),
  85. -- label);
  86. -- gtk_widget_show_all (dialog);
  87. -- }
  88. inherit
  89. GTK_WINDOW
  90. redefine
  91. make,
  92. struct_size
  93. end
  94. CLOSE_SIGNAL_RECEIVER
  95. insert
  96. GTK_DIALOG_EXTERNALS
  97. GTK_DIALOG_STRUCT
  98. GTK_STOCK_ITEMS
  99. -- GtkDialog implements AtkImplementorIface.
  100. creation new, make, from_external_pointer
  101. feature {} -- Creation
  102. make is
  103. -- Creates a new dialog box. Widgets should not be packed
  104. -- into this GtkWindow directly, but into the vbox and
  105. -- action_area.
  106. do
  107. from_external_pointer (gtk_dialog_new)
  108. end
  109. new is
  110. obsolete "use `make' instead."
  111. do
  112. make
  113. end
  114. -- TODO: reimplement gtk_dialog_new_with_buttons () without variadic as with_buttons
  115. -- GtkWidget* gtk_dialog_new_with_buttons (const gchar *title,
  116. -- GtkWindow *parent, GtkDialogFlags flags, const gchar
  117. -- *first_button_text, ...);
  118. -- Creates a new GtkDialog with title title (or NULL for the
  119. -- default title; see gtk_window_set_title()) and transient parent
  120. -- parent (or NULL for none; see
  121. -- gtk_window_set_transient_for()). The flags argument can be used
  122. -- to make the dialog modal (GTK_DIALOG_MODAL) and/or to have it
  123. -- destroyed along with its transient parent
  124. -- (GTK_DIALOG_DESTROY_WITH_PARENT). After flags, button
  125. -- text/response ID pairs should be listed, with a NULL pointer
  126. -- ending the list. Button text can be either a stock ID such as
  127. -- GTK_STOCK_OK, or some arbitrary text. A response ID can be any
  128. -- positive number, or one of the values in the GtkResponseType
  129. -- enumeration. If the user clicks one of these dialog buttons,
  130. -- GtkDialog will emit the "response" signal with the corresponding
  131. -- response ID. If a GtkDialog receives the "delete_event" signal,
  132. -- it will emit "response" with a response ID of
  133. -- GTK_RESPONSE_DELETE_EVENT. However, destroying a dialog does not
  134. -- emit the "response" signal; so be careful relying on "response"
  135. -- when using the GTK_DIALOG_DESTROY_WITH_PARENT flag. Buttons are
  136. -- from left to right, so the first button in the list will be the
  137. -- leftmost button in the dialog.
  138. -- Here's a simple example:
  139. -- GtkWidget *dialog = gtk_dialog_new_with_buttons ("My dialog",
  140. -- main_app_window, GTK_DIALOG_MODAL |
  141. -- GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
  142. -- GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
  143. -- title : Title of the dialog, or NULL
  144. -- parent : Transient parent of the dialog, or NULL
  145. -- flags : from GtkDialogFlags
  146. -- first_button_text : stock ID or text to go in first button, or NULL
  147. -- ... : response ID for first button, then additional buttons, ending with NULL
  148. -- Returns : a new GtkDialog
  149. feature -- Running dialog
  150. run: INTEGER is
  151. -- run the dialog until it emits the response signal, or is
  152. -- destroyed. If the dialog is destroyed during the call to
  153. -- run, it returns gtk_response_none. Otherwise, it returns
  154. -- the response ID from the "response" signal
  155. -- emission. Before entering the recursive main loop, run
  156. -- calls show on the dialog for you. Note that you still need
  157. -- to show any children of the dialog yourself. During run,
  158. -- the default behavior of "delete_event" is disabled; if the
  159. -- dialog receives "delete_event", it will not be destroyed
  160. -- as windows usually are, and run will return
  161. -- gtk_response_delete_event. Also, during run the dialog
  162. -- will be modal. You can force run to return at any time by
  163. -- calling emit_response to emit the "response" signal.
  164. do
  165. Result := gtk_dialog_run (handle)
  166. -- TODO: eiffelize this description and example
  167. -- Blocks in a recursive main loop until the dialog either
  168. -- emits the response signal, or is destroyed. If the dialog
  169. -- is destroyed during the call to gtk_dialog_run(),
  170. -- gtk_dialog_returns GTK_RESPONSE_NONE. Otherwise, it
  171. -- returns the response ID from the "response" signal
  172. -- emission. Before entering the recursive main loop,
  173. -- gtk_dialog_run() calls gtk_widget_show() on the dialog for
  174. -- you. Note that you still need to show any children of the
  175. -- dialog yourself.
  176. -- During gtk_dialog_run(), the default behavior of
  177. -- "delete_event" is disabled; if the dialog receives
  178. -- "delete_event", it will not be destroyed as windows
  179. -- usually are, and gtk_dialog_run() will return
  180. -- GTK_RESPONSE_DELETE_EVENT. Also, during gtk_dialog_run()
  181. -- the dialog will be modal. You can force gtk_dialog_run()
  182. -- to return at any time by calling gtk_dialog_response() to
  183. -- emit the "response" signal. Destroying the dialog during
  184. -- gtk_dialog_run() is a very bad idea, because your post-run
  185. -- code won't know whether the dialog was destroyed or not.
  186. -- After gtk_dialog_run() returns, you are responsible for
  187. -- hiding or destroying the dialog if you wish to do so.
  188. -- Typical usage of this function might be:
  189. -- gint result = gtk_dialog_run (GTK_DIALOG (dialog));
  190. -- switch (result)
  191. -- {
  192. -- case GTK_RESPONSE_ACCEPT:
  193. -- do_application_specific_something ();
  194. -- break;
  195. -- default:
  196. -- do_nothing_since_dialog_was_cancelled ();
  197. -- break;
  198. -- }
  199. -- gtk_widget_destroy (dialog);
  200. -- Note that even though the recursive main loop gives the
  201. -- effect of a modal dialog (it prevents the user from
  202. -- interacting with other windows in the same window group
  203. -- while the dialog is run), callbacks such as timeouts, IO
  204. -- channel watches, DND drops, etc, will be triggered during a
  205. -- gtk_dialog_run() call.
  206. -- dialog : a GtkDialog
  207. -- Returns : response ID
  208. end
  209. emit_response (a_response_id: INTEGER) is
  210. -- Emits the "response" signal with the given response
  211. -- ID. Used to indicate that the user has responded to the
  212. -- dialog in some way; typically either you or `run' be
  213. -- monitoring the "response" signal and take appropriate
  214. -- action.
  215. do
  216. gtk_dialog_response (handle, a_response_id)
  217. end
  218. add_button (a_button_text: STRING; a_response_id: INTEGER) is
  219. -- Adds a button with the given text (or a stock button, if
  220. -- `a_button_text' is a stock ID) and sets things up so that
  221. -- clicking the button will emit the "response" signal with
  222. -- the given `a_response_id'. The button is appended to the
  223. -- end of the dialog's action area. The button widget is
  224. -- returned, but usually you don't need it.
  225. -- `a_button_text': text of button, or stock ID
  226. -- `a_response_id' : response ID for the button
  227. -- TODO: store the button widget that was added somewhere
  228. local unused_button_ptr: POINTER
  229. do
  230. unused_button_ptr := gtk_dialog_add_button (handle, a_button_text.to_external, a_response_id)
  231. end
  232. add_buttons (some_buttons: COLLECTION[TUPLE[STRING, INTEGER]]) is
  233. -- Adds more buttons, calling add_button repeatedly on each tupla of `some_buttons'.
  234. require
  235. buttons_not_void: some_buttons /= Void
  236. -- valid_buttons: some_buttons.for_all (agent (i:TUPLE[STRING, INTEGER]) i.item_1 /= Void
  237. local
  238. iterator: ITERATOR[TUPLE[STRING, INTEGER]];
  239. a_text: STRING; an_id: INTEGER
  240. --a_button: GTK_BUTTON
  241. do
  242. iterator:=some_buttons.get_new_iterator;
  243. from iterator.start until iterator.is_off
  244. loop
  245. -- a_text:=iterator.item.item_1
  246. -- an_id:=iterator.item.item_2 add_button (a_text, an_id)
  247. add_button (iterator.item.item_1, iterator.item.item_2)
  248. iterator.next
  249. end
  250. end
  251. add_action_widget (a_widget: GTK_WIDGET; a_response_id: INTEGER) is
  252. -- Adds an activatable widget to the action area of a
  253. -- GtkDialog, connecting a signal handler that will emit the
  254. -- "response" signal on the dialog when the widget is
  255. -- activated. The widget is appended to the end of the
  256. -- dialog's action area. If you want to add a non-activatable
  257. -- widget, simply pack it into the action_area field of the
  258. -- GtkDialog struct.
  259. -- `a_widget': an activatable widget
  260. -- `a_response_id' : response ID for child
  261. require valid_widget: a_widget /= Void
  262. do
  263. gtk_dialog_add_action_widget (handle, a_widget.handle, a_response_id)
  264. end
  265. feature -- Separator
  266. has_separator: BOOLEAN is
  267. -- Has the dialog a separator?
  268. do
  269. Result := gtk_dialog_get_has_separator (handle).to_boolean
  270. end
  271. set_has_separator is
  272. -- Gives the dialog a separator above the buttons.
  273. do
  274. gtk_dialog_set_has_separator (handle, 1)
  275. ensure has_separator_set: has_separator = True
  276. end
  277. unset_has_separator is
  278. -- Remove the separator above the buttons.
  279. do
  280. gtk_dialog_set_has_separator (handle, 0)
  281. ensure has_separator_unset: has_separator = False
  282. end
  283. feature -- default response
  284. set_default_response (a_response_id: INTEGER) is
  285. -- Sets the last widget in the dialog's action area with the
  286. -- given `a_response_id' as the default widget for the
  287. -- dialog. Pressing "Enter" normally activates the default
  288. -- widget.
  289. do
  290. gtk_dialog_set_default_response (handle, a_response_id)
  291. end
  292. -- gtk_dialog_set_response_sensitive ()
  293. -- void gtk_dialog_set_response_sensitive
  294. -- (GtkDialog *dialog,
  295. -- gint response_id,
  296. -- gboolean setting);
  297. -- Calls gtk_widget_set_sensitive (widget, setting) for each widget in
  298. -- the dialog's action area with the given response_id. A convenient way to
  299. -- sensitize/desensitize dialog buttons.
  300. -- dialog : a GtkDialog
  301. -- response_id : a response ID
  302. -- setting : TRUE for sensitive
  303. -- gtk_dialog_get_response_for_widget ()
  304. -- gint gtk_dialog_get_response_for_widget
  305. -- (GtkDialog *dialog,
  306. -- GtkWidget *widget);
  307. -- Gets the response id of a widget in the action area of a dialog.
  308. -- dialog : a GtkDialog
  309. -- widget : a widget in the action area of dialog
  310. -- Returns : the response id of widget, or GTK_RESPONSE_NONE if widget doesn't have a response id set.
  311. -- Since 2.8
  312. -- gtk_alternative_dialog_button_order ()
  313. -- gboolean gtk_alternative_dialog_button_order
  314. -- (GdkScreen *screen);
  315. -- Returns TRUE if dialogs are expected to use an alternative button order on the screen screen. See gtk_dialog_set_alternative_button_order() for more details about alternative button order.
  316. -- If you need to use this function, you should probably connect to the ::notify:gtk-alternative-button-order signal on the GtkSettings object associated to screen, in order to be notified if the button order setting changes.
  317. -- screen : a GdkScreen, or NULL to use the default screen
  318. -- Returns : Whether the alternative button order should be used
  319. -- Since 2.6
  320. -- gtk_dialog_set_alternative_button_order ()
  321. -- void gtk_dialog_set_alternative_button_order
  322. -- (GtkDialog *dialog,
  323. -- gint first_response_id,
  324. -- ...);
  325. -- Sets an alternative button order. If the gtk-alternative-button-order setting is set to TRUE, the dialog buttons are reordered according to the order of the response ids passed to this function.
  326. -- By default, GTK+ dialogs use the button order advocated by the Gnome Human Interface Guidelines with the affirmative button at the far right, and the cancel button left of it. But the builtin GTK+ dialogs and GtkMessageDialogs do provide an alternative button order, which is more suitable on some platforms, e.g. Windows.
  327. -- Use this function after adding all the buttons to your dialog, as the following example shows:
  328. -- cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
  329. -- GTK_STOCK_CANCEL,
  330. -- GTK_RESPONSE_CANCEL);
  331. -- ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
  332. -- GTK_STOCK_OK,
  333. -- GTK_RESPONSE_OK);
  334. -- gtk_widget_grab_default (ok_button);
  335. -- help_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
  336. -- GTK_STOCK_HELP,
  337. -- GTK_RESPONSE_HELP);
  338. -- gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
  339. -- GTK_RESPONSE_OK,
  340. -- GTK_RESPONSE_CANCEL,
  341. -- GTK_RESPONSE_HELP,
  342. -- -1);
  343. -- dialog : a GtkDialog
  344. -- first_response_id : a response id used by one dialog's buttons
  345. -- ... : a list of more response ids of dialog's buttons, terminated by -1
  346. -- Since 2.6
  347. -- gtk_dialog_set_alternative_button_order_from_array ()
  348. -- void gtk_dialog_set_alternative_button_order_from_array
  349. -- (GtkDialog *dialog,
  350. -- gint n_params,
  351. -- gint *new_order);
  352. -- Sets an alternative button order. If the gtk-alternative-button-order setting is set to TRUE, the dialog buttons are reordered according to the order of the response ids in new_order.
  353. -- See gtk_dialog_set_alternative_button_order() for more information.
  354. -- This function is for use by language bindings.
  355. -- dialog : a GtkDialog
  356. -- n_params : the number of response ids in new_order
  357. -- new_order : an array of response ids of dialog's buttons
  358. -- Since 2.6
  359. -- Property Details
  360. -- The "has-separator" property
  361. -- "has-separator" gboolean : Read / Write
  362. -- The dialog has a separator bar above its buttons.
  363. -- Default value: TRUE
  364. -- Style Property Details
  365. -- The "action-area-border" style property
  366. -- "action-area-border" gint : Read
  367. -- Width of border around the button area at the bottom of the dialog.
  368. -- Allowed values: >= 0
  369. -- Default value: 5
  370. -- The "button-spacing" style property
  371. -- "button-spacing" gint : Read
  372. -- Spacing between buttons.
  373. -- Allowed values: >= 0
  374. -- Default value: 10
  375. -- The "content-area-border" style property
  376. -- "content-area-border" gint : Read
  377. -- Width of border around the main dialog area.
  378. -- Allowed values: >= 0
  379. -- Default value: 2
  380. -- Signal Details
  381. -- The "close" signal
  382. -- void user_function (GtkDialog *dialog,
  383. -- gpointer user_data) : Run last / Action
  384. -- dialog : the object which received the signal.
  385. -- user_data : user data set when the signal handler was connected.
  386. -- The "response" signal
  387. -- void user_function (GtkDialog *dialog,
  388. -- gint arg1,
  389. -- gpointer user_data) : Run last
  390. -- Emitted when an action widget is clicked, the dialog receives a
  391. -- delete event, or the application programmer calls gtk_dialog_response().
  392. -- On a delete event, the response ID is GTK_RESPONSE_NONE. Otherwise, it
  393. -- depends on which action widget was clicked.
  394. -- dialog : the object which received the signal.
  395. -- arg1 : the response ID
  396. -- user_data : user data set when the signal handler was connected.
  397. -- See Also
  398. -- GtkVBox
  399. -- Pack widgets vertically.
  400. -- GtkWindow
  401. -- Alter the properties of your dialog box.
  402. -- GtkButton
  403. -- Add them to the action_area to get a response from the user.
  404. feature -- From ewg implementation
  405. feature -- Adding stock buttons
  406. add_reject_button (a_label: STRING) is
  407. -- Add a "reject" button with a_label. Stock response is used
  408. require label_not_void: a_label /= Void
  409. local a_widget: POINTER
  410. do
  411. a_widget := gtk_dialog_add_button (handle, a_label.to_external, gtk_response_reject)
  412. end
  413. add_accept_button (a_label: STRING) is
  414. -- Add a "Accept" button. Stock item and response are used
  415. require label_not_void: a_label /= Void
  416. local a_widget: POINTER
  417. do
  418. a_widget := gtk_dialog_add_button (handle, a_label.to_external, gtk_response_accept)
  419. end
  420. add_ok_cancel_buttons is
  421. -- Add both 'Ok' and 'Cancel' buttons
  422. do
  423. add_ok_button
  424. add_cancel_button
  425. end
  426. add_ok_button is
  427. -- Add a "Ok" button. Stock item and response are used
  428. local a_widget: POINTER
  429. do
  430. a_widget := gtk_dialog_add_button (handle, gtk_stock_ok.to_external, gtk_response_ok)
  431. end
  432. add_cancel_button is
  433. -- Add a "Cancel" button. Stock item and response are used
  434. local a_widget: POINTER
  435. do
  436. a_widget := gtk_dialog_add_button (handle, gtk_stock_cancel.to_external, gtk_response_cancel)
  437. end
  438. add_close_button is
  439. -- Add a "Close" button. Stock item and response are used
  440. local a_widget: POINTER
  441. do
  442. a_widget := gtk_dialog_add_button (handle, gtk_stock_close.to_external, gtk_response_close)
  443. end
  444. add_yes_no_buttons is
  445. -- Add both 'Yes' and 'No' buttons
  446. do
  447. add_yes_button
  448. add_no_button
  449. end
  450. add_yes_button is
  451. -- Add a "Yes" button. Stock item and response are used
  452. local a_widget: POINTER
  453. do
  454. a_widget := gtk_dialog_add_button (handle, gtk_stock_yes.to_external, gtk_response_yes)
  455. end
  456. add_no_button is
  457. -- Add a "No" button. Stock item and response are used
  458. local a_widget: POINTER
  459. do
  460. a_widget := gtk_dialog_add_button (handle, gtk_stock_no.to_external, gtk_response_no)
  461. end
  462. add_apply_button is
  463. -- Add a "Apply" button. Stock item and response are used
  464. local a_widget: POINTER
  465. do
  466. a_widget := gtk_dialog_add_button (handle, gtk_stock_apply.to_external, gtk_response_apply)
  467. end
  468. add_help_button is
  469. -- Add a "Help" button. Stock item and response are used
  470. local a_widget: POINTER
  471. do
  472. a_widget := gtk_dialog_add_button (handle, gtk_stock_help.to_external, gtk_response_help)
  473. end
  474. -- TODO: wrap gtk_dialog_set_response_sensitive
  475. -- TODO: wrap gtk_alternative_dialog_button_order
  476. -- TODO: wrap gtk_dialog_set_alternative_button_order
  477. feature -- properties
  478. action_area_border: INTEGER is
  479. -- Width of border around the button area at the bottom of
  480. -- the dialog.
  481. local value: G_VALUE
  482. do
  483. create value.make_integer
  484. g_object_get_property (handle,action_area_border_property_name.to_external,value.handle)
  485. Result := value.integer
  486. ensure positive_result: Result >= 0
  487. end
  488. button_spacing: INTEGER is
  489. -- Spacing between buttons.
  490. local value: G_VALUE
  491. do
  492. create value.make_integer
  493. g_object_get_property (handle, button_spacing_property_name.to_external,value.handle)
  494. Result := value.integer
  495. ensure positive_result: Result >= 0
  496. end
  497. content_area_border: INTEGER is
  498. -- Width of border around the main dialog area.
  499. local value: G_VALUE
  500. do
  501. create value.make_integer
  502. g_object_get_property(handle, content_area_border_property_name.to_external,value.handle)
  503. Result:=value.integer
  504. ensure positive_result: Result >= 0
  505. end
  506. feature -- Dialog's parts
  507. vbox: GTK_VBOX is
  508. -- main part of the dialog box
  509. local
  510. retriever: G_OBJECT_FACTORY [GTK_VBOX]
  511. do
  512. Result := retriever.existant_wrapper (get_vbox (handle))
  513. if Result=Void then create Result.from_external_pointer (get_vbox(handle)) end
  514. ensure
  515. result_not_void: Result /= Void
  516. end
  517. action_area: GTK_HBOX is
  518. -- bottom area of the dialog. Generally used for packing
  519. -- buttons into the dialog which may perform functions such
  520. -- as cancel, ok, or apply
  521. local
  522. retriever: G_OBJECT_EXPANDED_FACTORY [GTK_HBOX]
  523. do
  524. Result := retriever.existant_wrapper (get_action_area (handle))
  525. if Result=Void then create Result.from_external_pointer (get_action_area(handle)) end
  526. ensure result_bot_void: Result /= Void
  527. end
  528. -- feature -- The "close" signal
  529. -- close_signal_name: STRING is "close"
  530. -- enable_on_close is
  531. -- -- Connects "close" signal to `on_close' feature.
  532. -- do
  533. -- connect (Current, close_signal_name, $on_close)
  534. -- end
  535. -- on_close is
  536. -- -- Built-in close signal handler; empty by design; redefine it.
  537. -- do
  538. -- end
  539. -- connect_agent_to_close_signal (a_procedure: PROCEDURE [ANY, TUPLE[GTK_DIALOG]]) is
  540. -- require
  541. -- valid_procedure: a_procedure /= Void
  542. -- wrapper_is_stored: is_eiffel_wrapper_stored
  543. -- local close_callback: CLOSE_CALLBACK
  544. -- do
  545. -- create close_callback.make
  546. -- close_callback.connect (Current, a_procedure)
  547. -- end
  548. -- content_area_border: INTEGER is
  549. -- -- Width of border around the main dialog area.
  550. -- local
  551. -- value: G_VALUE
  552. -- do
  553. -- create value.make_new_shared
  554. -- g_object_get_property (item,
  555. -- content_area_border_property_name,
  556. -- value.item)
  557. -- Result := value.integer
  558. -- ensure
  559. -- positive_result: Result >= 0
  560. -- end
  561. -- feature -- TODO: close signal
  562. -- -- connect_close_signal_receiver (a_receiver: GTK_CLOSE_SIGNAL_RECEIVER) is
  563. -- -- Connect `a_receiver' to the current widget
  564. -- --require
  565. -- -- a_receiver_not_void: a_receiver /= Void
  566. -- -- do
  567. -- -- connect_signal_receiver (a_receiver)
  568. -- --end
  569. -- feature -- TODO: response signals
  570. -- -- connect_response_signal_receiver (a_receiver: GTK_RESPONSE_SIGNAL_RECEIVER) is
  571. -- -- Connect `a_receiver' to the current widget
  572. -- -- require
  573. -- -- a_receiver_not_void: a_receiver /= Void
  574. -- -- do
  575. -- -- connect_signal_receiver (a_receiver)
  576. -- -- end
  577. -- feature {} -- Signals' names
  578. -- action_area_border_property_name: STRING is "action-area-border"
  579. -- button_spacing_property_name: STRING is "button-spacing"
  580. -- content_area_border_property_name: STRING is "content-area-border"
  581. -- end
  582. feature {} -- property names strings
  583. action_area_border_property_name: STRING is "action-area-border"
  584. button_spacing_property_name: STRING is "button-spacing"
  585. content_area_border_property_name: STRING is "content-area-border"
  586. feature -- size
  587. struct_size: INTEGER is
  588. external "C inline use <gtk/gtk.h>"
  589. alias "sizeof(GtkDialog)"
  590. end
  591. end