diff options
Diffstat (limited to 'gtk/gtkprintoperation.c')
-rw-r--r-- | gtk/gtkprintoperation.c | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/gtk/gtkprintoperation.c b/gtk/gtkprintoperation.c index c3b61c03d7..966417b22f 100644 --- a/gtk/gtkprintoperation.c +++ b/gtk/gtkprintoperation.c @@ -163,6 +163,8 @@ gtk_print_operation_init (GtkPrintOperation *operation) priv->export_filename = NULL; priv->track_print_status = FALSE; priv->is_sync = FALSE; + priv->support_selection = FALSE; + priv->has_selection = FALSE; priv->page_drawing_state = GTK_PAGE_DRAWING_STATE_READY; @@ -223,6 +225,7 @@ preview_iface_is_selected (GtkPrintOperationPreview *preview, switch (priv->print_pages) { + case GTK_PRINT_PAGES_SELECTION: case GTK_PRINT_PAGES_ALL: return (page_nr >= 0) && (page_nr < priv->nr_of_pages); case GTK_PRINT_PAGES_CURRENT: @@ -1193,6 +1196,39 @@ gtk_print_operation_class_init (GtkPrintOperationClass *class) NULL, GTK_PARAM_READWRITE)); + /** + * GtkPrintOperation:support-selection: + * + * If %TRUE, the print operation will support print of selection. + * This allows the print dialog to show a "Selection" button. + * + * Since: 2.18 + */ + g_object_class_install_property (gobject_class, + PROP_TRACK_PRINT_STATUS, + g_param_spec_boolean ("support-selection", + P_("Support Selection"), + P_("TRUE if the print operation will support print of selection."), + FALSE, + GTK_PARAM_READWRITE)); + + /** + * GtkPrintOperation:has-selection: + * + * Determines whether there is a selection in your application. + * This can allow your application to print the selection. + * This is typically used to make a "Selection" button sensitive. + * + * Since: 2.18 + */ + g_object_class_install_property (gobject_class, + PROP_TRACK_PRINT_STATUS, + g_param_spec_boolean ("has-selection", + P_("Has Selection"), + P_("TRUE if a selecion exists."), + FALSE, + GTK_PARAM_READWRITE)); + } /** @@ -2976,7 +3012,99 @@ gtk_print_operation_cancel (GtkPrintOperation *op) op->priv->cancelled = TRUE; } +/** + * gtk_print_operation_set_support_selection: + * @op: a #GtkPrintOperation + * @support_selection: %TRUE to support selection + * + * Sets whether selection is supported by #GtkPrintOperation. + * + * Since: 2.18 + */ +void +gtk_print_operation_set_support_selection (GtkPrintOperation *op, + gboolean support_selection) +{ + GtkPrintOperationPrivate *priv; + g_return_if_fail (GTK_IS_PRINT_OPERATION (op)); + + priv = op->priv; + + support_selection = support_selection != FALSE; + if (priv->support_selection != support_selection) + { + priv->support_selection = support_selection; + g_object_notify (G_OBJECT (op), "support-selection"); + } +} + +/** + * gtk_print_operation_get_support_selection: + * @op: a #GtkPrintOperation + * + * Gets the value of #GtkPrintOperation::support-selection property. + * + * Returns: whether the application supports print of selection + * + * Since: 2.18 + */ +gboolean +gtk_print_operation_get_support_selection (GtkPrintOperation *op) +{ + g_return_val_if_fail (GTK_IS_PRINT_OPERATION (op), FALSE); + + return op->priv->support_selection; +} + +/** + * gtk_print_operation_set_has_selection: + * @op: a #GtkPrintOperation + * @has_selection: %TRUE indicates that a selection exists + * + * Sets whether there is a selection to print. + * + * Application has to set number of pages to which the selection + * will draw by gtk_print_operation_set_n_pages() in a callback of + * #GtkPrintOperation::begin-print. + * + * Since: 2.18 + */ +void +gtk_print_operation_set_has_selection (GtkPrintOperation *op, + gboolean has_selection) +{ + GtkPrintOperationPrivate *priv; + + g_return_if_fail (GTK_IS_PRINT_OPERATION (op)); + + priv = op->priv; + + has_selection = has_selection != FALSE; + if (priv->has_selection != has_selection) + { + priv->has_selection = has_selection; + g_object_notify (G_OBJECT (op), "has-selection"); + } +} + +/** + * gtk_print_operation_get_has_selection: + * @op: a #GtkPrintOperation + * + * Gets the value of #GtkPrintOperation::has-selection property. + * + * Returns: whether there is a selection + * + * Since: 2.18 + */ +gboolean +gtk_print_operation_get_has_selection (GtkPrintOperation *op) +{ + g_return_val_if_fail (GTK_IS_PRINT_OPERATION (op), FALSE); + + return op->priv->has_selection; +} #define __GTK_PRINT_OPERATION_C__ #include "gtkaliasdef.c" |