820
853
G_TYPE_OBJECT, 0);
856
* GtkPrintOperation::update-custom-widget:
857
* @operation: the #GtkPrintOperation on which the signal was emitted
858
* @widget: the custom widget added in create-custom-widget
859
* @setup: actual page setup
860
* @settings: actual print settings
862
* Emitted after change of selected printer. The actual page setup and
863
* print settings are passed to the custom widget, which can actualize
864
* itself according to this change.
868
signals[UPDATE_CUSTOM_WIDGET] =
869
g_signal_new (I_("update-custom-widget"),
870
G_TYPE_FROM_CLASS (class),
872
G_STRUCT_OFFSET (GtkPrintOperationClass, update_custom_widget),
874
_gtk_marshal_VOID__OBJECT_OBJECT_OBJECT,
875
G_TYPE_NONE, 3, GTK_TYPE_WIDGET, GTK_TYPE_PAGE_SETUP, GTK_TYPE_PRINT_SETTINGS);
823
878
* GtkPrintOperation::custom-widget-apply:
824
879
* @operation: the #GtkPrintOperation on which the signal was emitted
825
880
* @widget: the custom widget added in create-custom-widget
827
882
* Emitted right before #GtkPrintOperation::begin-print if you added
828
* a custom widget in the #GtkPrintOperation:;create-custom-widget handler.
883
* a custom widget in the #GtkPrintOperation::create-custom-widget handler.
829
884
* When you get this signal you should read the information from the
830
885
* custom widgets, as the widgets are not guaraneed to be around at a
1168
1223
GTK_PARAM_READWRITE));
1226
* GtkPrintOperation:support-selection:
1228
* If %TRUE, the print operation will support print of selection.
1229
* This allows the print dialog to show a "Selection" button.
1233
g_object_class_install_property (gobject_class,
1234
PROP_SUPPORT_SELECTION,
1235
g_param_spec_boolean ("support-selection",
1236
P_("Support Selection"),
1237
P_("TRUE if the print operation will support print of selection."),
1239
GTK_PARAM_READWRITE));
1242
* GtkPrintOperation:has-selection:
1244
* Determines whether there is a selection in your application.
1245
* This can allow your application to print the selection.
1246
* This is typically used to make a "Selection" button sensitive.
1250
g_object_class_install_property (gobject_class,
1252
g_param_spec_boolean ("has-selection",
1253
P_("Has Selection"),
1254
P_("TRUE if a selecion exists."),
1256
GTK_PARAM_READWRITE));
1260
* GtkPrintOperation:embed-page-setup:
1262
* If %TRUE, page size combo box and orientation combo box are embedded into page setup page.
1266
g_object_class_install_property (gobject_class,
1267
PROP_EMBED_PAGE_SETUP,
1268
g_param_spec_boolean ("embed-page-setup",
1269
P_("Embed Page Setup"),
1270
P_("TRUE if page setup combos are embedded in GtkPrintDialog"),
1272
GTK_PARAM_READWRITE));
1274
* GtkPrintOperation:n-pages-to-print:
1276
* The number of pages that will be printed.
1278
* Note that this value is set during print preparation phase
1279
* (%GTK_PRINT_STATUS_PREPARING), so this value should never be
1280
* get before the data generation phase (%GTK_PRINT_STATUS_GENERATING_DATA).
1281
* You can connect to the #GtkPrintOperation::status-changed signal
1282
* and call gtk_print_operation_get_n_pages_to_print() when
1283
* print status is %GTK_PRINT_STATUS_GENERATING_DATA.
1284
* This is typically used to track the progress of print operation.
1288
g_object_class_install_property (gobject_class,
1289
PROP_N_PAGES_TO_PRINT,
1290
g_param_spec_int ("n-pages-to-print",
1291
P_("Number of Pages To Print"),
1292
P_("The number of pages that will be printed."),
1296
GTK_PARAM_READABLE));
1971
2091
data->num_ranges = num_of_correct_ranges;
1975
2095
increment_page_sequence (PrintPagesData *data)
1977
2097
GtkPrintOperationPrivate *priv = data->op->priv;
1980
data->page += data->inc;
1981
if (data->page == data->end)
1983
data->range += data->inc;
1984
if (data->range == -1 || data->range == data->num_ranges)
1987
if (data->uncollated == data->uncollated_copies)
1990
data->range = data->inc < 0 ? data->num_ranges - 1 : 0;
1993
data->page = data->start;
1996
while ((priv->manual_page_set == GTK_PAGE_SET_EVEN && data->page % 2 == 0) ||
1997
(priv->manual_page_set == GTK_PAGE_SET_ODD && data->page % 2 == 1));
2100
if (data->total == -1)
2106
/* check whether we reached last position */
2107
if (priv->page_position == data->last_position &&
2108
!(data->collated_copies > 1 && data->collated < (data->collated_copies - 1)))
2110
if (data->uncollated_copies > 1 && data->uncollated < (data->uncollated_copies - 1))
2112
priv->page_position = data->first_position;
2113
data->sheet = data->first_sheet;
2124
if (priv->manual_reverse)
2129
/* changing sheet */
2130
if ((priv->page_position + 1) % priv->manual_number_up == 0 ||
2131
priv->page_position == data->last_position ||
2132
priv->page_position == priv->nr_of_pages_to_print - 1)
2134
/* check whether to print the same sheet again */
2135
if (data->collated_copies > 1)
2137
if (data->collated < (data->collated_copies - 1))
2141
priv->page_position = data->sheet * priv->manual_number_up;
2143
if (priv->page_position < 0 ||
2144
priv->page_position >= priv->nr_of_pages_to_print ||
2146
data->sheet >= data->num_of_sheets)
2152
data->page = data->pages[priv->page_position];
2160
if (priv->manual_page_set == GTK_PAGE_SET_ODD ||
2161
priv->manual_page_set == GTK_PAGE_SET_EVEN)
2162
data->sheet += 2 * inc;
2166
priv->page_position = data->sheet * priv->manual_number_up;
2169
priv->page_position += 1;
2173
if (priv->page_position < 0 ||
2174
priv->page_position >= priv->nr_of_pages_to_print ||
2176
data->sheet >= data->num_of_sheets)
2182
data->page = data->pages[priv->page_position];
2272
* gtk_print_operation_set_embed_page_setup:
2273
* @op: a #GtkPrintOperation
2274
* @embed: %TRUE to embed page setup selection in the #GtkPrintDialog
2276
* Embed page size combo box and orientation combo box into page setup page.
2277
* Selected page setup is stored as default page setup in #GtkPrintOperation.
2282
gtk_print_operation_set_embed_page_setup (GtkPrintOperation *op,
2285
GtkPrintOperationPrivate *priv;
2287
g_return_if_fail (GTK_IS_PRINT_OPERATION (op));
2291
embed = embed != FALSE;
2292
if (priv->embed_page_setup != embed)
2294
priv->embed_page_setup = embed;
2295
g_object_notify (G_OBJECT (op), "embed-page-setup");
2300
* gtk_print_operation_get_embed_page_setup:
2301
* @op: a #GtkPrintOperation
2303
* Gets the value of #GtkPrintOperation::embed-page-setup property.
2305
* Returns: whether page setup selection combos are embedded
2310
gtk_print_operation_get_embed_page_setup (GtkPrintOperation *op)
2312
g_return_val_if_fail (GTK_IS_PRINT_OPERATION (op), FALSE);
2314
return op->priv->embed_page_setup;
2086
2318
* gtk_print_operation_draw_page_finish:
2087
2319
* @op: a #GtkPrintOperation
2141
2373
cr = gtk_print_context_get_cairo_context (print_context);
2143
2375
cairo_save (cr);
2144
if (priv->manual_scale != 1.0)
2376
if (priv->manual_scale != 1.0 && priv->manual_number_up <= 1)
2145
2377
cairo_scale (cr,
2146
2378
priv->manual_scale,
2147
2379
priv->manual_scale);
2149
2381
if (priv->manual_orientation)
2150
2382
_gtk_print_context_rotate_according_to_orientation (print_context);
2152
if (!priv->use_full_page)
2153
_gtk_print_context_translate_into_margin (print_context);
2384
if (priv->manual_number_up > 1)
2386
GtkPageOrientation orientation;
2387
GtkPageSetup *page_setup;
2388
gdouble paper_width, paper_height;
2389
gdouble page_width, page_height;
2390
gdouble context_width, context_height;
2391
gdouble bottom_margin, top_margin, left_margin, right_margin;
2392
gdouble x_step, y_step;
2393
gdouble x_scale, y_scale, scale;
2394
gdouble horizontal_offset = 0.0, vertical_offset = 0.0;
2395
gint columns, rows, x, y, tmp_length;
2397
page_setup = gtk_print_context_get_page_setup (print_context);
2398
orientation = gtk_page_setup_get_orientation (page_setup);
2400
top_margin = gtk_page_setup_get_top_margin (page_setup, GTK_UNIT_POINTS);
2401
bottom_margin = gtk_page_setup_get_bottom_margin (page_setup, GTK_UNIT_POINTS);
2402
left_margin = gtk_page_setup_get_left_margin (page_setup, GTK_UNIT_POINTS);
2403
right_margin = gtk_page_setup_get_right_margin (page_setup, GTK_UNIT_POINTS);
2405
paper_width = gtk_page_setup_get_paper_width (page_setup, GTK_UNIT_POINTS);
2406
paper_height = gtk_page_setup_get_paper_height (page_setup, GTK_UNIT_POINTS);
2408
context_width = gtk_print_context_get_width (print_context);
2409
context_height = gtk_print_context_get_height (print_context);
2411
if (orientation == GTK_PAGE_ORIENTATION_PORTRAIT ||
2412
orientation == GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT)
2414
page_width = paper_width - (left_margin + right_margin);
2415
page_height = paper_height - (top_margin + bottom_margin);
2419
page_width = paper_width - (top_margin + bottom_margin);
2420
page_height = paper_height - (left_margin + right_margin);
2423
if (orientation == GTK_PAGE_ORIENTATION_PORTRAIT ||
2424
orientation == GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT)
2425
cairo_translate (cr, left_margin, top_margin);
2427
cairo_translate (cr, top_margin, left_margin);
2429
switch (priv->manual_number_up)
2457
if (orientation == GTK_PAGE_ORIENTATION_LANDSCAPE ||
2458
orientation == GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE)
2460
tmp_length = columns;
2465
switch (priv->manual_number_up_layout)
2467
case GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM:
2468
x = priv->page_position % columns;
2469
y = (priv->page_position / columns) % rows;
2471
case GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_BOTTOM_TO_TOP:
2472
x = priv->page_position % columns;
2473
y = rows - 1 - (priv->page_position / columns) % rows;
2475
case GTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_TOP_TO_BOTTOM:
2476
x = columns - 1 - priv->page_position % columns;
2477
y = (priv->page_position / columns) % rows;
2479
case GTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_BOTTOM_TO_TOP:
2480
x = columns - 1 - priv->page_position % columns;
2481
y = rows - 1 - (priv->page_position / columns) % rows;
2483
case GTK_NUMBER_UP_LAYOUT_TOP_TO_BOTTOM_LEFT_TO_RIGHT:
2484
x = (priv->page_position / rows) % columns;
2485
y = priv->page_position % rows;
2487
case GTK_NUMBER_UP_LAYOUT_TOP_TO_BOTTOM_RIGHT_TO_LEFT:
2488
x = columns - 1 - (priv->page_position / rows) % columns;
2489
y = priv->page_position % rows;
2491
case GTK_NUMBER_UP_LAYOUT_BOTTOM_TO_TOP_LEFT_TO_RIGHT:
2492
x = (priv->page_position / rows) % columns;
2493
y = rows - 1 - priv->page_position % rows;
2495
case GTK_NUMBER_UP_LAYOUT_BOTTOM_TO_TOP_RIGHT_TO_LEFT:
2496
x = columns - 1 - (priv->page_position / rows) % columns;
2497
y = rows - 1 - priv->page_position % rows;
2501
if (priv->manual_number_up == 4 || priv->manual_number_up == 9 || priv->manual_number_up == 16)
2503
x_scale = page_width / (columns * paper_width);
2504
y_scale = page_height / (rows * paper_height);
2506
scale = x_scale < y_scale ? x_scale : y_scale;
2508
x_step = paper_width * (x_scale / scale);
2509
y_step = paper_height * (y_scale / scale);
2511
if ((left_margin + right_margin) > 0)
2513
horizontal_offset = left_margin * (x_step - context_width) / (left_margin + right_margin);
2514
vertical_offset = top_margin * (y_step - context_height) / (top_margin + bottom_margin);
2518
horizontal_offset = (x_step - context_width) / 2.0;
2519
vertical_offset = (y_step - context_height) / 2.0;
2522
cairo_scale (cr, scale, scale);
2524
cairo_translate (cr,
2525
x * x_step + horizontal_offset,
2526
y * y_step + vertical_offset);
2528
if (priv->manual_scale != 1.0)
2529
cairo_scale (cr, priv->manual_scale, priv->manual_scale);
2532
if (priv->manual_number_up == 2 || priv->manual_number_up == 6)
2534
x_scale = page_height / (columns * paper_width);
2535
y_scale = page_width / (rows * paper_height);
2537
scale = x_scale < y_scale ? x_scale : y_scale;
2539
horizontal_offset = (paper_width * (x_scale / scale) - paper_width) / 2.0 * columns;
2540
vertical_offset = (paper_height * (y_scale / scale) - paper_height) / 2.0 * rows;
2542
if (!priv->use_full_page)
2544
horizontal_offset -= right_margin;
2545
vertical_offset += top_margin;
2548
cairo_scale (cr, scale, scale);
2550
cairo_translate (cr,
2551
y * paper_height + vertical_offset,
2552
(columns - x) * paper_width + horizontal_offset);
2554
if (priv->manual_scale != 1.0)
2555
cairo_scale (cr, priv->manual_scale, priv->manual_scale);
2557
cairo_rotate (cr, - G_PI / 2);
2561
if (!priv->use_full_page)
2562
_gtk_print_context_translate_into_margin (print_context);
2155
2564
priv->page_drawing_state = GTK_PAGE_DRAWING_STATE_DRAWING;
2247
if (priv->manual_reverse)
2249
data->range = data->num_ranges - 1;
2259
/* go back one page, since we preincrement below */
2260
data->page = data->start - data->inc;
2261
data->collated = data->collated_copies - 1;
2656
priv->nr_of_pages_to_print = 0;
2657
for (i = 0; i < data->num_ranges; i++)
2658
priv->nr_of_pages_to_print += data->ranges[i].end - data->ranges[i].start + 1;
2660
data->pages = g_new (gint, priv->nr_of_pages_to_print);
2662
for (i = 0; i < data->num_ranges; i++)
2663
for (j = data->ranges[i].start; j <= data->ranges[i].end; j++)
2665
data->pages[counter] = j;
2671
data->uncollated = 0;
2673
if (priv->nr_of_pages_to_print % priv->manual_number_up == 0)
2674
data->num_of_sheets = priv->nr_of_pages_to_print / priv->manual_number_up;
2676
data->num_of_sheets = priv->nr_of_pages_to_print / priv->manual_number_up + 1;
2678
if (priv->manual_reverse)
2680
/* data->sheet is 0-based */
2681
if (priv->manual_page_set == GTK_PAGE_SET_ODD)
2682
data->sheet = (data->num_of_sheets - 1) - (data->num_of_sheets - 1) % 2;
2683
else if (priv->manual_page_set == GTK_PAGE_SET_EVEN)
2684
data->sheet = (data->num_of_sheets - 1) - (1 - (data->num_of_sheets - 1) % 2);
2686
data->sheet = data->num_of_sheets - 1;
2690
/* data->sheet is 0-based */
2691
if (priv->manual_page_set == GTK_PAGE_SET_ODD)
2693
else if (priv->manual_page_set == GTK_PAGE_SET_EVEN)
2695
if (data->num_of_sheets > 1)
2704
priv->page_position = data->sheet * priv->manual_number_up;
2706
if (priv->page_position < 0 || priv->page_position >= priv->nr_of_pages_to_print)
2708
priv->cancelled = TRUE;
2712
data->page = data->pages[priv->page_position];
2713
data->first_position = priv->page_position;
2714
data->first_sheet = data->sheet;
2716
if (priv->manual_reverse)
2718
if (priv->manual_page_set == GTK_PAGE_SET_ODD)
2719
data->last_position = MIN (priv->manual_number_up - 1, priv->nr_of_pages_to_print - 1);
2720
else if (priv->manual_page_set == GTK_PAGE_SET_EVEN)
2721
data->last_position = MIN (2 * priv->manual_number_up - 1, priv->nr_of_pages_to_print - 1);
2723
data->last_position = MIN (priv->manual_number_up - 1, priv->nr_of_pages_to_print - 1);
2727
if (priv->manual_page_set == GTK_PAGE_SET_ODD)
2728
data->last_position = MIN (((data->num_of_sheets - 1) - ((data->num_of_sheets - 1) % 2)) * priv->manual_number_up - 1, priv->nr_of_pages_to_print - 1);
2729
else if (priv->manual_page_set == GTK_PAGE_SET_EVEN)
2730
data->last_position = MIN (((data->num_of_sheets - 1) - (1 - (data->num_of_sheets - 1) % 2)) * priv->manual_number_up - 1, priv->nr_of_pages_to_print - 1);
2732
data->last_position = priv->nr_of_pages_to_print - 1;
2263
2736
_gtk_print_operation_set_status (data->op,
2264
2737
GTK_PRINT_STATUS_GENERATING_DATA,
2661
3128
op->priv->cancelled = TRUE;
3132
* gtk_print_operation_set_support_selection:
3133
* @op: a #GtkPrintOperation
3134
* @support_selection: %TRUE to support selection
3136
* Sets whether selection is supported by #GtkPrintOperation.
3141
gtk_print_operation_set_support_selection (GtkPrintOperation *op,
3142
gboolean support_selection)
3144
GtkPrintOperationPrivate *priv;
3146
g_return_if_fail (GTK_IS_PRINT_OPERATION (op));
3150
support_selection = support_selection != FALSE;
3151
if (priv->support_selection != support_selection)
3153
priv->support_selection = support_selection;
3154
g_object_notify (G_OBJECT (op), "support-selection");
3159
* gtk_print_operation_get_support_selection:
3160
* @op: a #GtkPrintOperation
3162
* Gets the value of #GtkPrintOperation::support-selection property.
3164
* Returns: whether the application supports print of selection
3169
gtk_print_operation_get_support_selection (GtkPrintOperation *op)
3171
g_return_val_if_fail (GTK_IS_PRINT_OPERATION (op), FALSE);
3173
return op->priv->support_selection;
3177
* gtk_print_operation_set_has_selection:
3178
* @op: a #GtkPrintOperation
3179
* @has_selection: %TRUE indicates that a selection exists
3181
* Sets whether there is a selection to print.
3183
* Application has to set number of pages to which the selection
3184
* will draw by gtk_print_operation_set_n_pages() in a callback of
3185
* #GtkPrintOperation::begin-print.
3190
gtk_print_operation_set_has_selection (GtkPrintOperation *op,
3191
gboolean has_selection)
3193
GtkPrintOperationPrivate *priv;
3195
g_return_if_fail (GTK_IS_PRINT_OPERATION (op));
3199
has_selection = has_selection != FALSE;
3200
if (priv->has_selection != has_selection)
3202
priv->has_selection = has_selection;
3203
g_object_notify (G_OBJECT (op), "has-selection");
3208
* gtk_print_operation_get_has_selection:
3209
* @op: a #GtkPrintOperation
3211
* Gets the value of #GtkPrintOperation::has-selection property.
3213
* Returns: whether there is a selection
3218
gtk_print_operation_get_has_selection (GtkPrintOperation *op)
3220
g_return_val_if_fail (GTK_IS_PRINT_OPERATION (op), FALSE);
3222
return op->priv->has_selection;
3226
* gtk_print_operation_get_n_pages_to_print:
3227
* @op: a #GtkPrintOperation
3229
* Returns the number of pages that will be printed.
3231
* Note that this value is set during print preparation phase
3232
* (%GTK_PRINT_STATUS_PREPARING), so this function should never be
3233
* called before the data generation phase (%GTK_PRINT_STATUS_GENERATING_DATA).
3234
* You can connect to the #GtkPrintOperation::status-changed signal
3235
* and call gtk_print_operation_get_n_pages_to_print() when
3236
* print status is %GTK_PRINT_STATUS_GENERATING_DATA.
3237
* This is typically used to track the progress of print operation.
3239
* Returns: the number of pages that will be printed
3244
gtk_print_operation_get_n_pages_to_print (GtkPrintOperation *op)
3246
g_return_val_if_fail (GTK_IS_PRINT_OPERATION (op), -1);
3248
return op->priv->nr_of_pages_to_print;
2666
3251
#define __GTK_PRINT_OPERATION_C__
2667
3252
#include "gtkaliasdef.c"