/src/wrappers/gtk/library/gtk_print_operation.e

http://github.com/tybor/Liberty · Specman e · 1059 lines · 164 code · 71 blank · 824 comment · 5 complexity · 39dbfb4de6893e254835d71582c897a6 MD5 · raw file

  1. indexing
  2. description: "GtkPrintOperation: High-level Printing API."
  3. copyright: "[
  4. Copyright (C) 2007 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. wrapped_version: "2.10.6"
  19. class GTK_PRINT_OPERATION
  20. -- GTK_PRINT_OPERATION is the high-level, portable printing API. It
  21. -- looks a bit different than other GTK+ dialogs such as the
  22. -- GtkFileChooser, since some platforms don't expose enough
  23. -- infrastructure to implement a good print dialog. On such
  24. -- platforms, GtkPrintOperation uses the native print dialog. On
  25. -- platforms which do not provide a native print dialog, GTK+ uses
  26. -- its own, see GtkPrintUnixDialog.
  27. -- The typical way to use the high-level printing API is to create
  28. -- a GtkPrintOperation object with `make' when the user selects to
  29. -- print. Then you set some properties on it, e.g. the page size,
  30. -- any GtkPrintSettings from previous print operations, the number
  31. -- of pages, the current page, etc.
  32. -- Then you start the print operation by calling `run'. It will
  33. -- then show a dialog, let the user select a printer and options.
  34. -- When the user finished the dialog various signals will be
  35. -- emitted on the GtkPrintOperation, the main one being
  36. -- ::draw-page, which you are supposed to catch and render the page
  37. -- on the provided GtkPrintContext using Cairo.
  38. -- TODO: Eiffellize this C Example: The high-level printing API
  39. -- static GtkPrintSettings *settings = NULL;
  40. --
  41. -- static void
  42. -- do_print (void)
  43. -- {
  44. -- GtkPrintOperation *print;
  45. -- GtkPrintOperationResult res;
  46. --
  47. -- print = gtk_print_operation_new ();
  48. --
  49. -- if (settings != NULL)
  50. -- gtk_print_operation_set_print_settings (print, settings);
  51. --
  52. -- g_signal_connect (print, "begin_print", G_CALLBACK (begin_print), NULL);
  53. -- g_signal_connect (print, "draw_page", G_CALLBACK (draw_page), NULL);
  54. --
  55. -- res = gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
  56. -- GTK_WINDOW (main_window), NULL);
  57. --
  58. -- if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
  59. -- {
  60. -- if (settings != NULL)
  61. -- g_object_unref (settings);
  62. -- settings = g_object_ref (gtk_print_operation_get_print_settings (print));
  63. -- }
  64. --
  65. -- g_object_unref (print);
  66. -- }
  67. -- By default GtkPrintOperation uses an external application to do print
  68. -- preview. To implement a custom print preview, an application must connect
  69. -- to the preview signal. The functions
  70. -- GTK_PRINT_OPERATION_PRINT_preview_render_page(),
  71. -- gtk_print_operation_preview_end_preview() and
  72. -- gtk_print_operation_preview_is_selected() are useful when implementing a
  73. -- print preview.
  74. -- Printing support was added in GTK+ 2.10.
  75. inherit
  76. G_OBJECT
  77. GTK_PRINT_OPERATION_PREVIEW
  78. redefine
  79. struct_size
  80. end
  81. insert
  82. GTK_PRINT_OPERATION_EXTERNALS
  83. GTK_PRINT_OPERATION_ACTIONS
  84. G_OBJECT_FACTORY[GTK_PAGE_SETUP]
  85. -- SHARED_G_ERROR
  86. GTK -- to get error
  87. creation make, from_external_pointer
  88. feature {} -- Creation
  89. make is
  90. -- Creates a new GtkPrintOperation.
  91. do
  92. from_external_pointer(gtk_print_operation_new)
  93. end
  94. feature -- Setters
  95. set_allow_async (a_setting: BOOLEAN) is
  96. -- Sets whether the `run' feature may return before the print
  97. -- operation is completed. Note that some platforms may not
  98. -- allow asynchronous operation. Make `a_setting' True to
  99. -- allow asynchronous operation.
  100. do
  101. gtk_print_operation_set_allow_async(handle, a_setting.to_integer)
  102. ensure set: a_setting = async_allowed
  103. end
  104. set_default_page_setup (a_default_page_setup: GTK_PAGE_SETUP) is
  105. -- Makes `a_default_page_setup' the default page setup.
  106. -- This page setup will be used by gtk_print_operation_run(),
  107. -- but it can be overridden on a per-page basis by connecting
  108. -- to the ::request-page-setup signal.
  109. -- `a_default_page_setup' can be Void. TODO: what's the
  110. -- meaning of a Void page setup?
  111. do
  112. gtk_print_operation_set_default_page_setup
  113. (handle, null_or(a_default_page_setup))
  114. end
  115. set_print_settings (some_print_settings: GTK_PRINT_SETTINGS) is
  116. -- Sets the print settings. This is typically used to
  117. -- re-establish print settings from a previous print
  118. -- operation, see `run'.
  119. -- `some_print_settings' can be Void.
  120. do
  121. gtk_print_operation_set_print_settings
  122. (handle, null_or(some_print_settings))
  123. end
  124. set_job_name (a_job_name: STRING) is
  125. -- Sets the name of the print job. The name is used to
  126. -- identify the job (e.g. in monitoring applications like
  127. -- eggcups). If you don't set a job name, GTK+ picks a
  128. -- default one by numbering successive print jobs.
  129. require name_not_void: a_job_name /= Void
  130. do
  131. gtk_print_operation_set_job_name(handle,a_job_name.to_external)
  132. end
  133. set_n_pages (a_number: INTEGER) is
  134. -- Sets the number of pages in the document.
  135. -- This must be set to a positive number before the rendering
  136. -- starts. It may be set in a ::begin-print signal hander.
  137. -- Note that the page numbers passed to the
  138. -- ::request-page-setup and ::draw-page signals are 0-based,
  139. -- i.e. if the user chooses to print all pages, the last
  140. -- ::draw-page signal will be for page n_pages - 1.
  141. require non_negative: a_number>=0
  142. do
  143. gtk_print_operation_set_n_pages (handle, a_number)
  144. end
  145. set_current_page (a_current_page_number: INTEGER) is
  146. -- Sets the current page; `a_current_page_number'
  147. -- If this is called before `run', the user will be able to
  148. -- select to print only the current page.
  149. -- Note that this only makes sense for pre-paginated documents.
  150. do
  151. gtk_print_operation_set_current_page(handle,a_current_page_number)
  152. end
  153. set_use_full_page (a_setting: BOOLEAN) is
  154. -- If `a_setting' is True, the transformation for the cairo
  155. -- context obtained from GTK_PRINT_CONTEXT puts the origin at
  156. -- the top left corner of the page (which may not be the top
  157. -- left corner of the sheet, depending on page orientation
  158. -- and the number of pages per sheet). Otherwise, the origin
  159. -- is at the top left corner of the imageable area
  160. -- (i.e. inside the margins).
  161. do
  162. gtk_print_operation_set_use_full_page(handle, a_setting.to_integer)
  163. end
  164. set_unit (a_unit: INTEGER) is
  165. -- Sets up the transformation for the cairo context obtained
  166. -- from GtkPrintContext in such a way that distances are
  167. -- measured in `a_unit'.
  168. require valid_unit: is_valid_gtk_unit(a_unit)
  169. do
  170. gtk_print_operation_set_unit (handle, a_unit)
  171. end
  172. set_export_filename (a_file_name: STRING) is
  173. -- Sets up the GtkPrintOperation to generate a file instead
  174. -- of showing the print dialog. The indended use of this
  175. -- function is for implementing "Export to PDF"
  176. -- actions. Currently, PDF is the only supported format.
  177. -- "Print to PDF" support is independent of this and is done
  178. -- by letting the user pick the "Print to PDF" item from the
  179. -- list of printers in the print dialog.
  180. require name_not_void: a_file_name/=Void
  181. do
  182. gtk_print_operation_set_export_filename(handle,
  183. a_file_name.to_external)
  184. end
  185. set_show_progress (a_setting: BOOLEAN) is
  186. -- If `a_setting' is True, the print operation will show a
  187. -- progress dialog during the print operation.
  188. do
  189. gtk_print_operation_set_show_progress(handle,a_setting.to_integer)
  190. end
  191. set_track_print_status (a_setting: BOOLEAN) is
  192. -- If `a_setting' is True, the print operation will try to
  193. -- continue report on the status of the print job in the
  194. -- printer queues and printer. This can allow your
  195. -- application to show things like "out of paper" issues, and
  196. -- when the print job actually reaches the printer.
  197. -- This feature is often implemented using some form of
  198. -- polling, so it should not be enabled unless needed.
  199. do
  200. gtk_print_operation_set_track_print_status
  201. (handle,a_setting.to_integer)
  202. end
  203. set_custom_tab_label (a_label: STRING) is
  204. -- Sets the label for the tab holding custom widgets to
  205. -- `a_label'; if Void the default label is used
  206. do
  207. if a_label=Void then
  208. gtk_print_operation_set_custom_tab_label(handle,default_pointer)
  209. else
  210. gtk_print_operation_set_custom_tab_label(handle,a_label.to_external)
  211. end
  212. end
  213. feature -- Getters
  214. -- TODO: void gtk_print_operation_get_error (GtkPrintOperation *op,
  215. -- GError **error);
  216. -- Call this when the result of a print operation is
  217. -- GTK_PRINT_OPERATION_RESULT_ERROR, either as returned by
  218. -- gtk_print_operation_run(), or in the ::done signal handler. The returned
  219. -- GError will contain more details on what went wrong.
  220. --
  221. -- op : a GtkPrintOperation
  222. -- error : return location for the error
  223. --
  224. default_page_setup: GTK_PAGE_SETUP is
  225. -- The default page setup. Can be Void
  226. local ptr: POINTER; r: G_OBJECT_EXPANDED_FACTORY[GTK_PAGE_SETUP]
  227. do
  228. ptr:=gtk_print_operation_get_default_page_setup(handle)
  229. if ptr.is_not_null then
  230. Result := existant_wrapper(ptr)
  231. if Result=Void then
  232. create Result.from_external_pointer(ptr)
  233. end
  234. end
  235. end
  236. settings: GTK_PRINT_SETTINGS is
  237. -- The current print settings. Void until either
  238. -- `set_print_settings' or `run' have been called.
  239. local factory: G_OBJECT_EXPANDED_FACTORY[GTK_PRINT_SETTINGS]
  240. do
  241. Result := factory.wrapper_or_void (gtk_print_operation_get_print_settings(handle))
  242. end
  243. operation_result: INTEGER
  244. -- The result of the last `run' call.
  245. run (an_action: INTEGER; a_parent: GTK_WINDOW) is
  246. -- Runs the print operation, by first letting the user modify
  247. -- print settings in the print dialog, and then print the
  248. -- document.
  249. -- Normally that this function does not return until the
  250. -- rendering of all pages is complete. You can connect to the
  251. -- ::status-changed signal on op to obtain some information
  252. -- about the progress of the print operation.
  253. -- Furthermore, it may use a recursive mainloop to show the
  254. -- print dialog.
  255. -- If you call `set_allow_async' (which changes the
  256. -- allow-async property) the operation will run asyncronously
  257. -- if this is supported on the platform. The ::done signal
  258. -- will be emitted with the operation results when the
  259. -- operation is done (i.e. when the dialog is canceled, or
  260. -- when the print succeeds or fails).
  261. -- parent : Transient parent of the dialog, or NULL
  262. -- error : Return location for errors, or NULL
  263. -- `status' will be the result of the print operation. A
  264. -- return value of `gtk_print_operation_result_apply'
  265. -- indicates that the printing was completed successfully. In
  266. -- this case, it is a good idea to store the used print
  267. -- settings (the `settings' feature) reuse with the next
  268. -- print operation. A value of
  269. -- `gtk_print_operation_result_in_progress' means the
  270. -- operation is running asynchronously, and will emit the
  271. -- ::done signal when done.
  272. -- TODO: Eiffellize the following example:
  273. -- if (settings != NULL)
  274. -- gtk_print_operation_set_print_settings (print, settings);
  275. --
  276. -- if (page_setup != NULL)
  277. -- gtk_print_operation_set_default_page_setup (print, page_setup);
  278. --
  279. -- g_signal_connect (print, "begin-print",
  280. -- G_CALLBACK (begin_print), &data);
  281. -- g_signal_connect (print, "draw-page",
  282. -- G_CALLBACK (draw_page), &data);
  283. --
  284. -- res = gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, parent, &error);
  285. --
  286. -- if (res == GTK_PRINT_OPERATION_RESULT_ERROR)
  287. -- {
  288. -- error_dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
  289. -- GTK_DIALOG_DESTROY_WITH_PARENT,
  290. -- GTK_MESSAGE_ERROR,
  291. -- GTK_BUTTONS_CLOSE,
  292. -- "Error printing file:\ns",
  293. -- error->message);
  294. -- g_signal_connect (error_dialog, "response",
  295. -- G_CALLBACK (gtk_widget_destroy), NULL);
  296. -- gtk_widget_show (error_dialog);
  297. -- g_error_free (error);
  298. -- }
  299. -- else if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
  300. -- {
  301. -- if (settings != NULL)
  302. -- g_object_unref (settings);
  303. -- settings = g_object_ref (gtk_print_operation_get_print_settings (print));
  304. -- }
  305. --
  306. do
  307. operation_result:=gtk_print_operation_run(handle, an_action,
  308. null_or(a_parent),
  309. address_of(gtk.error.handle))
  310. ensure valid_result: is_valid_gtk_print_operation_result (operation_result)
  311. end
  312. cancel is
  313. -- Cancels a running print operation. This feature may be
  314. -- called from a begin-print, paginate or draw-page signal
  315. -- handler to stop the currently running print operation.
  316. do
  317. gtk_print_operation_cancel(handle)
  318. end
  319. status: INTEGER is
  320. -- the status of the print operation. Also see
  321. -- `status_string'.
  322. do
  323. Result:=gtk_print_operation_get_status(handle)
  324. ensure valid: is_valid_gtk_print_status(Result)
  325. end
  326. status_string: CONST_STRING is
  327. -- a string representation of the status of the print
  328. -- operation. The string is translated and suitable for
  329. -- displaying the print status e.g. in a GtkStatusbar.
  330. -- Use `status' to obtain a status value that is suitable for
  331. -- programmatic use.
  332. do
  333. create Result.from_external(gtk_print_operation_get_status_string(handle))
  334. end
  335. is_finished: BOOLEAN is
  336. -- Is the print operation finished?
  337. -- This is a convenience feature to find out if the print
  338. -- operation is finished, either successfully
  339. -- (`gtk_print_status_finished') or unsuccessfully
  340. -- (`gtk_print_status_finished_aborted').
  341. -- Note: when you enable print status tracking the print
  342. -- operation can be in a non-finished state even after done
  343. -- has been called, as the operation status then tracks the
  344. -- print job status on the printer.
  345. do
  346. Result:=gtk_print_operation_is_finished(handle).to_boolean
  347. end
  348. error: G_ERROR is
  349. -- Detailed error description of what went wrong, useful when
  350. -- the result of a print operation is
  351. -- `gtk_print_operation_result_error', either as returned by
  352. -- `run', or in the ::done signal handler.
  353. do
  354. create Result.empty
  355. gtk_print_operation_get_error(handle, address_of(error.handle))
  356. end
  357. -- TODO: GtkPageSetup* gtk_print_run_page_setup_dialog
  358. -- (GtkWindow *parent,
  359. -- GtkPageSetup *page_setup,
  360. -- GtkPrintSettings *settings);
  361. --
  362. -- Runs a page setup dialog, letting the user modify the values from
  363. -- page_setup. If the user cancels the dialog, the returned GtkPageSetup is
  364. -- identical to the passed in page_setup, otherwise it contains the
  365. -- modifications done in the dialog.
  366. --
  367. -- Note that this function may use a recursive mainloop to show the page
  368. -- setup dialog. See gtk_print_run_page_setup_dialog_async() if this is a
  369. -- problem.
  370. --
  371. -- parent : transient parent, or NULL
  372. -- page_setup : an existing GtkPageSetup, or NULL
  373. -- settings : a GtkPrintSettings
  374. -- Returns : a new GtkPageSetup
  375. --
  376. -- Since 2.10
  377. --
  378. -- --------------------------------------------------------------------------
  379. --
  380. -- GtkPageSetupDoneFunc ()
  381. --
  382. -- void (*GtkPageSetupDoneFunc) (GtkPageSetup *page_setup,
  383. -- gpointer data);
  384. --
  385. -- The type of function that is passed to
  386. -- gtk_print_run_page_setup_dialog_async(). This function will be called when
  387. -- the page setup dialog is dismissed, and also serves as destroy notify for
  388. -- data.
  389. --
  390. -- page_setup : the GtkPageSetup that has been
  391. -- data : user data that has been passed to
  392. -- gtk_print_run_page_setup_dialog_async().
  393. --
  394. -- --------------------------------------------------------------------------
  395. --
  396. -- gtk_print_run_page_setup_dialog_async ()
  397. --
  398. -- void gtk_print_run_page_setup_dialog_async
  399. -- (GtkWindow *parent,
  400. -- GtkPageSetup *page_setup,
  401. -- GtkPrintSettings *settings,
  402. -- GtkPageSetupDoneFunc done_cb,
  403. -- gpointer data);
  404. --
  405. -- Runs a page setup dialog, letting the user modify the values from
  406. -- page_setup.
  407. --
  408. -- In contrast to gtk_print_run_page_setup_dialog(), this function returns
  409. -- after showing the page setup dialog on platforms that support this, and
  410. -- calls done_cb from a signal handler for the ::response signal of the
  411. -- dialog.
  412. --
  413. -- parent : transient parent, or NULL
  414. -- page_setup : an existing GtkPageSetup, or NULL
  415. -- settings : a GtkPrintSettings
  416. -- done_cb : a function to call when the user saves the modified page
  417. -- setup
  418. -- data : user data to pass to done_cb
  419. --
  420. -- Since 2.10
  421. --
  422. -- --------------------------------------------------------------------------
  423. --
  424. --
  425. feature -- Property Details
  426. --Properties
  427. --
  428. --
  429. -- "allow-async" gboolean : Read / Write
  430. -- "current-page" gint : Read / Write
  431. -- "custom-tab-label" gchararray : Read / Write
  432. -- "default-page-setup" GtkPageSetup : Read / Write
  433. -- "export-filename" gchararray : Read / Write
  434. -- "job-name" gchararray : Read / Write
  435. -- "n-pages" gint : Read / Write
  436. -- "print-settings" GtkPrintSettings : Read / Write
  437. -- "show-progress" gboolean : Read / Write
  438. -- "status" GtkPrintStatus : Read
  439. -- "status-string" gchararray : Read
  440. -- "track-print-status" gboolean : Read / Write
  441. -- "unit" GtkUnit : Read / Write
  442. -- "use-full-page" gboolean : Read / Write
  443. --
  444. async_allowed: BOOLEAN is
  445. -- May the print operation run asynchronously?
  446. -- Wraps the "allow-async" property
  447. -- "allow-async" gboolean : Read / Write
  448. -- Some systems don't support asynchronous printing, but
  449. -- those that do will return
  450. -- `gtk_print_operation_result_in_progress' as the status,
  451. -- and emit the done signal when the operation is actually
  452. -- done.
  453. -- The Windows port does not support asynchronous operation
  454. -- at all (this is unlikely to change). On other platforms,
  455. -- all actions except for GTK_PRINT_OPERATION_ACTION_EXPORT
  456. -- support asynchronous operation.
  457. -- Default value: FALSE
  458. do
  459. Result:=boolean_property_from_pspec(allow_async_property_spec)
  460. end
  461. --
  462. -- The "current-page" property
  463. --
  464. -- "current-page" gint : Read / Write
  465. --
  466. -- The current page in the document.
  467. --
  468. -- If this is set before gtk_print_operation_run(), the user will be able to
  469. -- select to print only the current page.
  470. --
  471. -- Note that this only makes sense for pre-paginated documents.
  472. --
  473. -- Allowed values: >= -1
  474. --
  475. -- Default value: -1
  476. --
  477. -- Since 2.10
  478. --
  479. -- --------------------------------------------------------------------------
  480. --
  481. -- The "custom-tab-label" property
  482. --
  483. -- "custom-tab-label" gchararray : Read / Write
  484. --
  485. -- Used as the label of the tab containing custom widgets. Note that this
  486. -- property may be ignored on some platforms.
  487. --
  488. -- If this is NULL, GTK+ uses a default label.
  489. --
  490. -- Default value: NULL
  491. --
  492. -- Since 2.10
  493. --
  494. -- --------------------------------------------------------------------------
  495. --
  496. -- The "default-page-setup" property
  497. --
  498. -- "default-page-setup" GtkPageSetup : Read / Write
  499. --
  500. -- The GtkPageSetup used by default.
  501. --
  502. -- This page setup will be used by gtk_print_operation_run(), but it can be
  503. -- overridden on a per-page basis by connecting to the ::request-page-setup
  504. -- signal.
  505. --
  506. -- Since 2.10
  507. --
  508. -- --------------------------------------------------------------------------
  509. --
  510. -- The "export-filename" property
  511. --
  512. -- "export-filename" gchararray : Read / Write
  513. --
  514. -- The name of a file file to generate instead of showing the print dialog.
  515. -- Currently, PDF is the only supported format.
  516. --
  517. -- The intended use of this property is for implementing "Export to PDF"
  518. -- actions.
  519. --
  520. -- "Print to PDF" support is independent of this and is done by letting the
  521. -- user pick the "Print to PDF" item from the list of printers in the print
  522. -- dialog.
  523. --
  524. -- Default value: NULL
  525. --
  526. -- Since 2.10
  527. --
  528. -- --------------------------------------------------------------------------
  529. --
  530. -- The "job-name" property
  531. --
  532. -- "job-name" gchararray : Read / Write
  533. --
  534. -- A string used to identify the job (e.g. in monitoring applications like
  535. -- eggcups).
  536. --
  537. -- If you don't set a job name, GTK+ picks a default one by numbering
  538. -- successive print jobs.
  539. --
  540. -- Default value: ""
  541. --
  542. -- Since 2.10
  543. --
  544. -- --------------------------------------------------------------------------
  545. --
  546. -- The "n-pages" property
  547. --
  548. -- "n-pages" gint : Read / Write
  549. --
  550. -- The number of pages in the document.
  551. --
  552. -- This must be set to a positive number before the rendering starts. It may
  553. -- be set in a ::begin-print signal hander.
  554. --
  555. -- Note that the page numbers passed to the ::request-page-setup and
  556. -- ::draw-page signals are 0-based, i.e. if the user chooses to print all
  557. -- pages, the last ::draw-page signal will be for page n_pages - 1.
  558. --
  559. -- Allowed values: >= -1
  560. --
  561. -- Default value: -1
  562. --
  563. -- Since 2.10
  564. --
  565. -- --------------------------------------------------------------------------
  566. --
  567. -- The "print-settings" property
  568. --
  569. -- "print-settings" GtkPrintSettings : Read / Write
  570. --
  571. -- The GtkPrintSettings used for initializing the dialog.
  572. --
  573. -- Setting this property is typically used to re-establish print settings
  574. -- from a previous print operation, see gtk_print_operation_run().
  575. --
  576. -- Since 2.10
  577. --
  578. -- --------------------------------------------------------------------------
  579. --
  580. -- The "show-progress" property
  581. --
  582. -- "show-progress" gboolean : Read / Write
  583. --
  584. -- Determines whether to show a progress dialog during the print operation.
  585. --
  586. -- Default value: FALSE
  587. --
  588. -- Since 2.10
  589. --
  590. -- --------------------------------------------------------------------------
  591. --
  592. -- The "status" property
  593. --
  594. -- "status" GtkPrintStatus : Read
  595. --
  596. -- The status of the print operation.
  597. --
  598. -- Default value: GTK_PRINT_STATUS_INITIAL
  599. --
  600. -- Since 2.10
  601. --
  602. -- --------------------------------------------------------------------------
  603. --
  604. -- The "status-string" property
  605. --
  606. -- "status-string" gchararray : Read
  607. --
  608. -- A string representation of the status of the print operation. The string
  609. -- is translated and suitable for displaying the print status e.g. in a
  610. -- GtkStatusbar.
  611. --
  612. -- See the ::status property for a status value that is suitable for
  613. -- programmatic use.
  614. --
  615. -- Default value: ""
  616. --
  617. -- Since 2.10
  618. --
  619. -- --------------------------------------------------------------------------
  620. --
  621. -- The "track-print-status" property
  622. --
  623. -- "track-print-status" gboolean : Read / Write
  624. --
  625. -- If TRUE, the print operation will try to continue report on the status of
  626. -- the print job in the printer queues and printer. This can allow your
  627. -- application to show things like "out of paper" issues, and when the print
  628. -- job actually reaches the printer. However, this is often implemented using
  629. -- polling, and should not be enabled unless needed.
  630. --
  631. -- Default value: FALSE
  632. --
  633. -- Since 2.10
  634. --
  635. -- --------------------------------------------------------------------------
  636. --
  637. -- The "unit" property
  638. --
  639. -- "unit" GtkUnit : Read / Write
  640. --
  641. -- The transformation for the cairo context obtained from GtkPrintContext is
  642. -- set up in such a way that distances are measured in units of unit.
  643. --
  644. -- Default value: GTK_UNIT_PIXEL
  645. --
  646. -- Since 2.10
  647. --
  648. -- --------------------------------------------------------------------------
  649. --
  650. -- The "use-full-page" property
  651. --
  652. -- "use-full-page" gboolean : Read / Write
  653. --
  654. -- If TRUE, the transformation for the cairo context obtained from
  655. -- GtkPrintContext puts the origin at the top left corner of the page (which
  656. -- may not be the top left corner of the sheet, depending on page orientation
  657. -- and the number of pages per sheet). Otherwise, the origin is at the top
  658. -- left corner of the imageable area (i.e. inside the margins).
  659. --
  660. -- Default value: FALSE
  661. --
  662. -- Since 2.10
  663. --
  664. feature -- TODO: Signal Details
  665. --Signals
  666. --
  667. --
  668. -- "begin-print"
  669. -- void user_function (GtkPrintOperation *operation,
  670. -- GtkPrintContext *context,
  671. -- gpointer user_data) : Run last
  672. -- "create-custom-widget"
  673. -- GObject* user_function (GtkPrintOperation *operation,
  674. -- gpointer user_data) : Run last
  675. -- "custom-widget-apply"
  676. -- void user_function (GtkPrintOperation *operation,
  677. -- GtkWidget *widget,
  678. -- gpointer user_data) : Run last
  679. -- "done" void user_function (GtkPrintOperation *operation,
  680. -- GtkPrintOperationResult result,
  681. -- gpointer user_data) : Run last
  682. -- "draw-page" void user_function (GtkPrintOperation *operation,
  683. -- GtkPrintContext *context,
  684. -- gint page_nr,
  685. -- gpointer user_data) : Run last
  686. -- "end-print" void user_function (GtkPrintOperation *operation,
  687. -- GtkPrintContext *context,
  688. -- gpointer user_data) : Run last
  689. -- "paginate" gboolean user_function (GtkPrintOperation *operation,
  690. -- GtkPrintContext *context,
  691. -- gpointer user_data) : Run last
  692. -- "preview" gboolean user_function (GtkPrintOperation *operation,
  693. -- GtkPrintOperationPreview *preview,
  694. -- GtkPrintContext *context,
  695. -- GtkWindow *parent,
  696. -- gpointer user_data) : Run last
  697. -- "request-page-setup"
  698. -- void user_function (GtkPrintOperation *operation,
  699. -- GtkPrintContext *context,
  700. -- gint page_nr,
  701. -- GtkPageSetup *setup,
  702. -- gpointer user_data) : Run last
  703. -- "status-changed"
  704. -- void user_function (GtkPrintOperation *operation,
  705. -- gpointer user_data) : Run last
  706. --
  707. --
  708. -- The "begin-print" signal
  709. --
  710. -- void user_function (GtkPrintOperation *operation,
  711. -- GtkPrintContext *context,
  712. -- gpointer user_data) : Run last
  713. --
  714. -- Emitted after the user has finished changing print settings in the dialog,
  715. -- before the actual rendering starts.
  716. --
  717. -- A typical use for this signal is to use the parameters from the
  718. -- GtkPrintContext and paginate the document accordingly, and then set the
  719. -- number of pages with gtk_print_operation_set_n_pages().
  720. --
  721. -- operation : the GtkPrintOperation on which the signal was emitted
  722. -- context : the GtkPrintContext for the current operation
  723. -- user_data : user data set when the signal handler was connected.
  724. --
  725. -- Since 2.10
  726. --
  727. -- --------------------------------------------------------------------------
  728. --
  729. -- The "create-custom-widget" signal
  730. --
  731. -- GObject* user_function (GtkPrintOperation *operation,
  732. -- gpointer user_data) : Run last
  733. --
  734. -- Emitted when displaying the print dialog. If you return a widget in a
  735. -- handler for this signal it will be added to a custom tab in the print
  736. -- dialog. You typically return a container widget with multiple widgets in
  737. -- it.
  738. --
  739. -- The print dialog owns the returned widget, and its lifetime isn't
  740. -- controlled by the app. However, the widget is guaranteed to stay around
  741. -- until the custom-widget-apply signal is emitted on the operation. Then you
  742. -- can read out any information you need from the widgets.
  743. --
  744. -- operation : the GtkPrintOperation on which the signal was emitted
  745. -- user_data : user data set when the signal handler was connected.
  746. -- Returns : A custom widget that gets embedded in the print dialog, or
  747. -- NULL
  748. --
  749. -- Since 2.10
  750. --
  751. -- --------------------------------------------------------------------------
  752. --
  753. -- The "custom-widget-apply" signal
  754. --
  755. -- void user_function (GtkPrintOperation *operation,
  756. -- GtkWidget *widget,
  757. -- gpointer user_data) : Run last
  758. --
  759. -- Emitted right before begin-print if you added a custom widget in the
  760. -- create-custom-widget handler. When you get this signal you should read the
  761. -- information from the custom widgets, as the widgets are not guaraneed to
  762. -- be around at a later time.
  763. --
  764. -- operation : the GtkPrintOperation on which the signal was emitted
  765. -- widget : the custom widget added in create-custom-widget
  766. -- user_data : user data set when the signal handler was connected.
  767. --
  768. -- Since 2.10
  769. --
  770. -- --------------------------------------------------------------------------
  771. --
  772. -- The "done" signal
  773. --
  774. -- void user_function (GtkPrintOperation *operation,
  775. -- GtkPrintOperationResult result,
  776. -- gpointer user_data) : Run last
  777. --
  778. -- Emitted when the print operation run has finished doing everything
  779. -- required for printing. result gives you information about what happened
  780. -- during the run. If result is GTK_PRINT_OPERATION_RESULT_ERROR then you can
  781. -- call gtk_print_operation_get_error() for more information.
  782. --
  783. -- If you enabled print status tracking then
  784. -- gtk_print_operation_is_finished() may still return FALSE after this was
  785. -- emitted.
  786. --
  787. -- operation : the GtkPrintOperation on which the signal was emitted
  788. -- result : the result of the print operation
  789. -- user_data : user data set when the signal handler was connected.
  790. --
  791. -- Since 2.10
  792. --
  793. -- --------------------------------------------------------------------------
  794. --
  795. -- The "draw-page" signal
  796. --
  797. -- void user_function (GtkPrintOperation *operation,
  798. -- GtkPrintContext *context,
  799. -- gint page_nr,
  800. -- gpointer user_data) : Run last
  801. --
  802. -- Emitted for every page that is printed. The signal handler must render the
  803. -- page_nr's page onto the cairo context obtained from context using
  804. -- gtk_print_context_get_cairo_context().
  805. --
  806. -- static void
  807. -- draw_page (GtkPrintOperation *operation,
  808. -- GtkPrintContext *context,
  809. -- gint page_nr,
  810. -- gpointer user_data)
  811. -- {
  812. -- cairo_t *cr;
  813. -- PangoLayout *layout;
  814. -- gdouble width, text_height;
  815. -- gint layout_height;
  816. -- PangoFontDescription *desc;
  817. --
  818. -- cr = gtk_print_context_get_cairo_context (context);
  819. -- width = gtk_print_context_get_width (context);
  820. --
  821. -- cairo_rectangle (cr, 0, 0, width, HEADER_HEIGHT);
  822. --
  823. -- cairo_set_source_rgb (cr, 0.8, 0.8, 0.8);
  824. -- cairo_fill (cr);
  825. --
  826. -- layout = gtk_print_context_create_pango_layout (context);
  827. --
  828. -- desc = pango_font_description_from_string ("sans 14");
  829. -- pango_layout_set_font_description (layout, desc);
  830. -- pango_font_description_free (desc);
  831. --
  832. -- pango_layout_set_text (layout, "some text", -1);
  833. -- pango_layout_set_width (layout, width);
  834. -- pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
  835. --
  836. -- pango_layout_get_size (layout, NULL, &layout_height);
  837. -- text_height = (gdouble)layout_height / PANGO_SCALE;
  838. --
  839. -- cairo_move_to (cr, width / 2, (HEADER_HEIGHT - text_height) / 2);
  840. -- pango_cairo_show_layout (cr, layout);
  841. --
  842. -- g_object_unref (layout);
  843. -- }
  844. --
  845. -- Use gtk_print_operation_set_use_full_page() and
  846. -- gtk_print_operation_set_unit() before starting the print operation to set
  847. -- up the transformation of the cairo context according to your needs.
  848. --
  849. -- operation : the GtkPrintOperation on which the signal was emitted
  850. -- context : the GtkPrintContext for the current operation
  851. -- page_nr : the number of the currently printed page
  852. -- user_data : user data set when the signal handler was connected.
  853. --
  854. -- Since 2.10
  855. --
  856. -- --------------------------------------------------------------------------
  857. --
  858. -- The "end-print" signal
  859. --
  860. -- void user_function (GtkPrintOperation *operation,
  861. -- GtkPrintContext *context,
  862. -- gpointer user_data) : Run last
  863. --
  864. -- Emitted after all pages have been rendered. A handler for this signal can
  865. -- clean up any resources that have been allocated in the ::begin-print
  866. -- handler.
  867. --
  868. -- operation : the GtkPrintOperation on which the signal was emitted
  869. -- context : the GtkPrintContext for the current operation
  870. -- user_data : user data set when the signal handler was connected.
  871. --
  872. -- Since 2.10
  873. --
  874. -- --------------------------------------------------------------------------
  875. --
  876. -- The "paginate" signal
  877. --
  878. -- gboolean user_function (GtkPrintOperation *operation,
  879. -- GtkPrintContext *context,
  880. -- gpointer user_data) : Run last
  881. --
  882. -- Emitted after the begin-print signal, but before the actual rendering
  883. -- starts. It keeps getting emitted until it returns FALSE.
  884. --
  885. -- This signal is intended to be used for paginating the document in small
  886. -- chunks, to avoid blocking the user interface for a long time. The signal
  887. -- handler should update the number of pages using
  888. -- gtk_print_operation_set_n_pages(), and return TRUE if the document has
  889. -- been completely paginated.
  890. --
  891. -- If you don't need to do pagination in chunks, you can simply do it all in
  892. -- the begin-print handler, and set the number of pages from there.
  893. --
  894. -- operation : the GtkPrintOperation on which the signal was emitted
  895. -- context : the GtkPrintContext for the current operation
  896. -- user_data : user data set when the signal handler was connected.
  897. -- Returns : TRUE if pagination is complete
  898. --
  899. -- Since 2.10
  900. --
  901. -- --------------------------------------------------------------------------
  902. --
  903. -- The "preview" signal
  904. --
  905. -- gboolean user_function (GtkPrintOperation *operation,
  906. -- GtkPrintOperationPreview *preview,
  907. -- GtkPrintContext *context,
  908. -- GtkWindow *parent,
  909. -- gpointer user_data) : Run last
  910. --
  911. -- Gets emitted when a preview is requested from the native dialog.
  912. --
  913. -- The default handler for this signal uses an external viewer application to
  914. -- preview.
  915. --
  916. -- To implement a custom print preview, an application must return TRUE from
  917. -- its handler for this signal. In order to use the provided context for the
  918. -- preview implementation, it must be given a suitable cairo context with
  919. -- gtk_print_context_set_cairo_context().
  920. --
  921. -- The custom preview implementation can use
  922. -- gtk_print_operation_preview_is_selected() and
  923. -- gtk_print_operation_preview_render_page() to find pages which are selected
  924. -- for print and render them. The preview must be finished by calling
  925. -- gtk_print_operation_preview_end_preview() (typically in response to the
  926. -- user clicking a close button).
  927. --
  928. -- operation : the GtkPrintOperation on which the signal was emitted
  929. -- preview : the GtkPrintPreviewOperation for the current operation
  930. -- context : the GtkPrintContext that will be used
  931. -- parent : the GtkWindow to use as window parent, or NULL
  932. -- user_data : user data set when the signal handler was connected.
  933. -- Returns : TRUE if the listener wants to take over control of the preview
  934. --
  935. -- Since 2.10
  936. --
  937. -- --------------------------------------------------------------------------
  938. --
  939. -- The "request-page-setup" signal
  940. --
  941. -- void user_function (GtkPrintOperation *operation,
  942. -- GtkPrintContext *context,
  943. -- gint page_nr,
  944. -- GtkPageSetup *setup,
  945. -- gpointer user_data) : Run last
  946. --
  947. -- Emitted once for every page that is printed, to give the application a
  948. -- chance to modify the page setup. Any changes done to setup will be in
  949. -- force only for printing this page.
  950. --
  951. -- operation : the GtkPrintOperation on which the signal was emitted
  952. -- context : the GtkPrintContext for the current operation
  953. -- page_nr : the number of the currently printed page
  954. -- setup : the GtkPageSetup
  955. -- user_data : user data set when the signal handler was connected.
  956. --
  957. -- Since 2.10
  958. --
  959. -- --------------------------------------------------------------------------
  960. --
  961. -- The "status-changed" signal
  962. --
  963. -- void user_function (GtkPrintOperation *operation,
  964. -- gpointer user_data) : Run last
  965. --
  966. -- Emitted at between the various phases of the print operation. See
  967. -- GtkPrintStatus for the phases that are being discriminated. Use
  968. -- gtk_print_operation_get_status() to find out the current status.
  969. --
  970. -- operation : the GtkPrintOperation on which the signal was emitted
  971. -- user_data : user data set when the signal handler was connected.
  972. --
  973. feature {} -- Unwrapped code
  974. -- #define GTK_PRINT_ERROR gtk_print_error_quark ()
  975. --
  976. -- The GQuark used for GtkPrintError errors.
  977. feature {} -- Hastened property spec
  978. allow_async_property_spec: G_PARAM_SPEC is
  979. once
  980. Result := find_property (allow_async_property_name)
  981. end
  982. allow_async_property_name: STRING is "allow-async"
  983. feature -- size
  984. struct_size: INTEGER is
  985. external "C inline use <gtk/gtk.h>"
  986. alias "sizeof(GtkPrintOperation)"
  987. end
  988. end -- class GTK_PRINT_OPERATION