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.c File Reference
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include "ev-document.h"
#include "ev-document-misc.h"
#include "synctex_parser.h"
+ Include dependency graph for ev-document.c:

Go to the source code of this file.

Data Structures

struct  _EvPageSize
 
struct  _EvDocumentPrivate
 

Macros

#define EV_DOCUMENT_GET_PRIVATE(obj)   (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EV_TYPE_DOCUMENT, EvDocumentPrivate))
 
#define EPSILON   0.0000001
 

Typedefs

typedef struct _EvPageSize EvPageSize
 

Functions

static guint64 _ev_document_get_size_gfile (GFile *file)
 
static guint64 _ev_document_get_size (const char *uri)
 
static gint _ev_document_get_n_pages (EvDocument *document)
 
static void _ev_document_get_page_size (EvDocument *document, EvPage *page, double *width, double *height)
 
static gchar * _ev_document_get_page_label (EvDocument *document, EvPage *page)
 
static EvDocumentInfo_ev_document_get_info (EvDocument *document)
 
static gboolean _ev_document_support_synctex (EvDocument *document)
 
GQuark ev_document_error_quark (void)
 
static EvPageev_document_impl_get_page (EvDocument *document, gint index)
 
static EvDocumentInfoev_document_impl_get_info (EvDocument *document)
 
static void ev_document_finalize (GObject *object)
 
static void ev_document_init (EvDocument *document)
 
static void ev_document_class_init (EvDocumentClass *klass)
 
void ev_document_doc_mutex_lock (void)
 
void ev_document_doc_mutex_unlock (void)
 
gboolean ev_document_doc_mutex_trylock (void)
 
void ev_document_fc_mutex_lock (void)
 
void ev_document_fc_mutex_unlock (void)
 
gboolean ev_document_fc_mutex_trylock (void)
 
static void ev_document_setup_cache (EvDocument *document)
 
static void ev_document_initialize_synctex (EvDocument *document, const gchar *uri)
 
gboolean ev_document_load_full (EvDocument *document, const char *uri, EvDocumentLoadFlags flags, GError **error)
 
gboolean ev_document_load (EvDocument *document, const char *uri, 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)
 
EvPageev_document_get_page (EvDocument *document, gint 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 *link)
 
gint ev_document_get_n_pages (EvDocument *document)
 
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)
 
EvDocumentInfoev_document_get_info (EvDocument *document)
 
gboolean ev_document_get_backend_info (EvDocument *document, EvDocumentBackendInfo *info)
 
cairo_surface_t * ev_document_render (EvDocument *document, EvRenderContext *rc)
 
static GdkPixbuf * _ev_document_get_thumbnail (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)
 
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)
 
guint64 ev_document_get_size (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)
 
EvSourceLinkev_source_link_new (const gchar *filename, gint line, gint col)
 
EvSourceLinkev_source_link_copy (EvSourceLink *link)
 
void ev_source_link_free (EvSourceLink *link)
 
EvDocumentInfoev_document_info_copy (EvDocumentInfo *info)
 
void ev_document_info_free (EvDocumentInfo *info)
 
EvDocumentLicenseev_document_license_new (void)
 
EvDocumentLicenseev_document_license_copy (EvDocumentLicense *license)
 
void ev_document_license_free (EvDocumentLicense *license)
 
const gchar * ev_document_license_get_text (EvDocumentLicense *license)
 
const gchar * ev_document_license_get_uri (EvDocumentLicense *license)
 
const gchar * ev_document_license_get_web_statement (EvDocumentLicense *license)
 
EvRectangleev_rectangle_new (void)
 
EvRectangleev_rectangle_copy (EvRectangle *rectangle)
 
void ev_rectangle_free (EvRectangle *rectangle)
 
gint ev_rect_cmp (EvRectangle *a, EvRectangle *b)
 

Variables

static GMutex ev_doc_mutex
 
static GMutex ev_fc_mutex
 

Detailed Description

See ev_document_load() for more information.

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

Since: 3.6

Definition in file ev-document.c.

Macro Definition Documentation

#define EPSILON   0.0000001

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

#define EV_DOCUMENT_GET_PRIVATE (   obj)    (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EV_TYPE_DOCUMENT, EvDocumentPrivate))

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

Typedef Documentation

typedef struct _EvPageSize EvPageSize

Function Documentation

static EvDocumentInfo * _ev_document_get_info ( EvDocument document)
static

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

756 {
757  EvDocumentClass *klass = EV_DOCUMENT_GET_CLASS (document);
758 
759  return klass->get_info (document);
760 }

+ Here is the caller graph for this function:

static gint _ev_document_get_n_pages ( EvDocument document)
static

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

654 {
655  EvDocumentClass *klass = EV_DOCUMENT_GET_CLASS (document);
656 
657  return klass->get_n_pages (document);
658 }

+ Here is the caller graph for this function:

static gchar * _ev_document_get_page_label ( EvDocument document,
EvPage page 
)
static

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

722 {
723  EvDocumentClass *klass = EV_DOCUMENT_GET_CLASS (document);
724 
725  return klass->get_page_label ?
726  klass->get_page_label (document, page) : NULL;
727 }

+ Here is the caller graph for this function:

static void _ev_document_get_page_size ( EvDocument document,
EvPage page,
double *  width,
double *  height 
)
static

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

673 {
674  EvDocumentClass *klass = EV_DOCUMENT_GET_CLASS (document);
675 
676  klass->get_page_size (document, page, width, height);
677 }

+ Here is the caller graph for this function:

static guint64 _ev_document_get_size ( const char *  uri)
static

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

643 {
644  GFile *file = g_file_new_for_uri (uri);
645  guint64 size = _ev_document_get_size_gfile (file);
646 
647  g_object_unref (file);
648 
649  return size;
650 }

+ Here is the caller graph for this function:

static guint64 _ev_document_get_size_gfile ( GFile *  file)
static

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

628 {
629  goffset size = 0;
630  GFileInfo *info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_SIZE,
631  G_FILE_QUERY_INFO_NONE, NULL, NULL);
632  if (info) {
633  size = g_file_info_get_size (info);
634 
635  g_object_unref (info);
636  }
637 
638  return size;
639 }

+ Here is the caller graph for this function:

static GdkPixbuf* _ev_document_get_thumbnail ( EvDocument document,
EvRenderContext rc 
)
static

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

796 {
797  cairo_surface_t *surface;
798  GdkPixbuf *pixbuf = NULL;
799 
800  surface = ev_document_render (document, rc);
801  if (surface != NULL) {
802  pixbuf = ev_document_misc_pixbuf_from_surface (surface);
803  cairo_surface_destroy (surface);
804  }
805 
806  return pixbuf;
807 }

+ Here is the caller graph for this function:

static gboolean _ev_document_support_synctex ( EvDocument document)
static

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

515 {
516  EvDocumentClass *klass = EV_DOCUMENT_GET_CLASS (document);
517 
518  return klass->support_synctex ? klass->support_synctex (document) : FALSE;
519 }

+ Here is the caller graph for this function:

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:

static void ev_document_class_init ( EvDocumentClass klass)
static

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

145 {
146  GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
147 
148  g_type_class_add_private (g_object_class, sizeof (EvDocumentPrivate));
149 
152  klass->get_backend_info = NULL;
153 
154  g_object_class->finalize = ev_document_finalize;
155 }
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:

static void ev_document_finalize ( GObject *  object)
static

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

106 {
107  EvDocument *document = EV_DOCUMENT (object);
108 
109  if (document->priv->uri) {
110  g_free (document->priv->uri);
111  document->priv->uri = NULL;
112  }
113 
114  if (document->priv->page_sizes) {
115  g_free (document->priv->page_sizes);
116  document->priv->page_sizes = NULL;
117  }
118 
119  g_clear_pointer (&document->priv->page_labels, g_strfreev);
120 
121  if (document->priv->info) {
122  ev_document_info_free (document->priv->info);
123  document->priv->info = NULL;
124  }
125 
126  if (document->priv->synctex_scanner) {
128  document->priv->synctex_scanner = NULL;
129  }
130 
131  G_OBJECT_CLASS (ev_document_parent_class)->finalize (object);
132 }

+ 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 }
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:

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:

static EvDocumentInfo* ev_document_impl_get_info ( EvDocument document)
static

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

100 {
101  return g_new0 (EvDocumentInfo, 1);
102 }

+ Here is the caller graph for this function:

static EvPage* ev_document_impl_get_page ( EvDocument document,
gint  index 
)
static

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

94 {
95  return ev_page_new (index);
96 }

+ Here is the caller graph for this function:

EvDocumentInfo* ev_document_info_copy ( EvDocumentInfo info)

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

1071 {
1072  EvDocumentInfo *copy;
1073 
1074  g_return_val_if_fail (info != NULL, NULL);
1075 
1076  copy = g_new0 (EvDocumentInfo, 1);
1077  copy->title = g_strdup (info->title);
1078  copy->format = g_strdup (info->format);
1079  copy->author = g_strdup (info->author);
1080  copy->subject = g_strdup (info->subject);
1081  copy->keywords = g_strdup (info->keywords);
1082  copy->security = g_strdup (info->security);
1083  copy->creator = g_strdup (info->creator);
1084  copy->producer = g_strdup (info->producer);
1085  copy->linearized = g_strdup (info->linearized);
1086 
1087  copy->creation_date = info->creation_date;
1088  copy->modified_date = info->modified_date;
1089  copy->layout = info->layout;
1090  copy->mode = info->mode;
1091  copy->ui_hints = info->ui_hints;
1092  copy->permissions = info->permissions;
1093  copy->n_pages = info->n_pages;
1094  copy->license = ev_document_license_copy (info->license);
1095 
1096  copy->fields_mask = info->fields_mask;
1097 
1098  return copy;
1099 }
void ev_document_info_free ( EvDocumentInfo info)

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

1103 {
1104  if (info == NULL)
1105  return;
1106 
1107  g_free (info->title);
1108  g_free (info->format);
1109  g_free (info->author);
1110  g_free (info->subject);
1111  g_free (info->keywords);
1112  g_free (info->creator);
1113  g_free (info->producer);
1114  g_free (info->linearized);
1115  g_free (info->security);
1116  ev_document_license_free (info->license);
1117 
1118  g_free (info);
1119 }

+ Here is the caller graph for this function:

static void ev_document_init ( EvDocument document)
static

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

136 {
137  document->priv = EV_DOCUMENT_GET_PRIVATE (document);
138 
139  /* Assume all pages are the same size until proven otherwise */
140  document->priv->uniform = TRUE;
141 }
static void ev_document_initialize_synctex ( EvDocument document,
const gchar *  uri 
)
static

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

281 {
282  EvDocumentPrivate *priv = document->priv;
283 
284  if (_ev_document_support_synctex (document)) {
285  gchar *filename;
286 
287  filename = g_filename_from_uri (uri, NULL, NULL);
288  if (filename != NULL) {
289  priv->synctex_scanner =
290  synctex_scanner_new_with_output_file (filename, NULL, 1);
291  g_free (filename);
292  }
293  }
294 }

+ 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:

EvDocumentLicense* ev_document_license_copy ( EvDocumentLicense license)

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

1132 {
1133  EvDocumentLicense *new_license;
1134 
1135  if (!license)
1136  return NULL;
1137 
1138  new_license = ev_document_license_new ();
1139 
1140  if (license->text)
1141  new_license->text = g_strdup (license->text);
1142  if (license->uri)
1143  new_license->uri = g_strdup (license->uri);
1144  if (license->web_statement)
1145  new_license->web_statement = g_strdup (license->web_statement);
1146 
1147  return new_license;
1148 }

+ Here is the caller graph for this function:

void ev_document_license_free ( EvDocumentLicense license)

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

1152 {
1153  if (!license)
1154  return;
1155 
1156  g_free (license->text);
1157  g_free (license->uri);
1158  g_free (license->web_statement);
1159 
1160  g_free (license);
1161 }

+ Here is the caller graph for this function:

const gchar* ev_document_license_get_text ( EvDocumentLicense license)

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

1165 {
1166  return license->text;
1167 }

+ Here is the caller graph for this function:

const gchar* ev_document_license_get_uri ( EvDocumentLicense license)

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

1171 {
1172  return license->uri;
1173 }

+ Here is the caller graph for this function:

const gchar* ev_document_license_get_web_statement ( EvDocumentLicense license)

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

1177 {
1178  return license->web_statement;
1179 }

+ Here is the caller graph for this function:

EvDocumentLicense* ev_document_license_new ( void  )

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

1126 {
1127  return g_new0 (EvDocumentLicense, 1);
1128 }

+ 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:

static void ev_document_setup_cache ( EvDocument document)
static

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

195 {
196  EvDocumentPrivate *priv = document->priv;
197  gboolean custom_page_labels = FALSE;
198  gint i;
199 
200  /* Cache some info about the document to avoid
201  * going to the backends since it requires locks
202  */
203  priv->cache_loaded = TRUE;
204 
205  for (i = 0; i < priv->n_pages; i++) {
206  EvPage *page = ev_document_get_page (document, i);
207  gdouble page_width = 0;
208  gdouble page_height = 0;
209  EvPageSize *page_size;
210  gchar *page_label;
211 
212  _ev_document_get_page_size (document, page, &page_width, &page_height);
213 
214  if (i == 0) {
215  priv->uniform_width = page_width;
216  priv->uniform_height = page_height;
217  priv->max_width = priv->uniform_width;
218  priv->max_height = priv->uniform_height;
219  priv->min_width = priv->uniform_width;
220  priv->min_height = priv->uniform_height;
221  } else if (priv->uniform &&
222  (priv->uniform_width != page_width ||
223  priv->uniform_height != page_height)) {
224  /* It's a different page size. Backfill the array. */
225  int j;
226 
227  priv->page_sizes = g_new0 (EvPageSize, priv->n_pages);
228 
229  for (j = 0; j < i; j++) {
230  page_size = &(priv->page_sizes[j]);
231  page_size->width = priv->uniform_width;
232  page_size->height = priv->uniform_height;
233  }
234  priv->uniform = FALSE;
235  }
236  if (!priv->uniform) {
237  page_size = &(priv->page_sizes[i]);
238 
239  page_size->width = page_width;
240  page_size->height = page_height;
241 
242  if (page_width > priv->max_width)
243  priv->max_width = page_width;
244  if (page_width < priv->min_width)
245  priv->min_width = page_width;
246 
247  if (page_height > priv->max_height)
248  priv->max_height = page_height;
249  if (page_height < priv->min_height)
250  priv->min_height = page_height;
251  }
252 
253  page_label = _ev_document_get_page_label (document, page);
254  if (page_label) {
255  if (!priv->page_labels)
256  priv->page_labels = g_new0 (gchar *, priv->n_pages + 1);
257 
258  if (!custom_page_labels) {
259  gchar *real_page_label;
260 
261  real_page_label = g_strdup_printf ("%d", i + 1);
262  custom_page_labels = g_strcmp0 (real_page_label, page_label) != 0;
263  g_free (real_page_label);
264  }
265 
266  priv->page_labels[i] = page_label;
267  priv->max_label = MAX (priv->max_label,
268  g_utf8_strlen (page_label, 256));
269  }
270 
271  g_object_unref (page);
272  }
273 
274  if (!custom_page_labels)
275  g_clear_pointer (&priv->page_labels, g_strfreev);
276 }

+ 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 rectangle)

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 rectangle)

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

1205 {
1206  g_free (rectangle);
1207 }

+ Here is the caller graph for this function:

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:

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:

Variable Documentation

GMutex ev_doc_mutex
static

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

GMutex ev_fc_mutex
static

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