summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorMatthias Clasen <matthiasc@src.gnome.org>2006-06-03 03:30:21 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2006-06-03 03:30:21 +0000
commit67dc5155af74be4175d7e694f710b96cdd12156a (patch)
tree9dfabd2973bde0e2ff9fcfabbd612d31e95f0482 /gtk
parentab882a28afaa0a1f4972f2c2664cda72654aa096 (diff)
downloadgtk+-67dc5155af74be4175d7e694f710b96cdd12156a.tar.gz
Add a GtkPrintOperation::show-preview property
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkprintoperation-private.h1
-rw-r--r--gtk/gtkprintoperation-unix.c12
-rw-r--r--gtk/gtkprintoperation.c54
-rw-r--r--gtk/gtkprintoperation.h4
4 files changed, 67 insertions, 4 deletions
diff --git a/gtk/gtkprintoperation-private.h b/gtk/gtkprintoperation-private.h
index 7edfc0cdce..dbc25bfa56 100644
--- a/gtk/gtkprintoperation-private.h
+++ b/gtk/gtkprintoperation-private.h
@@ -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;
diff --git a/gtk/gtkprintoperation-unix.c b/gtk/gtkprintoperation-unix.c
index 2eb0799adb..2f66fa1ca8 100644
--- a/gtk/gtkprintoperation-unix.c
+++ b/gtk/gtkprintoperation-unix.c
@@ -504,7 +504,10 @@ found_printer (GtkPrinter *printer,
if (printer != NULL)
{
- rdata->result = GTK_PRINT_OPERATION_RESULT_APPLY;
+ 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 &&
diff --git a/gtk/gtkprintoperation.c b/gtk/gtkprintoperation.c
index d4f8fa25a3..56810f67ce 100644
--- a/gtk/gtkprintoperation.c
+++ b/gtk/gtkprintoperation.c
@@ -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;
@@ -988,9 +996,24 @@ gtk_print_operation_class_init (GtkPrintOperationClass *class)
P_("TRUE if gtk_print_operation_run() should show the print dialog."),
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:
*
* Determines whether to show a progress dialog during the
@@ -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:
diff --git a/gtk/gtkprintoperation.h b/gtk/gtkprintoperation.h
index 4b8443c064..09ae769cb4 100644
--- a/gtk/gtkprintoperation.h
+++ b/gtk/gtkprintoperation.h
@@ -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);