Methods
gtksourceview2.PrintCompositor.draw_page
def draw_page(context
, page_nr
)
context :
| the gtk.PrintContext
encapsulating the context information that is required when drawing the page for printing. |
page_nr :
| the number of the page to print. |
The draw_page
() method draws 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 "draw_page" signal as shown in the following example:
# Signal handler for the GtkPrintOperation::draw_page signal
def draw_page(operation, context, page_nr, compositor)
compositor.draw_page(context, page_nr)
gtksourceview2.PrintCompositor.get_body_font_name
def get_body_font_name()
Returns : |
a new string containing the name of the font used to print the text body.
|
The get_body_font_name
() method returns the name of the font used to print
the text body.
gtksourceview2.PrintCompositor.get_bottom_margin
def get_bottom_margin(unit
)
unit :
| the unit for the return value. |
Returns : |
the bottom margin.
|
The get_bottom_margin
() method gets the bottom margin
in units of unit
.
gtksourceview2.PrintCompositor.get_buffer
def get_buffer()
The get_buffer
() method gets the
gtksourceview2.Buffer
associated with the compositor.
gtksourceview2.PrintCompositor.get_footer_font_name
def (get_footer_font_name)
Returns : |
a new string containing the name of the font used to print the page footer.
|
The get_footer_font_name
() method returns the name of
the font used to print the page footer.
gtksourceview2.PrintCompositor.get_header_font_name
def get_header_font_name()
Returns : |
a new string containing the name of the font used to print the page header.
|
The get_header_font_name
() method Returns the name
of the font used to print the page header
gtksourceview2.PrintCompositor.get_highlight_syntax
def get_highlight_syntax()
Returns : |
True if the printed output will be highlighted.
|
The get_highlight_syntax
() method 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.
gtksourceview2.PrintCompositor.get_left_margin
def get_left_margin(unit
)
unit :
| the unit for the return value. |
Returns : |
the left margin
|
The get_left_margin
() method gets the left margin
in units of unit
.
gtksourceview2.PrintCompositor.get_line_numbers_font_name
def get_line_numbers_font_name()
Returns : |
a new string containing the name of the font used to print line numbers on the left margin.
|
The get_line_numbers_font_name
() method returns the name
of the font used to print line numbers on the left margin.
gtksourceview2.PrintCompositor.get_n_pages
def get_n_pages()
Returns : |
the number of pages in the document or -1 if the document has not been completely paginated.
|
The get_n_pages
() method returns the number of pages in
the document or -1 if the document has not been completely paginated.
gtksourceview2.PrintCompositor.get_pagination_progress
def get_pagination_progress()
Returns : |
a fraction from 0.0 to 1.0 inclusive
|
The get_pagination_progress
() method returns the current
fraction of the document pagination that has been completed.
gtksourceview2.PrintCompositor.get_print_footer
def get_print_footer()
Returns : |
True if the footer is set to be printed.
|
The get_print_footer
() method 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
gtksourceview2.PrintCompositor.set_footer_format
().
gtksourceview2.PrintCompositor.get_print_header
def get_print_header()
Returns : |
True if the header is set to be printed.
|
The get_print_header
() method 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
gtksourceview2.PrintCompositor.set_header_format
().
gtksourceview2.PrintCompositor.get_print_line_numbers
def get_print_line_numbers()
Returns : |
the interval of printed line numbers.
|
The get_print_line_numbers
() method returns the interval
used for line number printing. If the value is 0, no line numbers will be printed.
The default value is 1 (i.e. numbers printed in all lines).
gtksourceview2.PrintCompositor.get_right_margin
def get_right_margin(unit
)
unit :
| the unit for the return value. |
Returns : |
the right margin
|
The get_right_margin
() method gets the right
margin in units of unit
.
gtksourceview2.PrintCompositor.get_tab_width
def get_tab_width()
The get_tab_width
() method returns the width of
tabulation in characters for printed text.
gtksourceview2.PrintCompositor.get_top_margin
def get_top_margin(unit
)
unit :
| the unit for the return value. |
Returns : |
the top margin
|
The get_top_margin
() method gets the top
margin in units of unit
.
gtksourceview2.PrintCompositor.get_wrap_mode
def get_wrap_mode()
Returns : |
the line wrap mode.
|
The get_wrap_mode
() method gets the line wrapping
mode for the printed text.
gtksourceview2.PrintCompositor.paginate
def paginate(context
)
context :
| the gtk.PrintContext
encapsulating the context information that is required when drawing the page for printing. |
Returns : |
True if the document has been completely paginated,
False otherwise.
|
The paginate
() method paginate the document associated with the compositor.
In order to support non-blocking pagination, document is paginated in small chunks. Each time
gtksourceview2.PrintCompositor.paginate
()
is invoked, a chunk of the document is paginated. To paginate the entire document,
gtksourceview2.PrintCompositor.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 "paginate" signal, as shown in the following example:
# Signal handler for the GtkPrintOperation::paginate signal
def paginate(operation, context, compositor)
if compositor.paginate(context):
n_pages = compositor.get_n_pages()
operation.set_n_pages(n_pages)
return True
else:
return False
If you don't need to do pagination in chunks, you can simply do it all in the
"begin-print" handler, and set the number of pages from there, like in the following example:
# Signal handler for the GtkPrintOperation::begin-print signal
def begin_print(operation, context, compositor)
while compositor.paginate(context):
n_pages = compositor.get_n_pages()
operation.set_n_pages(n_pages)
gtksourceview2.PrintCompositor.set_body_font_name
def set_body_font_name(font_name
)
font_name :
|
the name of the default font for the body of text.
|
The set_body_font_name
() method sets the default font for the printed text.
font_name
should be a string representation of a font description
Pango can understand. (e.g. "Monospace 10"). See
pango.FontDescription
()
for a description of the format of the string representation.
This function cannot be called anymore after the first call to the
gtksourceview2.PrintCompositor.paginate
() method.
gtksourceview2.PrintCompositor.set_bottom_margin
def set_bottom_margin(margin
, unit
)
margin :
|
the new bottom margin in units of unit
|
unit :
|
the units for margin
|
The set_bottom_margin
() method sets the bottom margin used by compositor.
gtksourceview2.PrintCompositor.set_footer_font_name
def set_footer_font_name(font_name
)
font_name :
|
the name of the default font for the footer text. or None .
|
The set_footer_font_name
() method Sets the font for printing the page footer.
If None
is supplied, the default font (i.e. the one being used for the text) will be used instead.
font_name
should be a string representation of a font description
Pango can understand. (e.g. "Monospace 10"). See
pango.FontDescription
()
for a description of the format of the string representation.
This function cannot be called anymore after the first call to the
gtksourceview2.PrintCompositor.paginate
() method.
gtksourceview2.PrintCompositor.set_footer_format
def set_footer_format(separator
, left
, center
, right
)
separator :
|
True if you want a separator line to be printed.
|
left :
|
a format string to print on the left of the footer.
|
center :
|
a format string to print on the center of the footer.
|
right :
|
a format string to print on the right of the footer.
|
The set_footer_format
() method sets strftime like header format strings,
to be printed on the left, center and right of the bottom of each page.
The strings may include strftime(3) codes which will be expanded at print time.
All strftime() codes are accepted, with the addition of N for the page number and Q for the page count.
separator specifies if a solid line should be drawn to separate the footer from the document text.
If None
is given for any of the three arguments, that particular string will not be printed.
For the footer to be printed, in addition to specifying format strings, you need to enable footer printing with
gtksourceview2.PrintCompositor.set_print_footer
().
This method cannot be called anymore after the first call to the
gtksourceview2.PrintCompositor.paginate
() method.
gtksourceview2.PrintCompositor.set_header_font_name
def set_header_font_name(font_name
)
font_name :
|
the name of the default font for the footer text. or None .
|
The set_header_font_name
() method Sets the font for printing the page header.
If None
is supplied, the default font (i.e. the one being used for the text) will be used instead.
font_name
should be a string representation of a font description
Pango can understand. (e.g. "Monospace 10"). See
pango.FontDescription
()
for a description of the format of the string representation.
This function cannot be called anymore after the first call to the
gtksourceview2.PrintCompositor.paginate
() method.
gtksourceview2.PrintCompositor.set_header_format
def set_header_format(separator
, left
, center
, right
)
separator :
|
True if you want a separator line to be printed.
|
left :
|
a format string to print on the left of the header.
|
center :
|
a format string to print on the center of the header.
|
right :
|
a format string to print on the right of the header.
|
The set_header_format
() method 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, with the addition of N for the page number and Q for the page count.
separator specifies if a solid line should be drawn to separate the footer from the document text.
If None
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
gtksourceview2.PrintCompositor.set_print_header
().
This method cannot be called anymore after the first call to the
gtksourceview2.PrintCompositor.paginate
() method.
gtksourceview2.PrintCompositor.set_highlight_syntax
def set_highlight_syntax(highlight
)
highlight :
|
whether syntax should be highlighted.
|
The set_highlight_syntax
() method sets whether the printed
text will be highlighted according to the buffer rules. Both color and font style are applied.
This function cannot be called anymore after the first call to the
gtksourceview2.PrintCompositor.paginate
() method.
gtksourceview2.PrintCompositor.set_left_margin
def set_left_margin(margin
, unit
)
margin :
|
the new left margin in units of unit
|
unit :
|
the units for margin
|
The set_left_margin
() method sets the left margin used by compositor.
gtksourceview2.PrintCompositor.set_line_numbers_font_name
def set_line_numbers_font_name(font_name
)
font_name :
|
the name of the default font for the line numbers. or None .
|
The set_line_numbers_font_name
() method sets the font for printing the line numbers.
If None
is supplied, the default font (i.e. the one being used for the text) will be used instead.
font_name
should be a string representation of a font description
Pango can understand. (e.g. "Monospace 10"). See
pango.FontDescription
()
for a description of the format of the string representation.
This function cannot be called anymore after the first call to the
gtksourceview2.PrintCompositor.paginate
() method.
gtksourceview2.PrintCompositor.set_print_footer
def set_print_footer(print
)
print :
|
True if you want the footer to be printed.
|
The set_print_footer
method sets whether you want to print a footer in each page.
The footer consists of three pieces of text and an optional line separator, configurable with
gtksourceview2.PrintCompositor.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.
This function cannot be called anymore after the first call to the
gtksourceview2.PrintCompositor.paginate
() method.
gtksourceview2.PrintCompositor.set_print_header
def set_print_header(print
)
print :
|
True if you want the header to be printed.
|
The set_print_header
() method sets whether you want to
print a header in each page. The footer consists of three pieces of text and an optional
line separator, configurable with
gtksourceview2.PrintCompositor.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.
This function cannot be called anymore after the first call to the
gtksourceview2.PrintCompositor.paginate
() method.
gtksourceview2.PrintCompositor.set_print_line_numbers
def set_print_line_numbers(interval
)
interval :
|
interval for printed line numbers.
|
The set_print_line_numbers
() method 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 (i.e. 1 will print all line numbers).
Maximum accepted value for interval is 100.
This function cannot be called anymore after the first call to the
gtksourceview2.PrintCompositor.paginate
() method.
gtksourceview2.PrintCompositor.set_right_margin
def set_right_margin(margin
, unit
)
margin :
|
the new left margin in units of unit
|
unit :
|
the units for margin
|
The set_right_margin
() method sets the right margin used by compositor.
gtksourceview2.PrintCompositor.set_tab_width
def set_tab_width(width
)
The set_right_margin
() method returns the width of tabulation in characters for printed text.
gtksourceview2.PrintCompositor.set_top_margin
def set_top_margin(margin
, unit
)
margin :
|
the new left margin in units of unit
|
unit :
|
the units for margin
|
The set_top_margin
() method sets the top margin used by compositor.
gtksourceview2.PrintCompositor.set_wrap_mode
def set_wrap_mode(wrap_mode
)
wrap_mode :
|
one of gtk.WRAP_NONE, gtk.WRAP_CHAR, gtk.WRAP_WORD, gtk.WRAP_WORD_CHAR.
|
The set_right_margin
() method sets the line wrapping mode for the printed text.
This function cannot be called anymore after the first call to the
gtksourceview2.PrintCompositor.paginate
() method.