diff options
author | Marek Kasik <mkasik@redhat.com> | 2009-06-08 15:37:32 +0200 |
---|---|---|
committer | Marek Kasik <mkasik@redhat.com> | 2009-06-08 15:37:32 +0200 |
commit | a12a583c99982a4072cb3ac8ae969a9ebd5cbd69 (patch) | |
tree | 74fafbcf4791378162fb3da35070aa08a77edd90 /gtk/gtkprintoperation.c | |
parent | 9a4122a1302ae4d09610b3b86995095c877d8f95 (diff) | |
download | gtk+-a12a583c99982a4072cb3ac8ae969a9ebd5cbd69.tar.gz |
Add ability to print selection
Add a new radio button "Selection" to the print dialog. Its presence
depends on calling of functions gtk_print_operation_set_support_selection()
and gtk_print_dialog_unix_set_support_selection().
Sensitivity of the radio depends on calling of
functions gtk_print_operation_set_has_selection() and
gtk_print_dialog_unix_set_has_selection().
There are new properties GtkPrintUnixDialog::support-selection,
GtkPrintUnixDialog::has-selection, GtkPrintOperation::support-selection
and GtkPrintOperation::has-selection. Corresponding getters are
gtk_print_dialog_unix_get_support_selection(),
gtk_print_dialog_unix_get_has_selection(),
gtk_print_operation_get_support_selection() and
gtk_print_operation_get_has_selection().
Application has to set number of pages to which the selection will be formated
in GtkPrintOperation::begin-print's callback by the
gtk_print_operation_set_n_pages() function (bug #344519).
There is also new property GtkPrintUnixDialog::manual-capabilities controled by
gtk_print_unix_dialog_set_manual_capabilities() and
gtk_print_unix_dialog_get_manual_capabilities().
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" |