X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=libdocument%2Fev-document.c;h=e1521b7b5596982c3e10c5d089f29f9b968390e8;hb=cc3f21efc8104182171c9300facc16d9a79177ef;hp=63dae75d63171b47ea4b24e9daca76199a015d1b;hpb=760bfb26364378df003b2db2ec31976d8e714b9c;p=evince.git diff --git a/libdocument/ev-document.c b/libdocument/ev-document.c index 63dae75d..e1521b7b 100644 --- a/libdocument/ev-document.c +++ b/libdocument/ev-document.c @@ -103,7 +103,13 @@ ev_document_fc_mutex_trylock (void) * @error: a #GError location to store an error, or %NULL * * Loads @document from @uri. - * On failure, @error is filled in. + * + * 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, 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. */ @@ -114,12 +120,37 @@ ev_document_load (EvDocument *document, { EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document); gboolean retval; - - retval = iface->load (document, uri, error); + GError *err = NULL; + + retval = iface->load (document, uri, &err); + if (!retval) { + if (err) { + g_propagate_error (error, err); + } else { + g_warning ("%s::EvDocumentIface::load returned FALSE but did not fill in @error; fix the backend!\n", + G_OBJECT_TYPE_NAME (document)); + + /* So upper layers don't crash */ + g_set_error_literal (error, + EV_DOCUMENT_ERROR, + EV_DOCUMENT_ERROR_INVALID, + "Internal error in backend"); + } + } return retval; } +/** + * ev_document_save: + * @document: + * @uri: the target URI + * @error: a #GError location to store an error, or %NULL + * + * Saves @document to @uri. + * + * Returns: %TRUE on success, or %FALSE on error with @error filled in + */ gboolean ev_document_save (EvDocument *document, const char *uri, @@ -239,15 +270,15 @@ ev_document_info_copy (EvDocumentInfo *info) g_return_val_if_fail (info != NULL, NULL); copy = g_new0 (EvDocumentInfo, 1); - copy->title = info->title ? g_strdup (info->title) : NULL; - copy->format = info->format ? g_strdup (info->format) : NULL; - copy->author = info->author ? g_strdup (info->author) : NULL; - copy->subject = info->subject ? g_strdup (info->subject) : NULL; - copy->keywords = info->keywords ? g_strdup (info->keywords) : NULL; - copy->security = info->security ? g_strdup (info->security) : NULL; - copy->creator = info->creator ? g_strdup (info->creator) : NULL; - copy->producer = info->producer ? g_strdup (info->producer) : NULL; - copy->linearized = info->linearized ? g_strdup (info->linearized) : NULL; + copy->title = g_strdup (info->title); + copy->format = g_strdup (info->format); + copy->author = g_strdup (info->author); + copy->subject = g_strdup (info->subject); + copy->keywords = g_strdup (info->keywords); + copy->security = g_strdup (info->security); + copy->creator = g_strdup (info->creator); + copy->producer = g_strdup (info->producer); + copy->linearized = g_strdup (info->linearized); copy->creation_date = info->creation_date; copy->modified_date = info->modified_date; @@ -280,6 +311,33 @@ ev_document_info_free (EvDocumentInfo *info) g_free (info); } +/* EvRectangle */ +EV_DEFINE_BOXED_TYPE (EvRectangle, ev_rectangle, ev_rectangle_copy, ev_rectangle_free) + +EvRectangle * +ev_rectangle_new (void) +{ + return g_new0 (EvRectangle, 1); +} + +EvRectangle * +ev_rectangle_copy (EvRectangle *rectangle) +{ + EvRectangle *new_rectangle; + + g_return_val_if_fail (rectangle != NULL, NULL); + + new_rectangle = g_new (EvRectangle, 1); + *new_rectangle = *rectangle; + + return new_rectangle; +} + +void +ev_rectangle_free (EvRectangle *rectangle) +{ + g_free (rectangle); +} /* Compares two rects. returns 0 if they're equal */ #define EPSILON 0.0000001 @@ -298,6 +356,3 @@ ev_rect_cmp (EvRectangle *a, (ABS (a->x2 - b->x2) < EPSILON) && (ABS (a->y2 - b->y2) < EPSILON)); } - - -