Main Page Widgets Namespaces Book

# Gtk::PrintOperation Class Reference
[Printing]

Inheritance diagram for Gtk::PrintOperation:

[legend]
List of all members.

## Detailed Description

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 PrintUnixDialog.

The typical way to use the high-level printing API is to create a PrintOperation object when the user chooses to print. Then you set some properties on it,such as 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 run(). It will then show a dialog to let the user select a printer and options. When the user finishes the dialog various signals will be emitted by the PrintOperation for you to handle, the main one being draw_page. You should then render the page on the provided PrintContext using Cairo.

Since gtkmm 2.10:

## Public Member Functions

void | cancel ()
Glib::RefPtr<PageSetup> | get_default_page_setup () const
Glib::RefPtr<PrintSettings> | get_print_settings () const
PrintStatus | get_status () const
Glib::ustring | get_status_string () const
const GtkPrintOperation* | gobj () const
| Provides access to the underlying C GObject.
GtkPrintOperation* | gobj ()
| Provides access to the underlying C GObject.
GtkPrintOperation* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
bool | is_finished () const
Glib::PropertyProxy_ReadOnly< bool > | property_allow_async () const
| TRUE if print process may run asynchronous.
Glib::PropertyProxy<bool> | property_allow_async ()
| TRUE if print process may run asynchronous.
Glib::PropertyProxy_ReadOnly< int > | property_current_page () const
| The current page in the document.
Glib::PropertyProxy<int> | property_current_page ()
| The current page in the document.
Glib::PropertyProxy_ReadOnly< Glib::ustring > | property_custom_tab_label () const
| Label for the tab containing custom widgets.
Glib::PropertyProxy<Glib::ustring> | property_custom_tab_label ()
| Label for the tab containing custom widgets.
Glib::PropertyProxy_ReadOnly< Glib::RefPtr<PageSetup >> | property_default_page_setup () const
| The GtkPageSetup used by default.
Glib::PropertyProxy< Glib::RefPtr< PageSetup > > | property_default_page_setup ()
| The GtkPageSetup used by default.
Glib::PropertyProxy_ReadOnly< std::string > | property_export_filename () const
| Export filename.
Glib::PropertyProxy<std::string> | property_export_filename ()
| Export filename.
Glib::PropertyProxy_ReadOnly< Glib::ustring > | property_job_name () const
| A string used for identifying the print job.
Glib::PropertyProxy<Glib::ustring> | property_job_name ()
| A string used for identifying the print job.
Glib::PropertyProxy_ReadOnly< int > | property_n_pages () const
| The number of pages in the document.
Glib::PropertyProxy<int> | property_n_pages ()
| The number of pages in the document.
Glib::PropertyProxy_ReadOnly< Glib::RefPtr<PrintSettings >> | property_print_settings () const
| The GtkPrintSettings used for initializing the dialog.
Glib::PropertyProxy< Glib::RefPtr< PrintSettings > > | property_print_settings ()
| The GtkPrintSettings used for initializing the dialog.
Glib::PropertyProxy_ReadOnly< bool > | property_show_progress () const
| TRUE if a progress dialog is shown while printing.
Glib::PropertyProxy<bool> | property_show_progress ()
| TRUE if a progress dialog is shown while printing.
Glib::PropertyProxy_ReadOnly< PrintStatus > | property_status () const
| The status of the print operation.
Glib::PropertyProxy_ReadOnly< Glib::ustring > | property_status_string () const
| A human-readable description of the status.
Glib::PropertyProxy_ReadOnly< Unit > | property_unit () const
| The unit in which distances can be measured in the context.
Glib::PropertyProxy<Unit> | property_unit ()
| The unit in which distances can be measured in the context.
Glib::PropertyProxy_ReadOnly< bool > | property_use_full_page () const
| TRUE if the the origin of the context should be at the corner of the page and not the corner of the imageable area.
Glib::PropertyProxy<bool> | property_use_full_page ()
| TRUE if the the origin of the context should be at the corner of the page and not the corner of the imageable area.
PrintOperationResult | run (PrintOperationAction action, Window& parent)
PrintOperationResult | run (PrintOperationAction action=PRINT_OPERATION_ACTION_PRINT_DIALOG)
void | set_allow_async (bool allow_async=true)
void | set_current_page (int current_page)
void | set_custom_tab_label (const Glib::ustring& label)
void | set_default_page_setup (const Glib::RefPtr<PageSetup>& default_page_setup)
void | set_export_filename (const std::string& filename)
void | set_job_name (const Glib::ustring& job_name)
void | set_n_pages (int n_pages)
void | set_print_settings (const Glib::RefPtr<PrintSettings>& print_settings)
void | set_show_progress (bool show_progress=true)
void | set_track_print_status (bool track_status=true)
void | set_unit (Unit unit)
void | set_use_full_page (bool use_full_page=true)
Glib::SignalProxy1< void, const Glib::RefPtr<PrintContext >&> | signal_begin_print ()
Glib::SignalProxy0<Widget*> | signal_create_custom_widget ()
Glib::SignalProxy1< void, Widget* > | signal_custom_widget_apply ()
Glib::SignalProxy1< void, PrintOperationResult > | signal_done ()
Glib::SignalProxy2< void, const Glib::RefPtr<PrintContext>&, int > | signal_draw_page ()
Glib::SignalProxy1< void, const Glib::RefPtr<PrintContext >&> | signal_end_print ()
Glib::SignalProxy1< bool, const Glib::RefPtr<PrintContext >&> | signal_paginate ()
Glib::SignalProxy3< bool, const Glib::RefPtr<PrintOperationPreview>&, const Glib::RefPtr<PrintContext>&, Window* > | signal_preview ()
Glib::SignalProxy3< void, const Glib::RefPtr<PrintContext>&, int, const Glib::RefPtr< PageSetup >& > | signal_request_page_setup ()
Glib::SignalProxy0<void> | signal_status_changed ()
virtual | ~PrintOperation ()

## Static Public Member Functions

static Glib::RefPtr<PrintOperation> | create ()

## Protected Member Functions

virtual void | on_begin_print (const Glib::RefPtr<PrintContext>& context)
virtual Widget* | on_create_custom_widget ()
virtual void | on_custom_widget_apply (Widget* widget)
virtual void | on_done (PrintOperationResult result)
virtual void | on_draw_page (const Glib::RefPtr<PrintContext>& context, int page_nr)
virtual void | on_end_print (const Glib::RefPtr<PrintContext>& context)
virtual bool | on_paginate (const Glib::RefPtr<PrintContext>& context)
virtual bool | on_preview (const Glib::RefPtr<PrintOperationPreview>& preview, const Glib::RefPtr<PrintContext>& context, Window* parent)
virtual void | on_request_page_setup (const Glib::RefPtr<PrintContext>& context, int page_no, const Glib::RefPtr<PageSetup>& setup)
virtual void | on_status_changed ()
| PrintOperation ()

## Related Functions

(Note that these are not member functions.)
Glib::RefPtr<Gtk::PrintOperation> | wrap (GtkPrintOperation* object, bool take_copy=false)

## Constructor & Destructor Documentation

virtual Gtk::PrintOperation::~PrintOperation | ( |  | ) | `[virtual]`

Gtk::PrintOperation::PrintOperation | ( |  | ) | `[protected]`

## Member Function Documentation

void Gtk::PrintOperation::cancel | ( |  | ) |

static Glib::RefPtr<PrintOperation> Gtk::PrintOperation::create | ( |  | ) | `[static]`

Glib::RefPtr<PageSetup> Gtk::PrintOperation::get_default_page_setup | ( |  | ) | const

Glib::RefPtr<PrintSettings> Gtk::PrintOperation::get_print_settings | ( |  | ) | const

PrintStatus Gtk::PrintOperation::get_status | ( |  | ) | const

Glib::ustring Gtk::PrintOperation::get_status_string | ( |  | ) | const

const GtkPrintOperation* Gtk::PrintOperation::gobj | ( |  | ) | const`[inline]`

| Provides access to the underlying C GObject. Reimplemented from Gtk::PrintOperationPreview.

GtkPrintOperation* Gtk::PrintOperation::gobj | ( |  | ) | `[inline]`

| Provides access to the underlying C GObject. Reimplemented from Gtk::PrintOperationPreview.

GtkPrintOperation* Gtk::PrintOperation::gobj_copy | ( |  | ) |

| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

bool Gtk::PrintOperation::is_finished | ( |  | ) | const

virtual void Gtk::PrintOperation::on_begin_print | ( | const Glib::RefPtr<PrintContext>& | context | ) | `[protected, virtual]`

virtual Widget* Gtk::PrintOperation::on_create_custom_widget | ( |  | ) | `[protected, virtual]`

virtual void Gtk::PrintOperation::on_custom_widget_apply | ( | Widget* | widget | ) | `[protected, virtual]`

virtual void Gtk::PrintOperation::on_done | ( | PrintOperationResult | result | ) | `[protected, virtual]`

virtual void Gtk::PrintOperation::on_draw_page | ( | const Glib::RefPtr<PrintContext>& | context,
|  | int | page_nr
| ) | `[protected, virtual]`

virtual void Gtk::PrintOperation::on_end_print | ( | const Glib::RefPtr<PrintContext>& | context | ) | `[protected, virtual]`

virtual bool Gtk::PrintOperation::on_paginate | ( | const Glib::RefPtr<PrintContext>& | context | ) | `[protected, virtual]`

virtual bool Gtk::PrintOperation::on_preview | ( | const Glib::RefPtr<PrintOperationPreview>& | preview,
|  | const Glib::RefPtr<PrintContext>& | context,
|  | Window* | parent
| ) | `[protected, virtual]`

virtual void Gtk::PrintOperation::on_request_page_setup | ( | const Glib::RefPtr<PrintContext>& | context,
|  | int | page_no,
|  | const Glib::RefPtr<PageSetup>& | setup
| ) | `[protected, virtual]`

virtual void Gtk::PrintOperation::on_status_changed | ( |  | ) | `[protected, virtual]`

Glib::PropertyProxy_ReadOnly<bool> Gtk::PrintOperation::property_allow_async | ( |  | ) | const

TRUE if print process may run asynchronous.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<bool> Gtk::PrintOperation::property_allow_async | ( |  | ) |

TRUE if print process may run asynchronous.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<int> Gtk::PrintOperation::property_current_page | ( |  | ) | const

The current page in the document.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<int> Gtk::PrintOperation::property_current_page | ( |  | ) |

The current page in the document.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<Glib::ustring> Gtk::PrintOperation::property_custom_tab_label | ( |  | ) | const

Label for the tab containing custom widgets.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<Glib::ustring> Gtk::PrintOperation::property_custom_tab_label | ( |  | ) |

Label for the tab containing custom widgets.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<Glib::RefPtr<PageSetup>> Gtk::PrintOperation::property_default_page_setup | ( |  | ) | const

The GtkPageSetup used by default.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<Glib::RefPtr<PageSetup>> Gtk::PrintOperation::property_default_page_setup | ( |  | ) |

The GtkPageSetup used by default.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<std::string> Gtk::PrintOperation::property_export_filename | ( |  | ) | const

Export filename.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<std::string> Gtk::PrintOperation::property_export_filename | ( |  | ) |

Export filename.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<Glib::ustring> Gtk::PrintOperation::property_job_name | ( |  | ) | const

A string used for identifying the print job.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<Glib::ustring> Gtk::PrintOperation::property_job_name | ( |  | ) |

A string used for identifying the print job.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<int> Gtk::PrintOperation::property_n_pages | ( |  | ) | const

The number of pages in the document.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<int> Gtk::PrintOperation::property_n_pages | ( |  | ) |

The number of pages in the document.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<Glib::RefPtr<PrintSettings>> Gtk::PrintOperation::property_print_settings | ( |  | ) | const

The GtkPrintSettings used for initializing the dialog.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<Glib::RefPtr<PrintSettings>> Gtk::PrintOperation::property_print_settings | ( |  | ) |

The GtkPrintSettings used for initializing the dialog.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<bool> Gtk::PrintOperation::property_show_progress | ( |  | ) | const

TRUE if a progress dialog is shown while printing.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<bool> Gtk::PrintOperation::property_show_progress | ( |  | ) |

TRUE if a progress dialog is shown while printing.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<PrintStatus> Gtk::PrintOperation::property_status | ( |  | ) | const

The status of the print operation.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<Glib::ustring> Gtk::PrintOperation::property_status_string | ( |  | ) | const

A human-readable description of the status.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<Unit> Gtk::PrintOperation::property_unit | ( |  | ) | const

The unit in which distances can be measured in the context.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<Unit> Gtk::PrintOperation::property_unit | ( |  | ) |

The unit in which distances can be measured in the context.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<bool> Gtk::PrintOperation::property_use_full_page | ( |  | ) | const

TRUE if the the origin of the context should be at the corner of the page and not the corner of the imageable area.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<bool> Gtk::PrintOperation::property_use_full_page | ( |  | ) |

TRUE if the the origin of the context should be at the corner of the page and not the corner of the imageable area.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

PrintOperationResult Gtk::PrintOperation::run | ( | PrintOperationAction | action,
|  | Window& | parent
| ) |

PrintOperationResult Gtk::PrintOperation::run | ( | PrintOperationAction | action = `PRINT_OPERATION_ACTION_PRINT_DIALOG` | ) |

void Gtk::PrintOperation::set_allow_async | ( | bool | allow_async = `true` | ) |

void Gtk::PrintOperation::set_current_page | ( | int | current_page | ) |

void Gtk::PrintOperation::set_custom_tab_label | ( | const Glib::ustring& | label | ) |

void Gtk::PrintOperation::set_default_page_setup | ( | const Glib::RefPtr<PageSetup>& | default_page_setup | ) |

void Gtk::PrintOperation::set_export_filename | ( | const std::string& | filename | ) |

void Gtk::PrintOperation::set_job_name | ( | const Glib::ustring& | job_name | ) |

void Gtk::PrintOperation::set_n_pages | ( | int | n_pages | ) |

void Gtk::PrintOperation::set_print_settings | ( | const Glib::RefPtr<PrintSettings>& | print_settings | ) |

void Gtk::PrintOperation::set_show_progress | ( | bool | show_progress = `true` | ) |

void Gtk::PrintOperation::set_track_print_status | ( | bool | track_status = `true` | ) |

void Gtk::PrintOperation::set_unit | ( | Unit | unit | ) |

void Gtk::PrintOperation::set_use_full_page | ( | bool | use_full_page = `true` | ) |

Glib::SignalProxy1<void,const Glib::RefPtr<PrintContext>&> Gtk::PrintOperation::signal_begin_print | ( |  | ) |

Prototype:
  `void begin_print(const Glib::RefPtr<PrintContext>& context)`

Glib::SignalProxy0<Widget*> Gtk::PrintOperation::signal_create_custom_widget | ( |  | ) |

Prototype:
  `Widget* create_custom_widget()`

Glib::SignalProxy1<void,Widget*> Gtk::PrintOperation::signal_custom_widget_apply | ( |  | ) |

Prototype:
  `void custom_widget_apply(Widget* widget)`

Glib::SignalProxy1<void,PrintOperationResult> Gtk::PrintOperation::signal_done | ( |  | ) |

Prototype:
  `void done(PrintOperationResult result)`

Glib::SignalProxy2<void,const Glib::RefPtr<PrintContext>&,int> Gtk::PrintOperation::signal_draw_page | ( |  | ) |

Prototype:
  `void draw_page(const Glib::RefPtr<PrintContext>& context, int page_nr)`

Glib::SignalProxy1<void,const Glib::RefPtr<PrintContext>&> Gtk::PrintOperation::signal_end_print | ( |  | ) |

Prototype:
  `void end_print(const Glib::RefPtr<PrintContext>& context)`

Glib::SignalProxy1<bool,const Glib::RefPtr<PrintContext>&> Gtk::PrintOperation::signal_paginate | ( |  | ) |

Prototype:
  `bool paginate(const Glib::RefPtr<PrintContext>& context)`

Glib::SignalProxy3<bool,const Glib::RefPtr<PrintOperationPreview>&,const Glib::RefPtr<PrintContext>&,Window*> Gtk::PrintOperation::signal_preview | ( |  | ) |

Prototype:
  `bool preview(const Glib::RefPtr<PrintOperationPreview>& preview, const Glib::RefPtr<PrintContext>& context, Window* parent)`

Glib::SignalProxy3<void,const Glib::RefPtr<PrintContext>&,int,const Glib::RefPtr<PageSetup>&> Gtk::PrintOperation::signal_request_page_setup | ( |  | ) |

Prototype:
  `void request_page_setup(const Glib::RefPtr<PrintContext>& context, int page_no, const Glib::RefPtr<PageSetup>& setup)`

Glib::SignalProxy0<void> Gtk::PrintOperation::signal_status_changed | ( |  | ) |

Prototype:
  `void status_changed()`

## Friends And Related Function Documentation

Glib::RefPtr<Gtk::PrintOperation> wrap | ( | GtkPrintOperation* | object,
|  | bool | take_copy = `false`
| ) | `[related]`

Parameters:

  | object | The C instance
  | take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns:
  A C++ instance that wraps this C instance.

The documentation for this class was generated from the following file:

- printoperation.h