[]Struct gtk::PrintOperation

pub struct PrintOperation(_, _);

PrintOperation is the high-level, portable printing API. It looks a bit different than other GTK+ dialogs such as the FileChooser, since some platforms don’t expose enough infrastructure to implement a good print dialog. On such platforms, PrintOperation 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 PrintOperation object with PrintOperation::new when the user selects to print. Then you set some properties on it, e.g. the page size, any PrintSettings from previous print operations, the number of pages, the current page, etc.

Then you start the print operation by calling PrintOperationExt::run. 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 PrintOperation, the main one being PrintOperation::draw-page, which you are supposed to catch and render the page on the provided PrintContext using Cairo.

The high-level printing API

static GtkPrintSettings *settings = NULL;

static void
do_print (void)
{
  GtkPrintOperation *print;
  GtkPrintOperationResult res;

  print = gtk_print_operation_new ();

  if (settings != NULL)
    gtk_print_operation_set_print_settings (print, settings);

  g_signal_connect (print, "begin_print", G_CALLBACK (begin_print), NULL);
  g_signal_connect (print, "draw_page", G_CALLBACK (draw_page), NULL);

  res = gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
                                 GTK_WINDOW (main_window), NULL);

  if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
    {
      if (settings != NULL)
        g_object_unref (settings);
      settings = g_object_ref (gtk_print_operation_get_print_settings (print));
    }

  g_object_unref (print);
}

By default PrintOperation uses an external application to do print preview. To implement a custom print preview, an application must connect to the preview signal. The functions PrintOperationPreview::render_page, PrintOperationPreview::end_preview and PrintOperationPreview::is_selected are useful when implementing a print preview.

Implements

PrintOperationExt, glib::object::ObjectExt, PrintOperationPreviewExt

Implementations

impl PrintOperation[src]

pub fn new() -> PrintOperation[src]

Creates a new PrintOperation.

Returns

a new PrintOperation

Trait Implementations

impl Clone for PrintOperation

impl Debug for PrintOperation

impl Default for PrintOperation[src]

impl Display for PrintOperation[src]

impl Eq for PrintOperation

impl Hash for PrintOperation

impl IsA<PrintOperationPreview> for PrintOperation

impl Ord for PrintOperation

impl<T: ObjectType> PartialEq<T> for PrintOperation

impl<T: ObjectType> PartialOrd<T> for PrintOperation

impl StaticType for PrintOperation

Auto Trait Implementations

impl RefUnwindSafe for PrintOperation

impl !Send for PrintOperation

impl !Sync for PrintOperation

impl Unpin for PrintOperation

impl UnwindSafe for PrintOperation

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Super, Sub> CanDowncast<Sub> for Super where
    Sub: IsA<Super>,
    Super: IsA<Super>, 

impl<T> Cast for T where
    T: ObjectType, 

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ObjectExt for T where
    T: ObjectType, 

impl<'a, T> ToGlibContainerFromSlice<'a, *const GList> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<List>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *const GPtrArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<PtrArray>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<Array>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GList> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<List>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GPtrArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<PtrArray>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> ToValue for T where
    T: SetValue + ?Sized

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.