Evince
Evince is a document viewer capable of displaying multiple and single page document formats like PDF and Postscript.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ev-print-operation.c File Reference
#include <config.h>
#include "ev-print-operation.h"
#include <glib/gi18n.h>
#include <glib/gstdio.h>
#include <unistd.h>
#include "ev-jobs.h"
#include "ev-job-scheduler.h"
+ Include dependency graph for ev-print-operation.c:

Go to the source code of this file.

Data Structures

struct  _EvPrintOperation
 
struct  _EvPrintOperationClass
 
struct  _EvPrintOperationPrint
 
struct  _EvPrintOperationPrintClass
 

Macros

#define EV_TYPE_PRINT_OPERATION_PRINT   (ev_print_operation_print_get_type())
 
#define EV_PRINT_OPERATION_PRINT(object)   (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_PRINT_OPERATION_PRINT, EvPrintOperationPrint))
 
#define EV_PRINT_OPERATION_PRINT_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_PRINT_OPERATION_PRINT, EvPrintOperationPrintClass))
 
#define EV_IS_PRINT_OPERATION_PRINT(object)   (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_PRINT_OPERATION_PRINT))
 
#define EV_PRINT_SETTING_PAGE_SCALE   "evince-print-setting-page-scale"
 
#define EV_PRINT_SETTING_AUTOROTATE   "evince-print-setting-page-autorotate"
 
#define EV_PRINT_SETTING_PAGE_SIZE   "evince-print-setting-page-size"
 

Typedefs

typedef struct
_EvPrintOperationPrint 
EvPrintOperationPrint
 
typedef struct
_EvPrintOperationPrintClass 
EvPrintOperationPrintClass
 

Enumerations

enum  { PROP_0, PROP_DOCUMENT }
 
enum  { DONE, BEGIN_PRINT, STATUS_CHANGED, LAST_SIGNAL }
 

Functions

static void ev_print_operation_finalize (GObject *object)
 
static void ev_print_operation_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
 
static void ev_print_operation_init (EvPrintOperation *op)
 
static void ev_print_operation_class_init (EvPrintOperationClass *klass)
 
void ev_print_operation_set_current_page (EvPrintOperation *op, gint current_page)
 
void ev_print_operation_set_print_settings (EvPrintOperation *op, GtkPrintSettings *print_settings)
 
GtkPrintSettings * ev_print_operation_get_print_settings (EvPrintOperation *op)
 
void ev_print_operation_set_default_page_setup (EvPrintOperation *op, GtkPageSetup *page_setup)
 
GtkPageSetup * ev_print_operation_get_default_page_setup (EvPrintOperation *op)
 
void ev_print_operation_set_job_name (EvPrintOperation *op, const gchar *job_name)
 
const gchar * ev_print_operation_get_job_name (EvPrintOperation *op)
 
void ev_print_operation_run (EvPrintOperation *op, GtkWindow *parent)
 
void ev_print_operation_cancel (EvPrintOperation *op)
 
void ev_print_operation_get_error (EvPrintOperation *op, GError **error)
 
void ev_print_operation_set_embed_page_setup (EvPrintOperation *op, gboolean embed)
 
gboolean ev_print_operation_get_embed_page_setup (EvPrintOperation *op)
 
const gchar * ev_print_operation_get_status (EvPrintOperation *op)
 
gdouble ev_print_operation_get_progress (EvPrintOperation *op)
 
static void ev_print_operation_update_status (EvPrintOperation *op, gint page, gint n_pages, gdouble progress)
 
static GType ev_print_operation_print_get_type (void)
 
static void ev_print_operation_print_set_current_page (EvPrintOperation *op, gint current_page)
 
static void ev_print_operation_print_set_print_settings (EvPrintOperation *op, GtkPrintSettings *print_settings)
 
static GtkPrintSettings * ev_print_operation_print_get_print_settings (EvPrintOperation *op)
 
static void ev_print_operation_print_set_default_page_setup (EvPrintOperation *op, GtkPageSetup *page_setup)
 
static GtkPageSetup * ev_print_operation_print_get_default_page_setup (EvPrintOperation *op)
 
static void ev_print_operation_print_set_job_name (EvPrintOperation *op, const gchar *job_name)
 
static const gchar * ev_print_operation_print_get_job_name (EvPrintOperation *op)
 
static void ev_print_operation_print_run (EvPrintOperation *op, GtkWindow *parent)
 
static void ev_print_operation_print_cancel (EvPrintOperation *op)
 
static void ev_print_operation_print_get_error (EvPrintOperation *op, GError **error)
 
static void ev_print_operation_print_set_embed_page_setup (EvPrintOperation *op, gboolean embed)
 
static gboolean ev_print_operation_print_get_embed_page_setup (EvPrintOperation *op)
 
static void ev_print_operation_print_begin_print (EvPrintOperationPrint *print, GtkPrintContext *context)
 
static void ev_print_operation_print_done (EvPrintOperationPrint *print, GtkPrintOperationResult result)
 
static void ev_print_operation_print_status_changed (EvPrintOperationPrint *print)
 
static void print_job_finished (EvJobPrint *job, EvPrintOperationPrint *print)
 
static gboolean draw_page_finish_idle (EvPrintOperationPrint *print)
 
static void print_job_cancelled (EvJobPrint *job, EvPrintOperationPrint *print)
 
static void ev_print_operation_print_request_page_setup (EvPrintOperationPrint *print, GtkPrintContext *context, gint page_nr, GtkPageSetup *setup)
 
static void _print_context_get_hard_margins (GtkPrintContext *context, gdouble *top, gdouble *bottom, gdouble *left, gdouble *right)
 
static void ev_print_operation_print_get_scaled_page_size (EvPrintOperationPrint *print, gint page, gdouble *width, gdouble *height, gdouble *manual_scale)
 
static void ev_print_operation_print_draw_page (EvPrintOperationPrint *print, GtkPrintContext *context, gint page)
 
static GObject * ev_print_operation_print_create_custom_widget (EvPrintOperationPrint *print, GtkPrintContext *context)
 
static void ev_print_operation_print_custom_widget_apply (EvPrintOperationPrint *print, GtkPrintContext *context)
 
static gboolean ev_print_operation_print_preview (EvPrintOperationPrint *print)
 
static void ev_print_operation_print_finalize (GObject *object)
 
static void ev_print_operation_print_init (EvPrintOperationPrint *print)
 
static void ev_print_operation_print_class_init (EvPrintOperationPrintClass *klass)
 
gboolean ev_print_operation_exists_for_document (EvDocument *document)
 
EvPrintOperationev_print_operation_new (EvDocument *document)
 

Variables

static guint signals [LAST_SIGNAL] = { 0 }
 
 EvPrintScale
 

Macro Definition Documentation

#define EV_IS_PRINT_OPERATION_PRINT (   object)    (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_PRINT_OPERATION_PRINT))

Definition at line 1549 of file ev-print-operation.c.

#define EV_PRINT_OPERATION_PRINT (   object)    (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_PRINT_OPERATION_PRINT, EvPrintOperationPrint))

Definition at line 1547 of file ev-print-operation.c.

#define EV_PRINT_OPERATION_PRINT_CLASS (   klass)    (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_PRINT_OPERATION_PRINT, EvPrintOperationPrintClass))

Definition at line 1548 of file ev-print-operation.c.

#define EV_PRINT_SETTING_AUTOROTATE   "evince-print-setting-page-autorotate"

Definition at line 1563 of file ev-print-operation.c.

#define EV_PRINT_SETTING_PAGE_SCALE   "evince-print-setting-page-scale"

Definition at line 1562 of file ev-print-operation.c.

#define EV_PRINT_SETTING_PAGE_SIZE   "evince-print-setting-page-size"

Definition at line 1564 of file ev-print-operation.c.

#define EV_TYPE_PRINT_OPERATION_PRINT   (ev_print_operation_print_get_type())

Definition at line 1546 of file ev-print-operation.c.

Typedef Documentation

Definition at line 1551 of file ev-print-operation.c.

Enumeration Type Documentation

anonymous enum
Enumerator
PROP_0 
PROP_DOCUMENT 

Definition at line 34 of file ev-print-operation.c.

34  {
35  PROP_0,
37 };
anonymous enum
Enumerator
DONE 
BEGIN_PRINT 
STATUS_CHANGED 
LAST_SIGNAL 

Definition at line 39 of file ev-print-operation.c.

39  {
40  DONE,
44 };

Function Documentation

static void _print_context_get_hard_margins ( GtkPrintContext *  context,
gdouble *  top,
gdouble *  bottom,
gdouble *  left,
gdouble *  right 
)
static

Definition at line 1813 of file ev-print-operation.c.

1818 {
1819  if (!gtk_print_context_get_hard_margins (context, top, bottom, left, right)) {
1820  *top = 0;
1821  *bottom = 0;
1822  *left = 0;
1823  *right = 0;
1824  }
1825 }

+ Here is the caller graph for this function:

static gboolean draw_page_finish_idle ( EvPrintOperationPrint print)
static

Definition at line 1759 of file ev-print-operation.c.

1760 {
1762  return TRUE;
1763 
1764  gtk_print_operation_draw_page_finish (print->op);
1765 
1766  return FALSE;
1767 }

+ Here is the caller graph for this function:

void ev_print_operation_cancel ( EvPrintOperation op)

Definition at line 279 of file ev-print-operation.c.

280 {
281  EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op);
282 
283  g_return_if_fail (EV_IS_PRINT_OPERATION (op));
284 
285  class->cancel (op);
286 }

+ Here is the caller graph for this function:

static void ev_print_operation_class_init ( EvPrintOperationClass klass)
static

Definition at line 133 of file ev-print-operation.c.

134 {
135  GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
136 
137  g_object_class->set_property = ev_print_operation_set_property;
138  g_object_class->finalize = ev_print_operation_finalize;
139 
140  g_object_class_install_property (g_object_class,
142  g_param_spec_object ("document",
143  "Document",
144  "The document to print",
146  G_PARAM_WRITABLE |
147  G_PARAM_CONSTRUCT_ONLY |
148  G_PARAM_STATIC_STRINGS));
149  signals[DONE] =
150  g_signal_new ("done",
151  G_TYPE_FROM_CLASS (g_object_class),
152  G_SIGNAL_RUN_LAST,
153  G_STRUCT_OFFSET (EvPrintOperationClass, done),
154  NULL, NULL,
155  g_cclosure_marshal_VOID__ENUM,
156  G_TYPE_NONE, 1,
157  GTK_TYPE_PRINT_OPERATION_RESULT);
159  g_signal_new ("begin_print",
160  G_TYPE_FROM_CLASS (g_object_class),
161  G_SIGNAL_RUN_LAST,
162  G_STRUCT_OFFSET (EvPrintOperationClass, begin_print),
163  NULL, NULL,
164  g_cclosure_marshal_VOID__VOID,
165  G_TYPE_NONE, 0);
167  g_signal_new ("status_changed",
168  G_TYPE_FROM_CLASS (g_object_class),
169  G_SIGNAL_RUN_LAST,
170  G_STRUCT_OFFSET (EvPrintOperationClass, status_changed),
171  NULL, NULL,
172  g_cclosure_marshal_VOID__VOID,
173  G_TYPE_NONE, 0);
174 }
gboolean ev_print_operation_exists_for_document ( EvDocument document)

Definition at line 2122 of file ev-print-operation.c.

2123 {
2124 #if GTKUNIXPRINT_ENABLED
2125  return (EV_IS_FILE_EXPORTER(document) || EV_IS_DOCUMENT_PRINT(document));
2126 #else
2127  return EV_IS_DOCUMENT_PRINT(document);
2128 #endif /* GTKUNIXPRINT_ENABLED */
2129 }

+ Here is the caller graph for this function:

static void ev_print_operation_finalize ( GObject *  object)
static

Definition at line 93 of file ev-print-operation.c.

94 {
95  EvPrintOperation *op = EV_PRINT_OPERATION (object);
96 
97  if (op->document) {
98  g_object_unref (op->document);
99  op->document = NULL;
100  }
101 
102  if (op->status) {
103  g_free (op->status);
104  op->status = NULL;
105  }
106 
107  (* G_OBJECT_CLASS (ev_print_operation_parent_class)->finalize) (object);
108 }

+ Here is the caller graph for this function:

GtkPageSetup* ev_print_operation_get_default_page_setup ( EvPrintOperation op)

ev_print_operation_get_default_page_setup: : an EvPrintOperation

Returns: (transfer none): a #GtkPageSetup

Definition at line 236 of file ev-print-operation.c.

237 {
238  EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op);
239 
240  g_return_val_if_fail (EV_IS_PRINT_OPERATION (op), NULL);
241 
242  return class->get_default_page_setup (op);
243 }

+ Here is the caller graph for this function:

gboolean ev_print_operation_get_embed_page_setup ( EvPrintOperation op)

Definition at line 311 of file ev-print-operation.c.

312 {
313  EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op);
314 
315  g_return_val_if_fail (EV_IS_PRINT_OPERATION (op), FALSE);
316 
317  return class->get_embed_page_setup (op);
318 }

+ Here is the caller graph for this function:

void ev_print_operation_get_error ( EvPrintOperation op,
GError **  error 
)

Definition at line 289 of file ev-print-operation.c.

291 {
292  EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op);
293 
294  g_return_if_fail (EV_IS_PRINT_OPERATION (op));
295 
296  class->get_error (op, error);
297 }

+ Here is the caller graph for this function:

const gchar* ev_print_operation_get_job_name ( EvPrintOperation op)

Definition at line 258 of file ev-print-operation.c.

259 {
260  EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op);
261 
262  g_return_val_if_fail (EV_IS_PRINT_OPERATION (op), NULL);
263 
264  return class->get_job_name (op);
265 }

+ Here is the caller graph for this function:

GtkPrintSettings* ev_print_operation_get_print_settings ( EvPrintOperation op)

ev_print_operation_get_print_settings: : an EvPrintOperation

Returns: (transfer none): a #GtkPrintSettings

Definition at line 208 of file ev-print-operation.c.

209 {
210  EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op);
211 
212  g_return_val_if_fail (EV_IS_PRINT_OPERATION (op), NULL);
213 
214  return class->get_print_settings (op);
215 }

+ Here is the caller graph for this function:

gdouble ev_print_operation_get_progress ( EvPrintOperation op)

Definition at line 329 of file ev-print-operation.c.

330 {
331  g_return_val_if_fail (EV_IS_PRINT_OPERATION (op), 0.0);
332 
333  return op->progress;
334 }

+ Here is the caller graph for this function:

const gchar* ev_print_operation_get_status ( EvPrintOperation op)

Definition at line 321 of file ev-print-operation.c.

322 {
323  g_return_val_if_fail (EV_IS_PRINT_OPERATION (op), NULL);
324 
325  return op->status ? op->status : "";
326 }

+ Here is the caller graph for this function:

static void ev_print_operation_init ( EvPrintOperation op)
static

Definition at line 128 of file ev-print-operation.c.

129 {
130 }
EvPrintOperation* ev_print_operation_new ( EvDocument document)

Definition at line 2133 of file ev-print-operation.c.

2134 {
2135  EvPrintOperation *op = NULL;
2136 
2137  g_return_val_if_fail (ev_print_operation_exists_for_document (document), NULL);
2138 
2139  if (EV_IS_DOCUMENT_PRINT (document))
2141  "document", document, NULL));
2142  else
2143 #if GTKUNIXPRINT_ENABLED
2144  op = EV_PRINT_OPERATION (g_object_new (EV_TYPE_PRINT_OPERATION_EXPORT,
2145  "document", document, NULL));
2146 #else
2147  op = NULL;
2148 #endif
2149  return op;
2150 }

+ Here is the caller graph for this function:

static void ev_print_operation_print_begin_print ( EvPrintOperationPrint print,
GtkPrintContext *  context 
)
static

Definition at line 1709 of file ev-print-operation.c.

1711 {
1712  EvPrintOperation *op = EV_PRINT_OPERATION (print);
1713  gint n_pages;
1714 
1715  n_pages = ev_document_get_n_pages (op->document);
1716  gtk_print_operation_set_n_pages (print->op, n_pages);
1717  ev_print_operation_update_status (op, -1, n_pages, 0);
1718 
1719  g_signal_emit (op, signals[BEGIN_PRINT], 0);
1720 }

+ Here is the caller graph for this function:

static void ev_print_operation_print_cancel ( EvPrintOperation op)
static

Definition at line 1672 of file ev-print-operation.c.

1673 {
1675 
1676  if (print->job_print)
1677  ev_job_cancel (print->job_print);
1678  else
1679  gtk_print_operation_cancel (print->op);
1680 }

+ Here is the caller graph for this function:

static void ev_print_operation_print_class_init ( EvPrintOperationPrintClass klass)
static

Definition at line 2100 of file ev-print-operation.c.

2101 {
2102  GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
2103  EvPrintOperationClass *ev_print_op_class = EV_PRINT_OPERATION_CLASS (klass);
2104 
2112  ev_print_op_class->run = ev_print_operation_print_run;
2113  ev_print_op_class->cancel = ev_print_operation_print_cancel;
2114  ev_print_op_class->get_error = ev_print_operation_print_get_error;
2117 
2118  g_object_class->finalize = ev_print_operation_print_finalize;
2119 }
static GObject* ev_print_operation_print_create_custom_widget ( EvPrintOperationPrint print,
GtkPrintContext *  context 
)
static

Definition at line 1937 of file ev-print-operation.c.

1939 {
1940  GtkPrintSettings *settings;
1941  GtkWidget *label;
1942  GtkWidget *grid;
1943  EvPrintScale page_scale;
1944  gboolean autorotate;
1945  gboolean use_source_size;
1946 
1947  settings = gtk_print_operation_get_print_settings (print->op);
1948  page_scale = gtk_print_settings_get_int_with_default (settings, EV_PRINT_SETTING_PAGE_SCALE, 1);
1949  autorotate = gtk_print_settings_has_key (settings, EV_PRINT_SETTING_AUTOROTATE) ?
1950  gtk_print_settings_get_bool (settings, EV_PRINT_SETTING_AUTOROTATE) :
1951  TRUE;
1952  use_source_size = gtk_print_settings_get_bool (settings, EV_PRINT_SETTING_PAGE_SIZE);
1953 
1954  grid = gtk_grid_new ();
1955  gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
1956  gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
1957  gtk_container_set_border_width (GTK_CONTAINER (grid), 12);
1958 
1959  label = gtk_label_new (_("Page Scaling:"));
1960  gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);
1961  gtk_widget_show (label);
1962 
1963  print->scale_combo = gtk_combo_box_text_new ();
1964  /* translators: Value for 'Page Scaling:' to not scale the document pages on printing */
1965  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (print->scale_combo), _("None"));
1966  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (print->scale_combo), _("Shrink to Printable Area"));
1967  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (print->scale_combo), _("Fit to Printable Area"));
1968  gtk_combo_box_set_active (GTK_COMBO_BOX (print->scale_combo), page_scale);
1969  gtk_widget_set_tooltip_text (print->scale_combo,
1970  _("Scale document pages to fit the selected printer page. Select from one of the following:\n"
1971  "\n"
1972  "• “None”: No page scaling is performed.\n"
1973  "\n"
1974  "• “Shrink to Printable Area”: Document pages larger than the printable area"
1975  " are reduced to fit the printable area of the printer page.\n"
1976  "\n"
1977  "• “Fit to Printable Area”: Document pages are enlarged or reduced as"
1978  " required to fit the printable area of the printer page.\n"));
1979  gtk_grid_attach (GTK_GRID (grid), print->scale_combo, 1, 0, 1, 1);
1980  gtk_widget_show (print->scale_combo);
1981 
1982  print->autorotate_button = gtk_check_button_new_with_label (_("Auto Rotate and Center"));
1983  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (print->autorotate_button), autorotate);
1984  gtk_widget_set_tooltip_text (print->autorotate_button,
1985  _("Rotate printer page orientation of each page to match orientation of each document page. "
1986  "Document pages will be centered within the printer page."));
1987  gtk_grid_attach (GTK_GRID (grid), print->autorotate_button, 0, 1, 2, 1);
1988  gtk_widget_show (print->autorotate_button);
1989 
1990  print->source_button = gtk_check_button_new_with_label (_("Select page size using document page size"));
1991  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (print->source_button), use_source_size);
1992  gtk_widget_set_tooltip_text (print->source_button, _("When enabled, each page will be printed on "
1993  "the same size paper as the document page."));
1994  gtk_grid_attach (GTK_GRID (grid), print->source_button, 0, 2, 2, 1);
1995  gtk_widget_show (print->source_button);
1996 
1997  return G_OBJECT (grid);
1998 }

+ Here is the caller graph for this function:

static void ev_print_operation_print_custom_widget_apply ( EvPrintOperationPrint print,
GtkPrintContext *  context 
)
static

Definition at line 2001 of file ev-print-operation.c.

2003 {
2004  GtkPrintSettings *settings;
2005 
2006  print->page_scale = gtk_combo_box_get_active (GTK_COMBO_BOX (print->scale_combo));
2007  print->autorotate = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (print->autorotate_button));
2008  print->use_source_size = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (print->source_button));
2009  settings = gtk_print_operation_get_print_settings (print->op);
2010  gtk_print_settings_set_int (settings, EV_PRINT_SETTING_PAGE_SCALE, print->page_scale);
2011  gtk_print_settings_set_bool (settings, EV_PRINT_SETTING_AUTOROTATE, print->autorotate);
2012  gtk_print_settings_set_bool (settings, EV_PRINT_SETTING_PAGE_SIZE, print->use_source_size);
2013 }

+ Here is the caller graph for this function:

static void ev_print_operation_print_done ( EvPrintOperationPrint print,
GtkPrintOperationResult  result 
)
static

Definition at line 1723 of file ev-print-operation.c.

1725 {
1726  EvPrintOperation *op = EV_PRINT_OPERATION (print);
1727 
1729 
1730  g_signal_emit (op, signals[DONE], 0, result);
1731 }

+ Here is the caller graph for this function:

static void ev_print_operation_print_draw_page ( EvPrintOperationPrint print,
GtkPrintContext *  context,
gint  page 
)
static

Definition at line 1849 of file ev-print-operation.c.

1852 {
1853  EvPrintOperation *op = EV_PRINT_OPERATION (print);
1854  cairo_t *cr;
1855  gdouble cr_width, cr_height;
1856  gdouble width, height, manual_scale, scale;
1857  gdouble x_scale, y_scale;
1858  gdouble x_offset, y_offset;
1859  gdouble top, bottom, left, right;
1860 
1861  gtk_print_operation_set_defer_drawing (print->op);
1862 
1863  if (!print->job_print) {
1864  print->job_print = ev_job_print_new (op->document);
1865  g_signal_connect (G_OBJECT (print->job_print), "finished",
1866  G_CALLBACK (print_job_finished),
1867  (gpointer)print);
1868  g_signal_connect (G_OBJECT (print->job_print), "cancelled",
1869  G_CALLBACK (print_job_cancelled),
1870  (gpointer)print);
1871  } else if (g_cancellable_is_cancelled (print->job_print->cancellable)) {
1872  gtk_print_operation_cancel (print->op);
1874  return;
1875  }
1876 
1877  ev_job_print_set_page (EV_JOB_PRINT (print->job_print), page);
1878 
1879  cr = gtk_print_context_get_cairo_context (context);
1880  cr_width = gtk_print_context_get_width (context);
1881  cr_height = gtk_print_context_get_height (context);
1882  ev_print_operation_print_get_scaled_page_size (print, page, &width, &height, &manual_scale);
1883 
1884  if (print->page_scale == EV_SCALE_NONE) {
1885  /* Center document page on the printed page */
1886  if (print->autorotate) {
1887  x_offset = (cr_width - width) / (2 * manual_scale);
1888  y_offset = (cr_height - height) / (2 * manual_scale);
1889  cairo_translate (cr, x_offset, y_offset);
1890  }
1891  } else {
1892  _print_context_get_hard_margins (context, &top, &bottom, &left, &right);
1893 
1894  x_scale = (cr_width - left - right) / width;
1895  y_scale = (cr_height - top - bottom) / height;
1896  scale = MIN (x_scale, y_scale);
1897 
1898  /* Ignore scale > 1 when shrinking to printable area */
1899  if (scale > 1.0 && print->page_scale == EV_SCALE_SHRINK_TO_PRINTABLE_AREA)
1900  scale = 1.0;
1901 
1902  if (print->autorotate) {
1903  x_offset = (cr_width - scale * width) / (2 * manual_scale);
1904  y_offset = (cr_height - scale * height) / (2 * manual_scale);
1905  cairo_translate (cr, x_offset, y_offset);
1906 
1907  /* Ensure document page is within the margins. The
1908  * scale guarantees the document will fit in the
1909  * margins so we just need to check each side and
1910  * if it overhangs the margin, translate it to the
1911  * margin. */
1912  if (x_offset < left)
1913  cairo_translate (cr, left - x_offset, 0);
1914 
1915  if (x_offset < right)
1916  cairo_translate (cr, -(right - x_offset), 0);
1917 
1918  if (y_offset < top)
1919  cairo_translate (cr, 0, top - y_offset);
1920 
1921  if (y_offset < bottom)
1922  cairo_translate (cr, 0, -(bottom - y_offset));
1923  } else {
1924  cairo_translate (cr, left, top);
1925  }
1926 
1927  if (print->page_scale == EV_SCALE_FIT_TO_PRINTABLE_AREA || scale < 1.0) {
1928  cairo_scale (cr, scale, scale);
1929  }
1930  }
1931 
1934 }

+ Here is the caller graph for this function:

static void ev_print_operation_print_finalize ( GObject *  object)
static

Definition at line 2024 of file ev-print-operation.c.

2025 {
2027  GApplication *application;
2028 
2029  if (print->op) {
2030  g_object_unref (print->op);
2031  print->op = NULL;
2032  }
2033 
2034  if (print->job_name) {
2035  g_free (print->job_name);
2036  print->job_name = NULL;
2037  }
2038 
2039  if (print->job_print) {
2040  if (!ev_job_is_finished (print->job_print))
2041  ev_job_cancel (print->job_print);
2042  g_signal_handlers_disconnect_by_func (print->job_print,
2044  print);
2045  g_signal_handlers_disconnect_by_func (print->job_print,
2047  print);
2048  g_object_unref (print->job_print);
2049  print->job_print = NULL;
2050  }
2051 
2052  (* G_OBJECT_CLASS (ev_print_operation_print_parent_class)->finalize) (object);
2053 
2054  application = g_application_get_default ();
2055  if (application)
2056  g_application_release (application);
2057 }

+ Here is the caller graph for this function:

static GtkPageSetup* ev_print_operation_print_get_default_page_setup ( EvPrintOperation op)
static

Definition at line 1626 of file ev-print-operation.c.

1627 {
1629 
1630  return gtk_print_operation_get_default_page_setup (print->op);
1631 }

+ Here is the caller graph for this function:

static gboolean ev_print_operation_print_get_embed_page_setup ( EvPrintOperation op)
static

Definition at line 1701 of file ev-print-operation.c.

1702 {
1704 
1705  return gtk_print_operation_get_embed_page_setup (print->op);
1706 }

+ Here is the caller graph for this function:

static void ev_print_operation_print_get_error ( EvPrintOperation op,
GError **  error 
)
static

Definition at line 1683 of file ev-print-operation.c.

1685 {
1687 
1688  gtk_print_operation_get_error (print->op, error);
1689 }

+ Here is the caller graph for this function:

static const gchar* ev_print_operation_print_get_job_name ( EvPrintOperation op)
static

Definition at line 1646 of file ev-print-operation.c.

1647 {
1649 
1650  if (!print->job_name) {
1651  gchar *name;
1652 
1653  g_object_get (print->op, "job_name", &name, NULL);
1654  print->job_name = name;
1655  }
1656 
1657  return print->job_name;
1658 }

+ Here is the caller graph for this function:

static GtkPrintSettings* ev_print_operation_print_get_print_settings ( EvPrintOperation op)
static

Definition at line 1609 of file ev-print-operation.c.

1610 {
1612 
1613  return gtk_print_operation_get_print_settings (print->op);
1614 }

+ Here is the caller graph for this function:

static void ev_print_operation_print_get_scaled_page_size ( EvPrintOperationPrint print,
gint  page,
gdouble *  width,
gdouble *  height,
gdouble *  manual_scale 
)
static

Definition at line 1828 of file ev-print-operation.c.

1833 {
1834  GtkPrintSettings *settings;
1835 
1836  ev_document_get_page_size (EV_PRINT_OPERATION (print)->document,
1837  page, width, height);
1838 
1839  settings = gtk_print_operation_get_print_settings (print->op);
1840  *manual_scale = gtk_print_settings_get_scale (settings) / 100.0;
1841  if (*manual_scale == 1.0)
1842  return;
1843 
1844  *width *= *manual_scale;
1845  *height *= *manual_scale;
1846 }

+ Here is the caller graph for this function:

static GType ev_print_operation_print_get_type ( void  )
static

Definition at line 1554 of file ev-print-operation.c.

1556  {
1557  EV_SCALE_NONE,
1558  EV_SCALE_SHRINK_TO_PRINTABLE_AREA,
1559  EV_SCALE_FIT_TO_PRINTABLE_AREA
1560 } EvPrintScale;
static void ev_print_operation_print_init ( EvPrintOperationPrint print)
static

Definition at line 2060 of file ev-print-operation.c.

2061 {
2062  GApplication *application;
2063 
2064  print->op = gtk_print_operation_new ();
2065  g_signal_connect_swapped (print->op, "begin_print",
2067  print);
2068  g_signal_connect_swapped (print->op, "done",
2069  G_CALLBACK (ev_print_operation_print_done),
2070  print);
2071  g_signal_connect_swapped (print->op, "draw_page",
2073  print);
2074  g_signal_connect_swapped (print->op, "status_changed",
2076  print);
2077  g_signal_connect_swapped (print->op, "request_page_setup",
2079  print);
2080  g_signal_connect_swapped (print->op, "create_custom_widget",
2082  print);
2083  g_signal_connect_swapped (print->op, "custom_widget_apply",
2085  print);
2086  g_signal_connect_swapped (print->op, "preview",
2087  G_CALLBACK (ev_print_operation_print_preview),
2088  print);
2089  gtk_print_operation_set_allow_async (print->op, TRUE);
2090  gtk_print_operation_set_use_full_page (print->op, TRUE);
2091  gtk_print_operation_set_unit (print->op, GTK_UNIT_POINTS);
2092  gtk_print_operation_set_custom_tab_label (print->op, _("Page Handling"));
2093 
2094  application = g_application_get_default ();
2095  if (application)
2096  g_application_hold (application);
2097 }
static gboolean ev_print_operation_print_preview ( EvPrintOperationPrint print)
static

Definition at line 2016 of file ev-print-operation.c.

2017 {
2018  EV_PRINT_OPERATION (print)->print_preview = TRUE;
2019 
2020  return FALSE;
2021 }

+ Here is the caller graph for this function:

static void ev_print_operation_print_request_page_setup ( EvPrintOperationPrint print,
GtkPrintContext *  context,
gint  page_nr,
GtkPageSetup *  setup 
)
static

Definition at line 1785 of file ev-print-operation.c.

1789 {
1790  EvPrintOperation *op = EV_PRINT_OPERATION (print);
1791  gdouble width, height;
1792  GtkPaperSize *paper_size;
1793 
1794  ev_document_get_page_size (op->document, page_nr,
1795  &width, &height);
1796 
1797  if (print->use_source_size) {
1798  paper_size = gtk_paper_size_new_custom ("custom", "custom",
1799  width, height, GTK_UNIT_POINTS);
1800  gtk_page_setup_set_paper_size_and_default_margins (setup, paper_size);
1801  gtk_paper_size_free (paper_size);
1802  }
1803 
1804  if (print->autorotate) {
1805  if (width > height)
1806  gtk_page_setup_set_orientation (setup, GTK_PAGE_ORIENTATION_LANDSCAPE);
1807  else
1808  gtk_page_setup_set_orientation (setup, GTK_PAGE_ORIENTATION_PORTRAIT);
1809  }
1810 }

+ Here is the caller graph for this function:

static void ev_print_operation_print_run ( EvPrintOperation op,
GtkWindow *  parent 
)
static

Definition at line 1661 of file ev-print-operation.c.

1663 {
1665 
1666  gtk_print_operation_run (print->op,
1667  GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
1668  parent, NULL);
1669 }

+ Here is the caller graph for this function:

static void ev_print_operation_print_set_current_page ( EvPrintOperation op,
gint  current_page 
)
static

Definition at line 1591 of file ev-print-operation.c.

1593 {
1595 
1596  gtk_print_operation_set_current_page (print->op, current_page);
1597 }

+ Here is the caller graph for this function:

static void ev_print_operation_print_set_default_page_setup ( EvPrintOperation op,
GtkPageSetup *  page_setup 
)
static

Definition at line 1617 of file ev-print-operation.c.

1619 {
1621 
1622  gtk_print_operation_set_default_page_setup (print->op, page_setup);
1623 }

+ Here is the caller graph for this function:

static void ev_print_operation_print_set_embed_page_setup ( EvPrintOperation op,
gboolean  embed 
)
static

Definition at line 1692 of file ev-print-operation.c.

1694 {
1696 
1697  gtk_print_operation_set_embed_page_setup (print->op, embed);
1698 }

+ Here is the caller graph for this function:

static void ev_print_operation_print_set_job_name ( EvPrintOperation op,
const gchar *  job_name 
)
static

Definition at line 1634 of file ev-print-operation.c.

1636 {
1638 
1639  g_free (print->job_name);
1640  print->job_name = g_strdup (job_name);
1641 
1642  gtk_print_operation_set_job_name (print->op, print->job_name);
1643 }

+ Here is the caller graph for this function:

static void ev_print_operation_print_set_print_settings ( EvPrintOperation op,
GtkPrintSettings *  print_settings 
)
static

Definition at line 1600 of file ev-print-operation.c.

1602 {
1604 
1605  gtk_print_operation_set_print_settings (print->op, print_settings);
1606 }

+ Here is the caller graph for this function:

static void ev_print_operation_print_status_changed ( EvPrintOperationPrint print)
static

Definition at line 1734 of file ev-print-operation.c.

1735 {
1736  GtkPrintStatus status;
1737 
1738  status = gtk_print_operation_get_status (print->op);
1739  if (status == GTK_PRINT_STATUS_GENERATING_DATA)
1740  print->n_pages_to_print = gtk_print_operation_get_n_pages_to_print (print->op);
1741 }

+ Here is the caller graph for this function:

void ev_print_operation_run ( EvPrintOperation op,
GtkWindow *  parent 
)

Definition at line 268 of file ev-print-operation.c.

270 {
271  EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op);
272 
273  g_return_if_fail (EV_IS_PRINT_OPERATION (op));
274 
275  class->run (op, parent);
276 }

+ Here is the caller graph for this function:

void ev_print_operation_set_current_page ( EvPrintOperation op,
gint  current_page 
)

Definition at line 178 of file ev-print-operation.c.

180 {
181  EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op);
182 
183  g_return_if_fail (EV_IS_PRINT_OPERATION (op));
184  g_return_if_fail (current_page >= 0);
185 
186  class->set_current_page (op, current_page);
187 }

+ Here is the caller graph for this function:

void ev_print_operation_set_default_page_setup ( EvPrintOperation op,
GtkPageSetup *  page_setup 
)

Definition at line 218 of file ev-print-operation.c.

220 {
221  EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op);
222 
223  g_return_if_fail (EV_IS_PRINT_OPERATION (op));
224  g_return_if_fail (GTK_IS_PAGE_SETUP (page_setup));
225 
226  class->set_default_page_setup (op, page_setup);
227 }

+ Here is the caller graph for this function:

void ev_print_operation_set_embed_page_setup ( EvPrintOperation op,
gboolean  embed 
)

Definition at line 300 of file ev-print-operation.c.

302 {
303  EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op);
304 
305  g_return_if_fail (EV_IS_PRINT_OPERATION (op));
306 
307  class->set_embed_page_setup (op, embed);
308 }

+ Here is the caller graph for this function:

void ev_print_operation_set_job_name ( EvPrintOperation op,
const gchar *  job_name 
)

Definition at line 246 of file ev-print-operation.c.

248 {
249  EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op);
250 
251  g_return_if_fail (EV_IS_PRINT_OPERATION (op));
252  g_return_if_fail (job_name != NULL);
253 
254  class->set_job_name (op, job_name);
255 }

+ Here is the caller graph for this function:

void ev_print_operation_set_print_settings ( EvPrintOperation op,
GtkPrintSettings *  print_settings 
)

Definition at line 190 of file ev-print-operation.c.

192 {
193  EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op);
194 
195  g_return_if_fail (EV_IS_PRINT_OPERATION (op));
196  g_return_if_fail (GTK_IS_PRINT_SETTINGS (print_settings));
197 
198  class->set_print_settings (op, print_settings);
199 }

+ Here is the caller graph for this function:

static void ev_print_operation_set_property ( GObject *  object,
guint  prop_id,
const GValue *  value,
GParamSpec *  pspec 
)
static

Definition at line 111 of file ev-print-operation.c.

115 {
116  EvPrintOperation *op = EV_PRINT_OPERATION (object);
117 
118  switch (prop_id) {
119  case PROP_DOCUMENT:
120  op->document = g_value_dup_object (value);
121  break;
122  default:
123  G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
124  }
125 }

+ Here is the caller graph for this function:

static void ev_print_operation_update_status ( EvPrintOperation op,
gint  page,
gint  n_pages,
gdouble  progress 
)
static

Definition at line 337 of file ev-print-operation.c.

341 {
342  if (op->status && op->progress == progress)
343  return;
344 
345  g_free (op->status);
346 
347  if (op->print_preview) {
348  if (page == -1) {
349  /* Initial state */
350  op->status = g_strdup (_("Preparing preview…"));
351  } else if (page > n_pages) {
352  op->status = g_strdup (_("Finishing…"));
353  } else {
354  op->status = g_strdup_printf (_("Generating preview: page %d of %d"),
355  page, n_pages);
356  }
357  } else {
358  if (page == -1) {
359  /* Initial state */
360  op->status = g_strdup (_("Preparing to print…"));
361  } else if (page > n_pages) {
362  op->status = g_strdup (_("Finishing…"));
363  } else {
364  op->status = g_strdup_printf (_("Printing page %d of %d…"),
365  page, n_pages);
366  }
367  }
368 
369  op->progress = MIN (1.0, progress);
370 
371  g_signal_emit (op, signals[STATUS_CHANGED], 0);
372 }

+ Here is the caller graph for this function:

static void print_job_cancelled ( EvJobPrint job,
EvPrintOperationPrint print 
)
static

Definition at line 1770 of file ev-print-operation.c.

1772 {
1773  /* Finish the current page, so that draw-page
1774  * is emitted again and it will cancel the
1775  * print operation. If the job is still
1776  * running, wait until it finishes.
1777  */
1779  g_idle_add ((GSourceFunc)draw_page_finish_idle, print);
1780  else
1781  gtk_print_operation_draw_page_finish (print->op);
1782 }

+ Here is the caller graph for this function:

static void print_job_finished ( EvJobPrint job,
EvPrintOperationPrint print 
)
static

Definition at line 1744 of file ev-print-operation.c.

1746 {
1747  EvPrintOperation *op = EV_PRINT_OPERATION (print);
1748 
1749  gtk_print_operation_draw_page_finish (print->op);
1750 
1751  print->total++;
1753  print->n_pages_to_print,
1754  print->total / (gdouble)print->n_pages_to_print);
1755  ev_job_print_set_cairo (job, NULL);
1756 }

+ Here is the caller graph for this function:

Variable Documentation

EvPrintScale

Definition at line 1560 of file ev-print-operation.c.

guint signals[LAST_SIGNAL] = { 0 }
static

Definition at line 46 of file ev-print-operation.c.