31 #define EV_DOCUMENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EV_TYPE_DOCUMENT, EvDocumentPrivate))
79 G_DEFINE_ABSTRACT_TYPE (
EvDocument, ev_document, G_TYPE_OBJECT)
86 q = g_quark_from_static_string (
"ev-document-error-quark");
131 G_OBJECT_CLASS (ev_document_parent_class)->finalize (
object);
146 GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
197 gboolean custom_page_labels =
FALSE;
205 for (i = 0; i < priv->
n_pages; i++) {
207 gdouble page_width = 0;
208 gdouble page_height = 0;
229 for (j = 0; j < i; j++) {
239 page_size->
width = page_width;
240 page_size->
height = page_height;
244 if (page_width < priv->min_width)
249 if (page_height < priv->min_height)
258 if (!custom_page_labels) {
259 gchar *real_page_label;
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);
268 g_utf8_strlen (page_label, 256));
271 g_object_unref (page);
274 if (!custom_page_labels)
287 filename = g_filename_from_uri (uri, NULL, NULL);
288 if (filename != NULL) {
324 retval = klass->
load (document, uri, &err);
327 g_propagate_error (error, err);
329 g_warning (
"%s::EvDocument::load returned FALSE but did not fill in @error; fix the backend!\n",
330 G_OBJECT_TYPE_NAME (document));
333 g_set_error_literal (error,
336 "Internal error in backend");
343 document->
priv->
uri = g_strdup (uri);
394 GInputStream *stream,
396 GCancellable *cancellable,
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);
408 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
409 "Backend does not support loading from stream");
413 if (!klass->
load_stream (document, stream, flags, cancellable, error))
444 GCancellable *cancellable,
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);
456 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
457 "Backend does not support loading from GFile");
461 if (!klass->
load_gfile (document, file, flags, cancellable, error))
470 document->
priv->
uri = g_file_get_uri (file);
494 return klass->
save (document, uri, error);
510 return klass->
get_page (document, index);
565 const gchar *filename;
612 result->
data = GINT_TO_POINTER (page);
630 GFileInfo *info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_SIZE,
631 G_FILE_QUERY_INFO_NONE, NULL, NULL);
633 size = g_file_info_get_size (info);
635 g_object_unref (info);
644 GFile *file = g_file_new_for_uri (uri);
647 g_object_unref (file);
695 g_return_if_fail (page_index >= 0 || page_index < document->priv->
n_pages);
697 priv = document->
priv;
714 g_object_unref (page);
734 g_return_val_if_fail (page_index >= 0 || page_index < document->priv->n_pages, NULL);
743 g_object_unref (page);
746 return page_label ? page_label : g_strdup_printf (
"%d", page_index + 1);
751 g_strdup_printf (
"%d", page_index + 1);
790 return klass->
render (document, rc);
797 cairo_surface_t *surface;
798 GdkPixbuf *pixbuf = NULL;
801 if (surface != NULL) {
803 cairo_surface_destroy (surface);
971 const gchar *page_label,
976 gchar *endptr = NULL;
980 g_return_val_if_fail (page_label != NULL,
FALSE);
981 g_return_val_if_fail (page_index != NULL,
FALSE);
1001 ! strcasecmp (page_label, priv->
page_labels[i])) {
1008 value = strtol (page_label, &endptr, 10);
1009 if (endptr[0] ==
'\0') {
1011 page = MIN (G_MAXINT, value);
1015 if (page >= 0 && page < priv->n_pages) {
1034 link->
filename = g_strdup (filename);
1046 g_return_val_if_fail (link != NULL, NULL);
1074 g_return_val_if_fail (info != NULL, NULL);
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);
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;
1096 copy->fields_mask = info->fields_mask;
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);
1141 new_license->
text = g_strdup (license->
text);
1143 new_license->
uri = g_strdup (license->
uri);
1156 g_free (license->
text);
1157 g_free (license->
uri);
1166 return license->
text;
1172 return license->
uri;
1195 g_return_val_if_fail (rectangle != NULL, NULL);
1198 *new_rectangle = *rectangle;
1200 return new_rectangle;
1210 #define EPSILON 0.0000001
1218 if (a == NULL || b == NULL)