summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5b2c3d9)
raw | patch | inline | side by side (parent: 5b2c3d9)
author | Sebastian Harl <sh@tokkee.org> | |
Fri, 11 Nov 2011 13:17:30 +0000 (14:17 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Fri, 11 Nov 2011 13:17:30 +0000 (14:17 +0100) |
src/gtk-tpdfv.c | patch | blob | history |
diff --git a/src/gtk-tpdfv.c b/src/gtk-tpdfv.c
index ee68357d1253de739f77b7002a4785f2b3f4346b..cba2e1f2a1c13697e384cb8d1eeab7e62c0547e8 100644 (file)
--- a/src/gtk-tpdfv.c
+++ b/src/gtk-tpdfv.c
#include <stdlib.h>
#include <string.h>
+#include <sys/stat.h>
+
#define TPDFV_MIN(a, b) ((a) <= (b) ? (a) : (b))
#define TPDFV_MAX(a, b) ((a) >= (b) ? (a) : (b))
typedef struct {
char *filename;
+ time_t mtime;
+
PopplerDocument *doc;
PopplerPage *current_page;
{
GError *err = NULL;
+ struct stat statbuf;
+
if ((! pdf) || (! pdf->filename))
return;
+ memset(&statbuf, 0, sizeof(statbuf));
+ if (stat(pdf->filename + strlen("file://"), &statbuf) != 0) {
+ char errbuf[1024];
+ strerror_r(errno, errbuf, sizeof(errbuf));
+ fprintf(stderr, "Failed to access PDF: %s.\n", errbuf);
+ return;
+ }
+
+ pdf->mtime = statbuf.st_mtime;
+
pdf->doc = poppler_document_new_from_file(pdf->filename,
/* password = */ NULL, &err);
if (! pdf->doc) {
gtk_tpdfv_t *pdf;
cairo_t *cr;
+ struct stat statbuf;
+
gdouble width, height;
gdouble page_width = 0.0;
if (! pdf)
return FALSE;
+ memset(&statbuf, 0, sizeof(statbuf));
+ if (stat(pdf->filename + strlen("file://"), &statbuf)) {
+ char errbuf[1024];
+ strerror_r(errno, errbuf, sizeof(errbuf));
+ fprintf(stderr, "Failed to access PDF: %s.\n", errbuf);
+ return FALSE;
+ }
+
+ if (statbuf.st_mtime > pdf->mtime)
+ gtk_tpdfv_reload(tpdfv);
+
cr = gdk_cairo_create(tpdfv->window);
cairo_rectangle(cr, event->area.x, event->area.y,
event->area.width, event->area.height);