Add a GtkPrintOperation::show-preview property

This commit is contained in:
Matthias Clasen 2006-06-03 03:30:21 +00:00
parent ab882a28af
commit 67dc5155af
6 changed files with 79 additions and 4 deletions

View File

@ -1,5 +1,11 @@
2006-06-02 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkprintoperation-private.h:
* gtk/gtkprintoperation.h:
* gtk/gtkprintoperation.c: Add a show-preview property.
* gtk/gtkprintoperation-unix.c: Implement it here.
* gtk/gtkprintoperation-unix.c: Cleanups
2006-06-02 Kristian Rietveld <kris@imendio.com>

View File

@ -1,5 +1,11 @@
2006-06-02 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkprintoperation-private.h:
* gtk/gtkprintoperation.h:
* gtk/gtkprintoperation.c: Add a show-preview property.
* gtk/gtkprintoperation-unix.c: Implement it here.
* gtk/gtkprintoperation-unix.c: Cleanups
2006-06-02 Kristian Rietveld <kris@imendio.com>

View File

@ -38,6 +38,7 @@ struct _GtkPrintOperationPrivate
gchar *pdf_target;
guint use_full_page : 1;
guint show_dialog : 1;
guint show_preview : 1;
guint track_print_status : 1;
guint show_progress : 1;
guint cancelled : 1;

View File

@ -504,6 +504,9 @@ found_printer (GtkPrinter *printer,
if (printer != NULL)
{
if (priv->show_preview)
rdata->result = GTK_PRINT_OPERATION_RESULT_PREVIEW;
else
rdata->result = GTK_PRINT_OPERATION_RESULT_APPLY;
rdata->do_print = TRUE;
@ -835,8 +838,11 @@ printer_added_cb (GtkPrintBackend *backend,
GtkPrinter *printer,
PrinterFinder *finder)
{
if (gtk_printer_is_virtual (printer) ||
finder->found_printer)
if (finder->found_printer)
return;
/* FIXME this skips "Print to PDF" - is this intentional ? */
if (gtk_printer_is_virtual (printer))
return;
if (finder->printer_name != NULL &&

View File

@ -60,6 +60,7 @@ enum {
PROP_TRACK_PRINT_STATUS,
PROP_UNIT,
PROP_SHOW_DIALOG,
PROP_SHOW_PREVIEW,
PROP_SHOW_PROGRESS,
PROP_PDF_TARGET,
PROP_STATUS,
@ -146,6 +147,7 @@ gtk_print_operation_init (GtkPrintOperation *operation)
priv->current_page = -1;
priv->use_full_page = FALSE;
priv->show_dialog = TRUE;
priv->show_preview = FALSE;
priv->show_progress = FALSE;
priv->pdf_target = NULL;
priv->track_print_status = FALSE;
@ -283,6 +285,9 @@ gtk_print_operation_set_property (GObject *object,
case PROP_SHOW_DIALOG:
gtk_print_operation_set_show_dialog (op, g_value_get_boolean (value));
break;
case PROP_SHOW_PREVIEW:
gtk_print_operation_set_show_preview (op, g_value_get_boolean (value));
break;
case PROP_SHOW_PROGRESS:
gtk_print_operation_set_show_progress (op, g_value_get_boolean (value));
break;
@ -336,6 +341,9 @@ gtk_print_operation_get_property (GObject *object,
case PROP_SHOW_DIALOG:
g_value_set_boolean (value, priv->show_dialog);
break;
case PROP_SHOW_PREVIEW:
g_value_set_boolean (value, priv->show_preview);
break;
case PROP_SHOW_PROGRESS:
g_value_set_boolean (value, priv->show_progress);
break;
@ -989,6 +997,21 @@ gtk_print_operation_class_init (GtkPrintOperationClass *class)
TRUE,
GTK_PARAM_READWRITE));
/**
* GtkPrintOperation:show-preview:
*
* Determines whether calling gtk_print_operation_run() will present
* the print preview to the user.
*
* Since: 2.10
*/
g_object_class_install_property (gobject_class,
PROP_SHOW_PREVIEW,
g_param_spec_boolean ("show-preview",
P_("Show Preview"),
P_("TRUE if gtk_print_operation_run() should show the print preview."),
TRUE,
GTK_PARAM_READWRITE));
/**
* GtkPrintOperation:show-progress:
@ -1573,6 +1596,35 @@ gtk_print_operation_set_show_dialog (GtkPrintOperation *op,
}
}
/**
* gtk_print_operation_set_show_preview:
* @op: a #GtkPrintOperation
* @show_preview: %TRUE to show the print preview
*
* Sets whether calling gtk_print_operation_run() will present
* the print preview to the user.
*
* Since: 2.10
*/
void
gtk_print_operation_set_show_preview (GtkPrintOperation *op,
gboolean show_preview)
{
GtkPrintOperationPrivate *priv;
g_return_if_fail (GTK_IS_PRINT_OPERATION (op));
priv = op->priv;
show_preview = show_preview != FALSE;
if (priv->show_preview != show_preview)
{
priv->show_preview = show_preview;
g_object_notify (G_OBJECT (op), "show-preview");
}
}
/**
* gtk_print_operation_set_show_progress:

View File

@ -140,6 +140,8 @@ void gtk_print_operation_set_unit (GtkPrintOper
GtkUnit unit);
void gtk_print_operation_set_show_dialog (GtkPrintOperation *op,
gboolean show_dialog);
void gtk_print_operation_set_show_preview (GtkPrintOperation *op,
gboolean show_preview);
void gtk_print_operation_set_pdf_target (GtkPrintOperation *op,
const gchar *filename);
void gtk_print_operation_set_track_print_status (GtkPrintOperation *op,
@ -151,6 +153,8 @@ void gtk_print_operation_set_custom_tab_label (GtkPrintOper
GtkPrintOperationResult gtk_print_operation_run (GtkPrintOperation *op,
GtkWindow *parent,
GError **error);
void gtk_print_operation_run_preview (GtkPrintOperation *op,
GtkWindow *parent);
GtkPrintStatus gtk_print_operation_get_status (GtkPrintOperation *op);
G_CONST_RETURN gchar * gtk_print_operation_get_status_string (GtkPrintOperation *op);
gboolean gtk_print_operation_is_finished (GtkPrintOperation *op);