Commit a12a583c authored by Marek Kasik's avatar Marek Kasik

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().
parent 9a4122a1
......@@ -6562,6 +6562,10 @@ gtk_print_operation_set_defer_drawing
gtk_print_operation_get_status
gtk_print_operation_get_status_string
gtk_print_operation_is_finished
gtk_print_operation_set_support_selection
gtk_print_operation_get_support_selection
gtk_print_operation_set_has_selection
gtk_print_operation_get_has_selection
gtk_print_run_page_setup_dialog
GtkPageSetupDoneFunc
gtk_print_run_page_setup_dialog_async
......@@ -6606,8 +6610,13 @@ gtk_print_unix_dialog_set_settings
gtk_print_unix_dialog_get_settings
gtk_print_unix_dialog_get_selected_printer
gtk_print_unix_dialog_add_custom_tab
gtk_print_unix_dialog_set_support_selection
gtk_print_unix_dialog_get_support_selection
gtk_print_unix_dialog_set_has_selection
gtk_print_unix_dialog_get_has_selection
GtkPrintCapabilities
gtk_print_unix_dialog_set_manual_capabilities
gtk_print_unix_dialog_get_manual_capabilities
<SUBSECTION Standard>
GTK_TYPE_PRINT_UNIX_DIALOG
......
......@@ -2986,6 +2986,10 @@ gtk_print_operation_is_finished
gtk_print_operation_cancel
gtk_print_operation_draw_page_finish
gtk_print_operation_set_defer_drawing
gtk_print_operation_set_support_selection
gtk_print_operation_get_support_selection
gtk_print_operation_set_has_selection
gtk_print_operation_get_has_selection
#endif
#endif
......@@ -3110,6 +3114,11 @@ gtk_print_unix_dialog_get_settings
gtk_print_unix_dialog_get_selected_printer
gtk_print_unix_dialog_add_custom_tab
gtk_print_unix_dialog_set_manual_capabilities
gtk_print_unix_dialog_get_manual_capabilities
gtk_print_unix_dialog_set_support_selection
gtk_print_unix_dialog_get_support_selection
gtk_print_unix_dialog_set_has_selection
gtk_print_unix_dialog_get_has_selection
#endif
#endif
#endif
......
......@@ -494,7 +494,8 @@ typedef enum
{
GTK_PRINT_PAGES_ALL,
GTK_PRINT_PAGES_CURRENT,
GTK_PRINT_PAGES_RANGES
GTK_PRINT_PAGES_RANGES,
GTK_PRINT_PAGES_SELECTION
} GtkPrintPages;
typedef enum
......
......@@ -54,6 +54,8 @@ struct _GtkPrintOperationPrivate
guint cancelled : 1;
guint allow_async : 1;
guint is_sync : 1;
guint support_selection : 1;
guint has_selection : 1;
GtkPageDrawingState page_drawing_state;
......
......@@ -421,6 +421,12 @@ get_print_dialog (GtkPrintOperation *op,
gtk_print_unix_dialog_set_current_page (GTK_PRINT_UNIX_DIALOG (pd),
priv->current_page);
gtk_print_unix_dialog_set_support_selection (GTK_PRINT_UNIX_DIALOG (pd),
priv->support_selection);
gtk_print_unix_dialog_set_has_selection (GTK_PRINT_UNIX_DIALOG (pd),
priv->has_selection);
g_signal_emit_by_name (op, "create-custom-widget",
&priv->custom_widget);
......
......@@ -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"
......@@ -178,6 +178,12 @@ gboolean gtk_print_operation_is_finished (GtkPrintOper
void gtk_print_operation_cancel (GtkPrintOperation *op);
void gtk_print_operation_draw_page_finish (GtkPrintOperation *op);
void gtk_print_operation_set_defer_drawing (GtkPrintOperation *op);
void gtk_print_operation_set_support_selection (GtkPrintOperation *op,
gboolean support_selection);
gboolean gtk_print_operation_get_support_selection (GtkPrintOperation *op);
void gtk_print_operation_set_has_selection (GtkPrintOperation *op,
gboolean has_selection);
gboolean gtk_print_operation_get_has_selection (GtkPrintOperation *op);
GtkPageSetup *gtk_print_run_page_setup_dialog (GtkWindow *parent,
GtkPageSetup *page_setup,
......
......@@ -1356,6 +1356,9 @@ gtk_print_settings_get_print_pages (GtkPrintSettings *settings)
if (val == NULL || (strcmp (val, "all") == 0))
return GTK_PRINT_PAGES_ALL;
if (strcmp (val, "selection") == 0)
return GTK_PRINT_PAGES_SELECTION;
if (strcmp (val, "current") == 0)
return GTK_PRINT_PAGES_CURRENT;
......@@ -1389,6 +1392,9 @@ gtk_print_settings_set_print_pages (GtkPrintSettings *settings,
case GTK_PRINT_PAGES_CURRENT:
str = "current";
break;
case GTK_PRINT_PAGES_SELECTION:
str = "selection";
break;
case GTK_PRINT_PAGES_RANGES:
str = "ranges";
break;
......
This diff is collapsed.
......@@ -83,6 +83,13 @@ void gtk_print_unix_dialog_add_custom_tab (GtkPrintUnixDialog
GtkWidget *tab_label);
void gtk_print_unix_dialog_set_manual_capabilities (GtkPrintUnixDialog *dialog,
GtkPrintCapabilities capabilities);
GtkPrintCapabilities gtk_print_unix_dialog_get_manual_capabilities (GtkPrintUnixDialog *dialog);
void gtk_print_unix_dialog_set_support_selection (GtkPrintUnixDialog *dialog,
gboolean support_selection);
gboolean gtk_print_unix_dialog_get_support_selection (GtkPrintUnixDialog *dialog);
void gtk_print_unix_dialog_set_has_selection (GtkPrintUnixDialog *dialog,
gboolean has_selection);
gboolean gtk_print_unix_dialog_get_has_selection (GtkPrintUnixDialog *dialog);
G_END_DECLS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment