summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--ChangeLog.pre-2-108
-rw-r--r--gtk/gtkaboutdialog.c2
-rw-r--r--gtk/gtkprintbackend.h10
-rw-r--r--gtk/gtkprinter-private.h10
-rw-r--r--gtk/gtkprinter.c202
-rw-r--r--gtk/gtkprinter.h12
-rw-r--r--gtk/gtkprintjob.c241
-rw-r--r--gtk/gtkprintjob.h20
9 files changed, 372 insertions, 141 deletions
diff --git a/ChangeLog b/ChangeLog
index 6c17dc7e3c..7115e01668 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2006-04-23 Matthias Clasen <mclasen@redhat.com>
+ * gtk/gtkprinter-private.h:
+ * gtk/gtkprintbackend.h:
+ * gtk/gtkprinter.[hc]:
+ * gtk/gtkprintjob.[hc]: Use g types, add documentation, and some
+ stylistic fixups.
+
+ * gtk/gtkaboutdialog.c (activate_url): Avoid a compiler warning.
+
* gtk/gtkpapersize.[hc]: Use g types, add documentation.
* gtk/gtkprintunixdialog.c (gtk_print_unix_dialog_get_settings):
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 6c17dc7e3c..7115e01668 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,5 +1,13 @@
2006-04-23 Matthias Clasen <mclasen@redhat.com>
+ * gtk/gtkprinter-private.h:
+ * gtk/gtkprintbackend.h:
+ * gtk/gtkprinter.[hc]:
+ * gtk/gtkprintjob.[hc]: Use g types, add documentation, and some
+ stylistic fixups.
+
+ * gtk/gtkaboutdialog.c (activate_url): Avoid a compiler warning.
+
* gtk/gtkpapersize.[hc]: Use g types, add documentation.
* gtk/gtkprintunixdialog.c (gtk_print_unix_dialog_get_settings):
diff --git a/gtk/gtkaboutdialog.c b/gtk/gtkaboutdialog.c
index 7acd0da0b0..65c21ecb5b 100644
--- a/gtk/gtkaboutdialog.c
+++ b/gtk/gtkaboutdialog.c
@@ -1621,7 +1621,7 @@ activate_url (GtkWidget *widget,
gpointer data)
{
GtkAboutDialog *about = GTK_ABOUT_DIALOG (data);
- gchar *url = gtk_link_button_get_uri (GTK_LINK_BUTTON (widget));
+ const gchar *url = gtk_link_button_get_uri (GTK_LINK_BUTTON (widget));
if (activate_url_hook != NULL)
(* activate_url_hook) (about, url, activate_url_hook_data);
diff --git a/gtk/gtkprintbackend.h b/gtk/gtkprintbackend.h
index 940ab49bcf..de225f9e3a 100644
--- a/gtk/gtkprintbackend.h
+++ b/gtk/gtkprintbackend.h
@@ -134,15 +134,15 @@ void gtk_printer_set_has_details (GtkPrinter *printer,
void gtk_printer_set_is_default (GtkPrinter *printer,
gboolean val);
void gtk_printer_set_icon_name (GtkPrinter *printer,
- const char *icon);
+ const gchar *icon);
gboolean gtk_printer_set_job_count (GtkPrinter *printer,
- int count);
+ gint count);
gboolean gtk_printer_set_location (GtkPrinter *printer,
- const char *location);
+ const gchar *location);
gboolean gtk_printer_set_description (GtkPrinter *printer,
- const char *description);
+ const gchar *description);
gboolean gtk_printer_set_state_message (GtkPrinter *printer,
- const char *message);
+ const gchar *message);
void gtk_printer_set_is_active (GtkPrinter *printer,
gboolean active);
diff --git a/gtk/gtkprinter-private.h b/gtk/gtkprinter-private.h
index 49663c0da2..99ece474b1 100644
--- a/gtk/gtkprinter-private.h
+++ b/gtk/gtkprinter-private.h
@@ -32,7 +32,7 @@ G_BEGIN_DECLS
gboolean _gtk_printer_has_details (GtkPrinter *printer);
void _gtk_printer_request_details (GtkPrinter *printer);
GtkPrinterOptionSet *_gtk_printer_get_options (GtkPrinter *printer,
- GtkPrintSettings *settings,
+ GtkPrintSettings *settings,
GtkPageSetup *page_setup);
gboolean _gtk_printer_mark_conflicts (GtkPrinter *printer,
GtkPrinterOptionSet *options);
@@ -49,10 +49,10 @@ cairo_surface_t * _gtk_printer_create_cairo_surface (GtkPrinter
gint cache_fd);
GList * _gtk_printer_list_papers (GtkPrinter *printer);
void _gtk_printer_get_hard_margins (GtkPrinter *printer,
- double *top,
- double *bottom,
- double *left,
- double *right);
+ gdouble *top,
+ gdouble *bottom,
+ gdouble *left,
+ gdouble *right);
GHashTable * _gtk_printer_get_custom_widgets (GtkPrinter *printer);
diff --git a/gtk/gtkprinter.c b/gtk/gtkprinter.c
index db166a6843..2fd25abcdd 100644
--- a/gtk/gtkprinter.c
+++ b/gtk/gtkprinter.c
@@ -127,7 +127,7 @@ gtk_printer_class_init (GtkPrinterClass *class)
PROP_IS_VIRTUAL,
g_param_spec_boolean ("is-virtual",
P_("Is Virtual"),
- P_("False if this represents a real hardware printer"),
+ P_("FALSE if this represents a real hardware printer"),
FALSE,
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (G_OBJECT_CLASS (class),
@@ -161,7 +161,17 @@ gtk_printer_class_init (GtkPrinterClass *class)
0,
GTK_PARAM_READABLE));
-
+ /**
+ * GtkPrinter::details-acquired:
+ * @printer: the #GtkPrinter on which the signal is emitted
+ * @success: %TRUE if the details were successfully acquired
+ *
+ * Gets emitted in response to a request for detailed information
+ * about a printer from the print backend. The @success parameter
+ * indicates if the information was actually obtained.
+ *
+ * Since: 2.10
+ */
signals[DETAILS_ACQUIRED] =
g_signal_new ("details-acquired",
G_TYPE_FROM_CLASS (class),
@@ -286,15 +296,18 @@ gtk_printer_get_property (GObject *object,
/**
* gtk_printer_new:
+ * @name: the name of the printer
+ * @backend: a #GtkPrintBackend
+ * @gboolean: whether the printer is virtual
*
* Creates a new #GtkPrinter.
*
* Return value: a new #GtkPrinter
*
- * Since: 2.8
+ * Since: 2.10
**/
GtkPrinter *
-gtk_printer_new (const char *name,
+gtk_printer_new (const gchar *name,
GtkPrintBackend *backend,
gboolean virtual)
{
@@ -309,6 +322,16 @@ gtk_printer_new (const char *name,
return (GtkPrinter *) result;
}
+/**
+ * gtk_printer_get_backend:
+ * @printer: a #GtkPrinter
+ *
+ * Returns the backend of the printer.
+ *
+ * Return value: the backend of @printer
+ *
+ * Since: 2.10
+ */
GtkPrintBackend *
gtk_printer_get_backend (GtkPrinter *printer)
{
@@ -321,13 +344,26 @@ void
gtk_printer_set_backend (GtkPrinter *printer,
GtkPrintBackend *backend)
{
+ g_return_if_fail (GTK_IS_PRINTER (printer));
+ g_return_if_fail (GTK_IS_PRINT_BACKEND (backend));
+
if (printer->priv->backend)
g_object_unref (printer->priv->backend);
printer->priv->backend = g_object_ref (backend);
}
-const gchar *
+/**
+ * gtk_printer_get_name:
+ * @printer: a #GtkPrinter
+ *
+ * Returns the name of the printer.
+ *
+ * Return value: the name of @printer
+ *
+ * Since: 2.10
+ */
+G_CONST_RETURN gchar *
gtk_printer_get_name (GtkPrinter *printer)
{
g_return_val_if_fail (GTK_IS_PRINTER (printer), NULL);
@@ -335,7 +371,17 @@ gtk_printer_get_name (GtkPrinter *printer)
return printer->priv->name;
}
-const gchar *
+/**
+ * gtk_printer_get_description:
+ * @printer: a #GtkPrinter
+ *
+ * Gets the description of the printer.
+ *
+ * Return value: the description of @printer
+ *
+ * Since: 2.10
+ */
+G_CONST_RETURN gchar *
gtk_printer_get_description (GtkPrinter *printer)
{
g_return_val_if_fail (GTK_IS_PRINTER (printer), NULL);
@@ -344,9 +390,11 @@ gtk_printer_get_description (GtkPrinter *printer)
}
gboolean
-gtk_printer_set_description (GtkPrinter *printer,
- const char *description)
+gtk_printer_set_description (GtkPrinter *printer,
+ const gchar *description)
{
+ g_return_val_if_fail (GTK_IS_PRINTER (printer), FALSE);
+
if (safe_strcmp (printer->priv->description, description) == 0)
return FALSE;
@@ -356,7 +404,18 @@ gtk_printer_set_description (GtkPrinter *printer,
return TRUE;
}
-const gchar *
+/**
+ * gtk_printer_get_state_message:
+ * @printer: a #GtkPrinter
+ *
+ * Returns the state message describing the current state
+ * of the printer.
+ *
+ * Return value: the state message of @printer
+ *
+ * Since: 2.10
+ */
+G_CONST_RETURN gchar *
gtk_printer_get_state_message (GtkPrinter *printer)
{
g_return_val_if_fail (GTK_IS_PRINTER (printer), NULL);
@@ -365,9 +424,11 @@ gtk_printer_get_state_message (GtkPrinter *printer)
}
gboolean
-gtk_printer_set_state_message (GtkPrinter *printer,
- const char *message)
+gtk_printer_set_state_message (GtkPrinter *printer,
+ const gchar *message)
{
+ g_return_val_if_fail (GTK_IS_PRINTER (printer), FALSE);
+
if (safe_strcmp (printer->priv->state_message, message) == 0)
return FALSE;
@@ -378,7 +439,17 @@ gtk_printer_set_state_message (GtkPrinter *printer,
return TRUE;
}
-const gchar *
+/**
+ * gtk_printer_get_location:
+ * @printer: a #GtkPrinter
+ *
+ * Returns a description of the location of the printer.
+ *
+ * Return value: the location of @printer
+ *
+ * Since: 2.10
+ */
+G_CONST_RETURN gchar *
gtk_printer_get_location (GtkPrinter *printer)
{
g_return_val_if_fail (GTK_IS_PRINTER (printer), NULL);
@@ -387,9 +458,11 @@ gtk_printer_get_location (GtkPrinter *printer)
}
gboolean
-gtk_printer_set_location (GtkPrinter *printer,
- const char *location)
+gtk_printer_set_location (GtkPrinter *printer,
+ const gchar *location)
{
+ g_return_val_if_fail (GTK_IS_PRINTER (printer), FALSE);
+
if (safe_strcmp (printer->priv->location, location) == 0)
return FALSE;
@@ -400,7 +473,17 @@ gtk_printer_set_location (GtkPrinter *printer,
return TRUE;
}
-const gchar *
+/**
+ * gtk_printer_get_icon_name:
+ * @printer: a #GtkPrinter
+ *
+ * Gets the name of the icon to use for the printer.
+ *
+ * Return value: the icon name for @printer
+ *
+ * Since: 2.10
+ */
+G_CONST_RETURN gchar *
gtk_printer_get_icon_name (GtkPrinter *printer)
{
g_return_val_if_fail (GTK_IS_PRINTER (printer), NULL);
@@ -409,14 +492,26 @@ gtk_printer_get_icon_name (GtkPrinter *printer)
}
void
-gtk_printer_set_icon_name (GtkPrinter *printer,
- const char *icon)
+gtk_printer_set_icon_name (GtkPrinter *printer,
+ const gchar *icon)
{
+ g_return_if_fail (GTK_IS_PRINTER (printer));
+
g_free (printer->priv->icon_name);
printer->priv->icon_name = g_strdup (icon);
g_object_notify (G_OBJECT (printer), "icon-name");
}
+/**
+ * gtk_printer_get_job_count:
+ * @printer: a #GtkPrinter
+ *
+ * Gets the number of jobs currently queued on the printer.
+ *
+ * Return value: the number of jobs on @printer
+ *
+ * Since: 2.10
+ */
gint
gtk_printer_get_job_count (GtkPrinter *printer)
{
@@ -427,8 +522,10 @@ gtk_printer_get_job_count (GtkPrinter *printer)
gboolean
gtk_printer_set_job_count (GtkPrinter *printer,
- int count)
+ gint count)
{
+ g_return_val_if_fail (GTK_IS_PRINTER (printer), FALSE);
+
if (printer->priv->job_count == count)
return FALSE;
@@ -442,8 +539,6 @@ gtk_printer_set_job_count (GtkPrinter *printer,
gboolean
_gtk_printer_has_details (GtkPrinter *printer)
{
- g_return_val_if_fail (GTK_IS_PRINTER (printer), TRUE);
-
return printer->priv->has_details;
}
@@ -454,6 +549,17 @@ gtk_printer_set_has_details (GtkPrinter *printer,
printer->priv->has_details = val;
}
+/**
+ * gtk_printer_is_active:
+ * @printer: a #GtkPrinter
+ *
+ * Returns whether the printer is currently active (i.e.
+ * accepts new jobs).
+ *
+ * Return value: %TRUE if @printer is active
+ *
+ * Since: 2.10
+ */
gboolean
gtk_printer_is_active (GtkPrinter *printer)
{
@@ -466,10 +572,24 @@ void
gtk_printer_set_is_active (GtkPrinter *printer,
gboolean val)
{
+ g_return_if_fail (GTK_IS_PRINTER (printer));
+
printer->priv->is_active = val;
}
+/**
+ * gtk_printer_is_virtual:
+ * @printer: a #GtkPrinter
+ *
+ * Returns whether the printer is virtual (i.e. does not
+ * represent actual printer hardware, but something like
+ * a CUPS class).
+ *
+ * Return value: %TRUE if @printer is virtual
+ *
+ * Since: 2.10
+ */
gboolean
gtk_printer_is_virtual (GtkPrinter *printer)
{
@@ -490,10 +610,22 @@ void
gtk_printer_set_is_new (GtkPrinter *printer,
gboolean val)
{
+ g_return_if_fail (GTK_IS_PRINTER (printer));
+
printer->priv->is_new = val;
}
+/**
+ * gtk_printer_is_default:
+ * @printer: a #GtkPrinter
+ *
+ * Returns whether the printer is the default printer.
+ *
+ * Return value: %TRUE if @printer is the default
+ *
+ * Since: 2.10
+ */
gboolean
gtk_printer_is_default (GtkPrinter *printer)
{
@@ -504,8 +636,10 @@ gtk_printer_is_default (GtkPrinter *printer)
void
gtk_printer_set_is_default (GtkPrinter *printer,
- gboolean val)
+ gboolean val)
{
+ g_return_if_fail (GTK_IS_PRINTER (printer));
+
printer->priv->is_default = TRUE;
}
@@ -517,9 +651,9 @@ _gtk_printer_request_details (GtkPrinter *printer)
}
GtkPrinterOptionSet *
-_gtk_printer_get_options (GtkPrinter *printer,
+_gtk_printer_get_options (GtkPrinter *printer,
GtkPrintSettings *settings,
- GtkPageSetup *page_setup)
+ GtkPageSetup *page_setup)
{
GtkPrintBackendIface *backend_iface = GTK_PRINT_BACKEND_GET_IFACE (printer->priv->backend);
return backend_iface->printer_get_options (printer, settings, page_setup);
@@ -543,10 +677,10 @@ _gtk_printer_get_settings_from_options (GtkPrinter *printer,
}
void
-_gtk_printer_prepare_for_print (GtkPrinter *printer,
- GtkPrintJob *print_job,
+_gtk_printer_prepare_for_print (GtkPrinter *printer,
+ GtkPrintJob *print_job,
GtkPrintSettings *settings,
- GtkPageSetup *page_setup)
+ GtkPageSetup *page_setup)
{
GtkPrintBackendIface *backend_iface = GTK_PRINT_BACKEND_GET_IFACE (printer->priv->backend);
return backend_iface->printer_prepare_for_print (printer, print_job, settings, page_setup);
@@ -554,9 +688,9 @@ _gtk_printer_prepare_for_print (GtkPrinter *printer,
cairo_surface_t *
_gtk_printer_create_cairo_surface (GtkPrinter *printer,
- gdouble width,
- gdouble height,
- gint cache_fd)
+ gdouble width,
+ gdouble height,
+ gint cache_fd)
{
GtkPrintBackendIface *backend_iface = GTK_PRINT_BACKEND_GET_IFACE (printer->priv->backend);
@@ -572,11 +706,11 @@ _gtk_printer_list_papers (GtkPrinter *printer)
}
void
-_gtk_printer_get_hard_margins (GtkPrinter *printer,
- double *top,
- double *bottom,
- double *left,
- double *right)
+_gtk_printer_get_hard_margins (GtkPrinter *printer,
+ gdouble *top,
+ gdouble *bottom,
+ gdouble *left,
+ gdouble *right)
{
GtkPrintBackendIface *backend_iface = GTK_PRINT_BACKEND_GET_IFACE (printer->priv->backend);
diff --git a/gtk/gtkprinter.h b/gtk/gtkprinter.h
index 285605f1ef..5a87b03f2b 100644
--- a/gtk/gtkprinter.h
+++ b/gtk/gtkprinter.h
@@ -66,15 +66,15 @@ struct _GtkPrinterClass
};
GType gtk_printer_get_type (void) G_GNUC_CONST;
-GtkPrinter *gtk_printer_new (const char *name,
+GtkPrinter *gtk_printer_new (const gchar *name,
GtkPrintBackend *backend,
gboolean virtual);
GtkPrintBackend *gtk_printer_get_backend (GtkPrinter *printer);
-const gchar *gtk_printer_get_name (GtkPrinter *printer);
-const gchar *gtk_printer_get_state_message (GtkPrinter *printer);
-const gchar *gtk_printer_get_description (GtkPrinter *printer);
-const gchar *gtk_printer_get_location (GtkPrinter *printer);
-const gchar *gtk_printer_get_icon_name (GtkPrinter *printer);
+G_CONST_RETURN gchar *gtk_printer_get_name (GtkPrinter *printer);
+G_CONST_RETURN gchar *gtk_printer_get_state_message (GtkPrinter *printer);
+G_CONST_RETURN gchar *gtk_printer_get_description (GtkPrinter *printer);
+G_CONST_RETURN gchar *gtk_printer_get_location (GtkPrinter *printer);
+G_CONST_RETURN gchar *gtk_printer_get_icon_name (GtkPrinter *printer);
gint gtk_printer_get_job_count (GtkPrinter *printer);
gboolean gtk_printer_is_active (GtkPrinter *printer);
gboolean gtk_printer_is_virtual (GtkPrinter *printer);
diff --git a/gtk/gtkprintjob.c b/gtk/gtkprintjob.c
index 3abffaa076..13fd2e0150 100644
--- a/gtk/gtkprintjob.c
+++ b/gtk/gtkprintjob.c
@@ -143,6 +143,15 @@ gtk_print_job_class_init (GtkPrintJobClass *class)
GTK_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
+ /**
+ * GtkPrintJob::status-changed:
+ * @job: the #GtkPrintJob object on which the signal was emitted
+ *
+ * Gets emitted when the status of a job changes. The signal handler
+ * can use gtk_print_job_get_status() to obtain the new status.
+ *
+ * Since: 2.10
+ */
signals[STATUS_CHANGED] =
g_signal_new ("status-changed",
G_TYPE_FROM_CLASS (class),
@@ -154,30 +163,30 @@ gtk_print_job_class_init (GtkPrintJobClass *class)
}
static void
-gtk_print_job_init (GtkPrintJob *print_job)
+gtk_print_job_init (GtkPrintJob *job)
{
- print_job->priv = GTK_PRINT_JOB_GET_PRIVATE (print_job);
- print_job->priv->spool_file_fd = -1;
-
- print_job->priv->title = g_strdup ("");
- print_job->priv->surface = NULL;
- print_job->priv->backend = NULL;
- print_job->priv->printer = NULL;
-
- print_job->priv->printer_set = FALSE;
- print_job->priv->settings_set = FALSE;
- print_job->priv->page_setup_set = FALSE;
- print_job->priv->status = GTK_PRINT_STATUS_INITIAL;
-
- print_job->print_pages = GTK_PRINT_PAGES_ALL;
- print_job->page_ranges = NULL;
- print_job->num_page_ranges = 0;
- print_job->collate = FALSE;
- print_job->reverse = FALSE;
- print_job->num_copies = 1;
- print_job->scale = 1.0;
- print_job->page_set = GTK_PAGE_SET_ALL;
- print_job->rotate_to_orientation = FALSE;
+ job->priv = GTK_PRINT_JOB_GET_PRIVATE (job);
+ job->priv->spool_file_fd = -1;
+
+ job->priv->title = g_strdup ("");
+ job->priv->surface = NULL;
+ job->priv->backend = NULL;
+ job->priv->printer = NULL;
+
+ job->priv->printer_set = FALSE;
+ job->priv->settings_set = FALSE;
+ job->priv->page_setup_set = FALSE;
+ job->priv->status = GTK_PRINT_STATUS_INITIAL;
+
+ 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;
}
@@ -212,38 +221,38 @@ gtk_print_job_constructor (GType type,
static void
gtk_print_job_finalize (GObject *object)
{
- GtkPrintJob *print_job;
+ GtkPrintJob *job;
g_return_if_fail (object != NULL);
- print_job = GTK_PRINT_JOB (object);
+ job = GTK_PRINT_JOB (object);
- if (print_job->priv->spool_file_fd > 0)
+ if (job->priv->spool_file_fd > 0)
{
- close (print_job->priv->spool_file_fd);
- print_job->priv->spool_file_fd = -1;
+ close (job->priv->spool_file_fd);
+ job->priv->spool_file_fd = -1;
}
- if (print_job->priv->backend)
- g_object_unref (G_OBJECT (print_job->priv->backend));
+ if (job->priv->backend)
+ g_object_unref (G_OBJECT (job->priv->backend));
- if (print_job->priv->printer)
- g_object_unref (G_OBJECT (print_job->priv->printer));
+ if (job->priv->printer)
+ g_object_unref (G_OBJECT (job->priv->printer));
- if (print_job->priv->surface)
- cairo_surface_destroy (print_job->priv->surface);
+ if (job->priv->surface)
+ cairo_surface_destroy (job->priv->surface);
- if (print_job->priv->settings)
- g_object_unref (print_job->priv->settings);
+ if (job->priv->settings)
+ g_object_unref (job->priv->settings);
- if (print_job->priv->page_setup)
- g_object_unref (print_job->priv->page_setup);
+ if (job->priv->page_setup)
+ g_object_unref (job->priv->page_setup);
- g_free (print_job->page_ranges);
- print_job->page_ranges = NULL;
+ g_free (job->page_ranges);
+ job->page_ranges = NULL;
- g_free (print_job->priv->title);
- print_job->priv->title = NULL;
+ g_free (job->priv->title);
+ job->priv->title = NULL;
if (G_OBJECT_CLASS (gtk_print_job_parent_class)->finalize)
G_OBJECT_CLASS (gtk_print_job_parent_class)->finalize (object);
@@ -251,18 +260,22 @@ gtk_print_job_finalize (GObject *object)
/**
* gtk_print_job_new:
+ * @title: the job title
+ * @printer: a #GtkPrinter
+ * @settings: a #GtkPrintSettings
+ * @page_setup: a #GtkPageSetup
*
* Creates a new #GtkPrintJob.
*
* Return value: a new #GtkPrintJob
*
- * Since: 2.8
+ * Since: 2.10
**/
GtkPrintJob *
-gtk_print_job_new (const gchar *title,
- GtkPrinter *printer,
+gtk_print_job_new (const gchar *title,
+ GtkPrinter *printer,
GtkPrintSettings *settings,
- GtkPageSetup *page_setup)
+ GtkPageSetup *page_setup)
{
GObject *result;
result = g_object_new (GTK_TYPE_PRINT_JOB,
@@ -274,42 +287,84 @@ gtk_print_job_new (const gchar *title,
return (GtkPrintJob *) result;
}
+/**
+ * gtk_print_job_get_settings:
+ * @job: a #GtkPrintJob
+ *
+ * Gets the #GtkPrintSettings of the print job.
+ *
+ * Return value: the settings of @job
+ *
+ * Since: 2.10
+ */
GtkPrintSettings *
-gtk_print_job_get_settings (GtkPrintJob *print_job)
+gtk_print_job_get_settings (GtkPrintJob *job)
{
- g_return_val_if_fail (GTK_IS_PRINT_JOB (print_job), NULL);
+ g_return_val_if_fail (GTK_IS_PRINT_JOB (job), NULL);
- return print_job->priv->settings;
+ return job->priv->settings;
}
+/**
+ * gtk_print_job_get_printer:
+ * @job: a #GtkPrintJob
+ *
+ * Gets the #GtkPrinter of the print job.
+ *
+ * Return value: the printer of @job
+ *
+ * Since: 2.10
+ */
GtkPrinter *
-gtk_print_job_get_printer (GtkPrintJob *print_job)
+gtk_print_job_get_printer (GtkPrintJob *job)
{
- g_return_val_if_fail (GTK_IS_PRINT_JOB (print_job), NULL);
+ g_return_val_if_fail (GTK_IS_PRINT_JOB (job), NULL);
- return print_job->priv->printer;
+ return job->priv->printer;
}
-const char *
-gtk_print_job_get_title (GtkPrintJob *print_job)
+/**
+ * gtk_print_job_get_title:
+ * @job: a #GtkPrintJob
+ *
+ * Gets the job title.
+ *
+ * Return value: the title of @job
+ *
+ * Since: 2.10
+ */
+G_CONST_RETURN gchar *
+gtk_print_job_get_title (GtkPrintJob *job)
{
- g_return_val_if_fail (GTK_IS_PRINT_JOB (print_job), NULL);
+ g_return_val_if_fail (GTK_IS_PRINT_JOB (job), NULL);
- return print_job->priv->title;
+ return job->priv->title;
}
+/**
+ * gtk_print_job_get_status:
+ * @job: a #GtkPrintJob
+ *
+ * Gets the status of the print job.
+ *
+ * Return value: the status of @job
+ *
+ * Since: 2.10
+ */
GtkPrintStatus
-gtk_print_job_get_status (GtkPrintJob *print_job)
+gtk_print_job_get_status (GtkPrintJob *job)
{
- g_return_val_if_fail (GTK_IS_PRINT_JOB (print_job), GTK_PRINT_STATUS_FINISHED);
+ g_return_val_if_fail (GTK_IS_PRINT_JOB (job), GTK_PRINT_STATUS_FINISHED);
- return print_job->priv->status;
+ return job->priv->status;
}
void
gtk_print_job_set_status (GtkPrintJob *job,
GtkPrintStatus status)
{
+ g_return_if_fail (GTK_IS_PRINT_JOB (job));
+
if (job->priv->status == status)
return;
@@ -319,7 +374,7 @@ gtk_print_job_set_status (GtkPrintJob *job,
gboolean
gtk_print_job_set_source_file (GtkPrintJob *job,
- const char *filename,
+ const gchar *filename,
GError **error)
{
g_return_val_if_fail (GTK_IS_PRINT_JOB (job), FALSE);
@@ -344,12 +399,24 @@ gtk_print_job_set_source_file (GtkPrintJob *job,
return TRUE;
}
+/**
+ * gtk_print_job_get_surface:
+ * @job: a #GtkPrintJob
+ * @error: return location for errors, or %NULL
+ *
+ * Gets a cairo surface onto which the pages of
+ * the print job should be rendered.
+ *
+ * Return value: the cairo surface of @job
+ *
+ * Since: 2.10
+ **/
cairo_surface_t *
-gtk_print_job_get_surface (GtkPrintJob *job,
- GError **error)
+gtk_print_job_get_surface (GtkPrintJob *job,
+ GError **error)
{
- char *filename;
- double width, height;
+ gchar *filename;
+ gdouble width, height;
GtkPaperSize *paper_size;
g_return_val_if_fail (GTK_IS_PRINT_JOB (job), NULL);
@@ -358,8 +425,8 @@ gtk_print_job_get_surface (GtkPrintJob *job,
return job->priv->surface;
job->priv->spool_file_fd = g_file_open_tmp ("gtkprint_XXXXXX",
- &filename,
- error);
+ &filename,
+ error);
if (job->priv->spool_file_fd == -1)
return NULL;
@@ -369,7 +436,7 @@ gtk_print_job_get_surface (GtkPrintJob *job,
paper_size = gtk_page_setup_get_paper_size (job->priv->page_setup);
width = gtk_paper_size_get_width (paper_size, GTK_UNIT_POINTS);
height = gtk_paper_size_get_height (paper_size, GTK_UNIT_POINTS);
-
+
job->priv->surface = _gtk_printer_create_cairo_surface (job->priv->printer,
width, height,
job->priv->spool_file_fd);
@@ -446,21 +513,35 @@ gtk_print_job_get_property (GObject *object,
}
}
+/**
+ * gtk_print_job_send:
+ * @job: a GtkPrintJob
+ * @callback: function to call when the job completes
+ * @user_data: user data that gets passed to @callback
+ * @dnotify: destroy notify for @user_data
+ * @error: return location for errors, or %NULL
+ *
+ * Sends the print job off to the printer.
+ *
+ * Return value: %FALSE if an error occurred
+ *
+ * Since: 2.10
+ **/
gboolean
-gtk_print_job_send (GtkPrintJob *print_job,
- GtkPrintJobCompleteFunc callback,
- gpointer user_data,
- GDestroyNotify dnotify,
- GError **error)
+gtk_print_job_send (GtkPrintJob *job,
+ GtkPrintJobCompleteFunc callback,
+ gpointer user_data,
+ GDestroyNotify dnotify,
+ GError **error)
{
- g_return_val_if_fail (GTK_IS_PRINT_JOB (print_job), FALSE);
- g_return_val_if_fail (print_job->priv->spool_file_fd > 0, FALSE);
-
- gtk_print_job_set_status (print_job, GTK_PRINT_STATUS_SENDING_DATA);
- lseek (print_job->priv->spool_file_fd, 0, SEEK_SET);
- gtk_print_backend_print_stream (print_job->priv->backend,
- print_job,
- print_job->priv->spool_file_fd,
+ g_return_val_if_fail (GTK_IS_PRINT_JOB (job), FALSE);
+ g_return_val_if_fail (job->priv->spool_file_fd > 0, FALSE);
+
+ gtk_print_job_set_status (job, GTK_PRINT_STATUS_SENDING_DATA);
+ lseek (job->priv->spool_file_fd, 0, SEEK_SET);
+ gtk_print_backend_print_stream (job->priv->backend,
+ job,
+ job->priv->spool_file_fd,
callback,
user_data,
dnotify);
diff --git a/gtk/gtkprintjob.h b/gtk/gtkprintjob.h
index a5116c9995..2999001249 100644
--- a/gtk/gtkprintjob.h
+++ b/gtk/gtkprintjob.h
@@ -39,8 +39,8 @@ typedef struct _GtkPrintJobClass GtkPrintJobClass;
typedef struct _GtkPrintJobPrivate GtkPrintJobPrivate;
typedef void (*GtkPrintJobCompleteFunc) (GtkPrintJob *print_job,
- void *user_data,
- GError *error);
+ gpointer user_data,
+ GError *error);
struct _GtkPrinter;
@@ -85,17 +85,17 @@ GtkPrintJob *gtk_print_job_new (const gchar *t
GtkPrinter *printer,
GtkPrintSettings *settings,
GtkPageSetup *page_setup);
-GtkPrintSettings *gtk_print_job_get_settings (GtkPrintJob *print_job);
-GtkPrinter *gtk_print_job_get_printer (GtkPrintJob *print_job);
-const char *gtk_print_job_get_title (GtkPrintJob *print_job);
-GtkPrintStatus gtk_print_job_get_status (GtkPrintJob *print_job);
+GtkPrintSettings *gtk_print_job_get_settings (GtkPrintJob *job);
+GtkPrinter *gtk_print_job_get_printer (GtkPrintJob *job);
+G_CONST_RETURN gchar *gtk_print_job_get_title (GtkPrintJob *job);
+GtkPrintStatus gtk_print_job_get_status (GtkPrintJob *job);
-gboolean gtk_print_job_set_source_file (GtkPrintJob *print_job,
- const char *filename,
+gboolean gtk_print_job_set_source_file (GtkPrintJob *job,
+ const gchar *filename,
GError **error);
-cairo_surface_t *gtk_print_job_get_surface (GtkPrintJob *print_job,
+cairo_surface_t *gtk_print_job_get_surface (GtkPrintJob *job,
GError **error);
-gboolean gtk_print_job_send (GtkPrintJob *print_job,
+gboolean gtk_print_job_send (GtkPrintJob *job,
GtkPrintJobCompleteFunc callback,
gpointer user_data,
GDestroyNotify dnotify,