Determines whether the print operation may run asynchronously or not.
Some systems don't support asynchronous printing, but those that do will return %GTK_PRINT_OPERATION_RESULT_IN_PROGRESS as the status, and emit the #GtkPrintOperation::done signal when the operation is actually done.
The Windows port does not support asynchronous operation at all (this is unlikely to change). On other platforms, all actions except for %GTK_PRINT_OPERATION_ACTION_EXPORT support asynchronous operation.
The current page in the document.
If this is set before gtk_print_operation_run(), the user will be able to select to print only the current page.
Note that this only makes sense for pre-paginated documents.
Used as the label of the tab containing custom widgets. Note that this property may be ignored on some platforms.
If this is %NULL, GTK+ uses a default label.
The #GtkPageSetup used by default.
This page setup will be used by gtk_print_operation_run(), but it can be overridden on a per-page basis by connecting to the #GtkPrintOperation::request-page-setup signal.
If %TRUE, page size combo box and orientation combo box are embedded into page setup page.
The name of a file to generate instead of showing the print dialog. Currently, PDF is the only supported format.
The intended use of this property is for implementing "Export to PDF" actions.
"Print to PDF" support is independent of this and is done by letting the user pick the "Print to PDF" item from the list of printers in the print dialog.
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.
A string used to identify the job (e.g. in monitoring applications like eggcups).
If you don't set a job name, GTK+ picks a default one by numbering successive print jobs.
The number of pages in the document.
This
Note that the page numbers passed to the
#GtkPrintOperation::request-page-setup and
#GtkPrintOperation::draw-page signals are 0-based, i.e. if
the user chooses to print all pages, the last ::draw-page signal
will be for page n_pages
- 1.
The number of pages that will be printed.
Note that this value is set during print preparation phase (%GTK_PRINT_STATUS_PREPARING), so this value should never be get before the data generation phase (%GTK_PRINT_STATUS_GENERATING_DATA). You can connect to the #GtkPrintOperation::status-changed signal and call gtk_print_operation_get_n_pages_to_print() when print status is %GTK_PRINT_STATUS_GENERATING_DATA. This is typically used to track the progress of print operation.
The #GtkPrintSettings used for initializing the dialog.
Setting this property is typically used to re-establish print settings from a previous print operation, see gtk_print_operation_run().
Determines whether to show a progress dialog during the print operation.
The status of the print operation.
A string representation of the status of the print operation. The string is translated and suitable for displaying the print status e.g. in a #GtkStatusbar.
See the #GtkPrintOperation:status property for a status value that is suitable for programmatic use.
If %TRUE, the print operation will support print of selection. This allows the print dialog to show a "Selection" button.
If %TRUE, the print operation will try to continue report on the status of the print job in the printer queues and printer. This can allow your application to show things like "out of paper" issues, and when the print job actually reaches the printer. However, this is often implemented using polling, and should not be enabled unless needed.
The transformation for the cairo context obtained from
#GtkPrintContext is set up in such a way that distances
are measured in units of unit
.
If %TRUE, the transformation for the cairo context obtained from #GtkPrintContext puts the origin at the top left corner of the page (which may not be the top left corner of the sheet, depending on page orientation and the number of pages per sheet). Otherwise, the origin is at the top left corner of the imageable area (i.e. inside the margins).
Creates a binding between source_property
on source
and target_property
on target
.
Whenever the source_property
is changed the target_property
is
updated using the same value. For instance:
g_object_bind_property (action, "active", widget, "sensitive", 0);
Will result in the "sensitive" property of the widget #GObject instance to be updated with the same value of the "active" property of the action #GObject instance.
If flags
contains %G_BINDING_BIDIRECTIONAL then the binding will be mutual:
if target_property
on target
changes then the source_property
on source
will be updated as well.
The binding will automatically be removed when either the source
or the
target
instances are finalized. To remove the binding without affecting the
source
and the target
you can just call g_object_unref() on the returned
#GBinding instance.
Removing the binding by calling g_object_unref() on it must only be done if
the binding, source
and target
are only used from a single thread and it
is clear that both source
and target
outlive the binding. Especially it
is not safe to rely on this if the binding, source
or target
can be
finalized from different threads. Keep another reference to the binding and
use g_binding_unbind() instead to be on the safe side.
A #GObject can have multiple bindings.
the property on source
to bind
the target #GObject
the property on target
to bind
flags to pass to #GBinding
Creates a binding between source_property
on source
and target_property
on target,
allowing you to set the transformation functions to be used by
the binding.
This function is the language bindings friendly version of g_object_bind_property_full(), using #GClosures instead of function pointers.
the property on source
to bind
the target #GObject
the property on target
to bind
flags to pass to #GBinding
a #GClosure wrapping the transformation function from the source
to the target,
or %NULL to use the default
a #GClosure wrapping the transformation function from the target
to the source,
or %NULL to use the default
Cancels a running print operation. This function may be called from a #GtkPrintOperation::begin-print, #GtkPrintOperation::paginate or #GtkPrintOperation::draw-page signal handler to stop the currently running print operation.
Signalize that drawing of particular page is complete.
It is called after completion of page drawing (e.g. drawing in another thread). If gtk_print_operation_set_defer_drawing() was called before, then this function has to be called by application. In another case it is called by the library itself.
Ends a preview.
This function must be called to finish a custom print preview.
This function is intended for #GObject implementations to re-enforce a [floating][floating-ref] object reference. Doing this is seldom required: all #GInitiallyUnowneds are created with a floating reference which usually just needs to be sunken by calling g_object_ref_sink().
Increases the freeze count on object
. If the freeze count is
non-zero, the emission of "notify" signals on object
is
stopped. The signals are queued until the freeze count is decreased
to zero. Duplicate notifications are squashed so that at most one
#GObject::notify signal is emitted for each property modified while the
object is frozen.
This is necessary for accessors that modify multiple properties to prevent premature notification while the object is still being modified.
Gets a named field from the objects table of associations (see g_object_set_data()).
name of the key for that association
Gets the value of #GtkPrintOperation::embed-page-setup property.
Call this when the result of a print operation is %GTK_PRINT_OPERATION_RESULT_ERROR, either as returned by gtk_print_operation_run(), or in the #GtkPrintOperation::done signal handler. The returned #GError will contain more details on what went wrong.
Gets the value of #GtkPrintOperation::has-selection property.
Returns the number of pages that will be printed.
Note that this value is set during print preparation phase (%GTK_PRINT_STATUS_PREPARING), so this function should never be called before the data generation phase (%GTK_PRINT_STATUS_GENERATING_DATA). You can connect to the #GtkPrintOperation::status-changed signal and call gtk_print_operation_get_n_pages_to_print() when print status is %GTK_PRINT_STATUS_GENERATING_DATA. This is typically used to track the progress of print operation.
Returns the current print settings.
Note that the return value is %NULL until either gtk_print_operation_set_print_settings() or gtk_print_operation_run() have been called.
Gets a property of an object.
The value
can be:
In general, a copy is made of the property contents and the caller is responsible for freeing the memory by calling g_value_unset().
Note that g_object_get_property() is really intended for language bindings, g_object_get() is much more convenient for C programming.
the name of the property to get
return location for the property value
This function gets back user data pointers stored via g_object_set_qdata().
A #GQuark, naming the user data pointer
Returns the status of the print operation. Also see gtk_print_operation_get_status_string().
Returns a string representation of the status of the print operation. The string is translated and suitable for displaying the print status e.g. in a #GtkStatusbar.
Use gtk_print_operation_get_status() to obtain a status value that is suitable for programmatic use.
Gets the value of #GtkPrintOperation::support-selection property.
Gets n_properties
properties for an object
.
Obtained properties will be set to values
. All properties must be valid.
Warnings will be emitted and undefined behaviour may result if invalid
properties are passed in.
the names of each property to get
the values of each property to get
A convenience function to find out if the print operation is finished, either successfully (%GTK_PRINT_STATUS_FINISHED) or unsuccessfully (%GTK_PRINT_STATUS_FINISHED_ABORTED).
Note: when you enable print status tracking the print operation can be in a non-finished state even after done has been called, as the operation status then tracks the print job status on the printer.
Checks whether object
has a [floating][floating-ref] reference.
Returns whether the given page is included in the set of pages that have been selected for printing.
a page number
Emits a "notify" signal for the property property_name
on object
.
When possible, eg. when signaling a property change from within the class that registered the property, you should use g_object_notify_by_pspec() instead.
Note that emission of the notify signal may be blocked with g_object_freeze_notify(). In this case, the signal emissions are queued and will be emitted (in reverse order) when g_object_thaw_notify() is called.
the name of a property installed on the class of object
.
Emits a "notify" signal for the property specified by pspec
on object
.
This function omits the property name lookup, hence it is faster than g_object_notify().
One way to avoid using g_object_notify() from within the class that registered the properties, and using g_object_notify_by_pspec() instead, is to store the GParamSpec used with g_object_class_install_property() inside a static array, e.g.:
enum
{
PROP_0,
PROP_FOO,
PROP_LAST
};
static GParamSpec *properties[PROP_LAST];
static void
my_object_class_init (MyObjectClass *klass)
{
properties[PROP_FOO] = g_param_spec_int ("foo", "Foo", "The foo",
0, 100,
50,
G_PARAM_READWRITE);
g_object_class_install_property (gobject_class,
PROP_FOO,
properties[PROP_FOO]);
}
and then notify a change on the "foo" property with:
g_object_notify_by_pspec (self, properties[PROP_FOO]);
the #GParamSpec of a property installed on the class of object
.
Increase the reference count of object,
and possibly remove the
[floating][floating-ref] reference, if object
has a floating reference.
In other words, if the object is floating, then this call "assumes ownership" of the floating reference, converting it to a normal reference by clearing the floating flag while leaving the reference count unchanged. If the object is not floating, then this call adds a new normal reference increasing the reference count by one.
Since GLib 2.56, the type of object
will be propagated to the return type
under the same conditions as for g_object_ref().
Renders a page to the preview, using the print context that
was passed to the #GtkPrintOperation::preview handler together
with preview
.
A custom iprint preview should use this function in its ::expose handler to render the currently selected page.
Note that this function requires a suitable cairo context to be associated with the print context.
the page to render
Runs the print operation, by first letting the user modify print settings in the print dialog, and then print the document.
Normally that this function does not return until the rendering of all
pages is complete. You can connect to the
#GtkPrintOperation::status-changed signal on op
to obtain some
information about the progress of the print operation.
Furthermore, it may use a recursive mainloop to show the print dialog.
If you call gtk_print_operation_set_allow_async() or set the #GtkPrintOperation:allow-async property the operation will run asynchronously if this is supported on the platform. The #GtkPrintOperation::done signal will be emitted with the result of the operation when the it is done (i.e. when the dialog is canceled, or when the print succeeds or fails). |[ if (settings != NULL) gtk_print_operation_set_print_settings (print, settings);
if (page_setup != NULL) gtk_print_operation_set_default_page_setup (print, page_setup);
g_signal_connect (print, "begin-print", G_CALLBACK (begin_print), &data); g_signal_connect (print, "draw-page", G_CALLBACK (draw_page), &data);
res = gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, parent, &error);
if (res == GTK_PRINT_OPERATION_RESULT_ERROR) { error_dialog = gtk_message_dialog_new (GTK_WINDOW (parent), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Error printing file:\n%s", error->message); g_signal_connect (error_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL); gtk_widget_show (error_dialog); g_error_free (error); } else if (res == GTK_PRINT_OPERATION_RESULT_APPLY) { if (settings != NULL) g_object_unref (settings); settings = g_object_ref (gtk_print_operation_get_print_settings (print)); }
Note that gtk_print_operation_run() can only be called once on a
given #GtkPrintOperation.
@param action the action to start
@param parent Transient parent of the dialog
Releases all references to other objects. This can be used to break reference cycles.
This function should only be called from object system implementations.
Sets whether the gtk_print_operation_run() may return before the print operation is completed. Note that some platforms may not allow asynchronous operation.
%TRUE to allow asynchronous operation
Sets the current page.
If this is called before gtk_print_operation_run(), the user will be able to select to print only the current page.
Note that this only makes sense for pre-paginated documents.
the current page, 0-based
Sets the label for the tab holding custom widgets.
the label to use, or %NULL to use the default label
Each object carries around a table of associations from strings to pointers. This function lets you set an association.
If the object already had an association with that name, the old association will be destroyed.
Internally, the key
is converted to a #GQuark using g_quark_from_string().
This means a copy of key
is kept permanently (even after object
has been
finalized) — so it is recommended to only use a small, bounded set of values
for key
in your program, to avoid the #GQuark storage growing unbounded.
name of the key
data to associate with that key
Makes default_page_setup
the default page setup for op
.
This page setup will be used by gtk_print_operation_run(), but it can be overridden on a per-page basis by connecting to the #GtkPrintOperation::request-page-setup signal.
Sets up the #GtkPrintOperation to wait for calling of gtk_print_operation_draw_page_finish() from application. It can be used for drawing page in another thread.
This function must be called in the callback of "draw-page" signal.
Embed page size combo box and orientation combo box into page setup page. Selected page setup is stored as default page setup in #GtkPrintOperation.
%TRUE to embed page setup selection in the #GtkPrintDialog
Sets up the #GtkPrintOperation to generate a file instead of showing the print dialog. The indended use of this function is for implementing "Export to PDF" actions. Currently, PDF is the only supported format.
"Print to PDF" support is independent of this and is done by letting the user pick the "Print to PDF" item from the list of printers in the print dialog.
the filename for the exported file
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.
%TRUE indicates that a selection exists
Sets the name of the print job. The name is used to identify the job (e.g. in monitoring applications like eggcups).
If you don't set a job name, GTK+ picks a default one by numbering successive print jobs.
a string that identifies the print job
Sets the number of pages in the document.
This
Note that the page numbers passed to the
#GtkPrintOperation::request-page-setup
and #GtkPrintOperation::draw-page signals are 0-based, i.e. if
the user chooses to print all pages, the last ::draw-page signal
will be for page n_pages
- 1.
the number of pages
Sets the print settings for op
. This is typically used to
re-establish print settings from a previous print operation,
see gtk_print_operation_run().
#GtkPrintSettings
Sets a property on an object.
the name of the property to set
the value
If show_progress
is %TRUE, the print operation will show a
progress dialog during the print operation.
%TRUE to show a progress dialog
Sets whether selection is supported by #GtkPrintOperation.
%TRUE to support selection
If track_status is %TRUE, the print operation will try to continue report on the status of the print job in the printer queues and printer. This can allow your application to show things like "out of paper" issues, and when the print job actually reaches the printer.
This function is often implemented using some form of polling, so it should not be enabled unless needed.
%TRUE to track status after printing
If full_page
is %TRUE, the transformation for the cairo context
obtained from #GtkPrintContext puts the origin at the top left
corner of the page (which may not be the top left corner of the
sheet, depending on page orientation and the number of pages per
sheet). Otherwise, the origin is at the top left corner of the
imageable area (i.e. inside the margins).
%TRUE to set up the #GtkPrintContext for the full page
Remove a specified datum from the object's data associations, without invoking the association's destroy handler.
name of the key
This function gets back user data pointers stored via
g_object_set_qdata() and removes the data
from object
without invoking its destroy() function (if any was
set).
Usually, calling this function is only required to update
user data pointers with a destroy notifier, for example:
void
object_add_to_user_list (GObject *object,
const gchar *new_string)
{
// the quark, naming the object data
GQuark quark_string_list = g_quark_from_static_string ("my-string-list");
// retrieve the old string list
GList *list = g_object_steal_qdata (object, quark_string_list);
// prepend new string
list = g_list_prepend (list, g_strdup (new_string));
// this changed 'list', so we need to set it again
g_object_set_qdata_full (object, quark_string_list, list, free_string_list);
}
static void
free_string_list (gpointer data)
{
GList *node, *list = data;
for (node = list; node; node = node->next)
g_free (node->data);
g_list_free (list);
}
Using g_object_get_qdata() in the above example, instead of g_object_steal_qdata() would have left the destroy function set, and thus the partial string list would have been freed upon g_object_set_qdata_full().
A #GQuark, naming the user data pointer
Reverts the effect of a previous call to
g_object_freeze_notify(). The freeze count is decreased on object
and when it reaches zero, queued "notify" signals are emitted.
Duplicate notifications for each property are squashed so that at most one #GObject::notify signal is emitted for each property, in the reverse order in which they have been queued.
It is an error to call this function when the freeze count is zero.
Decreases the reference count of object
. When its reference count
drops to 0, the object is finalized (i.e. its memory is freed).
If the pointer to the #GObject may be reused in future (for example, if it is an instance variable of another object), it is recommended to clear the pointer to %NULL rather than retain a dangling pointer to a potentially invalid #GObject instance. Use g_clear_object() for this.
Ends a preview.
This function must be called to finish a custom print preview.
Returns whether the given page is included in the set of pages that have been selected for printing.
a page number
Emits a "notify" signal for the property property_name
on object
.
When possible, eg. when signaling a property change from within the class that registered the property, you should use g_object_notify_by_pspec() instead.
Note that emission of the notify signal may be blocked with g_object_freeze_notify(). In this case, the signal emissions are queued and will be emitted (in reverse order) when g_object_thaw_notify() is called.
Renders a page to the preview, using the print context that
was passed to the #GtkPrintOperation::preview handler together
with preview
.
A custom iprint preview should use this function in its ::expose handler to render the currently selected page.
Note that this function requires a suitable cairo context to be associated with the print context.
the page to render
This function essentially limits the life time of the closure
to
the life time of the object. That is, when the object is finalized,
the closure
is invalidated by calling g_closure_invalidate() on
it, in order to prevent invocations of the closure with a finalized
(nonexisting) object. Also, g_object_ref() and g_object_unref() are
added as marshal guards to the closure,
to ensure that an extra
reference count is held on object
during invocation of the
closure
. Usually, this function will be called on closures that
use this object
as closure data.
#GClosure to watch
Find the #GParamSpec with the given name for an
interface. Generally, the interface vtable passed in as g_iface
will be the default vtable from g_type_default_interface_ref(), or,
if you know the interface has already been loaded,
g_type_default_interface_peek().
any interface vtable for the interface, or the default vtable for the interface
name of a property to look up.
Add a property to an interface; this is only useful for interfaces that are added to GObject-derived types. Adding a property to an interface forces all objects classes with that interface to have a compatible property. The compatible property could be a newly created #GParamSpec, but normally g_object_class_override_property() will be used so that the object class only needs to provide an implementation and inherits the property description, default value, bounds, and so forth from the interface property.
This function is meant to be called from the interface's default
vtable initialization function (the class_init
member of
#GTypeInfo.) It must not be called after after class_init
has
been called for any object types implementing this interface.
If pspec
is a floating reference, it will be consumed.
any interface vtable for the interface, or the default vtable for the interface.
the #GParamSpec for the new property
Lists the properties of an interface.Generally, the interface
vtable passed in as g_iface
will be the default vtable from
g_type_default_interface_ref(), or, if you know the interface has
already been loaded, g_type_default_interface_peek().
any interface vtable for the interface, or the default vtable for the interface
Creates a new #GtkPrintOperation.
Creates a new instance of a #GObject subtype and sets its properties.
Construction parameters (see %G_PARAM_CONSTRUCT, %G_PARAM_CONSTRUCT_ONLY) which are not explicitly specified are set to their default values.
the type id of the #GObject subtype to instantiate
an array of #GParameter
Creates a new #GtkPrintOperation.