File xpdf-poppler-outline-when-needed.patch of Package xpdf-poppler
Index: XPDFViewer.cc
===================================================================
--- XPDFViewer.cc.orig
+++ XPDFViewer.cc
@@ -256,6 +256,7 @@ XPDFViewer::XPDFViewer(XPDFApp *appA, Go
LinkDest *dest = NULL;
int pg = pageA;
double z;
+ Dimension width;
#ifndef DISABLE_OUTLINE
outlineLabels = NULL;
@@ -272,6 +273,14 @@ XPDFViewer::XPDFViewer(XPDFApp *appA, Go
initFindDialog();
initPrintDialog();
+#ifndef DISABLE_OUTLINE
+ if (outlineScroll != None)
+ {
+ width = 1;
+ XtVaSetValues(outlineScroll, XmNwidth, 1, NULL);
+ }
+#endif
+
if (fileName) {
if (loadFile(fileName, ownerPassword, userPassword)) {
getPageAndDest(pageA, destName, &pg, &dest);
@@ -280,18 +289,23 @@ XPDFViewer::XPDFViewer(XPDFApp *appA, Go
core->getDoc()->getOutline()->getItems() &&
core->getDoc()->getOutline()->getItems()->getLength() > 0) {
XtVaSetValues(outlineScroll, XmNwidth, outlinePaneWidth, NULL);
+ width = outlinePaneWidth;
}
#endif
} else {
+ setOutlinePaneWidth(1); /* if show outline here is matter of taste */
return;
}
}
core->resizeToPage(pg);
-
+
// map the window -- we do this after calling resizeToPage to avoid
// an annoying on-screen resize
mapWindow();
+ // close or leave open outline pane; it needs to be after mapWindow() for some reason
+ setOutlinePaneWidth(width);
+
// display the first page
z = core->getZoom();
if (dest) {
@@ -312,6 +326,7 @@ XPDFViewer::XPDFViewer(XPDFApp *appA, PD
LinkDest *dest = NULL;
int pg = pageA;
double z;
+ Dimension width;
#ifndef DISABLE_OUTLINE
outlineLabels = NULL;
@@ -328,6 +343,14 @@ XPDFViewer::XPDFViewer(XPDFApp *appA, PD
initFindDialog();
initPrintDialog();
+#ifndef DISABLE_OUTLINE
+ if (outlineScroll != None)
+ {
+ width = 1;
+ XtVaSetValues(outlineScroll, XmNwidth, 1, NULL);
+ }
+#endif
+
if (doc) {
core->loadDoc(doc);
getPageAndDest(pageA, destName, &pg, &dest);
@@ -336,6 +359,7 @@ XPDFViewer::XPDFViewer(XPDFApp *appA, PD
core->getDoc()->getOutline()->getItems() &&
core->getDoc()->getOutline()->getItems()->getLength() > 0) {
XtVaSetValues(outlineScroll, XmNwidth, outlinePaneWidth, NULL);
+ width = outlinePaneWidth;
}
#endif
}
@@ -344,6 +368,9 @@ XPDFViewer::XPDFViewer(XPDFApp *appA, PD
// map the window -- we do this after calling resizeToPage to avoid
// an annoying on-screen resize
mapWindow();
+
+ // close or leave open outline pane; it needs to be after mapWindow() for some reason
+ setOutlinePaneWidth(width);
// display the first page
z = core->getZoom();
@@ -772,24 +799,33 @@ void XPDFViewer::cmdAbout(GooString *arg
XtManageChild(aboutDialog);
}
+void XPDFViewer::setOutlinePaneWidth(Dimension width) {
+ #ifndef DISABLE_OUTLINE
+ Dimension w;
+
+ if (outlineScroll == None) {
+ return;
+ }
+
+ XtVaGetValues(outlineScroll, XmNwidth, &w, NULL);
+ if (w != width) {
+ outlinePaneWidth = width;
+ // this ugly kludge is apparently the only way to resize the panes
+ // within an XmPanedWindow
+ XtVaSetValues(outlineScroll, XmNpaneMinimum, width,
+ XmNpaneMaximum, width, NULL);
+ }
+ #endif
+}
+
void XPDFViewer::cmdCloseOutline(GooString *args[], int nArgs,
XEvent *event) {
#ifndef DISABLE_OUTLINE
- Dimension w;
-
if (outlineScroll == None) {
return;
}
- XtVaGetValues(outlineScroll, XmNwidth, &w, NULL);
- if (w > 1) {
- outlinePaneWidth = w;
- // this ugly kludge is apparently the only way to resize the panes
- // within an XmPanedWindow
- XtVaSetValues(outlineScroll, XmNpaneMinimum, 1,
- XmNpaneMaximum, 1, NULL);
- XtVaSetValues(outlineScroll, XmNpaneMinimum, 1,
- XmNpaneMaximum, 10000, NULL);
- }
+
+ setOutlinePaneWidth(1);
#endif
}
@@ -997,20 +1033,11 @@ void XPDFViewer::cmdOpenInNewWin(GooStri
void XPDFViewer::cmdOpenOutline(GooString *args[], int nArgs,
XEvent *event) {
#ifndef DISABLE_OUTLINE
- Dimension w;
-
if (outlineScroll == None) {
return;
}
- XtVaGetValues(outlineScroll, XmNwidth, &w, NULL);
- if (w == 1) {
- // this ugly kludge is apparently the only way to resize the panes
- // within an XmPanedWindow
- XtVaSetValues(outlineScroll, XmNpaneMinimum, outlinePaneWidth,
- XmNpaneMaximum, outlinePaneWidth, NULL);
- XtVaSetValues(outlineScroll, XmNpaneMinimum, 1,
- XmNpaneMaximum, 10000, NULL);
- }
+
+ setOutlinePaneWidth(outlinePaneWidth);
#endif
}
Index: XPDFViewer.h
===================================================================
--- XPDFViewer.h.orig
+++ XPDFViewer.h
@@ -242,6 +242,7 @@ private:
void setupOutlineItems(GooList *items, Widget parent, UnicodeMap *uMap);
static void outlineSelectCbk(Widget widget, XtPointer ptr,
XtPointer callData);
+ void setOutlinePaneWidth(Dimension width);
#endif
//----- GUI code: "about" dialog