Skip to content

Commit

Permalink
[shell] Do not link to poppler directly
Browse files Browse the repository at this point in the history
Fixes bgo#608832.
  • Loading branch information
Hib Eris committed Feb 3, 2010
1 parent e67a9f0 commit ee37f08
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 34 deletions.
24 changes: 24 additions & 0 deletions backend/pdf/ev-poppler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,29 @@ pdf_document_get_info (EvDocument *document)
return info;
}

static gboolean
pdf_document_get_backend_info (EvDocument *document, EvDocumentBackendInfo *info)
{
PopplerBackend backend;

backend = poppler_get_backend ();
switch (backend) {
case POPPLER_BACKEND_CAIRO:
info->name = "poppler/cairo";
break;
case POPPLER_BACKEND_SPLASH:
info->name = "poppler/splash";
break;
default:
info->name = "poppler/unknown";
break;
}

info->version = poppler_get_version ();

return TRUE;
}

static void
pdf_document_class_init (PdfDocumentClass *klass)
{
Expand All @@ -846,6 +869,7 @@ pdf_document_class_init (PdfDocumentClass *klass)
ev_document_class->get_page_label = pdf_document_get_page_label;
ev_document_class->render = pdf_document_render;
ev_document_class->get_info = pdf_document_get_info;
ev_document_class->get_backend_info = pdf_document_get_backend_info;
}

/* EvDocumentSecurity */
Expand Down
4 changes: 0 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,6 @@ if test "x$enable_pdf" = "xyes"; then
PKG_CHECK_MODULES(POPPLER, poppler-glib >= $POPPLER_REQUIRED libxml-2.0 >= $LIBXML_REQUIRED,enable_pdf=yes,enable_pdf=no)

if test "x$enable_pdf" = "xyes"; then
AC_DEFINE([ENABLE_PDF], [1], [Enable pdf support.])
SHELL_LIBS="$SHELL_LIBS $POPPLER_LIBS"
SHELL_CFLAGS="$SHELL_CFLAGS $POPPLER_CFLAGS"

evince_save_LIBS=$LIBS
LIBS="$LIBS $POPPLER_LIBS"
AC_CHECK_FUNCS(poppler_page_render)
Expand Down
13 changes: 13 additions & 0 deletions libdocument/ev-document.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ ev_document_class_init (EvDocumentClass *klass)

klass->get_page = ev_document_impl_get_page;
klass->get_info = ev_document_impl_get_info;
klass->get_backend_info = NULL;

g_object_class->finalize = ev_document_finalize;
}
Expand Down Expand Up @@ -423,6 +424,18 @@ ev_document_get_info (EvDocument *document)
return document->priv->info;
}

gboolean
ev_document_get_backend_info (EvDocument *document, EvDocumentBackendInfo *info)
{
g_return_val_if_fail (EV_IS_DOCUMENT (document), FALSE);

EvDocumentClass *klass = EV_DOCUMENT_GET_CLASS (document);
if (klass->get_backend_info == NULL)
return FALSE;

return klass->get_backend_info (document, info);
}

cairo_surface_t *
ev_document_render (EvDocument *document,
EvRenderContext *rc)
Expand Down
11 changes: 11 additions & 0 deletions libdocument/ev-document.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ typedef struct {

typedef struct _EvRectangle EvRectangle;

typedef struct _EvDocumentBackendInfo EvDocumentBackendInfo;
struct _EvDocumentBackendInfo
{
const gchar *name;
const gchar *version;
};

struct _EvDocument
{
GObject base;
Expand Down Expand Up @@ -96,6 +103,8 @@ struct _EvDocumentClass
cairo_surface_t * (* render) (EvDocument *document,
EvRenderContext *rc);
EvDocumentInfo * (* get_info) (EvDocument *document);
gboolean (* get_backend_info)(EvDocument *document,
EvDocumentBackendInfo *info);
};

GType ev_document_get_type (void) G_GNUC_CONST;
Expand All @@ -114,6 +123,8 @@ void ev_document_fc_mutex_unlock (void);
gboolean ev_document_fc_mutex_trylock (void);

EvDocumentInfo *ev_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);
Expand Down
45 changes: 15 additions & 30 deletions shell/ev-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@
#include "ev-media-player-keys.h"
#endif /* ENABLE_DBUS */

#ifdef ENABLE_PDF
#include <poppler.h>
#endif

typedef enum {
PAGE_MODE_DOCUMENT,
PAGE_MODE_PASSWORD
Expand Down Expand Up @@ -4173,33 +4169,21 @@ ev_window_dual_mode_changed_cb (EvDocumentModel *model,
}

static char *
build_comments_string (void)
{
#ifdef ENABLE_PDF
PopplerBackend backend;
const char *backend_name;
const char *version;

backend = poppler_get_backend ();
version = poppler_get_version ();
switch (backend) {
case POPPLER_BACKEND_CAIRO:
backend_name = "cairo";
break;
case POPPLER_BACKEND_SPLASH:
backend_name = "splash";
break;
default:
backend_name = "unknown";
break;
build_comments_string (EvDocument *document)
{
gchar *comments = NULL;
EvDocumentBackendInfo info;

if (document && ev_document_get_backend_info (document, &info)) {
comments = g_strdup_printf (
_("Document Viewer\nUsing %s (%s)"),
info.name, info.version);
} else {
comments = g_strdup_printf (
_("Document Viewer"));
}

return g_strdup_printf (_("Document Viewer.\n"
"Using Poppler %s (%s)"),
version, backend_name);
#else
return g_strdup_printf (_("Document Viewer"));
#endif
return comments;
}

static void
Expand Down Expand Up @@ -4251,7 +4235,8 @@ ev_window_cmd_help_about (GtkAction *action, EvWindow *ev_window)

license_trans = g_strconcat (_(license[0]), "\n", _(license[1]), "\n",
_(license[2]), "\n", NULL);
comments = build_comments_string ();

comments = build_comments_string (ev_window->priv->document);

gtk_show_about_dialog (
GTK_WINDOW (ev_window),
Expand Down

0 comments on commit ee37f08

Please sign in to comment.