From f7e2749411023efcdf4db4ea9d18e2bc3dcc0070 Mon Sep 17 00:00:00 2001 From: Jason Crain Date: Mon, 7 Jan 2013 22:20:10 -0600 Subject: [PATCH] glib: forward poppler warnings through g_warning --- glib/poppler-document.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc index 61d92e8..b7b9556 100644 --- a/glib/poppler-document.cc +++ b/glib/poppler-document.cc @@ -151,6 +151,30 @@ poppler_password_to_latin1 (const gchar *password) return password_g; } +static void +poppler_error_callback (void *data, + ErrorCategory category, + int pos, + char *msg) +{ + const char *errorCategoryNames[] = { + "Syntax Warning", + "Syntax Error", + "Config Error", + "Command Line Error", + "I/O Error", + "Permission Error", + "Unimplemented Feature", + "Internal Error" + }; + + if (pos >= 0) { + g_warning ("%s: (%d): %s", errorCategoryNames[category], pos, msg); + } else { + g_warning ("%s: %s", errorCategoryNames[category], msg); + } +} + /** * poppler_document_new_from_file: * @uri: uri of the file to load @@ -173,6 +197,7 @@ poppler_document_new_from_file (const char *uri, char *filename; if (!globalParams) { + setErrorCallback (poppler_error_callback, NULL); globalParams = new GlobalParams(); } @@ -233,6 +258,7 @@ poppler_document_new_from_data (char *data, GooString *password_g; if (!globalParams) { + setErrorCallback (poppler_error_callback, NULL); globalParams = new GlobalParams(); } @@ -288,6 +314,7 @@ poppler_document_new_from_stream (GInputStream *stream, g_return_val_if_fail(length == (goffset)-1 || length > 0, NULL); if (!globalParams) { + setErrorCallback (poppler_error_callback, NULL); globalParams = new GlobalParams(); } -- 1.7.10.4