Class: GtkSource::PrintCompositor
- Inherits:
-
Object
- Object
- GtkSource::PrintCompositor
- Defined in:
- (unknown)
Instance Method Summary collapse
-
#body_font_name ⇒ String
Name of the font used for the text body.
-
#body_font_name=(body_font_name) ⇒ String
Name of the font used for the text body.
-
#buffer ⇒ GtkSource::Buffer
The [classBuffer] object to print.
-
#buffer=(buffer) ⇒ GtkSource::Buffer
The [classBuffer] object to print.
-
#draw_page(context, page_nr) ⇒ nil
Draw page page_nr for printing on the the Cairo context encapsuled in context.
-
#footer_font_name ⇒ String
Name of the font used to print page footer.
-
#footer_font_name=(footer_font_name) ⇒ String
Name of the font used to print page footer.
-
#get_bottom_margin(unit) ⇒ Float
Gets the bottom margin in units of unit.
-
#get_left_margin(unit) ⇒ Float
Gets the left margin in units of unit.
-
#get_right_margin(unit) ⇒ Float
Gets the right margin in units of unit.
-
#get_top_margin(unit) ⇒ Float
Gets the top margin in units of unit.
-
#header_font_name ⇒ String
Name of the font used to print page header.
-
#header_font_name=(header_font_name) ⇒ String
Name of the font used to print page header.
-
#highlight_syntax ⇒ Boolean
Determines whether the printed text will be highlighted according to the buffer rules.
-
#highlight_syntax=(highlight_syntax) ⇒ Boolean
Whether to print the document with highlighted syntax.
-
#highlight_syntax? ⇒ Boolean
Whether to print the document with highlighted syntax.
-
#ignore_tag(tag) ⇒ nil
Specifies a tag whose style should be ignored when compositing the document to the printable page.
-
#initialize(view) ⇒ GtkSource::PrintCompositor
constructor
Creates a new print compositor that can be used to print the buffer associated with view.
-
#line_numbers_font_name ⇒ String
Name of the font used to print line numbers on the left margin.
-
#line_numbers_font_name=(line_numbers_font_name) ⇒ String
Name of the font used to print line numbers on the left margin.
-
#n_pages ⇒ Integer
The number of pages in the document or -1 if the document has not been completely paginated.
-
#n_pages=(n_pages) ⇒ Integer
The number of pages in the document or -1 if the document has not been completely paginated.
-
#paginate(context) ⇒ Boolean
Paginate the document associated with the compositor.
-
#pagination_progress ⇒ Float
Returns the current fraction of the document pagination that has been completed.
-
#print_footer ⇒ Boolean
Determines if a footer is set to be printed for each page.
-
#print_footer=(print_footer) ⇒ Boolean
Whether to print a footer in each page.
-
#print_footer? ⇒ Boolean
Whether to print a footer in each page.
-
#print_header ⇒ Boolean
Determines if a header is set to be printed for each page.
-
#print_header=(print_header) ⇒ Boolean
Whether to print a header in each page.
-
#print_header? ⇒ Boolean
Whether to print a header in each page.
-
#print_line_numbers ⇒ Integer
Interval of printed line numbers.
-
#print_line_numbers=(print_line_numbers) ⇒ Integer
Interval of printed line numbers.
-
#set_bottom_margin(margin, unit) ⇒ nil
Sets the bottom margin used by compositor.
-
#set_footer_format(separator, left, center, right) ⇒ nil
See [methodPrintCompositor.set_header_format] for more information about the parameters.
-
#set_header_format(separator, left, center, right) ⇒ nil
Sets strftime like header format strings, to be printed on the left, center and right of the top of each page.
-
#set_left_margin(margin, unit) ⇒ nil
Sets the left margin used by compositor.
-
#set_right_margin(margin, unit) ⇒ nil
Sets the right margin used by compositor.
-
#set_top_margin(margin, unit) ⇒ nil
Sets the top margin used by compositor.
-
#tab_width ⇒ Integer
Width of a tab character expressed in spaces.
-
#tab_width=(tab_width) ⇒ Integer
Width of a tab character expressed in spaces.
-
#wrap_mode ⇒ Gtk::WrapMode
Whether to wrap lines never, at word boundaries, or at character boundaries.
-
#wrap_mode=(wrap_mode) ⇒ Gtk::WrapMode
Whether to wrap lines never, at word boundaries, or at character boundaries.
Constructor Details
#initialize(view) ⇒ GtkSource::PrintCompositor
Creates a new print compositor that can be used to print the buffer associated with view.
This constructor sets some configuration properties to make the printed output match view as much as possible. The properties set are [propertyPrintCompositor:tab-width], [propertyPrintCompositor:highlight-syntax], [propertyPrintCompositor:wrap-mode], [propertyPrintCompositor:body-font-name] and [propertyPrintCompositor:print-line-numbers].
Instance Method Details
#body_font_name ⇒ String
Name of the font used for the text body.
Accepted values are strings representing a font description Pango can understand. (e.g. "Monospace 10"). See [funcPango.FontDescription.from_string] for a description of the format of the string representation.
The value of this property cannot be changed anymore after the first call to the [methodPrintCompositor.paginate] function.
#body_font_name=(body_font_name) ⇒ String
Name of the font used for the text body.
Accepted values are strings representing a font description Pango can understand. (e.g. "Monospace 10"). See [funcPango.FontDescription.from_string] for a description of the format of the string representation.
The value of this property cannot be changed anymore after the first call to the [methodPrintCompositor.paginate] function.
#buffer ⇒ GtkSource::Buffer
The [classBuffer] object to print.
#buffer=(buffer) ⇒ GtkSource::Buffer
The [classBuffer] object to print.
#draw_page(context, page_nr) ⇒ nil
Draw page page_nr for printing on the the Cairo context encapsuled in context.
This method has been designed to be called in the handler of the [signalGtk.PrintOperation::draw_page] signal as shown in the following example:
// Signal handler for the GtkPrintOperation::draw_page signal
static void
draw_page (GtkPrintOperation *operation,
GtkPrintContext *context,
gint page_nr,
gpointer user_data)
{
GtkSourcePrintCompositor *compositor;
compositor = GTK_SOURCE_PRINT_COMPOSITOR (user_data);
gtk_source_print_compositor_draw_page (compositor,
context,
page_nr);
}
#footer_font_name ⇒ String
Name of the font used to print page footer. If this property is unspecified, the text body font is used.
Accepted values are strings representing a font description Pango can understand. (e.g. "Monospace 10"). See [funcPango.FontDescription.from_string] for a description of the format of the string representation.
The value of this property cannot be changed anymore after the first call to the [methodPrintCompositor.paginate] function.
#footer_font_name=(footer_font_name) ⇒ String
Name of the font used to print page footer. If this property is unspecified, the text body font is used.
Accepted values are strings representing a font description Pango can understand. (e.g. "Monospace 10"). See [funcPango.FontDescription.from_string] for a description of the format of the string representation.
The value of this property cannot be changed anymore after the first call to the [methodPrintCompositor.paginate] function.
#get_bottom_margin(unit) ⇒ Float
Gets the bottom margin in units of unit.
#get_left_margin(unit) ⇒ Float
Gets the left margin in units of unit.
#get_right_margin(unit) ⇒ Float
Gets the right margin in units of unit.
#get_top_margin(unit) ⇒ Float
Gets the top margin in units of unit.
#header_font_name ⇒ String
Name of the font used to print page header. If this property is unspecified, the text body font is used.
Accepted values are strings representing a font description Pango can understand. (e.g. "Monospace 10"). See [funcPango.FontDescription.from_string] for a description of the format of the string representation.
The value of this property cannot be changed anymore after the first call to the [methodPrintCompositor.paginate] function.
#header_font_name=(header_font_name) ⇒ String
Name of the font used to print page header. If this property is unspecified, the text body font is used.
Accepted values are strings representing a font description Pango can understand. (e.g. "Monospace 10"). See [funcPango.FontDescription.from_string] for a description of the format of the string representation.
The value of this property cannot be changed anymore after the first call to the [methodPrintCompositor.paginate] function.
#highlight_syntax ⇒ Boolean
Determines whether the printed text will be highlighted according to the buffer rules.
Note that highlighting will happen only if the buffer to print has highlighting activated.
#highlight_syntax=(highlight_syntax) ⇒ Boolean
Whether to print the document with highlighted syntax.
The value of this property cannot be changed anymore after the first call to the [methodPrintCompositor.paginate] function.
#highlight_syntax? ⇒ Boolean
Whether to print the document with highlighted syntax.
The value of this property cannot be changed anymore after the first call to the [methodPrintCompositor.paginate] function.
#ignore_tag(tag) ⇒ nil
Specifies a tag whose style should be ignored when compositing the document to the printable page.
#line_numbers_font_name ⇒ String
Name of the font used to print line numbers on the left margin. If this property is unspecified, the text body font is used.
Accepted values are strings representing a font description Pango can understand. (e.g. "Monospace 10"). See [funcPango.FontDescription.from_string] for a description of the format of the string representation.
The value of this property cannot be changed anymore after the first call to the [methodPrintCompositor.paginate] function.
#line_numbers_font_name=(line_numbers_font_name) ⇒ String
Name of the font used to print line numbers on the left margin. If this property is unspecified, the text body font is used.
Accepted values are strings representing a font description Pango can understand. (e.g. "Monospace 10"). See [funcPango.FontDescription.from_string] for a description of the format of the string representation.
The value of this property cannot be changed anymore after the first call to the [methodPrintCompositor.paginate] function.
#n_pages ⇒ Integer
The number of pages in the document or -1 if the document has not been completely paginated.
#n_pages=(n_pages) ⇒ Integer
The number of pages in the document or -1 if the document has not been completely paginated.
#paginate(context) ⇒ Boolean
Paginate the document associated with the compositor.
In order to support non-blocking pagination, document is paginated in small chunks. Each time [methodPrintCompositor.paginate] is invoked, a chunk of the document is paginated. To paginate the entire document, [methodPrintCompositor.paginate] must be invoked multiple times. It returns true if the document has been completely paginated, otherwise it returns false.
This method has been designed to be invoked in the handler of the [signalGtk.PrintOperation::paginate] signal, as shown in the following example:
// Signal handler for the GtkPrintOperation::paginate signal
static gboolean
paginate (GtkPrintOperation *operation,
GtkPrintContext *context,
gpointer user_data)
{
GtkSourcePrintCompositor *compositor;
compositor = GTK_SOURCE_PRINT_COMPOSITOR (user_data);
if (gtk_source_print_compositor_paginate (compositor, context))
{
gint n_pages;
n_pages = gtk_source_print_compositor_get_n_pages (compositor);
gtk_print_operation_set_n_pages (operation, n_pages);
return TRUE;
}
return FALSE;
}
If you don't need to do pagination in chunks, you can simply do it all in the [signalGtk.PrintOperation::begin-print] handler, and set the number of pages from there, like in the following example:
// Signal handler for the GtkPrintOperation::begin-print signal
static void
begin_print (GtkPrintOperation *operation,
GtkPrintContext *context,
gpointer user_data)
{
GtkSourcePrintCompositor *compositor;
gint n_pages;
compositor = GTK_SOURCE_PRINT_COMPOSITOR (user_data);
while (!gtk_source_print_compositor_paginate (compositor, context));
n_pages = gtk_source_print_compositor_get_n_pages (compositor);
gtk_print_operation_set_n_pages (operation, n_pages);
}
are used by the the compositor to paginate the document.
#pagination_progress ⇒ Float
Returns the current fraction of the document pagination that has been completed.
#print_footer ⇒ Boolean
Determines if a footer is set to be printed for each page.
A footer will be printed if this function returns true and some format strings have been specified with [methodPrintCompositor.set_footer_format].
#print_footer=(print_footer) ⇒ Boolean
Whether to print a footer in each page.
Note that by default the footer format is unspecified, and if it is unspecified the footer will not be printed, regardless of the value of this property.
The value of this property cannot be changed anymore after the first call to the [methodPrintCompositor.paginate] function.
#print_footer? ⇒ Boolean
Whether to print a footer in each page.
Note that by default the footer format is unspecified, and if it is unspecified the footer will not be printed, regardless of the value of this property.
The value of this property cannot be changed anymore after the first call to the [methodPrintCompositor.paginate] function.
#print_header ⇒ Boolean
Determines if a header is set to be printed for each page.
A header will be printed if this function returns true and some format strings have been specified with [methodPrintCompositor.set_header_format].
#print_header=(print_header) ⇒ Boolean
Whether to print a header in each page.
Note that by default the header format is unspecified, and if it is unspecified the header will not be printed, regardless of the value of this property.
The value of this property cannot be changed anymore after the first call to the [methodPrintCompositor.paginate] function.
#print_header? ⇒ Boolean
Whether to print a header in each page.
Note that by default the header format is unspecified, and if it is unspecified the header will not be printed, regardless of the value of this property.
The value of this property cannot be changed anymore after the first call to the [methodPrintCompositor.paginate] function.
#print_line_numbers ⇒ Integer
Interval of printed line numbers.
If this property is set to 0 no numbers will be printed. If greater than 0, a number will be printed every "print-line-numbers" lines (i.e. 1 will print all line numbers).
The value of this property cannot be changed anymore after the first call to the [methodPrintCompositor.paginate] function.
#print_line_numbers=(print_line_numbers) ⇒ Integer
Interval of printed line numbers.
If this property is set to 0 no numbers will be printed. If greater than 0, a number will be printed every "print-line-numbers" lines (i.e. 1 will print all line numbers).
The value of this property cannot be changed anymore after the first call to the [methodPrintCompositor.paginate] function.
#set_bottom_margin(margin, unit) ⇒ nil
Sets the bottom margin used by compositor.
#set_footer_format(separator, left, center, right) ⇒ nil
See [methodPrintCompositor.set_header_format] for more information about the parameters.
#set_header_format(separator, left, center, right) ⇒ nil
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. A subset of strftime() codes are accepted, see [methodGLib.DateTime.format] for more details on the accepted format specifiers. Additionally the following format specifiers are accepted:
- #N: the page number
- #Q: the page count.
separator specifies if a solid line should be drawn to separate the header from the document text.
If nil 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 [methodPrintCompositor.set_print_header].
This function cannot be called anymore after the first call to the [methodPrintCompositor.paginate] function.
#set_left_margin(margin, unit) ⇒ nil
Sets the left margin used by compositor.
#set_right_margin(margin, unit) ⇒ nil
Sets the right margin used by compositor.
#set_top_margin(margin, unit) ⇒ nil
Sets the top margin used by compositor.
#tab_width ⇒ Integer
Width of a tab character expressed in spaces.
The value of this property cannot be changed anymore after the first call to the [methodPrintCompositor.paginate] function.
#tab_width=(tab_width) ⇒ Integer
Width of a tab character expressed in spaces.
The value of this property cannot be changed anymore after the first call to the [methodPrintCompositor.paginate] function.
#wrap_mode ⇒ Gtk::WrapMode
Whether to wrap lines never, at word boundaries, or at character boundaries.
The value of this property cannot be changed anymore after the first call to the [methodPrintCompositor.paginate] function.
#wrap_mode=(wrap_mode) ⇒ Gtk::WrapMode
Whether to wrap lines never, at word boundaries, or at character boundaries.
The value of this property cannot be changed anymore after the first call to the [methodPrintCompositor.paginate] function.