Bug#4088: ghostview does not put filename in window title
Package: ghostview
Version: 1.5-8
This is a change request: I would very much like ghostview to put the
filename (or document title) in the X window title. This will make it
much easier to pick the right ghostview window out of a list.
In fact, I wanted this so much I went and implemented it :-). The
patch is below. The new feature is optional, but enabled by default.
Ian.
diff -ru ghostview_1.5-8.dist/ghostview.man ghostview_1.5-8/ghostview.man
--- ghostview_1.5-8.dist/ghostview.man Sat Jul 24 03:29:12 1993
+++ ghostview_1.5-8/ghostview.man Fri Aug 9 20:19:57 1996
@@ -463,6 +463,9 @@
.IP "\fBshowTitle (\fPclass\fB Labels)\fP" 1i
Tells whether to display the \fB%%Title\fP comment.
The default is ``true''.
+.IP "\fBwindowTitle (\fPclass\fB Labels)\fP" 1i
+Tells whether to copy the \fB%%Title\fP comment into the window title.
+The default is ``true''.
.IP "\fBshowDate (\fPclass\fB Labels)\fP" 1i
Tells whether to display the \fB%%Data\fP comment.
The default is ``true''.
@@ -623,6 +626,10 @@
Equivalent to setting ``Ghostview.showTitle: True''.
.IP \fB\-notitle\fP 1i
Equivalent to setting ``Ghostview.showTitle: False''.
+.IP \fB\-wtitle\fP 1i
+Equivalent to setting ``Ghostview.windowTitle: True''.
+.IP \fB\-nowtitle\fP 1i
+Equivalent to setting ``Ghostview.windowTitle: False''.
.IP \fB\-date\fP 1i
Equivalent to setting ``Ghostview.showDate: True''.
.IP \fB\-nodate\fP 1i
diff -ru ghostview_1.5-8.dist/gv.h ghostview_1.5-8/gv.h
--- ghostview_1.5-8.dist/gv.h Sat Jul 24 03:29:12 1993
+++ ghostview_1.5-8/gv.h Fri Aug 9 20:17:56 1996
@@ -39,6 +39,7 @@
/* Application resources */
typedef struct _AppResources {
Boolean show_title; /* whether to show title */
+ Boolean window_title; /* whether to put document title in window title */
Boolean show_date; /* whether to show date */
Boolean show_locator; /* whether to show locator */
Boolean auto_center; /* whether to automatically center the page */
@@ -103,6 +104,8 @@
extern XErrorHandler old_Xerror;
extern Boolean dying;
extern XErrorEvent bomb;
+extern XTextProperty nameprop;
+extern String version;
enum {OPEN, PRINT_WHOLE, PRINT_MARKED, SAVE};
extern int mode;
diff -ru ghostview_1.5-8.dist/main.c ghostview_1.5-8/main.c
--- ghostview_1.5-8.dist/main.c Sat Jul 24 03:29:12 1993
+++ ghostview_1.5-8/main.c Fri Aug 9 20:43:53 1996
@@ -55,11 +55,13 @@
extern char *getenv();
-static String version = "Ghostview, version 1.5";
+String version = "Ghostview, version 1.5";
static XtResource resources[] = {
{"showTitle", "Labels", XtRBoolean, sizeof(Boolean),
XtOffsetOf(AppResources, show_title), XtRImmediate, (XtPointer)True},
+ {"windowTitle", "Labels", XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(AppResources, window_title), XtRImmediate, (XtPointer)True},
{"showDate", "Labels", XtRBoolean, sizeof(Boolean),
XtOffsetOf(AppResources, show_date), XtRImmediate, (XtPointer)True},
{"showLocator", "Labels", XtRBoolean, sizeof(Boolean),
@@ -138,6 +140,8 @@
{"-page", ".page", XrmoptionSepArg, NULL},
{"-title", ".showTitle", XrmoptionNoArg, "True"},
{"-notitle", ".showTitle", XrmoptionNoArg, "False"},
+ {"-wtitle", ".windowTitle", XrmoptionNoArg, "True"},
+ {"-nowtitle", ".windowTitle", XrmoptionNoArg, "False"},
{"-date", ".showDate", XrmoptionNoArg, "True"},
{"-nodate", ".showDate", XrmoptionNoArg, "False"},
{"-locator", ".showLocator", XrmoptionNoArg, "True"},
@@ -287,6 +291,7 @@
XErrorHandler old_Xerror; /* standard error handler */
Boolean dying; /* whether an X error caused our exit */
XErrorEvent bomb; /* what the error was */
+XTextProperty nameprop; /* the XStringProperty for the window name */
XtAppContext app_con;
AppResources app_res;
@@ -363,7 +368,6 @@
Boolean set_vert_dist;
String s1, s2;
XFontStruct *font;
- XTextProperty nameprop;
Dimension bottomMargin, leftMargin, rightMargin, topMargin;
Dimension width, height;
Dimension button_width;
@@ -371,6 +375,7 @@
static XawTextSelectType sarry[] =
{XawselectLine, XawselectAll, XawselectNull};
+ nameprop.value= 0;
XtToolkitInitialize();
XtSetTypeConverter(XtRString, XtRPageOrientation,
XmuCvtStringToPageOrientation, NULL, 0,
@@ -871,7 +876,7 @@
XtSetArg(args[0], XtNtransientFor, toplevel);
XtSetValues(dialogpopup, args, ONE);
XSetWMProtocols(dpy, XtWindow(toplevel), &wm_delete_window, 1);
- if (XStringListToTextProperty(&version, 1, &nameprop)) {
+ if (nameprop.value) {
XSetWMName(dpy, XtWindow(toplevel), &nameprop);
}
diff -ru ghostview_1.5-8.dist/misc.c ghostview_1.5-8/misc.c
--- ghostview_1.5-8.dist/misc.c Sat Jul 24 03:29:12 1993
+++ ghostview_1.5-8/misc.c Fri Aug 9 20:43:43 1996
@@ -297,6 +297,7 @@
static String nothing = "";
String label;
Pixmap bitmap;
+ char *title, *versionfilename;
/* Reset to a known state. */
psfree(olddoc);
@@ -328,6 +329,28 @@
titlemenu = build_label_menu(titlebutton, "title", label, bitmap);
}
+ if (nameprop.value) {
+ XFree(nameprop.value);
+ nameprop.value = 0;
+ }
+ if (app_res.window_title) {
+ if (doc && doc->title) {
+ title = doc->title;
+ } else {
+ title = filename;
+ }
+ versionfilename = XtMalloc(strlen(version)+3+strlen(title)+1);
+ strcpy(versionfilename, version);
+ strcat(versionfilename, " - ");
+ strcat(versionfilename, title);
+ XStringListToTextProperty(&versionfilename, 1, &nameprop);
+ XtFree(versionfilename);
+ } else {
+ XStringListToTextProperty(&version, 1, &nameprop);
+ }
+ if (nameprop.value && XtIsRealized(toplevel)) {
+ XSetWMName(XtDisplay(toplevel), XtWindow(toplevel), &nameprop);
+ }
if (app_res.show_date) {
if (doc && doc->date) {
label = doc->date;
--
Ian Jackson, at home. ian@chiark.chu.cam.ac.uk + 44 1223 3 31579
General: ijackson@chiark.chu.cam.ac.uk Permanent: ijackson@gnu.ai.mit.edu
Churchill College, Cambridge, CB3 0DS. http://www.cl.cam.ac.uk/users/iwj10/
Reply to: