gtk-High-level-Printing-API      package:RGtk2      R Documentation

_G_t_k_P_r_i_n_t_O_p_e_r_a_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     High-level Printing API

_M_e_t_h_o_d_s _a_n_d _F_u_n_c_t_i_o_n_s:

     'gtkPrintOperationNew()'
      'gtkPrintOperationSetAllowAsync(object, allow.async)'
      'gtkPrintOperationGetError(object, .errwarn = TRUE)'
      'gtkPrintOperationSetDefaultPageSetup(object, default.page.setup
     = NULL)'
      'gtkPrintOperationGetDefaultPageSetup(object)'
      'gtkPrintOperationSetPrintSettings(object, print.settings =
     NULL)'
      'gtkPrintOperationGetPrintSettings(object)'
      'gtkPrintOperationSetJobName(object, job.name)'
      'gtkPrintOperationSetNPages(object, n.pages)'
      'gtkPrintOperationSetCurrentPage(object, current.page)'
      'gtkPrintOperationSetUseFullPage(object, full.page)'
      'gtkPrintOperationSetUnit(object, unit)'
      'gtkPrintOperationSetExportFilename(object, filename)'
      'gtkPrintOperationSetShowProgress(object, show.progress)'
      'gtkPrintOperationSetTrackPrintStatus(object, track.status)'
      'gtkPrintOperationSetCustomTabLabel(object, label)'
      'gtkPrintOperationRun(object, action, parent = NULL, .errwarn =
     TRUE)'
      'gtkPrintOperationCancel(object)'
      'gtkPrintOperationGetStatus(object)'
      'gtkPrintOperationGetStatusString(object)'
      'gtkPrintOperationIsFinished(object)'
      'gtkPrintRunPageSetupDialog(parent, page.setup = NULL, settings)'
      'gtkPrintRunPageSetupDialogAsync(parent, page.setup, settings,
     done.cb, data)'
      'gtkPrintOperationPreviewEndPreview(object)'
      'gtkPrintOperationPreviewIsSelected(object, page.nr)'
      'gtkPrintOperationPreviewRenderPage(object, page.nr)'
      'gtkPrintOperation()'

_H_i_e_r_a_r_c_h_y:


     GObject
        +----GtkPrintOperation
     GInterface
        +----GtkPrintOperationPreview


_I_m_p_l_e_m_e_n_t_a_t_i_o_n_s:

     GtkPrintOperationPreview is implemented by 'GtkPrintOperation'.

_I_n_t_e_r_f_a_c_e_s:

     GtkPrintOperation implements 'GtkPrintOperationPreview'.

_D_e_t_a_i_l_e_d _D_e_s_c_r_i_p_t_i_o_n:

     GtkPrintOperation is the high-level, portable printing API. It
     looks  a bit different than other GTK+ dialogs such as the
     'GtkFileChooser',  since some platforms don't expose enough
     infrastructure to implement a good print dialog. On such
     platforms, GtkPrintOperation uses the  native print dialog. On
     platforms which do not provide a native  print dialog, GTK+ uses
     its own, see 'GtkPrintUnixDialog'.

     The typical way to use the high-level printing API is to create a 
     'GtkPrintOperation' object with 'gtkPrintOperationNew' when the
     user  selects to print. Then you set some properties on it, e.g.
     the page size,  any 'GtkPrintSettings' from previous print
     operations, the number of pages,  the current page, etc. 

     Then you start the print operation by calling
     'gtkPrintOperationRun'. It will then show a dialog, let the user
     select a printer and options.  When the user finished the dialog
     various signals will be emitted on the  'GtkPrintOperation', the
     main one being ::draw-page, which you are supposed  to catch and
     render the page on the provided 'GtkPrintContext' using Cairo.

     _The high-level printing API_


     settings <- NULL
     print_something <-
     {
       op <- gtkPrintOperation()

       if (!is.null(settings)) 
         op$setPrintSettings(settings)

       gSignalConnect(op, "begin_print", begin_print)
       gSignalConnect(op, "draw_page", draw_page)

       res <- op$run("print-dialog", main_window)[[1]]

       if (res == "apply")
         settings <- op$getPrintSettings()
     }
      By default GtkPrintOperation uses an external application to do
     print preview. To implement a custom print preview, an application
      must connect to the preview signal. The functions 
     'gtkPrintOperationPrintPreviewRenderPage()', 
     'gtkPrintOperationPreviewEndPreview' and 
     'gtkPrintOperationPreviewIsSelected' are useful  when implementing
     a print preview.

     Printing support was added in GTK+ 2.10.

_S_t_r_u_c_t_u_r_e_s:


     '_G_t_k_P_r_i_n_t_O_p_e_r_a_t_i_o_n' _undocumented _


     '_G_t_k_P_r_i_n_t_O_p_e_r_a_t_i_o_n_P_r_e_v_i_e_w' _undocumented _


_C_o_n_v_e_n_i_e_n_t _C_o_n_s_t_r_u_c_t_i_o_n:

     'gtkPrintOperation' is the equivalent of 'gtkPrintOperationNew'.

_E_n_u_m_s _a_n_d _F_l_a_g_s:


     '_G_t_k_P_r_i_n_t_S_t_a_t_u_s' The status gives a rough indication of the
          completion of a running print operation.

          '_i_n_i_t_i_a_l' The printing has not started yet; this status is
               set initially, and while the print dialog is shown.

          '_p_r_e_p_a_r_i_n_g' This status is set while the begin-print  signal
               is emitted and during pagination.

          '_g_e_n_e_r_a_t_i_n_g-_d_a_t_a' This status is set while the pages are
               being rendered.

          '_s_e_n_d_i_n_g-_d_a_t_a' The print job is being sent off to the 
               printer.

          '_p_e_n_d_i_n_g' The print job has been sent to the printer, but is
               not printed for some reason, e.g. the printer may be
               stopped.

          '_p_e_n_d_i_n_g-_i_s_s_u_e' Some problem has occurred during  printing,
               e.g. a paper jam.

          '_p_r_i_n_t_i_n_g' The printer is processing the print job.

          '_f_i_n_i_s_h_e_d' The printing has been completed successfully.

          '_f_i_n_i_s_h_e_d-_a_b_o_r_t_e_d' The printing has been aborted.


     '_G_t_k_P_r_i_n_t_O_p_e_r_a_t_i_o_n_A_c_t_i_o_n' The 'action' parameter to
          'gtkPrintOperationRun' determines what action the print
          operation should perform.

          '_p_r_i_n_t-_d_i_a_l_o_g' Show the print dialog.

          '_p_r_i_n_t' Start to print without showing the print dialog,
               based on the current print settings.

          '_p_r_e_v_i_e_w' Show the print preview.

          '_e_x_p_o_r_t' Export to a file. This requires the export-filename
               property to be set.


     '_G_t_k_P_r_i_n_t_O_p_e_r_a_t_i_o_n_R_e_s_u_l_t' A value of this type is returned by
          'gtkPrintOperationRun'.

          '_e_r_r_o_r' An error has occured.

          '_a_p_p_l_y' The print settings should be stored.

          '_c_a_n_c_e_l' The print operation has been canceled, the print
               settings should not be stored.

          '_i_n-_p_r_o_g_r_e_s_s' The print operation is complete yet. This value
               will only be returned when running asynchronously.


     '_G_t_k_P_r_i_n_t_E_r_r_o_r' _undocumented _

          '_g_e_n_e_r_a_l' _undocumented _

          '_i_n_t_e_r_n_a_l-_e_r_r_o_r' _undocumented _

          '_n_o_m_e_m' _undocumented _


_U_s_e_r _F_u_n_c_t_i_o_n_s:


     '_G_t_k_P_a_g_e_S_e_t_u_p_D_o_n_e_F_u_n_c(_p_a_g_e._s_e_t_u_p, _d_a_t_a)' The type of function that
          is passed to 'gtkPrintRunPageSetupDialogAsync'. This function
          will be called when the page setup dialog is dismissed, and
          also serves as destroy notify for 'data'.

          '_p_a_g_e._s_e_t_u_p' ['GtkPageSetup'] the 'GtkPageSetup' that has
               been

          '_d_a_t_a' [R object] user data that has been passed to 
               'gtkPrintRunPageSetupDialogAsync'.


_S_i_g_n_a_l_s:


     '_b_e_g_i_n-_p_r_i_n_t(_o_p_e_r_a_t_i_o_n, _c_o_n_t_e_x_t, _u_s_e_r._d_a_t_a)' Emitted after the
          user has finished changing print settings in the dialog,
          before the actual rendering starts. 

          A typical use for ::begin-print is to use the parameters from
          the 'GtkPrintContext' and paginate the document accordingly,
          and then set the number of pages with
          'gtkPrintOperationSetNPages'.  

          Since  2.10

          '_o_p_e_r_a_t_i_o_n' ['GtkPrintOperation']  the 'GtkPrintOperation' on
               which the signal was emitted

          '_c_o_n_t_e_x_t' ['GtkPrintContext']  the 'GtkPrintContext' for the
               current operation

          '_u_s_e_r._d_a_t_a' [R object] user data set when the signal handler
               was connected.


     '_c_r_e_a_t_e-_c_u_s_t_o_m-_w_i_d_g_e_t(_o_p_e_r_a_t_i_o_n, _u_s_e_r._d_a_t_a)' Emitted when
          displaying the print dialog. If you return a widget in a
          handler for this signal it will be added to a custom tab in
          the print dialog. You typically return a container widget
          with multiple widgets in it.

          The print dialog owns the returned widget, and its lifetime
          isn't controlled by the app. However, the widget is
          guaranteed to stay around until the '"custom-widget-apply"' 
          signal is emitted on the operation. Then you can read out any
           information you need from the widgets.  

          Since  2.10

          '_o_p_e_r_a_t_i_o_n' ['GtkPrintOperation']  the 'GtkPrintOperation' on
               which the signal was emitted

          '_u_s_e_r._d_a_t_a' [R object] user data set when the signal handler
               was connected.

          _Returns:_ ['GObject']  A custom widget that gets embedded in
          the print dialog, or 'NULL'


     '_c_u_s_t_o_m-_w_i_d_g_e_t-_a_p_p_l_y(_o_p_e_r_a_t_i_o_n, _w_i_d_g_e_t, _u_s_e_r._d_a_t_a)' Emitted right
          before '"begin-print"' if you added a custom widget in the
          'gtkPrintOperation';create-custom-widget handler.  When you
          get this signal you should read the information from the 
          custom widgets, as the widgets are not guaraneed to be around
          at a  later time.  

          Since  2.10

          '_o_p_e_r_a_t_i_o_n' ['GtkPrintOperation']  the 'GtkPrintOperation' on
               which the signal was emitted

          '_w_i_d_g_e_t' ['GtkWidget']  the custom widget added in
               create-custom-widget

          '_u_s_e_r._d_a_t_a' [R object] user data set when the signal handler
               was connected.


     '_d_o_n_e(_o_p_e_r_a_t_i_o_n, _r_e_s_u_l_t, _u_s_e_r._d_a_t_a)' Emitted when the print
          operation run has finished doing everything required for
          printing. 'result' gives you information about what happened
          during the run. If 'result' is
          'GTK_PRINT_OPERATION_RESULT_ERROR' then you can call
          'gtkPrintOperationGetError' for more information.

          If you enabled print status tracking then 
          'gtkPrintOperationIsFinished' may still return 'FALSE'  after
          '"done"' was emitted.  

          Since  2.10

          '_o_p_e_r_a_t_i_o_n' ['GtkPrintOperation']  the 'GtkPrintOperation' on
               which the signal was emitted

          '_r_e_s_u_l_t' ['GtkPrintOperationResult']  the result of the print
               operation

          '_u_s_e_r._d_a_t_a' [R object] user data set when the signal handler
               was connected.


     '_d_r_a_w-_p_a_g_e(_o_p_e_r_a_t_i_o_n, _c_o_n_t_e_x_t, _p_a_g_e._n_r, _u_s_e_r._d_a_t_a)' Emitted for
          every page that is printed. The signal handler must render
          the 'page.nr''s page onto the cairo context obtained from
          'context' using 'gtkPrintContextGetCairoContext'.


          draw_page <- (operation, context, page_nr, user_data)
          {
            cr <- context$getCairoContext()
            width <- context$getWidth()

            cr$rectangle(0, 0, width, HEADER_HEIGHT)

            cr$setSourceRgb(0.8, 0.8, 0.8)
            cr$fill()

            layout <- context$createPangoLayout()

            desc <- pangoFontDescriptionFromString("sans 14")
            layout$setFontDescription(desc)

            layout$setText("some text")
            layout$setWidth(width)
            layout$setAlignment(layout, "center")

            layout_height <- layout$getSize()$height
            text_height <- layout_height / PANGO_SCALE

            cr$moveTo(width / 2,  (HEADER_HEIGHT - text_height) / 2)
            pangoCairoShowLayout(cr, layout)
          }
           Use 'gtkPrintOperationSetUseFullPage' and 
          'gtkPrintOperationSetUnit' before starting the print
          operation to set up the transformation of the cairo context
          according to your needs.  

          Since  2.10

          '_o_p_e_r_a_t_i_o_n' ['GtkPrintOperation']  the 'GtkPrintOperation' on
               which the signal was emitted

          '_c_o_n_t_e_x_t' ['GtkPrintContext']  the 'GtkPrintContext' for the
               current operation

          '_p_a_g_e._n_r' [integer]  the number of the currently printed page

          '_u_s_e_r._d_a_t_a' [R object] user data set when the signal handler
               was connected.


     '_e_n_d-_p_r_i_n_t(_o_p_e_r_a_t_i_o_n, _c_o_n_t_e_x_t, _u_s_e_r._d_a_t_a)' Emitted after all pages
          have been rendered.  A handler for this signal can clean up
          any resources that have been allocated in the '"begin-print"'
          handler.  

          Since  2.10

          '_o_p_e_r_a_t_i_o_n' ['GtkPrintOperation']  the 'GtkPrintOperation' on
               which the signal was emitted

          '_c_o_n_t_e_x_t' ['GtkPrintContext']  the 'GtkPrintContext' for the
               current operation

          '_u_s_e_r._d_a_t_a' [R object] user data set when the signal handler
               was connected.


     '_p_a_g_i_n_a_t_e(_o_p_e_r_a_t_i_o_n, _c_o_n_t_e_x_t, _u_s_e_r._d_a_t_a)' Emitted after the
          '"begin-print"' signal, but before  the actual rendering
          starts. It keeps getting emitted until it  returns 'FALSE'. 

          The ::paginate signal is intended to be used for paginating
          the document in small chunks, to avoid blocking the user
          interface for a long time. The signal handler should update
          the number of pages using 'gtkPrintOperationSetNPages', and
          return 'TRUE' if the document has been completely paginated.

          If you don't need to do pagination in chunks, you can simply
          do it all in the ::begin-print handler, and set the number of
          pages from there.  

          Since  2.10

          '_o_p_e_r_a_t_i_o_n' ['GtkPrintOperation']  the 'GtkPrintOperation' on
               which the signal was emitted

          '_c_o_n_t_e_x_t' ['GtkPrintContext']  the 'GtkPrintContext' for the
               current operation

          '_u_s_e_r._d_a_t_a' [R object] user data set when the signal handler
               was connected.

          _Returns:_ [logical] 'TRUE' if pagination is complete


     '_p_r_e_v_i_e_w(_o_p_e_r_a_t_i_o_n, _p_r_e_v_i_e_w, _c_o_n_t_e_x_t, _p_a_r_e_n_t, _u_s_e_r._d_a_t_a)' Gets
          emitted when a preview is requested from the native dialog.

          The default handler for this signal uses an external viewer 
          application to preview.

          To implement a custom print preview, an application must
          return 'TRUE' from its handler for this signal. In order to
          use the provided 'context' for the preview implementation, it
          must be given a suitable cairo context with
          'gtkPrintContextSetCairoContext'.

          The custom preview implementation can use 
          'gtkPrintOperationPreviewIsSelected' and 
          'gtkPrintOperationPreviewRenderPage' to find pages which are
          selected for print and render them. The preview must be
          finished by calling 'gtkPrintOperationPreviewEndPreview'
          (typically in response to the user clicking a close button).  

          Since  2.10

          '_o_p_e_r_a_t_i_o_n' ['GtkPrintOperation']  the 'GtkPrintOperation' on
               which the signal was emitted

          '_p_r_e_v_i_e_w' ['GtkPrintOperationPreview']  the
               'GtkPrintPreviewOperation' for the current operation

          '_c_o_n_t_e_x_t' ['GtkPrintContext']  the 'GtkPrintContext' that
               will be used

          '_p_a_r_e_n_t' ['GtkWindow']  the 'GtkWindow' to use as window
               parent, or 'NULL'

          '_u_s_e_r._d_a_t_a' [R object] user data set when the signal handler
               was connected.

          _Returns:_ [logical] 'TRUE' if the listener wants to take
          over control of the preview


     '_r_e_q_u_e_s_t-_p_a_g_e-_s_e_t_u_p(_o_p_e_r_a_t_i_o_n, _c_o_n_t_e_x_t, _p_a_g_e._n_r, _s_e_t_u_p, _u_s_e_r._d_a_t_a)' 
          Emitted once for every page that is printed, to give the
          application a chance to modify the page setup. Any changes 
          done to 'setup' will be in force only for printing this page.            

          Since  2.10

          '_o_p_e_r_a_t_i_o_n' ['GtkPrintOperation']  the 'GtkPrintOperation' on
               which the signal was emitted

          '_c_o_n_t_e_x_t' ['GtkPrintContext']  the 'GtkPrintContext' for the
               current operation

          '_p_a_g_e._n_r' [integer]  the number of the currently printed page

          '_s_e_t_u_p' ['GtkPageSetup']  the 'GtkPageSetup' 

          '_u_s_e_r._d_a_t_a' [R object] user data set when the signal handler
               was connected.


     '_s_t_a_t_u_s-_c_h_a_n_g_e_d(_o_p_e_r_a_t_i_o_n, _u_s_e_r._d_a_t_a)' Emitted at between the
          various phases of the print operation. See 'GtkPrintStatus'
          for the phases that are being discriminated. Use
          'gtkPrintOperationGetStatus' to find out the current status.  

          Since  2.10

          '_o_p_e_r_a_t_i_o_n' ['GtkPrintOperation']  the 'GtkPrintOperation' on
               which the signal was emitted

          '_u_s_e_r._d_a_t_a' [R object] user data set when the signal handler
               was connected.


_P_r_o_p_e_r_t_i_e_s:


     '_a_l_l_o_w-_a_s_y_n_c' [_l_o_g_i_c_a_l : _R_e_a_d / _W_r_i_t_e] Determines whether the
          print operation may run asynchronously or not.

          Some systems don't support asynchronous printing, but those
          that do will return 'GTK_PRINT_OPERATION_RESULT_IN_PROGRESS'
          as the status, and emit the done signal when the operation is
          actually done.

          The Windows port does not support asynchronous operation at
          all (this is unlikely to change). On other platforms, all
          actions except for 'GTK_PRINT_OPERATION_ACTION_EXPORT'
          support asynchronous operation.  

          Default value: FALSE  Since  2.10


     '_c_u_r_r_e_n_t-_p_a_g_e' [_i_n_t_e_g_e_r : _R_e_a_d / _W_r_i_t_e] The current page in the
          document.

          If this is set before 'gtkPrintOperationRun',  the user will
          be able to select to print only the current page.

          Note that this only makes sense for pre-paginated documents.  

          Allowed values: >= -1  Default value: -1  Since  2.10


     '_c_u_s_t_o_m-_t_a_b-_l_a_b_e_l' [_c_h_a_r_a_c_t_e_r : _R_e_a_d / _W_r_i_t_e] Used as the label of
          the tab containing custom widgets. Note that this property
          may be ignored on some platforms.

          If this is 'NULL', GTK+ uses a default label.  

          Default value: NULL  Since  2.10


     '_d_e_f_a_u_l_t-_p_a_g_e-_s_e_t_u_p' ['_G_t_k_P_a_g_e_S_e_t_u_p' : _R_e_a_d / _W_r_i_t_e] The
          'GtkPageSetup' used by default.

          This page setup will be used by 'gtkPrintOperationRun', but
          it can be overridden on a per-page basis by connecting to the
          '"request-page-setup"' signal.  

          Since  2.10


     '_e_x_p_o_r_t-_f_i_l_e_n_a_m_e' [_c_h_a_r_a_c_t_e_r : _R_e_a_d / _W_r_i_t_e] The name of a file
          file to generate instead of showing  the print dialog.
          Currently, PDF is the only supported format.

          The intended use of this property is for implementing 
          "Export to PDF" actions.

          "Print to PDF" support is independent of this and is done by
          letting the user pick the "Print to PDF" item from the  list
          of printers in the print dialog.  

          Default value: NULL  Since  2.10


     '_j_o_b-_n_a_m_e' [_c_h_a_r_a_c_t_e_r : _R_e_a_d / _W_r_i_t_e] A string used to identify
          the job (e.g. in monitoring  applications like eggcups). 

          If you don't set a job name, GTK+ picks a default one  by
          numbering successive print jobs.  

          Default value: ""  Since  2.10


     '_n-_p_a_g_e_s' [_i_n_t_e_g_e_r : _R_e_a_d / _W_r_i_t_e] The number of pages in the
          document. 

          This _must_ be set to a positive number before the rendering
          starts. It may be set in a  '"begin-print"' signal hander.

          Note that the page numbers passed to the 
          '"request-page-setup"' and  '"draw-page"' signals are
          0-based, i.e. if  the user chooses to print all pages, the
          last ::draw-page signal  will be for page 'n.pages' - 1.  

          Allowed values: >= -1  Default value: -1  Since  2.10


     '_p_r_i_n_t-_s_e_t_t_i_n_g_s' ['_G_t_k_P_r_i_n_t_S_e_t_t_i_n_g_s' : _R_e_a_d / _W_r_i_t_e] The
          'GtkPrintSettings' used for initializing the dialog.

          Setting this property is typically used to re-establish 
          print settings from a previous print operation, see 
          'gtkPrintOperationRun'.  

          Since  2.10


     '_s_h_o_w-_p_r_o_g_r_e_s_s' [_l_o_g_i_c_a_l : _R_e_a_d / _W_r_i_t_e] Determines whether to
          show a progress dialog during the  print operation.  

          Default value: FALSE  Since  2.10


     '_s_t_a_t_u_s' ['_G_t_k_P_r_i_n_t_S_t_a_t_u_s' : _R_e_a_d] The status of the print
          operation.  

          Default value: GTK_PRINT_STATUS_INITIAL  Since  2.10


     '_s_t_a_t_u_s-_s_t_r_i_n_g' [_c_h_a_r_a_c_t_e_r : _R_e_a_d] A string representation of the
          status of the print operation.  The string is translated and
          suitable for displaying the print  status e.g. in a
          'GtkStatusbar'.

          See the ::status property for a status value that is suitable
           for programmatic use.  

          Default value: ""  Since  2.10


     '_t_r_a_c_k-_p_r_i_n_t-_s_t_a_t_u_s' [_l_o_g_i_c_a_l : _R_e_a_d / _W_r_i_t_e] If 'TRUE', the print
          operation will try to continue report on  the status of the
          print job in the printer queues and printer.  This can allow
          your application to show things like "out of paper"  issues,
          and when the print job actually reaches the printer. 
          However, this is often implemented using polling, and should 
          not be enabled unless needed.  

          Default value: FALSE  Since  2.10


     '_u_n_i_t' ['_G_t_k_U_n_i_t' : _R_e_a_d / _W_r_i_t_e] The transformation for the cairo
          context obtained from 'GtkPrintContext' is set up in such a
          way that distances  are measured in units of 'unit'.  

          Default value: GTK_UNIT_PIXEL  Since  2.10


     '_u_s_e-_f_u_l_l-_p_a_g_e' [_l_o_g_i_c_a_l : _R_e_a_d / _W_r_i_t_e] If 'TRUE', the
          transformation for the cairo context obtained  from
          'GtkPrintContext' puts the origin at the top left corner  of
          the page (which may not be the top left corner of the sheet, 
          depending on page orientation and the number of pages per
          sheet).  Otherwise, the origin is at the top left corner of
          the imageable  area (i.e. inside the margins).  

          Default value: FALSE  Since  2.10


_A_u_t_h_o_r(_s):

     Derived by RGtkGen from GTK+ documentation

_R_e_f_e_r_e_n_c_e_s:

     <URL:
     http://developer.gnome.org/doc/API/2.0/gtk/gtk-High-level-Printing-API.html>

_S_e_e _A_l_s_o:

     'GtkPrintContext'

