[Eyecatcher-general] Bug#310062: xpdf-reader: Patch for slideshow
Christoph Berg
Christoph Berg <cb@df7cb.de>, 310062@bugs.debian.org
Sat, 21 May 2005 13:56:06 +0200
--TakKZr9L6Hm6aLOc
Content-Type: multipart/mixed; boundary="d6Gm4EdcadzBjdND"
Content-Disposition: inline
--d6Gm4EdcadzBjdND
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Package: xpdf-reader
Version: 3.00-13
Severity: wishlist
Tags: patch
Hi,
the attached patch adds slideshow support to xpdf, i.e. with the
-slidedelay option it will automatically advance to the next page. The
-loop option then makes it wrap back to the beginning of the file.
Independently, the patch add -next and -prev options if the user
wishes to control the slideshow remotely (this is an independent patch
=66rom #223944).
The patch was written for presentations running on a beamer at Debian
booths at fairs. We would be grateful if it got added to the xpdf
package.
Christoph
--=20
cb@df7cb.de | http://www.df7cb.de/
--d6Gm4EdcadzBjdND
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="slideshow.patch.2"
Content-Transfer-Encoding: quoted-printable
diff -u xpdf-3.00/doc/xpdf.1 xpdf-3.00/doc/xpdf.1
--- xpdf-3.00/doc/xpdf.1
+++ xpdf-3.00/doc/xpdf.1
@@ -173,12 +173,24 @@
.B \-reload
Reload xpdf remote server window (with -remote only).
.TP
+.B \-next
+Display next page in xpdf remote server window (with -remote only).
+.TP
+.B \-prev
+Display previous page in xpdf remote server window (with -remote only).
+.TP
.B \-raise
Raise xpdf remote server window (with -remote only).
.TP
.B \-quit
Kill xpdf remote server (with -remote only).
.TP
+.B \-loop
+Wrap to first page after the last.
+.TP
+.B \-slidedelay
+Delay in seconds for slideshow in -fullscreen mode.
+.TP
.B \-cmd
Print commands as they're executed (useful for debugging).
.RB "[config file: " printCommands ]
diff -u xpdf-3.00/xpdf/XPDFCore.cc xpdf-3.00/xpdf/XPDFCore.cc
--- xpdf-3.00/xpdf/XPDFCore.cc
+++ xpdf-3.00/xpdf/XPDFCore.cc
@@ -105,6 +105,7 @@
=20
XPDFCore::XPDFCore(Widget shellA, Widget parentWidgetA,
SplashRGB8 paperColorA, GBool fullScreenA,
+ GBool loopA, int slideDelayA,
GBool reverseVideo, GBool installCmap, int rgbCubeSize) {
GString *initialZoom;
SplashColor paperColor2;
@@ -118,6 +119,8 @@
=20
paperColor =3D paperColorA;
fullScreen =3D fullScreenA;
+ loop =3D loopA;
+ slideDelay =3D slideDelayA;
=20
// for some reason, querying XmNvisual doesn't work (even if done
// after the window is mapped)
@@ -617,9 +620,9 @@
if (!doc || doc->getNumPages() =3D=3D 0) {
return;
}
- if (page < doc->getNumPages()) {
+ if (page < doc->getNumPages() || loop) {
if ((pg =3D page + inc) > doc->getNumPages()) {
- pg =3D doc->getNumPages();
+ pg =3D loop ? 1 : doc->getNumPages();
}
displayPage(pg, zoom, rotate, top, gTrue);
} else {
@@ -633,7 +636,7 @@
if (!doc || doc->getNumPages() =3D=3D 0) {
return;
}
- if (page > 1) {
+ if (page > 1 || loop) {
if (!fullScreen && bottom) {
scrollY =3D out->getBitmapHeight() - drawAreaHeight;
if (scrollY < 0) {
@@ -642,7 +645,7 @@
// displayPage will call updateScrollBars()
}
if ((pg =3D page - dec) < 1) {
- pg =3D 1;
+ pg =3D loop ? doc->getNumPages() : 1;
}
displayPage(pg, zoom, rotate, top, gTrue);
} else {
diff -u xpdf-3.00/xpdf/XPDFViewer.cc xpdf-3.00/xpdf/XPDFViewer.cc
--- xpdf-3.00/xpdf/XPDFViewer.cc
+++ xpdf-3.00/xpdf/XPDFViewer.cc
@@ -17,6 +17,7 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
+#include <signal.h>
#include <X11/cursorfont.h>
#ifdef HAVE_X11_XPM_H
#include <X11/xpm.h>
@@ -112,6 +113,17 @@
=20
//------------------------------------------------------------------------
=20
+static XPDFViewer *alarm_viewer =3D NULL;
+static int alarm_slideDelay =3D 0;
+
+void alarm_hander(int sig) {
+ if(alarm_viewer)
+ alarm_viewer->next();
+ alarm(alarm_slideDelay);
+}
+
+//------------------------------------------------------------------------
+
XPDFViewer::XPDFViewer(XPDFApp *appA, GString *fileName,
int pageA, GString *destName,
GString *ownerPassword, GString *userPassword) {
@@ -178,6 +190,13 @@
displayPage(pg, z, core->getRotate(), gTrue, gTrue);
}
=20
+ if(app->getSlideDelay()) {
+ alarm_viewer =3D this;
+ alarm_slideDelay =3D app->getSlideDelay();
+ signal(SIGALRM, alarm_hander);
+ alarm(app->getSlideDelay());
+ }
+
ok =3D gTrue;
}
=20
@@ -269,6 +288,20 @@
displayPage(pg, core->getZoom(), core->getRotate(), gFalse, gFalse);
}
=20
+void XPDFViewer::next() { /* callback for -remove -next */
+ if (!core->getDoc()) {
+ return;
+ }
+ core->gotoNextPage(1, gTrue);
+}
+
+void XPDFViewer::prev() { /* callback for -remove -prev */
+ if (!core->getDoc()) {
+ return;
+ }
+ core->gotoPrevPage(1, gTrue, gFalse);
+}
+
void XPDFViewer::displayPage(int pageA, double zoomA, int rotateA,
GBool scrollToTop, GBool addToHist) {
core->displayPage(pageA, zoomA, rotateA, scrollToTop, addToHist);
@@ -815,7 +848,8 @@
=20
// core
core =3D new XPDFCore(win, form, app->getPaperRGB(),
- app->getFullScreen(), app->getReverseVideo(),
+ app->getFullScreen(), app->getLoop(), app->getSlideDelay(),
+ app->getReverseVideo(),
app->getInstallCmap(), app->getRGBCubeSize());
core->setUpdateCbk(&updateCbk, this);
core->setActionCbk(&actionCbk, this);
@@ -873,7 +907,8 @@
=20
// core
core =3D new XPDFCore(win, panedWin, app->getPaperRGB(),
- app->getFullScreen(), app->getReverseVideo(),
+ app->getFullScreen(), app->getLoop(), app->getSlideDelay(),
+ app->getReverseVideo(),
app->getInstallCmap(), app->getRGBCubeSize());
core->setUpdateCbk(&updateCbk, this);
core->setActionCbk(&actionCbk, this);
diff -u xpdf-3.00/debian/changelog xpdf-3.00/debian/changelog
--- xpdf-3.00/debian/changelog
+++ xpdf-3.00/debian/changelog
@@ -1,3 +1,9 @@
+xpdf (3.00-13slideshow.1) unstable; urgency=3Dlow
+
+ * Patch for -slidedelay, -loop, -prev, and -next options.
+
+ -- Christoph Berg <cb@df7cb.de> Sat, 21 May 2005 13:21:40 +0200
+
xpdf (3.00-13) unstable; urgency=3Dlow
=20
* SECURITY UPDATE: fix buffer overflow for PDF documents with an /Encrypt
only in patch2:
unchanged:
--- xpdf-3.00.orig/xpdf/XPDFApp.cc
+++ xpdf-3.00/xpdf/XPDFApp.cc
@@ -331,6 +331,18 @@
XFlush(display);
}
=20
+void XPDFApp::remoteNext() {
+ XChangeProperty(display, remoteXWin, remoteAtom, remoteAtom, 8,
+ PropModeReplace, (Guchar *)"n", 2);
+ XFlush(display);
+}
+
+void XPDFApp::remotePrev() {
+ XChangeProperty(display, remoteXWin, remoteAtom, remoteAtom, 8,
+ PropModeReplace, (Guchar *)"p", 2);
+ XFlush(display);
+}
+
void XPDFApp::remoteQuit() {
XChangeProperty(display, remoteXWin, remoteAtom, remoteAtom, 8,
PropModeReplace, (Guchar *)"q", 2);
@@ -395,6 +407,14 @@
} else if (cmd[0] =3D=3D 'l' || cmd[0] =3D=3D 'L') {
app->remoteViewer->reloadFile();
=20
+ // next
+ } else if (cmd[0] =3D=3D 'n') {
+ app->remoteViewer->next();
+
+ // prev
+ } else if (cmd[0] =3D=3D 'p') {
+ app->remoteViewer->prev();
+
// quit
} else if (cmd[0] =3D=3D 'q') {
app->quit();
only in patch2:
unchanged:
--- xpdf-3.00.orig/xpdf/XPDFApp.h
+++ xpdf-3.00/xpdf/XPDFApp.h
@@ -57,6 +57,8 @@
void remoteOpenAtDest(GString *fileName, GString *dest, GBool raise);
void remoteReload(GBool raise);
void remoteRaise();
+ void remoteNext();
+ void remotePrev();
void remoteQuit();
=20
//----- resource/option values
@@ -71,6 +73,10 @@
GBool getViKeys() { return viKeys; }
void setFullScreen(GBool fullScreenA) { fullScreen =3D fullScreenA; }
GBool getFullScreen() { return fullScreen; }
+ void setSlideDelay(int slideDelayA) { slideDelay =3D slideDelayA; }
+ GBool getSlideDelay() { return slideDelay; }
+ void setLoop(GBool loopA) { loop =3D loopA; }
+ GBool getLoop() { return loop; }
=20
XtAppContext getAppContext() { return appContext; }
Widget getAppShell() { return appShell; }
@@ -103,6 +109,8 @@
GString *initialZoom;
GBool viKeys;
GBool fullScreen;
+ int slideDelay;
+ GBool loop;
};
=20
#endif
only in patch2:
unchanged:
--- xpdf-3.00.orig/xpdf/XPDFCore.h
+++ xpdf-3.00/xpdf/XPDFCore.h
@@ -88,6 +88,7 @@
// Create viewer core inside <parentWidgetA>.
XPDFCore(Widget shellA, Widget parentWidgetA,
SplashRGB8 paperColorA, GBool fullScreenA,
+ GBool loopA, int slideDelayA,
GBool reverseVideo, GBool installCmap, int rgbCubeSize);
=20
~XPDFCore();
@@ -231,6 +232,8 @@
=20
SplashRGB8 paperColor;
GBool fullScreen;
+ GBool loop;
+ int slideDelay;
=20
Display *display;
int screenNum;
only in patch2:
unchanged:
--- xpdf-3.00.orig/xpdf/XPDFViewer.h
+++ xpdf-3.00/xpdf/XPDFViewer.h
@@ -58,6 +58,8 @@
void open(GString *fileName, int pageA, GString *destName);
void clear();
void reloadFile();
+ void next();
+ void prev();
=20
Widget getWindow() { return win; }
=20
only in patch2:
unchanged:
--- xpdf-3.00.orig/xpdf/xpdf.cc
+++ xpdf-3.00/xpdf/xpdf.cc
@@ -36,8 +36,12 @@
static GBool fullScreen =3D gFalse;
static char remoteName[100] =3D "xpdf_";
static GBool doRemoteReload =3D gFalse;
+static GBool doRemoteNext =3D gFalse;
+static GBool doRemotePrev =3D gFalse;
static GBool doRemoteRaise =3D gFalse;
static GBool doRemoteQuit =3D gFalse;
+static GBool loop =3D gFalse;
+static int slidedelay =3D 0;
static GBool printCommands =3D gFalse;
static GBool quiet =3D gFalse;
static char cfgFileName[256] =3D "";
@@ -95,10 +99,18 @@
"start/contact xpdf remote server with specified name"},
{"-reload", argFlag, &doRemoteReload, 0,
"reload xpdf remove server window (with -remote only)"},
+ {"-next", argFlag, &doRemoteNext, 0,
+ "display next page in xpdf remote server window (with -remote only)"},
+ {"-prev", argFlag, &doRemotePrev, 0,
+ "display previous page in xpdf remote server window (with -remote only)=
"},
{"-raise", argFlag, &doRemoteRaise, 0,
"raise xpdf remote server window (with -remote only)"},
{"-quit", argFlag, &doRemoteQuit, 0,
"kill xpdf remote server (with -remote only)"},
+ {"-loop", argFlag, &loop, 0,
+ "wrap to first page after the last"},
+ {"-slidedelay", argInt, &slidedelay, 0,
+ "delay in seconds for slideshow in -fullscreen mode"},
{"-cmd", argFlag, &printCommands, 0,
"print commands as they're executed"},
{"-q", argFlag, &quiet, 0,
@@ -209,6 +221,12 @@
if (doRemoteReload) {
ok =3D ok && remoteName[5] && !doRemoteQuit && argc =3D=3D 1;
}
+ if (doRemoteNext) {
+ ok =3D ok && remoteName[5] && !doRemoteQuit && !doRemotePrev;
+ }
+ if (doRemotePrev) {
+ ok =3D ok && remoteName[5] && !doRemoteQuit && !doRemoteNext;
+ }
if (doRemoteRaise) {
ok =3D ok && remoteName[5] && !doRemoteQuit;
}
@@ -251,6 +269,10 @@
}
} else if (doRemoteReload) {
app->remoteReload(doRemoteRaise);
+ } else if (doRemoteNext) {
+ app->remoteNext();
+ } else if (doRemotePrev) {
+ app->remotePrev();
} else if (doRemoteRaise) {
app->remoteRaise();
} else if (doRemoteQuit) {
@@ -265,6 +287,8 @@
=20
// set options
app->setFullScreen(fullScreen);
+ app->setLoop(loop);
+ app->setSlideDelay(slidedelay);
=20
// check for password string(s)
ownerPasswordStr =3D ownerPassword[0] !=3D '\001' ? new GString(ownerPas=
sword)
--d6Gm4EdcadzBjdND--
--TakKZr9L6Hm6aLOc
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFCjyHWxa93SlhRC1oRAj1NAJ42IIpowKiMRMXinm0lx81euxpqAgCg8kd2
soubM252cV8ullFpB24U0SI=
=JcOE
-----END PGP SIGNATURE-----
--TakKZr9L6Hm6aLOc--