Evince
Evince is a document viewer capable of displaying multiple and single page document formats like PDF and Postscript.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ev-document.h File Reference
#include <glib-object.h>
#include <glib.h>
#include <gio/gio.h>
#include <gdk/gdk.h>
#include <cairo.h>
#include "ev-document-info.h"
#include "ev-page.h"
#include "ev-render-context.h"
+ Include dependency graph for ev-document.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _EvPoint
 
struct  _EvDocumentBackendInfo
 
struct  _EvDocument
 
struct  _EvDocumentClass
 
struct  _EvRectangle
 
struct  _EvMapping
 
struct  _EvSourceLink
 

Macros

#define EV_TYPE_DOCUMENT   (ev_document_get_type ())
 
#define EV_DOCUMENT(o)   (G_TYPE_CHECK_INSTANCE_CAST ((o), EV_TYPE_DOCUMENT, EvDocument))
 
#define EV_DOCUMENT_CLASS(k)   (G_TYPE_CHECK_CLASS_CAST((k), EV_TYPE_DOCUMENT, EvDocumentClass))
 
#define EV_IS_DOCUMENT(o)   (G_TYPE_CHECK_INSTANCE_TYPE ((o), EV_TYPE_DOCUMENT))
 
#define EV_IS_DOCUMENT_CLASS(k)   (G_TYPE_CHECK_CLASS_TYPE ((k), EV_TYPE_DOCUMENT))
 
#define EV_DOCUMENT_GET_CLASS(inst)   (G_TYPE_INSTANCE_GET_CLASS ((inst), EV_TYPE_DOCUMENT, EvDocumentClass))
 
#define EV_DOCUMENT_ERROR   ev_document_error_quark ()
 
#define EV_DOC_MUTEX_LOCK   (ev_document_doc_mutex_lock ())
 
#define EV_DOC_MUTEX_UNLOCK   (ev_document_doc_mutex_unlock ())
 
#define EV_TYPE_RECTANGLE   (ev_rectangle_get_type ())
 
#define EV_TYPE_SOURCE_LINK   (ev_source_link_get_type ())
 
#define EV_BACKEND_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init)
 
#define EV_BACKEND_REGISTER_WITH_CODE(BackendName, backend_name, CODE)
 
#define EV_BACKEND_REGISTER(BackendName, backend_name)   EV_BACKEND_REGISTER_WITH_CODE(BackendName, backend_name, ;)
 

Typedefs

typedef struct _EvDocument EvDocument
 
typedef struct _EvDocumentClass EvDocumentClass
 
typedef struct _EvDocumentPrivate EvDocumentPrivate
 
typedef struct _EvPoint EvPoint
 
typedef struct _EvRectangle EvRectangle
 
typedef struct _EvMapping EvMapping
 
typedef struct _EvSourceLink EvSourceLink
 
typedef struct
_EvDocumentBackendInfo 
EvDocumentBackendInfo
 

Enumerations

enum  EvDocumentLoadFlags { EV_DOCUMENT_LOAD_FLAG_NONE = 0, EV_DOCUMENT_LOAD_FLAG_NO_CACHE }
 
enum  EvDocumentError { EV_DOCUMENT_ERROR_INVALID, EV_DOCUMENT_ERROR_ENCRYPTED }
 

Functions

GType ev_document_get_type (void) G_GNUC_CONST
 
GQuark ev_document_error_quark (void)
 
GMutex * ev_document_get_doc_mutex (void)
 
void ev_document_doc_mutex_lock (void)
 
void ev_document_doc_mutex_unlock (void)
 
gboolean ev_document_doc_mutex_trylock (void)
 
GMutex * ev_document_get_fc_mutex (void)
 
void ev_document_fc_mutex_lock (void)
 
void ev_document_fc_mutex_unlock (void)
 
gboolean ev_document_fc_mutex_trylock (void)
 
EvDocumentInfoev_document_get_info (EvDocument *document)
 
gboolean ev_document_get_backend_info (EvDocument *document, EvDocumentBackendInfo *info)
 
gboolean ev_document_load (EvDocument *document, const char *uri, GError **error)
 
gboolean ev_document_load_full (EvDocument *document, const char *uri, EvDocumentLoadFlags flags, GError **error)
 
gboolean ev_document_load_stream (EvDocument *document, GInputStream *stream, EvDocumentLoadFlags flags, GCancellable *cancellable, GError **error)
 
gboolean ev_document_load_gfile (EvDocument *document, GFile *file, EvDocumentLoadFlags flags, GCancellable *cancellable, GError **error)
 
gboolean ev_document_save (EvDocument *document, const char *uri, GError **error)
 
gint ev_document_get_n_pages (EvDocument *document)
 
EvPageev_document_get_page (EvDocument *document, gint index)
 
void ev_document_get_page_size (EvDocument *document, gint page_index, double *width, double *height)
 
gchar * ev_document_get_page_label (EvDocument *document, gint page_index)
 
cairo_surface_t * ev_document_render (EvDocument *document, EvRenderContext *rc)
 
GdkPixbuf * ev_document_get_thumbnail (EvDocument *document, EvRenderContext *rc)
 
cairo_surface_t * ev_document_get_thumbnail_surface (EvDocument *document, EvRenderContext *rc)
 
guint64 ev_document_get_size (EvDocument *document)
 
const gchar * ev_document_get_uri (EvDocument *document)
 
const gchar * ev_document_get_title (EvDocument *document)
 
gboolean ev_document_is_page_size_uniform (EvDocument *document)
 
void ev_document_get_max_page_size (EvDocument *document, gdouble *width, gdouble *height)
 
void ev_document_get_min_page_size (EvDocument *document, gdouble *width, gdouble *height)
 
gboolean ev_document_check_dimensions (EvDocument *document)
 
gint ev_document_get_max_label_len (EvDocument *document)
 
gboolean ev_document_has_text_page_labels (EvDocument *document)
 
gboolean ev_document_find_page_by_label (EvDocument *document, const gchar *page_label, gint *page_index)
 
gboolean ev_document_has_synctex (EvDocument *document)
 
EvSourceLinkev_document_synctex_backward_search (EvDocument *document, gint page_index, gfloat x, gfloat y)
 
EvMappingev_document_synctex_forward_search (EvDocument *document, EvSourceLink *source_link)
 
gint ev_rect_cmp (EvRectangle *a, EvRectangle *b)
 
GType ev_rectangle_get_type (void) G_GNUC_CONST
 
EvRectangleev_rectangle_new (void)
 
EvRectangleev_rectangle_copy (EvRectangle *ev_rect)
 
void ev_rectangle_free (EvRectangle *ev_rect)
 
GType ev_source_link_get_type (void) G_GNUC_CONST
 
EvSourceLinkev_source_link_new (const gchar *filename, gint line, gint col)
 
EvSourceLinkev_source_link_copy (EvSourceLink *link)
 
void ev_source_link_free (EvSourceLink *link)
 

Macro Definition Documentation

#define EV_BACKEND_IMPLEMENT_INTERFACE (   TYPE_IFACE,
  iface_init 
)
Value:
{ \
const GInterfaceInfo g_implement_interface_info = { \
(GInterfaceInitFunc) iface_init, NULL, NULL \
}; \
g_type_module_add_interface (module, \
g_define_type_id, \
TYPE_IFACE, \
&g_implement_interface_info); \
}

Definition at line 262 of file ev-document.h.

#define EV_BACKEND_REGISTER (   BackendName,
  backend_name 
)    EV_BACKEND_REGISTER_WITH_CODE(BackendName, backend_name, ;)

Definition at line 331 of file ev-document.h.

#define EV_BACKEND_REGISTER_WITH_CODE (   BackendName,
  backend_name,
  CODE 
)

Definition at line 277 of file ev-document.h.

#define EV_DOC_MUTEX_LOCK   (ev_document_doc_mutex_lock ())

Definition at line 54 of file ev-document.h.

#define EV_DOC_MUTEX_UNLOCK   (ev_document_doc_mutex_unlock ())

Definition at line 55 of file ev-document.h.

#define EV_DOCUMENT (   o)    (G_TYPE_CHECK_INSTANCE_CAST ((o), EV_TYPE_DOCUMENT, EvDocument))

Definition at line 43 of file ev-document.h.

#define EV_DOCUMENT_CLASS (   k)    (G_TYPE_CHECK_CLASS_CAST((k), EV_TYPE_DOCUMENT, EvDocumentClass))

Definition at line 44 of file ev-document.h.

#define EV_DOCUMENT_ERROR   ev_document_error_quark ()

Definition at line 53 of file ev-document.h.

#define EV_DOCUMENT_GET_CLASS (   inst)    (G_TYPE_INSTANCE_GET_CLASS ((inst), EV_TYPE_DOCUMENT, EvDocumentClass))

Definition at line 47 of file ev-document.h.

#define EV_IS_DOCUMENT (   o)    (G_TYPE_CHECK_INSTANCE_TYPE ((o), EV_TYPE_DOCUMENT))

Definition at line 45 of file ev-document.h.

#define EV_IS_DOCUMENT_CLASS (   k)    (G_TYPE_CHECK_CLASS_TYPE ((k), EV_TYPE_DOCUMENT))

Definition at line 46 of file ev-document.h.

#define EV_TYPE_DOCUMENT   (ev_document_get_type ())

Definition at line 42 of file ev-document.h.

#define EV_TYPE_RECTANGLE   (ev_rectangle_get_type ())

Definition at line 220 of file ev-document.h.

#define EV_TYPE_SOURCE_LINK   (ev_source_link_get_type ())

Definition at line 239 of file ev-document.h.

Typedef Documentation

typedef struct _EvDocument EvDocument

Definition at line 49 of file ev-document.h.

Definition at line 72 of file ev-document.h.

Definition at line 50 of file ev-document.h.

Definition at line 51 of file ev-document.h.

typedef struct _EvMapping EvMapping

Definition at line 70 of file ev-document.h.

typedef struct _EvPoint EvPoint

Definition at line 68 of file ev-document.h.

typedef struct _EvRectangle EvRectangle

Definition at line 69 of file ev-document.h.

typedef struct _EvSourceLink EvSourceLink

Definition at line 71 of file ev-document.h.

Enumeration Type Documentation

Enumerator
EV_DOCUMENT_ERROR_INVALID 
EV_DOCUMENT_ERROR_ENCRYPTED 

Definition at line 62 of file ev-document.h.

Enumerator
EV_DOCUMENT_LOAD_FLAG_NONE 
EV_DOCUMENT_LOAD_FLAG_NO_CACHE 

Definition at line 57 of file ev-document.h.

Function Documentation

gboolean ev_document_check_dimensions ( EvDocument document)

Definition at line 920 of file ev-document.c.

921 {
922  g_return_val_if_fail (EV_IS_DOCUMENT (document), FALSE);
923 
924  if (!document->priv->cache_loaded) {
925  g_mutex_lock (&ev_doc_mutex);
926  ev_document_setup_cache (document);
927  g_mutex_unlock (&ev_doc_mutex);
928  }
929 
930  return (document->priv->max_width > 0 && document->priv->max_height > 0);
931 }

+ Here is the caller graph for this function:

void ev_document_doc_mutex_lock ( void  )

Definition at line 158 of file ev-document.c.

159 {
160  g_mutex_lock (&ev_doc_mutex);
161 }

+ Here is the caller graph for this function:

gboolean ev_document_doc_mutex_trylock ( void  )

Definition at line 170 of file ev-document.c.

171 {
172  return g_mutex_trylock (&ev_doc_mutex);
173 }

+ Here is the caller graph for this function:

void ev_document_doc_mutex_unlock ( void  )

Definition at line 164 of file ev-document.c.

165 {
166  g_mutex_unlock (&ev_doc_mutex);
167 }

+ Here is the caller graph for this function:

GQuark ev_document_error_quark ( void  )

Definition at line 82 of file ev-document.c.

83 {
84  static GQuark q = 0;
85  if (q == 0)
86  q = g_quark_from_static_string ("ev-document-error-quark");
87 
88  return q;
89 }
void ev_document_fc_mutex_lock ( void  )

Definition at line 176 of file ev-document.c.

177 {
178  g_mutex_lock (&ev_fc_mutex);
179 }

+ Here is the caller graph for this function:

gboolean ev_document_fc_mutex_trylock ( void  )

Definition at line 188 of file ev-document.c.

189 {
190  return g_mutex_trylock (&ev_fc_mutex);
191 }

+ Here is the caller graph for this function:

void ev_document_fc_mutex_unlock ( void  )

Definition at line 182 of file ev-document.c.

183 {
184  g_mutex_unlock (&ev_fc_mutex);
185 }

+ Here is the caller graph for this function:

gboolean ev_document_find_page_by_label ( EvDocument document,
const gchar *  page_label,
gint *  page_index 
)

Definition at line 970 of file ev-document.c.

973 {
974  gint i, page;
975  glong value;
976  gchar *endptr = NULL;
977  EvDocumentPrivate *priv = document->priv;
978 
979  g_return_val_if_fail (EV_IS_DOCUMENT (document), FALSE);
980  g_return_val_if_fail (page_label != NULL, FALSE);
981  g_return_val_if_fail (page_index != NULL, FALSE);
982 
983  if (!document->priv->cache_loaded) {
984  g_mutex_lock (&ev_doc_mutex);
985  ev_document_setup_cache (document);
986  g_mutex_unlock (&ev_doc_mutex);
987  }
988 
989  /* First, look for a literal label match */
990  for (i = 0; priv->page_labels && i < priv->n_pages; i ++) {
991  if (priv->page_labels[i] != NULL &&
992  ! strcmp (page_label, priv->page_labels[i])) {
993  *page_index = i;
994  return TRUE;
995  }
996  }
997 
998  /* Second, look for a match with case insensitively */
999  for (i = 0; priv->page_labels && i < priv->n_pages; i++) {
1000  if (priv->page_labels[i] != NULL &&
1001  ! strcasecmp (page_label, priv->page_labels[i])) {
1002  *page_index = i;
1003  return TRUE;
1004  }
1005  }
1006 
1007  /* Next, parse the label, and see if the number fits */
1008  value = strtol (page_label, &endptr, 10);
1009  if (endptr[0] == '\0') {
1010  /* Page number is an integer */
1011  page = MIN (G_MAXINT, value);
1012 
1013  /* convert from a page label to a page offset */
1014  page --;
1015  if (page >= 0 && page < priv->n_pages) {
1016  *page_index = page;
1017  return TRUE;
1018  }
1019  }
1020 
1021  return FALSE;
1022 }

+ Here is the caller graph for this function:

gboolean ev_document_get_backend_info ( EvDocument document,
EvDocumentBackendInfo info 
)

Definition at line 771 of file ev-document.c.

772 {
773  EvDocumentClass *klass;
774 
775  g_return_val_if_fail (EV_IS_DOCUMENT (document), FALSE);
776 
777  klass = EV_DOCUMENT_GET_CLASS (document);
778  if (klass->get_backend_info == NULL)
779  return FALSE;
780 
781  return klass->get_backend_info (document, info);
782 }
GMutex* ev_document_get_doc_mutex ( void  )
GMutex* ev_document_get_fc_mutex ( void  )
EvDocumentInfo* ev_document_get_info ( EvDocument document)

Definition at line 763 of file ev-document.c.

764 {
765  g_return_val_if_fail (EV_IS_DOCUMENT (document), NULL);
766 
767  return document->priv->info;
768 }

+ Here is the caller graph for this function:

gint ev_document_get_max_label_len ( EvDocument document)

Definition at line 942 of file ev-document.c.

943 {
944  g_return_val_if_fail (EV_IS_DOCUMENT (document), -1);
945 
946  if (!document->priv->cache_loaded) {
947  g_mutex_lock (&ev_doc_mutex);
948  ev_document_setup_cache (document);
949  g_mutex_unlock (&ev_doc_mutex);
950  }
951 
952  return document->priv->max_label;
953 }

+ Here is the caller graph for this function:

void ev_document_get_max_page_size ( EvDocument document,
gdouble *  width,
gdouble *  height 
)

Definition at line 882 of file ev-document.c.

885 {
886  g_return_if_fail (EV_IS_DOCUMENT (document));
887 
888  if (!document->priv->cache_loaded) {
889  g_mutex_lock (&ev_doc_mutex);
890  ev_document_setup_cache (document);
891  g_mutex_unlock (&ev_doc_mutex);
892  }
893 
894  if (width)
895  *width = document->priv->max_width;
896  if (height)
897  *height = document->priv->max_height;
898 }

+ Here is the caller graph for this function:

void ev_document_get_min_page_size ( EvDocument document,
gdouble *  width,
gdouble *  height 
)

Definition at line 901 of file ev-document.c.

904 {
905  g_return_if_fail (EV_IS_DOCUMENT (document));
906 
907  if (!document->priv->cache_loaded) {
908  g_mutex_lock (&ev_doc_mutex);
909  ev_document_setup_cache (document);
910  g_mutex_unlock (&ev_doc_mutex);
911  }
912 
913  if (width)
914  *width = document->priv->min_width;
915  if (height)
916  *height = document->priv->min_height;
917 }

+ Here is the caller graph for this function:

gint ev_document_get_n_pages ( EvDocument document)

Definition at line 661 of file ev-document.c.

662 {
663  g_return_val_if_fail (EV_IS_DOCUMENT (document), 0);
664 
665  return document->priv->n_pages;
666 }
EvPage* ev_document_get_page ( EvDocument document,
gint  index 
)

ev_document_get_page: : a EvDocument : index of page

Returns: (transfer full): Newly created EvPage for the given index.

Definition at line 505 of file ev-document.c.

507 {
508  EvDocumentClass *klass = EV_DOCUMENT_GET_CLASS (document);
509 
510  return klass->get_page (document, index);
511 }

+ Here is the caller graph for this function:

gchar* ev_document_get_page_label ( EvDocument document,
gint  page_index 
)

Definition at line 730 of file ev-document.c.

732 {
733  g_return_val_if_fail (EV_IS_DOCUMENT (document), NULL);
734  g_return_val_if_fail (page_index >= 0 || page_index < document->priv->n_pages, NULL);
735 
736  if (!document->priv->cache_loaded) {
737  EvPage *page;
738  gchar *page_label;
739 
740  g_mutex_lock (&ev_doc_mutex);
741  page = ev_document_get_page (document, page_index);
742  page_label = _ev_document_get_page_label (document, page);
743  g_object_unref (page);
744  g_mutex_unlock (&ev_doc_mutex);
745 
746  return page_label ? page_label : g_strdup_printf ("%d", page_index + 1);
747  }
748 
749  return (document->priv->page_labels && document->priv->page_labels[page_index]) ?
750  g_strdup (document->priv->page_labels[page_index]) :
751  g_strdup_printf ("%d", page_index + 1);
752 }

+ Here is the caller graph for this function:

void ev_document_get_page_size ( EvDocument document,
gint  page_index,
double *  width,
double *  height 
)

ev_document_get_page_size: : a EvDocument : index of page : (out) (allow-none): return location for the width of the page, or NULL : (out) (allow-none): return location for the height of the page, or NULL

Definition at line 687 of file ev-document.c.

691 {
692  EvDocumentPrivate *priv;
693 
694  g_return_if_fail (EV_IS_DOCUMENT (document));
695  g_return_if_fail (page_index >= 0 || page_index < document->priv->n_pages);
696 
697  priv = document->priv;
698 
699  if (priv->cache_loaded) {
700  if (width)
701  *width = priv->uniform ?
702  priv->uniform_width :
703  priv->page_sizes[page_index].width;
704  if (height)
705  *height = priv->uniform ?
706  priv->uniform_height :
707  priv->page_sizes[page_index].height;
708  } else {
709  EvPage *page;
710 
711  g_mutex_lock (&ev_doc_mutex);
712  page = ev_document_get_page (document, page_index);
713  _ev_document_get_page_size (document, page, width, height);
714  g_object_unref (page);
715  g_mutex_unlock (&ev_doc_mutex);
716  }
717 }

+ Here is the caller graph for this function:

guint64 ev_document_get_size ( EvDocument document)

Definition at line 934 of file ev-document.c.

935 {
936  g_return_val_if_fail (EV_IS_DOCUMENT (document), 0);
937 
938  return document->priv->file_size;
939 }

+ Here is the caller graph for this function:

GdkPixbuf* ev_document_get_thumbnail ( EvDocument document,
EvRenderContext rc 
)

ev_document_get_thumbnail: : an EvDocument : an EvRenderContext

Returns: (transfer full): a #GdkPixbuf

Definition at line 817 of file ev-document.c.

819 {
820  EvDocumentClass *klass = EV_DOCUMENT_GET_CLASS (document);
821 
822  if (klass->get_thumbnail)
823  return klass->get_thumbnail (document, rc);
824 
825  return _ev_document_get_thumbnail (document, rc);
826 }

+ Here is the caller graph for this function:

cairo_surface_t* ev_document_get_thumbnail_surface ( EvDocument document,
EvRenderContext rc 
)

ev_document_get_thumbnail_surface: : an EvDocument : an EvRenderContext

Returns: (transfer full): a #cairo_surface_t

Since: 3.14

Definition at line 838 of file ev-document.c.

840 {
841  EvDocumentClass *klass = EV_DOCUMENT_GET_CLASS (document);
842 
843  if (klass->get_thumbnail_surface)
844  return klass->get_thumbnail_surface (document, rc);
845 
846  return ev_document_render (document, rc);
847 }

+ Here is the caller graph for this function:

const gchar* ev_document_get_title ( EvDocument document)

Definition at line 859 of file ev-document.c.

860 {
861  g_return_val_if_fail (EV_IS_DOCUMENT (document), NULL);
862 
863  return (document->priv->info->fields_mask & EV_DOCUMENT_INFO_TITLE) ?
864  document->priv->info->title : NULL;
865 }

+ Here is the caller graph for this function:

GType ev_document_get_type ( void  )
const gchar* ev_document_get_uri ( EvDocument document)

Definition at line 851 of file ev-document.c.

852 {
853  g_return_val_if_fail (EV_IS_DOCUMENT (document), NULL);
854 
855  return document->priv->uri;
856 }

+ Here is the caller graph for this function:

gboolean ev_document_has_synctex ( EvDocument document)

Definition at line 522 of file ev-document.c.

523 {
524  g_return_val_if_fail (EV_IS_DOCUMENT (document), FALSE);
525 
526  return document->priv->synctex_scanner != NULL;
527 }

+ Here is the caller graph for this function:

gboolean ev_document_has_text_page_labels ( EvDocument document)

Definition at line 956 of file ev-document.c.

957 {
958  g_return_val_if_fail (EV_IS_DOCUMENT (document), FALSE);
959 
960  if (!document->priv->cache_loaded) {
961  g_mutex_lock (&ev_doc_mutex);
962  ev_document_setup_cache (document);
963  g_mutex_unlock (&ev_doc_mutex);
964  }
965 
966  return document->priv->page_labels != NULL;
967 }

+ Here is the caller graph for this function:

gboolean ev_document_is_page_size_uniform ( EvDocument document)

Definition at line 868 of file ev-document.c.

869 {
870  g_return_val_if_fail (EV_IS_DOCUMENT (document), TRUE);
871 
872  if (!document->priv->cache_loaded) {
873  g_mutex_lock (&ev_doc_mutex);
874  ev_document_setup_cache (document);
875  g_mutex_unlock (&ev_doc_mutex);
876  }
877 
878  return document->priv->uniform;
879 }

+ Here is the caller graph for this function:

gboolean ev_document_load ( EvDocument document,
const char *  uri,
GError **  error 
)

ev_document_load: : a EvDocument : the document's URI : a #GError location to store an error, or NULL

Loads from .

On failure, FALSE is returned and is filled in. If the document is encrypted, EV_DEFINE_ERROR_ENCRYPTED is returned. If the backend cannot load the specific document, EV_DOCUMENT_ERROR_INVALID is returned. Other errors are possible too, depending on the backend used to load the document and the URI, e.g. #GIOError, #GFileError, and #GConvertError.

Returns: TRUE on success, or FALSE on failure.

Definition at line 369 of file ev-document.c.

372 {
373  return ev_document_load_full (document, uri,
375 }

+ Here is the caller graph for this function:

gboolean ev_document_load_full ( EvDocument document,
const char *  uri,
EvDocumentLoadFlags  flags,
GError **  error 
)

ev_document_load_full: : a EvDocument : the document's URI : flags from EvDocumentLoadFlags : a #GError location to store an error, or NULL

Loads from .

On failure, FALSE is returned and is filled in. If the document is encrypted, EV_DEFINE_ERROR_ENCRYPTED is returned. If the backend cannot load the specific document, EV_DOCUMENT_ERROR_INVALID is returned. Other errors are possible too, depending on the backend used to load the document and the URI, e.g. #GIOError, #GFileError, and #GConvertError.

Returns: TRUE on success, or FALSE on failure.

Definition at line 315 of file ev-document.c.

319 {
320  EvDocumentClass *klass = EV_DOCUMENT_GET_CLASS (document);
321  gboolean retval;
322  GError *err = NULL;
323 
324  retval = klass->load (document, uri, &err);
325  if (!retval) {
326  if (err) {
327  g_propagate_error (error, err);
328  } else {
329  g_warning ("%s::EvDocument::load returned FALSE but did not fill in @error; fix the backend!\n",
330  G_OBJECT_TYPE_NAME (document));
331 
332  /* So upper layers don't crash */
333  g_set_error_literal (error,
336  "Internal error in backend");
337  }
338  } else {
339  document->priv->info = _ev_document_get_info (document);
340  document->priv->n_pages = _ev_document_get_n_pages (document);
341  if (!(flags & EV_DOCUMENT_LOAD_FLAG_NO_CACHE))
342  ev_document_setup_cache (document);
343  document->priv->uri = g_strdup (uri);
344  document->priv->file_size = _ev_document_get_size (uri);
345  ev_document_initialize_synctex (document, uri);
346  }
347 
348  return retval;
349 }

+ Here is the caller graph for this function:

gboolean ev_document_load_gfile ( EvDocument document,
GFile *  file,
EvDocumentLoadFlags  flags,
GCancellable *  cancellable,
GError **  error 
)

Definition at line 441 of file ev-document.c.

446 {
447  EvDocumentClass *klass;
448 
449  g_return_val_if_fail (EV_IS_DOCUMENT (document), FALSE);
450  g_return_val_if_fail (G_IS_FILE (file), FALSE);
451  g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), FALSE);
452  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
453 
454  klass = EV_DOCUMENT_GET_CLASS (document);
455  if (!klass->load_gfile) {
456  g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
457  "Backend does not support loading from GFile");
458  return FALSE;
459  }
460 
461  if (!klass->load_gfile (document, file, flags, cancellable, error))
462  return FALSE;
463 
464  document->priv->info = _ev_document_get_info (document);
465  document->priv->n_pages = _ev_document_get_n_pages (document);
466 
467  if (!(flags & EV_DOCUMENT_LOAD_FLAG_NO_CACHE))
468  ev_document_setup_cache (document);
469 
470  document->priv->uri = g_file_get_uri (file);
471  document->priv->file_size = _ev_document_get_size_gfile (file);
472  ev_document_initialize_synctex (document, document->priv->uri);
473 
474  return TRUE;
475 }

+ Here is the caller graph for this function:

gboolean ev_document_load_stream ( EvDocument document,
GInputStream *  stream,
EvDocumentLoadFlags  flags,
GCancellable *  cancellable,
GError **  error 
)

ev_document_load_stream: : a EvDocument : a #GInputStream : flags from EvDocumentLoadFlags : (allow-none): a #GCancellable, or NULL : (allow-none): a #GError location to store an error, or NULL

Synchronously loads the document from . See ev_document_load() for more information.

Returns: TRUE if loading succeeded, or FALSE on error with filled in

Since: 3.6

Definition at line 393 of file ev-document.c.

398 {
399  EvDocumentClass *klass;
400 
401  g_return_val_if_fail (EV_IS_DOCUMENT (document), FALSE);
402  g_return_val_if_fail (G_IS_INPUT_STREAM (stream), FALSE);
403  g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), FALSE);
404  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
405 
406  klass = EV_DOCUMENT_GET_CLASS (document);
407  if (!klass->load_stream) {
408  g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
409  "Backend does not support loading from stream");
410  return FALSE;
411  }
412 
413  if (!klass->load_stream (document, stream, flags, cancellable, error))
414  return FALSE;
415 
416  document->priv->info = _ev_document_get_info (document);
417  document->priv->n_pages = _ev_document_get_n_pages (document);
418 
419  if (!(flags & EV_DOCUMENT_LOAD_FLAG_NO_CACHE))
420  ev_document_setup_cache (document);
421 
422  return TRUE;
423 }

+ Here is the caller graph for this function:

cairo_surface_t* ev_document_render ( EvDocument document,
EvRenderContext rc 
)

Definition at line 785 of file ev-document.c.

787 {
788  EvDocumentClass *klass = EV_DOCUMENT_GET_CLASS (document);
789 
790  return klass->render (document, rc);
791 }

+ Here is the caller graph for this function:

gboolean ev_document_save ( EvDocument document,
const char *  uri,
GError **  error 
)

ev_document_save: : a EvDocument : the target URI : a #GError location to store an error, or NULL

Saves to .

Returns: TRUE on success, or FALSE on error with filled in

Definition at line 488 of file ev-document.c.

491 {
492  EvDocumentClass *klass = EV_DOCUMENT_GET_CLASS (document);
493 
494  return klass->save (document, uri, error);
495 }

+ Here is the caller graph for this function:

EvSourceLink* ev_document_synctex_backward_search ( EvDocument document,
gint  page_index,
gfloat  x,
gfloat  y 
)

Definition at line 545 of file ev-document.c.

549 {
550  EvSourceLink *result = NULL;
551  synctex_scanner_t scanner;
552 
553  g_return_val_if_fail (EV_IS_DOCUMENT (document), NULL);
554 
555  scanner = document->priv->synctex_scanner;
556  if (!scanner)
557  return NULL;
558 
559  if (synctex_edit_query (scanner, page_index + 1, x, y) > 0) {
560  synctex_node_t node;
561 
562  /* We assume that a backward search returns either zero or one result_node */
563  node = synctex_next_result (scanner);
564  if (node != NULL) {
565  const gchar *filename;
566 
567  filename = synctex_scanner_get_name (scanner, synctex_node_tag (node));
568 
569  if (filename) {
570  result = ev_source_link_new (filename,
571  synctex_node_line (node),
572  synctex_node_column (node));
573  }
574  }
575  }
576 
577  return result;
578 }

+ Here is the caller graph for this function:

EvMapping* ev_document_synctex_forward_search ( EvDocument document,
EvSourceLink link 
)

ev_document_synctex_forward_search: : a EvDocument : a EvSourceLink

Peforms a Synctex forward search to obtain the area in the document corresponding to the position

Returns: An EvMapping with the page number and area corresponfing to the given line in the source file. It must be free with g_free when done

Definition at line 592 of file ev-document.c.

594 {
595  EvMapping *result = NULL;
596  synctex_scanner_t scanner;
597 
598  g_return_val_if_fail (EV_IS_DOCUMENT (document), NULL);
599 
600  scanner = document->priv->synctex_scanner;
601  if (!scanner)
602  return NULL;
603 
604  if (synctex_display_query (scanner, link->filename, link->line, link->col) > 0) {
605  synctex_node_t node;
606  gint page;
607 
608  if ((node = synctex_next_result (scanner))) {
609  result = g_new (EvMapping, 1);
610 
611  page = synctex_node_page (node) - 1;
612  result->data = GINT_TO_POINTER (page);
613 
614  result->area.x1 = synctex_node_box_visible_h (node);
615  result->area.y1 = synctex_node_box_visible_v (node) -
617  result->area.x2 = synctex_node_box_visible_width (node) + result->area.x1;
618  result->area.y2 = synctex_node_box_visible_depth (node) +
619  synctex_node_box_visible_height (node) + result->area.y1;
620  }
621  }
622 
623  return result;
624 }

+ Here is the caller graph for this function:

gint ev_rect_cmp ( EvRectangle a,
EvRectangle b 
)

Definition at line 1213 of file ev-document.c.

1215 {
1216  if (a == b)
1217  return 0;
1218  if (a == NULL || b == NULL)
1219  return 1;
1220 
1221  return ! ((ABS (a->x1 - b->x1) < EPSILON) &&
1222  (ABS (a->y1 - b->y1) < EPSILON) &&
1223  (ABS (a->x2 - b->x2) < EPSILON) &&
1224  (ABS (a->y2 - b->y2) < EPSILON));
1225 }

+ Here is the caller graph for this function:

EvRectangle* ev_rectangle_copy ( EvRectangle ev_rect)

Definition at line 1191 of file ev-document.c.

1192 {
1193  EvRectangle *new_rectangle;
1194 
1195  g_return_val_if_fail (rectangle != NULL, NULL);
1196 
1197  new_rectangle = g_new (EvRectangle, 1);
1198  *new_rectangle = *rectangle;
1199 
1200  return new_rectangle;
1201 }

+ Here is the caller graph for this function:

void ev_rectangle_free ( EvRectangle ev_rect)

Definition at line 1204 of file ev-document.c.

1205 {
1206  g_free (rectangle);
1207 }

+ Here is the caller graph for this function:

GType ev_rectangle_get_type ( void  )
EvRectangle* ev_rectangle_new ( void  )

Definition at line 1185 of file ev-document.c.

1186 {
1187  return g_new0 (EvRectangle, 1);
1188 }

+ Here is the caller graph for this function:

EvSourceLink* ev_source_link_copy ( EvSourceLink link)

Definition at line 1042 of file ev-document.c.

1043 {
1044  EvSourceLink *copy;
1045 
1046  g_return_val_if_fail (link != NULL, NULL);
1047 
1048  copy = g_slice_new (EvSourceLink);
1049 
1050  *copy = *link;
1051  copy->filename = g_strdup (link->filename);
1052 
1053  return copy;
1054 }
void ev_source_link_free ( EvSourceLink link)

Definition at line 1057 of file ev-document.c.

1058 {
1059  if (link == NULL)
1060  return;
1061 
1062  g_free (link->filename);
1063  g_slice_free (EvSourceLink, link);
1064 }

+ Here is the caller graph for this function:

GType ev_source_link_get_type ( void  )
EvSourceLink* ev_source_link_new ( const gchar *  filename,
gint  line,
gint  col 
)

Definition at line 1028 of file ev-document.c.

1031 {
1032  EvSourceLink *link = g_slice_new (EvSourceLink);
1033 
1034  link->filename = g_strdup (filename);
1035  link->line = line;
1036  link->col = col;
1037 
1038  return link;
1039 }

+ Here is the caller graph for this function: