EvinceDocument.Document

g EvinceDocument.Document EvinceDocument.Document GObject.Object GObject.Object GObject.Object->EvinceDocument.Document

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

doc_mutex_lock ()

class

doc_mutex_trylock ()

class

doc_mutex_unlock ()

class

factory_add_filters (chooser, document)

class

factory_get_document (uri)

class

factory_get_document_for_fd (fd, mime_type, flags, cancellable)

class

factory_get_document_for_gfile (file, flags, cancellable)

class

factory_get_document_for_stream (stream, mime_type, flags, cancellable)

class

factory_get_document_full (uri, flags)

class

fc_mutex_lock ()

class

fc_mutex_trylock ()

class

fc_mutex_unlock ()

class

misc_format_date (utime)

class

misc_format_datetime (dt)

class

misc_get_loading_thumbnail (width, height, inverted_colors)

class

misc_get_page_border_size (page_width, page_height, border)

class

misc_get_pointer_position (widget)

class

misc_get_screen_dpi (screen)

class

misc_get_thumbnail_frame (width, height, source_pixbuf)

class

misc_get_widget_dpi (widget)

class

misc_invert_pixbuf (pixbuf)

class

misc_invert_surface (surface)

class

misc_paint_one_page (cr, widget, area, border, highlight, inverted_colors)

class

misc_pixbuf_from_surface (surface)

class

misc_render_loading_thumbnail (widget, width, height, inverted_colors)

class

misc_render_loading_thumbnail_surface (widget, width, height, inverted_colors)

class

misc_render_thumbnail_surface_with_frame (widget, source_surface, width, height)

class

misc_render_thumbnail_with_frame (widget, source_pixbuf)

class

misc_surface_from_pixbuf (pixbuf)

class

misc_surface_rotate_and_scale (surface, dest_width, dest_height, dest_rotation)

check_dimensions ()

find_page_by_label (page_label, page_index)

get_backend_info (info)

get_info ()

get_max_label_len ()

get_max_page_size (width, height)

get_min_page_size (width, height)

get_modified ()

get_n_pages ()

get_page (index)

get_page_label (page_index)

get_page_size (page_index)

get_size ()

get_thumbnail (rc)

get_thumbnail_surface (rc)

get_title ()

get_uri ()

has_synctex ()

has_text_page_labels ()

is_page_size_uniform ()

load (uri)

load_fd (fd, flags, cancellable)

load_full (uri, flags)

load_gfile (file, flags, cancellable)

load_stream (stream, flags, cancellable)

render (rc)

save (uri)

set_modified (modified)

synctex_backward_search (page_index, x, y)

Virtual Methods

Inherited:

GObject.Object (7)

do_get_backend_info (info)

do_get_info ()

do_get_n_pages ()

do_get_page (index)

do_get_page_label (page)

do_get_page_size (page_index)

do_get_thumbnail (rc)

do_get_thumbnail_surface (rc)

do_load (uri)

do_load_fd (fd, flags, cancellable)

do_load_gfile (file, flags, cancellable)

do_load_stream (stream, flags, cancellable)

do_render (rc)

do_save (uri)

do_support_synctex ()

Properties

Name

Type

Flags

Short Description

modified

bool

r/w

Whether the document has been modified

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

base

GObject.Object

r

Class Details

class EvinceDocument.Document(**kwargs)
Bases:

GObject.Object

Abstract:

Yes

Structure:

EvinceDocument.DocumentClass

classmethod doc_mutex_lock()
classmethod doc_mutex_trylock()
Return type:

bool

classmethod doc_mutex_unlock()
classmethod factory_add_filters(chooser, document)
Parameters:

Adds some file filters to chooser.

Always add a “All documents” format.

If document is not None, adds a Gtk.FileFilter for document's MIME type.

If document is None, adds a Gtk.FileFilter for each document type that evince can handle.

classmethod factory_get_document(uri)
Parameters:

uri (str) – an URI

Raises:

GLib.Error

Returns:

a new EvinceDocument.Document, or None

Return type:

EvinceDocument.Document

Creates a EvinceDocument.Document for the document at uri; or, if no backend handling the document’s type is found, or an error occurred on opening the document, returns None and fills in error. If the document is encrypted, it is returned but also error is set to EvinceDocument.DocumentError.ENCRYPTED.

classmethod factory_get_document_for_fd(fd, mime_type, flags, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

a new EvinceDocument.Document, or None

Return type:

EvinceDocument.Document

Synchronously creates a EvinceDocument.Document for the document from fd using the backend for loading documents of type mime_type; or, if the backend does not support loading from file descriptors, or an error occurred on opening the document, returns None and fills in error. If the document is encrypted, it is returned but also error is set to EvinceDocument.DocumentError.ENCRYPTED.

If the mime type cannot be inferred from the file descriptor, and mime_type is None, an error is returned.

Note that this function takes ownership of fd; you must not ever operate on it again. It will be closed automatically if the document is destroyed, or if this function returns None.

New in version 42.0.

classmethod factory_get_document_for_gfile(file, flags, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

a new EvinceDocument.Document, or None

Return type:

EvinceDocument.Document

Synchronously creates a EvinceDocument.Document for the document at file; or, if no backend handling the document’s type is found, or an error occurred on opening the document, returns None and fills in error. If the document is encrypted, it is returned but also error is set to EvinceDocument.DocumentError.ENCRYPTED.

New in version 3.6.

classmethod factory_get_document_for_stream(stream, mime_type, flags, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

a new EvinceDocument.Document, or None

Return type:

EvinceDocument.Document

Synchronously creates a EvinceDocument.Document for the document from stream; or, if no backend handling the document’s type is found, or an error occurred on opening the document, returns None and fills in error. If the document is encrypted, it is returned but also error is set to EvinceDocument.DocumentError.ENCRYPTED.

If mime_type is non-None, this overrides any type inferred from the stream. If the mime type cannot be inferred from the stream, and mime_type is None, an error is returned.

New in version 3.6.

classmethod factory_get_document_full(uri, flags)
Parameters:
Raises:

GLib.Error

Returns:

a new EvinceDocument.Document, or None

Return type:

EvinceDocument.Document

Creates a EvinceDocument.Document for the document at uri; or, if no backend handling the document’s type is found, or an error occurred on opening the document, returns None and fills in error. If the document is encrypted, it is returned but also error is set to EvinceDocument.DocumentError.ENCRYPTED.

classmethod fc_mutex_lock()
classmethod fc_mutex_trylock()
Return type:

bool

classmethod fc_mutex_unlock()
classmethod misc_format_date(utime)
Parameters:

utime (int) – a #GTime

Returns:

a locale specific date and time representation.

Return type:

str

Deprecated since version 3.38: use EvinceDocument.Document.misc_format_datetime instead as GTime is deprecated because it is not year-2038 safe.

classmethod misc_format_datetime(dt)
Parameters:

dt (GLib.DateTime) – a GLib.DateTime

Returns:

a new allocated string or None in the case that there was an error (such as a format specifier not being supported in the current locale). The string should be freed with GLib.free().

Return type:

str

Determine the preferred date and time representation for the current locale for dt.

New in version 3.38.

classmethod misc_get_loading_thumbnail(width, height, inverted_colors)
Parameters:
  • width (int) – the desired width

  • height (int) – the desired height

  • inverted_colors (bool) – whether to invert colors

Returns:

a GdkPixbuf.Pixbuf

Return type:

GdkPixbuf.Pixbuf

classmethod misc_get_page_border_size(page_width, page_height, border)
Parameters:
classmethod misc_get_pointer_position(widget)
Parameters:

widget (Gtk.Widget) – a Gtk.Widget

Returns:

x:

the pointer’s “x” position, or -1 if the position is not available

y:

the pointer’s “y” position, or -1 if the position is not available

Return type:

(x: int, y: int)

Get the pointer’s x and y position relative to widget.

classmethod misc_get_screen_dpi(screen)
Parameters:

screen (Gdk.Screen) – a Gdk.Screen

Returns:

The DPI of screen, or 96 if the DPI is not available

Return type:

float

Deprecated since version 3.36: This uses a deprecated GDK API. Use EvinceDocument.Document.misc_get_widget_dpi() instead, which uses GDK’s per-monitor information.

classmethod misc_get_thumbnail_frame(width, height, source_pixbuf)
Parameters:
Returns:

a GdkPixbuf.Pixbuf

Return type:

GdkPixbuf.Pixbuf

classmethod misc_get_widget_dpi(widget)
Parameters:

widget (Gtk.Widget) – a Gtk.Widget

Returns:

DPI as float

Return type:

float

Returns sensible guess for DPI of monitor on which given widget has been realized. If HiDPI display, use 192, else 96. Returns 96 as fallback value.

classmethod misc_invert_pixbuf(pixbuf)
Parameters:

pixbuf (GdkPixbuf.Pixbuf) –

classmethod misc_invert_surface(surface)
Parameters:

surface (cairo.Surface) –

classmethod misc_paint_one_page(cr, widget, area, border, highlight, inverted_colors)
Parameters:

Deprecated since version 3.10..

classmethod misc_pixbuf_from_surface(surface)
Parameters:

surface (cairo.Surface) – a cairo.Surface

Returns:

a GdkPixbuf.Pixbuf

Return type:

GdkPixbuf.Pixbuf

classmethod misc_render_loading_thumbnail(widget, width, height, inverted_colors)
Parameters:
  • widget (Gtk.Widget) – a Gtk.Widget to use for style information

  • width (int) – the desired width

  • height (int) – the desired height

  • inverted_colors (bool) – whether to invert colors

Returns:

a GdkPixbuf.Pixbuf

Return type:

GdkPixbuf.Pixbuf

New in version 3.8.

classmethod misc_render_loading_thumbnail_surface(widget, width, height, inverted_colors)
Parameters:
  • widget (Gtk.Widget) – a Gtk.Widget to use for style information

  • width (int) – the desired width

  • height (int) – the desired height

  • inverted_colors (bool) – whether to invert colors

Returns:

a cairo.Surface

Return type:

cairo.Surface

New in version 3.14.

classmethod misc_render_thumbnail_surface_with_frame(widget, source_surface, width, height)
Parameters:
Returns:

a cairo.Surface

Return type:

cairo.Surface

New in version 3.14.

classmethod misc_render_thumbnail_with_frame(widget, source_pixbuf)
Parameters:
Returns:

a GdkPixbuf.Pixbuf

Return type:

GdkPixbuf.Pixbuf

New in version 3.8.

classmethod misc_surface_from_pixbuf(pixbuf)
Parameters:

pixbuf (GdkPixbuf.Pixbuf) –

Return type:

cairo.Surface

classmethod misc_surface_rotate_and_scale(surface, dest_width, dest_height, dest_rotation)
Parameters:
Return type:

cairo.Surface

check_dimensions()
Return type:

bool

find_page_by_label(page_label, page_index)
Parameters:
  • page_label (str) –

  • page_index (int) –

Return type:

bool

get_backend_info(info)
Parameters:

info (EvinceDocument.DocumentBackendInfo) –

Return type:

bool

get_info()
Returns:

a EvinceDocument.DocumentInfo

Return type:

EvinceDocument.DocumentInfo

Returns the EvinceDocument.DocumentInfo for the document.

get_max_label_len()
Return type:

int

get_max_page_size(width, height)
Parameters:
get_min_page_size(width, height)
Parameters:
get_modified()
Returns:

True iff the document has been modified.

You can monitor changes to the modification state by connecting to the notify::modified signal on self.

Return type:

bool

New in version 3.28.

get_n_pages()
Return type:

int

get_page(index)
Parameters:

index (int) – index of page

Returns:

Newly created EvinceDocument.Page for the given index.

Return type:

EvinceDocument.Page

get_page_label(page_index)
Parameters:

page_index (int) –

Return type:

str

get_page_size(page_index)
Parameters:

page_index (int) – index of page

Returns:

width:

return location for the width of the page, or None

height:

return location for the height of the page, or None

Return type:

(width: float, height: float)

get_size()
Return type:

int

get_thumbnail(rc)
Parameters:

rc (EvinceDocument.RenderContext) – an EvinceDocument.RenderContext

Returns:

a GdkPixbuf.Pixbuf

Return type:

GdkPixbuf.Pixbuf

get_thumbnail_surface(rc)
Parameters:

rc (EvinceDocument.RenderContext) – an EvinceDocument.RenderContext

Returns:

a cairo.Surface

Return type:

cairo.Surface

New in version 3.14.

get_title()
Return type:

str

get_uri()
Return type:

str

has_synctex()
Return type:

bool

has_text_page_labels()
Return type:

bool

is_page_size_uniform()
Return type:

bool

load(uri)
Parameters:

uri (str) – the document’s URI

Raises:

GLib.Error

Returns:

True on success, or False on failure.

Return type:

bool

Loads self from uri.

On failure, False is returned and error is filled in. If the document is encrypted, EV_DEFINE_ERROR_ENCRYPTED is returned. If the backend cannot load the specific document, EvinceDocument.DocumentError.INVALID is returned. If the backend does not support the format for the document’s contents, EvinceDocument.DocumentError.UNSUPPORTED_CONTENT is returned. Other errors are possible too, depending on the backend used to load the document and the URI, e.g. GLib.IOError, GLib.FileError, and GLib.ConvertError.

load_fd(fd, flags, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

True if loading succeeded, or False on error with error filled in

Return type:

bool

Synchronously loads the document from fd, which must refer to a regular file.

Note that this function takes ownership of fd; you must not ever operate on it again. It will be closed automatically if the document is destroyed, or if this function returns None.

See EvinceDocument.Document.load() for more information.

New in version 42.0.

load_full(uri, flags)
Parameters:
Raises:

GLib.Error

Returns:

True on success, or False on failure.

Return type:

bool

Loads self from uri.

On failure, False is returned and error is filled in. If the document is encrypted, EV_DEFINE_ERROR_ENCRYPTED is returned. If the backend cannot load the specific document, EvinceDocument.DocumentError.INVALID is returned. Other errors are possible too, depending on the backend used to load the document and the URI, e.g. GLib.IOError, GLib.FileError, and GLib.ConvertError.

load_gfile(file, flags, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

True if loading succeeded, or False on error with error filled in

Return type:

bool

Synchronously loads the document from file. See EvinceDocument.Document.load() for more information.

New in version 3.6.

load_stream(stream, flags, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

True if loading succeeded, or False on error with error filled in

Return type:

bool

Synchronously loads the document from stream. See EvinceDocument.Document.load() for more information.

New in version 3.6.

render(rc)
Parameters:

rc (EvinceDocument.RenderContext) –

Return type:

cairo.Surface

save(uri)
Parameters:

uri (str) – the target URI

Raises:

GLib.Error

Returns:

True on success, or False on error with error filled in

Return type:

bool

Saves self to uri.

set_modified(modified)
Parameters:

modified (bool) – a boolean value to set the document as modified or not.

Set the self modification state as modified.

New in version 3.28.

Parameters:
  • page_index (int) – the target page

  • x (float) – X coordinate

  • y (float) – Y coordinate

Returns:

A pointer to the EvinceDocument.SourceLink structure that holds the result. None if synctex is not enabled for the document or no result is found. The EvinceDocument.SourceLink pointer should be freed with GLib.free after it is used.

Return type:

EvinceDocument.SourceLink

Peforms a Synctex backward search to obtain the TeX input file, line and (possibly) column corresponding to the position (x,`y`) (in 72dpi coordinates) in the page of self.

do_get_backend_info(info) virtual
Parameters:

info (EvinceDocument.DocumentBackendInfo) –

Return type:

bool

do_get_info() virtual
Returns:

a EvinceDocument.DocumentInfo

Return type:

EvinceDocument.DocumentInfo

Returns the EvinceDocument.DocumentInfo for the document.

do_get_n_pages() virtual
Return type:

int

do_get_page(index) virtual
Parameters:

index (int) – index of page

Returns:

Newly created EvinceDocument.Page for the given index.

Return type:

EvinceDocument.Page

do_get_page_label(page) virtual
Parameters:

page (EvinceDocument.Page) –

Return type:

str

do_get_page_size(page_index) virtual
Parameters:

page_index (EvinceDocument.Page) – index of page

Returns:

width:

return location for the width of the page, or None

height:

return location for the height of the page, or None

Return type:

(width: float, height: float)

do_get_thumbnail(rc) virtual
Parameters:

rc (EvinceDocument.RenderContext) – an EvinceDocument.RenderContext

Returns:

a GdkPixbuf.Pixbuf

Return type:

GdkPixbuf.Pixbuf

do_get_thumbnail_surface(rc) virtual
Parameters:

rc (EvinceDocument.RenderContext) – an EvinceDocument.RenderContext

Returns:

a cairo.Surface

Return type:

cairo.Surface

New in version 3.14.

do_load(uri) virtual
Parameters:

uri (str) – the document’s URI

Returns:

True on success, or False on failure.

Return type:

bool

Loads document from uri.

On failure, False is returned and error is filled in. If the document is encrypted, EV_DEFINE_ERROR_ENCRYPTED is returned. If the backend cannot load the specific document, EvinceDocument.DocumentError.INVALID is returned. If the backend does not support the format for the document’s contents, EvinceDocument.DocumentError.UNSUPPORTED_CONTENT is returned. Other errors are possible too, depending on the backend used to load the document and the URI, e.g. GLib.IOError, GLib.FileError, and GLib.ConvertError.

do_load_fd(fd, flags, cancellable) virtual
Parameters:
Returns:

True if loading succeeded, or False on error with error filled in

Return type:

bool

Synchronously loads the document from fd, which must refer to a regular file.

Note that this function takes ownership of fd; you must not ever operate on it again. It will be closed automatically if the document is destroyed, or if this function returns None.

See EvinceDocument.Document.load() for more information.

New in version 42.0.

do_load_gfile(file, flags, cancellable) virtual
Parameters:
Returns:

True if loading succeeded, or False on error with error filled in

Return type:

bool

Synchronously loads the document from file. See EvinceDocument.Document.load() for more information.

New in version 3.6.

do_load_stream(stream, flags, cancellable) virtual
Parameters:
Returns:

True if loading succeeded, or False on error with error filled in

Return type:

bool

Synchronously loads the document from stream. See EvinceDocument.Document.load() for more information.

New in version 3.6.

do_render(rc) virtual
Parameters:

rc (EvinceDocument.RenderContext) –

Return type:

cairo.Surface

do_save(uri) virtual
Parameters:

uri (str) – the target URI

Returns:

True on success, or False on error with error filled in

Return type:

bool

Saves document to uri.

do_support_synctex() virtual
Return type:

bool

Property Details

EvinceDocument.Document.props.modified
Name:

modified

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the document has been modified