Remove sealed members from GtkPrintJob

Also add accessors for these members, and use them in print backends.
This commit is contained in:
Matthias Clasen 2010-12-18 17:45:31 -05:00
parent 5863382e11
commit 8105125369
8 changed files with 514 additions and 103 deletions

View File

@ -6668,6 +6668,26 @@ gtk_print_job_get_surface
gtk_print_job_send
gtk_print_job_set_track_print_status
gtk_print_job_get_track_print_status
gtk_print_job_get_pages
gtk_print_job_set_pages
gtk_print_job_get_page_ranges
gtk_print_job_set_page_ranges
gtk_print_job_get_page_set
gtk_print_job_set_page_set
gtk_print_job_get_num_copies
gtk_print_job_set_num_copies
gtk_print_job_get_scale
gtk_print_job_set_scale
gtk_print_job_get_n_up
gtk_print_job_set_n_up
gtk_print_job_get_n_up_layout
gtk_print_job_set_n_up_layout
gtk_print_job_get_rotate
gtk_print_job_set_rotate
gtk_print_job_get_collate
gtk_print_job_set_collate
gtk_print_job_get_reverse
gtk_print_job_set_reverse
<SUBSECTION Standard>
GTK_TYPE_PRINT_JOB

View File

@ -1776,7 +1776,17 @@ gtk_printer_set_is_paused
gtk_printer_set_job_count
gtk_printer_set_location
gtk_printer_set_state_message
gtk_print_job_get_collate
gtk_print_job_get_n_up
gtk_print_job_get_n_up_layout
gtk_print_job_get_num_copies
gtk_print_job_get_pages
gtk_print_job_get_page_ranges
gtk_print_job_get_page_set
gtk_print_job_get_printer
gtk_print_job_get_reverse
gtk_print_job_get_rotate
gtk_print_job_get_scale
gtk_print_job_get_settings
gtk_print_job_get_status
gtk_print_job_get_surface
@ -1785,6 +1795,16 @@ gtk_print_job_get_track_print_status
gtk_print_job_get_type G_GNUC_CONST
gtk_print_job_new
gtk_print_job_send
gtk_print_job_set_collate
gtk_print_job_set_n_up
gtk_print_job_set_n_up_layout
gtk_print_job_set_num_copies
gtk_print_job_set_pages
gtk_print_job_set_page_ranges
gtk_print_job_set_page_set
gtk_print_job_set_reverse
gtk_print_job_set_rotate
gtk_print_job_set_scale
gtk_print_job_set_source_file
gtk_print_job_set_status
gtk_print_job_set_track_print_status

View File

@ -50,17 +50,28 @@ struct _GtkPrintJobPrivate
cairo_surface_t *surface;
GtkPrintStatus status;
GtkPrintBackend *backend;
GtkPrintBackend *backend;
GtkPrinter *printer;
GtkPrintSettings *settings;
GtkPageSetup *page_setup;
guint printer_set : 1;
guint page_setup_set : 1;
guint settings_set : 1;
guint track_print_status : 1;
};
GtkPrintPages print_pages;
GtkPageRange *page_ranges;
gint num_page_ranges;
GtkPageSet page_set;
gint num_copies;
gdouble scale;
guint number_up;
GtkNumberUpLayout number_up_layout;
guint printer_set : 1;
guint page_setup_set : 1;
guint settings_set : 1;
guint track_print_status : 1;
guint rotate_to_orientation : 1;
guint collate : 1;
guint reverse : 1;
};
#define GTK_PRINT_JOB_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_PRINT_JOB, GtkPrintJobPrivate))
@ -180,7 +191,7 @@ gtk_print_job_init (GtkPrintJob *job)
{
GtkPrintJobPrivate *priv;
priv = job->priv = GTK_PRINT_JOB_GET_PRIVATE (job);
priv = job->priv = GTK_PRINT_JOB_GET_PRIVATE (job);
priv->spool_io = NULL;
@ -194,18 +205,18 @@ gtk_print_job_init (GtkPrintJob *job)
priv->page_setup_set = FALSE;
priv->status = GTK_PRINT_STATUS_INITIAL;
priv->track_print_status = FALSE;
job->print_pages = GTK_PRINT_PAGES_ALL;
job->page_ranges = NULL;
job->num_page_ranges = 0;
job->collate = FALSE;
job->reverse = FALSE;
job->num_copies = 1;
job->scale = 1.0;
job->page_set = GTK_PAGE_SET_ALL;
job->rotate_to_orientation = FALSE;
job->number_up = 1;
job->number_up_layout = GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM;
priv->print_pages = GTK_PRINT_PAGES_ALL;
priv->page_ranges = NULL;
priv->num_page_ranges = 0;
priv->collate = FALSE;
priv->reverse = FALSE;
priv->num_copies = 1;
priv->scale = 1.0;
priv->page_set = GTK_PAGE_SET_ALL;
priv->rotate_to_orientation = FALSE;
priv->number_up = 1;
priv->number_up_layout = GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM;
}
@ -250,7 +261,7 @@ gtk_print_job_finalize (GObject *object)
g_io_channel_unref (priv->spool_io);
priv->spool_io = NULL;
}
if (priv->backend)
g_object_unref (priv->backend);
@ -262,13 +273,13 @@ gtk_print_job_finalize (GObject *object)
if (priv->settings)
g_object_unref (priv->settings);
if (priv->page_setup)
g_object_unref (priv->page_setup);
g_free (job->page_ranges);
job->page_ranges = NULL;
g_free (priv->page_ranges);
priv->page_ranges = NULL;
g_free (priv->title);
priv->title = NULL;
@ -683,3 +694,330 @@ gtk_print_job_send (GtkPrintJob *job,
priv->spool_io,
callback, user_data, dnotify);
}
/**
* gtk_print_job_get_pages:
* @job: a #GtkPrintJob
*
* Gets the #GtkPrintPages setting for this job.
*
* Returns: the #GtkPrintPages setting
*
* Since: 3.0
*/
GtkPrintPages
gtk_print_job_get_pages (GtkPrintJob *job)
{
return job->priv->print_pages;
}
/**
* gtk_print_job_set_pages:
* @job: a #GtkPrintJob
* @pages: the #GtkPrintPages setting
*
* Sets the #GtkPrintPages setting for this job.
*
* Since: 3.0
*/
void
gtk_print_job_set_pages (GtkPrintJob *job,
GtkPrintPages pages)
{
job->priv->print_pages = pages;
}
/**
* gtk_print_job_get_page_ranges:
* @job: a #GtkPrintJob
* @n_ranges: (out): return location for the number of ranges
*
* Gets the page ranges for this job.
*
* Returns: a pointer to an array of #GtkPageRange structs
*
* Since: 3.0
*/
GtkPageRange *
gtk_print_job_get_page_ranges (GtkPrintJob *job,
gint *n_ranges)
{
*n_ranges = job->priv->num_page_ranges;
return job->priv->page_ranges;
}
/**
* gtk_print_job_set_page_ranges:
* @job: a #GtkPrintJob
* @ranges: pointer to an array of #GtkPageRange structs
* @n_ranges: the length of the @ranges array
*
* Sets the page ranges for this job.
*
* Since: 3.0
*/
void
gtk_print_job_set_page_ranges (GtkPrintJob *job,
GtkPageRange *ranges,
gint n_ranges)
{
job->priv->page_ranges = ranges;
job->priv->num_page_ranges = n_ranges;
}
/**
* gtk_print_job_get_page_set:
* @job: a #GtkPrintJob
*
* Gets the #GtkPageSet setting for this job.
*
* Returns: the #GtkPageSet setting
*
* Since: 3.0
*/
GtkPageSet
gtk_print_job_get_page_set (GtkPrintJob *job)
{
return job->priv->page_set;
}
/**
* gtk_print_job_set_page_set:
* @job: a #GtkPrintJob
* @page_set: a #GtkPageSet setting
*
* Sets the #GtkPageSet setting for this job.
*
* Since: 3.0
*/
void
gtk_print_job_set_page_set (GtkPrintJob *job,
GtkPageSet page_set)
{
job->priv->page_set = page_set;
}
/**
* gtk_print_job_get_num_copies:
* @job: a #GtkPrintJob
*
* Gets the number of copies of this job.
*
* Returns: the number of copies
*
* Since: 3.0
*/
gint
gtk_print_job_get_num_copies (GtkPrintJob *job)
{
return job->priv->num_copies;
}
/**
* gtk_print_job_set_num_copies:
* @job: a #GtkPrintJob
* @num_copies: the number of copies
*
* Sets the number of copies for this job.
*
* Since: 3.0
*/
void
gtk_print_job_set_num_copies (GtkPrintJob *job,
gint num_copies)
{
job->priv->num_copies = num_copies;
}
/**
* gtk_print_job_get_scale:
* @job: a #GtkPrintJob
*
* Gets the scale for this job (where 1.0 means unscaled).
*
* Returns: the scale
*
* Since: 3.0
*/
gdouble
gtk_print_job_get_scale (GtkPrintJob *job)
{
return job->priv->scale;
}
/**
* gtk_print_job_set_scale:
* @job: a #GtkPrintJob
* @scale: the scale
*
* Sets the scale for this job (where 1.0 means unscaled).
*
* Since: 3.0
*/
void
gtk_print_job_set_scale (GtkPrintJob *job,
gdouble scale)
{
job->priv->scale = scale;
}
/**
* gtk_print_job_get_n_up:
* @job: a #GtkPrintJob
*
* Gets the n-up setting for this job.
*
* Returns: the n-up setting
*
* Since: 3.0
*/
guint
gtk_print_job_get_n_up (GtkPrintJob *job)
{
return job->priv->number_up;
}
/**
* gtk_print_job_set_n_up:
* @job: a #GtkPrintJob
* @n_up: the n-up value
*
* Sets the n-up setting for this job.
*
* Since: 3.0
*/
void
gtk_print_job_set_n_up (GtkPrintJob *job,
guint n_up)
{
job->priv->number_up = n_up;
}
/**
* gtk_print_job_get_n_up_layout:
* @job: a #GtkPrintJob
*
* Gets the n-up layout setting for this job.
*
* Returns: the n-up layout
*
* Since: 3.0
*/
GtkNumberUpLayout
gtk_print_job_get_n_up_layout (GtkPrintJob *job)
{
return job->priv->number_up_layout;
}
/**
* gtk_print_job_set_n_up_layout:
* @job: a #GtkPrintJob
* @layout: the n-up layout setting
*
* Sets the n-up layout setting for this job.
*
* Since: 3.0
*/
void
gtk_print_job_set_n_up_layout (GtkPrintJob *job,
GtkNumberUpLayout layout)
{
job->priv->number_up_layout = layout;
}
/**
* gtk_print_job_get_rotate:
* @job: a #GtkPrintJob
*
* Gets whether the job is printed rotated.
*
* Returns: whether the job is printed rotated
*
* Since: 3.0
*/
gboolean
gtk_print_job_get_rotate (GtkPrintJob *job)
{
return job->priv->rotate_to_orientation;
}
/**
* gtk_print_job_set_rotate:
* @job: a #GtkPrintJob
* @rotate: whether to print rotated
*
* Sets whether this job is printed rotated.
*
* Since: 3.0
*/
void
gtk_print_job_set_rotate (GtkPrintJob *job,
gboolean rotate)
{
job->priv->rotate_to_orientation = rotate;
}
/**
* gtk_print_job_get_collate:
* @job: a #GtkPrintJob
*
* Gets whether this job is printed collated.
*
* Returns: whether the job is printed collated
*
* Since: 3.0
*/
gboolean
gtk_print_job_get_collate (GtkPrintJob *job)
{
return job->priv->collate;
}
/**
* gtk_print_job_set_collated:
* @job: a #GtkPrintJob
* @collate: whether the job is printed collated
*
* Sets whether this job is printed collated.
*
* Since: 3.0
*/
void
gtk_print_job_set_collate (GtkPrintJob *job,
gboolean collate)
{
job->priv->collate = collate;
}
/**
* gtk_print_job_get_reverse:
* @job: a #GtkPrintJob
*
* Gets whether this job is printed reversed.
*
* Returns: whether the job is printed reversed.
*
* Since: 3.0
*/
gboolean
gtk_print_job_get_reverse (GtkPrintJob *job)
{
return job->priv->reverse;
}
/**
* gtk_print_job_set_reverse:
* @job: a #GtkPrintJob
* @reverse: whether the job is printed reversed
*
* Sets whether this job is printed reversed.
*
* Since: 3.0
*/
void
gtk_print_job_set_reverse (GtkPrintJob *job,
gboolean reverse)
{
job->priv->reverse = reverse;
}

View File

@ -52,22 +52,7 @@ struct _GtkPrintJob
{
GObject parent_instance;
GtkPrintJobPrivate *GSEAL (priv);
/* Settings the client has to implement:
* (These are read-only, set at initialization)
*/
GtkPrintPages GSEAL (print_pages);
GtkPageRange *GSEAL (page_ranges);
gint GSEAL (num_page_ranges);
GtkPageSet GSEAL (page_set);
gint GSEAL (num_copies);
gdouble GSEAL (scale);
guint GSEAL (rotate_to_orientation) : 1;
guint GSEAL (collate) : 1;
guint GSEAL (reverse) : 1;
guint GSEAL (number_up);
GtkNumberUpLayout GSEAL (number_up_layout);
GtkPrintJobPrivate *priv;
};
struct _GtkPrintJobClass
@ -105,6 +90,39 @@ void gtk_print_job_send (GtkPrintJob
gpointer user_data,
GDestroyNotify dnotify);
GtkPrintPages gtk_print_job_get_pages (GtkPrintJob *job);
void gtk_print_job_set_pages (GtkPrintJob *job,
GtkPrintPages pages);
GtkPageRange * gtk_print_job_get_page_ranges (GtkPrintJob *job,
gint *n_ranges);
void gtk_print_job_set_page_ranges (GtkPrintJob *job,
GtkPageRange *ranges,
gint n_ranges);
GtkPageSet gtk_print_job_get_page_set (GtkPrintJob *job);
void gtk_print_job_set_page_set (GtkPrintJob *job,
GtkPageSet page_set);
gint gtk_print_job_get_num_copies (GtkPrintJob *job);
void gtk_print_job_set_num_copies (GtkPrintJob *job,
gint num_copies);
gdouble gtk_print_job_get_scale (GtkPrintJob *job);
void gtk_print_job_set_scale (GtkPrintJob *job,
gdouble scale);
guint gtk_print_job_get_n_up (GtkPrintJob *job);
void gtk_print_job_set_n_up (GtkPrintJob *job,
guint n_up);
GtkNumberUpLayout gtk_print_job_get_n_up_layout (GtkPrintJob *job);
void gtk_print_job_set_n_up_layout (GtkPrintJob *job,
GtkNumberUpLayout layout);
gboolean gtk_print_job_get_rotate (GtkPrintJob *job);
void gtk_print_job_set_rotate (GtkPrintJob *job,
gboolean rotate);
gboolean gtk_print_job_get_collate (GtkPrintJob *job);
void gtk_print_job_set_collate (GtkPrintJob *job,
gboolean collate);
gboolean gtk_print_job_get_reverse (GtkPrintJob *job);
void gtk_print_job_set_reverse (GtkPrintJob *job,
gboolean reverse);
G_END_DECLS
#endif /* __GTK_PRINT_JOB_H__ */

View File

@ -577,18 +577,16 @@ finish_print (PrintResponseData *rdata,
g_signal_connect (job, "status-changed",
G_CALLBACK (job_status_changed_cb), op);
priv->print_pages = job->print_pages;
priv->page_ranges = job->page_ranges;
priv->num_page_ranges = job->num_page_ranges;
priv->manual_num_copies = job->num_copies;
priv->manual_collation = job->collate;
priv->manual_reverse = job->reverse;
priv->manual_page_set = job->page_set;
priv->manual_scale = job->scale;
priv->manual_orientation = job->rotate_to_orientation;
priv->manual_number_up = job->number_up;
priv->manual_number_up_layout = job->number_up_layout;
priv->print_pages = gtk_print_job_get_pages (job);
priv->page_ranges = gtk_print_job_get_page_ranges (job, &priv->num_page_ranges);
priv->manual_num_copies = gtk_print_job_get_num_copies (job);
priv->manual_collation = gtk_print_job_get_collate (job);
priv->manual_reverse = gtk_print_job_get_reverse (job);
priv->manual_page_set = gtk_print_job_get_page_set (job);
priv->manual_scale = gtk_print_job_get_scale (job);
priv->manual_orientation = gtk_print_job_get_rotate (job);
priv->manual_number_up = gtk_print_job_get_n_up (job);
priv->manual_number_up_layout = gtk_print_job_get_n_up_layout (job);
}
}
out:

View File

@ -4366,44 +4366,49 @@ cups_printer_prepare_for_print (GtkPrinter *printer,
GtkPrintSettings *settings,
GtkPageSetup *page_setup)
{
GtkPrintPages pages;
GtkPageRange *ranges;
gint n_ranges;
GtkPageSet page_set;
GtkPaperSize *paper_size;
const char *ppd_paper_name;
double scale;
print_job->print_pages = gtk_print_settings_get_print_pages (settings);
print_job->page_ranges = NULL;
print_job->num_page_ranges = 0;
if (print_job->print_pages == GTK_PRINT_PAGES_RANGES)
print_job->page_ranges =
gtk_print_settings_get_page_ranges (settings,
&print_job->num_page_ranges);
pages = gtk_print_settings_get_print_pages (settings);
gtk_print_job_set_pages (print_job, pages);
if (pages == GTK_PRINT_PAGES_RANGES)
ranges = gtk_print_settings_get_page_ranges (settings, &n_ranges);
else
{
ranges = NULL;
n_ranges = 0;
}
gtk_print_job_set_page_ranges (print_job, ranges, n_ranges);
if (gtk_print_settings_get_collate (settings))
gtk_print_settings_set (settings, "cups-Collate", "True");
print_job->collate = FALSE;
gtk_print_job_set_collate (print_job, FALSE);
if (gtk_print_settings_get_reverse (settings))
gtk_print_settings_set (settings, "cups-OutputOrder", "Reverse");
print_job->reverse = FALSE;
gtk_print_job_set_reverse (print_job, FALSE);
if (gtk_print_settings_get_n_copies (settings) > 1)
gtk_print_settings_set_int (settings, "cups-copies",
gtk_print_settings_get_n_copies (settings));
print_job->num_copies = 1;
gtk_print_settings_get_n_copies (settings));
gtk_print_job_set_num_copies (print_job, 1);
scale = gtk_print_settings_get_scale (settings);
print_job->scale = 1.0;
if (scale != 100.0)
print_job->scale = scale/100.0;
gtk_print_job_set_scale (print_job, scale / 100.0);
page_set = gtk_print_settings_get_page_set (settings);
if (page_set == GTK_PAGE_SET_EVEN)
gtk_print_settings_set (settings, "cups-page-set", "even");
else if (page_set == GTK_PAGE_SET_ODD)
gtk_print_settings_set (settings, "cups-page-set", "odd");
print_job->page_set = GTK_PAGE_SET_ALL;
gtk_print_job_set_page_set (print_job, GTK_PAGE_SET_ALL);
paper_size = gtk_page_setup_get_paper_size (page_setup);
ppd_paper_name = gtk_paper_size_get_ppd_name (paper_size);
@ -4455,7 +4460,7 @@ cups_printer_prepare_for_print (GtkPrinter *printer,
g_type_class_unref (enum_class);
}
print_job->rotate_to_orientation = TRUE;
gtk_print_job_set_rotate (print_job, TRUE);
}
static GtkPageSetup *

View File

@ -706,28 +706,34 @@ file_printer_prepare_for_print (GtkPrinter *printer,
GtkPageSetup *page_setup)
{
gdouble scale;
GtkPrintPages pages;
GtkPageRange *ranges;
gint n_ranges;
print_job->print_pages = gtk_print_settings_get_print_pages (settings);
print_job->page_ranges = NULL;
print_job->num_page_ranges = 0;
if (print_job->print_pages == GTK_PRINT_PAGES_RANGES)
print_job->page_ranges =
gtk_print_settings_get_page_ranges (settings,
&print_job->num_page_ranges);
print_job->collate = gtk_print_settings_get_collate (settings);
print_job->reverse = gtk_print_settings_get_reverse (settings);
print_job->num_copies = gtk_print_settings_get_n_copies (settings);
print_job->number_up = gtk_print_settings_get_number_up (settings);
print_job->number_up_layout = gtk_print_settings_get_number_up_layout (settings);
pages = gtk_print_settings_get_print_pages (settings);
gtk_print_job_set_pages (print_job, pages);
if (pages == GTK_PRINT_PAGES_RANGES)
ranges = gtk_print_settings_get_page_ranges (settings, &n_ranges);
else
{
ranges = NULL;
n_ranges = 0;
}
gtk_print_job_set_page_ranges (print_job, ranges, n_ranges);
gtk_print_job_set_collate (print_job, gtk_print_settings_get_collate (settings));
gtk_print_job_set_reverse (print_job, gtk_print_settings_get_reverse (settings));
gtk_print_job_set_num_copies (print_job, gtk_print_settings_get_n_copies (settings));
gtk_print_job_set_n_up (print_job, gtk_print_settings_get_number_up (settings));
gtk_print_job_set_n_up_layout (print_job, gtk_print_settings_get_number_up_layout (settings));
scale = gtk_print_settings_get_scale (settings);
if (scale != 100.0)
print_job->scale = scale/100.0;
gtk_print_job_set_scale (print_job, scale / 100.0);
print_job->page_set = gtk_print_settings_get_page_set (settings);
print_job->rotate_to_orientation = TRUE;
gtk_print_job_set_page_set (print_job, gtk_print_settings_get_page_set (settings));
gtk_print_job_set_rotate (print_job, TRUE);
}
static GList *

View File

@ -465,26 +465,32 @@ lpr_printer_prepare_for_print (GtkPrinter *printer,
GtkPageSetup *page_setup)
{
double scale;
GtkPrintPages pages;
GtkPageRange *ranges;
gint n_ranges;
print_job->print_pages = gtk_print_settings_get_print_pages (settings);
print_job->page_ranges = NULL;
print_job->num_page_ranges = 0;
if (print_job->print_pages == GTK_PRINT_PAGES_RANGES)
print_job->page_ranges =
gtk_print_settings_get_page_ranges (settings,
&print_job->num_page_ranges);
print_job->collate = gtk_print_settings_get_collate (settings);
print_job->reverse = gtk_print_settings_get_reverse (settings);
print_job->num_copies = gtk_print_settings_get_n_copies (settings);
print_job->number_up = gtk_print_settings_get_number_up (settings);
print_job->number_up_layout = gtk_print_settings_get_number_up_layout (settings);
pages = gtk_print_settings_get_print_pages (settings);
gtk_print_job_set_pages (print_job, pages);
if (pages == GTK_PRINT_PAGES_RANGES)
ranges = gtk_print_settings_get_page_ranges (settings, &n_ranges);
else
{
ranges = NULL;
n_ranges = 0;
}
gtk_print_job_set_page_ranges (print_job, ranges, n_ranges);
gtk_print_job_set_collate (print_job, gtk_print_settings_get_collate (settings));
gtk_print_job_set_reverse (print_job, gtk_print_settings_get_reverse (settings));
gtk_print_job_set_num_copies (print_job, gtk_print_settings_get_n_copies (settings));
gtk_print_job_set_n_up (print_job, gtk_print_settings_get_number_up (settings));
gtk_print_job_set_n_up_layout (print_job, gtk_print_settings_get_number_up_layout (settings));
scale = gtk_print_settings_get_scale (settings);
if (scale != 100.0)
print_job->scale = scale/100.0;
gtk_print_job_set_scale (print_job, scale / 100.0);
print_job->page_set = gtk_print_settings_get_page_set (settings);
print_job->rotate_to_orientation = TRUE;
gtk_print_job_set_page_set (print_job, gtk_print_settings_get_page_set (settings));
gtk_print_job_set_rotate (print_job, TRUE);
}