Reference Manual |
![]() |
#include <inti/gtk-sourceview/sourceprintjob.h>
The SourcePrintJob object is used to print the contents of a SourceBuffer. You can set various configuration options to customize the printed output, and the result is obtained as a GnomePrintJob object, which you can then preview with gnome_print_job_preview_new() or print directly with gnome_print_job_print().
The easiest way to construct a new print job is from a SourceView. In this case the print job's buffer, tabs width, highlight, wrap mode, and font will be set to the values currently set in the source view. Other constructors take a SourceBuffer, a GnomePrintConfig object or both. If a GnomePrintConfig is not specified the print job will use the default gnome print configuration. If no font is set the print job will use the default font: 'Monospace Regular 10'.
Printing can be done synchronously and asynchronously. Asynchronous methods are provided so you can give the user feedback about what's going on when printing long documents (see the "begin_page" and "finished" signals).
The task of a SourcePrintJob is to produce a GnomePrintJob. What this means is that once you get the resulting GnomePrintJob, you might reuse the SourcePrintJob to produce another output (with different configuration options for example) or just unreference it and forget about it. The lifetime of the produced object is independent of that of the producer.
Before printing you should at least set the SourceBuffer you want to print (using set_buffer()). Besides that, you might configure word wrapping, font, whether to print hightlighted text as seen in the SourceView, line numbers, basic headers and footers.
SourcePrintJob can print basic headers and footers in each page. You can specify strftime() like strings for text on the left, right and center of the top and bottom of the page. You can also make SourcePrintJob draw a separator line between the text document and the header and footer. And you can specify a different font (from that used for the text document).
Customization beyond that is possible, but you have to do the printing manually. To do that, you need to connect to the "begin_page" signal of the job and allocate some space in the page using set_text_margins(). Whenever SourcePrintJob is about to print a new text page, the signal will be emitted. You can then get the GnomePrintContext being used with get_print_context() and use Gnome Print functions directly. The space you allocate is inside the document margins defined in the specified GnomePrintConfig, but outside all print area used by SourcePrintJob itself.
Example: A quick bootstrap code sequence to get you started using SourcePrintJob:
GnomePrintJob * print_source_buffer_from_view(Gtk::SourceView& view, const String& title) { // Create a job using the default print configuration and setup the buffer, // font and wrapping with those values set in the source view. Pointer<Gtk::SourcePrintJob> job = new Gtk::SourcePrintJob(*view); // Print line numbers every 5 lines, using the default font. job->set_print_numbers(5); // Print a header with the title centered. job->set_header_footer_font("Sans Regular 12.0"); job->set_header_format(0, title, 0, true); job->set_print_header(true); // Print the page number in the page bottom. job->set_footer_format(0, 0, "Page N of Q", true); job->set_print_footer(true); // Print the whole buffer and return the result (that is, a GnomePrintJob pointer). return job->print(); }
|
Construct a new SourcePrintJob from an existing GtkSourcePrintJob.
The job can be a newly created GtkSourcePrintJob or an existing GtkSourcePrintJob (see G::Object::Object). |
|
Constructs a new source print job.
If no GnomePrintConfig is set by calling set_config() the print job will use the default gnome print configuration. |
|
Constructs a new source print job with the specified configuration.
|
|
Convenience constructor that sets several configuration options at once, so that the printed output matches the view.
The configuration options set are the buffer, tabs width, highlighting, wrap mode and default font. This is the easiest way to set up a print job. If no configuration is set later the default GnomePrintConfig is used. |
|
Cancels an asynchronous printing operation.
|
|
Gets the SourceBuffer the print job would print.
|
|
Gets the current GnomePrintConfig the print job will use.
If not previously set, this will create a default configuration and return it. |
|
Gets the default font to be used for the printed text.
The returned string is of the form "Fontfamily Style Size", for example "Monospace Regular 10.0". |
|
Gets the font to be used for the header and footer.
The returned string is of the form "Fontfamily Style Size", for example "Monospace Regular 10.0". This method might return null if a specific font has not been set. |
|
Gets whether the job is configured to print the text highlighted with colors and font styles.
Note that highlighting will happen only if the buffer to print has highlighting activated. |
|
Gets the font to be used for the line numbers.
The returned string is of the form "Fontfamily Style Size", for example "Monospace Regular 10.0". This function might return a null String if a specific font for line numbers has not been set. |
|
Gets the currently printing page number.
This method is only valid while printing (either synchronously or asynchronously). |
|
Obtains the total number of pages the job will print.
The returned value is only meaninful after pagination has finished. In practice, for synchronous printing this means when "begin_page" is emitted, or after print_async() has returned. |
|
Gets the GnomePrintContext of the current job.
This method is only valid while printing. Normally you would use this method to print in the margins set by set_margins() in a handler for the "begin_page" signal. The returned object is owned by job. |
|
Determines if a footer is set to be printed for each page.
A footer will be printed if this method returns true and some format strings have been specified with set_footer_format(). |
|
Determines if a header is set to be printed for each page.
A header will be printed if this method returns true and some format strings have been specified with set_header_format(). |
|
Gets a reference to the GnomePrintJob which the job is printing or has recently finished printing.
Note you need to unref the returned object. You may call this method in the middle of an asynchronous printing operation, but the returned GnomePrintJob will not be closed until the last page is printed and the "finished" signal is emitted. |
|
Obtains the interval used for line number printing.
If the return value is 0, no line numbers will be printed. The default value is 1 (that is, line numbers are printed on all lines). |
|
Gets the configured tabs width in equivalent spaces (the default value is 8).
|
|
Gets the user set margins for the print job.
This function retrieves the values previously set by set_text_margins(). The default for all four margins is 0. Any of the pointers can be null if you want to ignore that value. |
|
Gets the wrapping style for text lines wider than the printable width.
The default is no wrapping. |
|
Called whenever the print job is about to print a new text page. You can connect to this signal to provide the user with feedback about the progress of printing, or to customize the printed page by for example, printing your own headers and footers. |
|
Called whenever an asynchronous print job has finished. You can connect to this signal to get notification when a job has finished printing. When it's emitted, the GnomePrintJob the print job was producing has been closed and it can be either previewed or printed to the physical device. |
|
Produces a GnomePrintJob with the source buffer range from start to end.
The returned GnomePrintJob pointer is referenced and so must be unreferenced when no longer required. |
|
Produces a GnomePrintJob with the printed document.
The whole contents of the configured SourceBuffer are printed. The returned job is already closed and ready to be previewed (using gnome_print_job_preview_new()) or printed directly. The caller of this method owns a reference to the returned object, so job can be destroyed and the output will still be valid, or the document can be printed again with different settings. |
|
Starts to print the job asynchronously.
This method will ready the job for printing and install an idle handler that will render one page at a time. This method will not return immediatly, as only page rendering is done asynchronously. Text retrieval and paginating happens within this method. Also, if highlighting is enabled, the whole buffer needs to be highlighted first. To get notification when the job has finished, you must connect to the "finished" signal. After this signal is emitted you can retrieve the resulting GnomePrintJob with get_print_job(). You may cancel the job with cancel(). |
|
Sets the SourceBuffer the print job will print.
You need to specify a buffer to print, either by using this method or by specifying a buffer when you construct the print job. |
|
Sets the print configuration for the job.
If you don't set a configuration object for the print job, when needed one will be created with gnome_print_config_default(). |
|
Sets the default font for the printed text.
The font_name should be a full font name GnomePrint can understand. The default font name is "Monospace Regular 10"; |
|
Sets strftime-like footer format strings, to be printed on the left, center and right of the bottom of each page (see set_header_format()).
|
|
Sets the font for printing headers and footers.
If a null String is supplied, the default font (that is, the one being used for the text) will be used instead. The default font name is 'Monospace Regular 10'; |
|
Sets strftime-like header format strings, to be printed on the left, center and right of the top of each page.
The strings may include strftime(3) codes which will be expanded at print time. All strftime() codes are accepted (A for the day, F for the date, T for the time), with the addition of N for the page number and Q for the total page count. separator specifies if a solid line should be drawn to separate the header from the document text. If a null String is given for any of the three arguments, that particular string will not be printed. For the header to be printed, in addition to specifying format strings, you need to enable header printing with set_print_header(). |
|
Sets whether the printed text will be highlighted according to the buffer rules.
If highlight is true both color and font style are applied. |
|
Sets the font for printing line numbers on the left margin.
If a null String is supplied, the default font (that is, the one being used for the text) will be used instead. |
|
Sets whether you want to print a footer in each page.
The default footer consists of three pieces of text and an optional line separator, configurable with set_footer_format(). Note that by default the footer format is unspecified, and if it's empty it will not be printed, regardless of this setting. |
|
Sets whether you want to print a header in each page.
The default header consists of three pieces of text and an optional line separator, configurable with set_header_format(). Note that by default the header format is unspecified, and if it's empty it will not be printed, regardless of this setting. |
|
Sets the interval for printed line numbers.
If interval is 0 no numbers will be printed. If greater than 0, a number will be printed every interval lines (that is, 1 will print a number on every line, 2 will print a number on every second line, 3 will print a number on every third line, and so on). |
|
Sets the tabs width (in equivalent spaces) for the printed text.
The width in printing units will be calculated as the width of a string containing tabs_width spaces of the default font. Tab stops are set for the full width of printed text. |
|
Sets the four user margins for the print job.
These margins are in addition to the document margins provided in the GnomePrintConfig and will not be used for headers, footers or line numbers (those are calculated separatedly). You can print in the space allocated by these margins by connecting to the "begin_page" signal. The space is around the printed text, and inside the margins specified in the GnomePrintConfig. The margin numbers are given in device units. If any of the given values is less than 0, that particular margin is not altered by this function. |
|
Sets the wrap mode for lines of text larger than the printable width.
|
|
Generated on Wed Aug 27 21:17:28 2003 for Inti-SourceView by ![]() |