Index: xc/ChangeLog =================================================================== RCS file: /cvs/xorg/xc/ChangeLog,v retrieving revision 1.56 diff -u -2 -0 -r1.56 ChangeLog --- a/xc/ChangeLog 2 Jun 2004 18:29:10 -0000 1.56 +++ b/xc/ChangeLog 8 Jun 2004 02:40:38 -0000 @@ -1,20 +1,41 @@ +2004-06-07 Roland Mainz + * xc/programs/xedit/Xedit.ad + * xc/programs/xman/Imakefile + * xc/programs/xman/ScrollByL.c + * xc/programs/xman/ScrollByL.h + * xc/programs/xman/ScrollByLP.h + * xc/programs/xman/Xman.ad + * xc/programs/xman/buttons.c + * xc/programs/xman/defs.h + * xc/programs/xman/handler.c + * xc/programs/xman/man.h + * xc/programs/xman/misc.c + * xc/programs/xman/print.c + * xc/programs/xman/print.h + * xc/programs/xman/search.c + * xc/programs/xman/version.h + * xc/programs/xmore/XMore.ad + * xc/programs/xmore/print.c + * xc/programs/xmore/printdialog.c + Bugzilla #668: Add print support to xman. + 2004-06-02 Roland Mainz * xc/programs/Xserver/Xprint/etc/init.d/xprint Bugzilla #714: 'Fix' for Debian Bug#250887 ("/etc/init.d/xprint non-free") - the reporter does not like the "All rights reserved"-string in the file so lets get rid of it. License of all the Xprint sources is MIT/X.org anyway. 2004-05-31 Eric Anholt * fonts/scaled/TTF/Imakefile: VeraIt.ttf wasn't getting installed. 2004-05-30 Roland Mainz * xc/programs/xedit/Imakefile * xc/programs/xedit/Xedit.ad * xc/programs/xedit/commands.c * xc/programs/xedit/hook.c * xc/programs/xedit/ispell.c * xc/programs/xedit/xedit.c * xc/programs/xedit/xedit.h * xc/programs/xmore/XMore.ad Index: xc/programs/xedit/Xedit.ad =================================================================== RCS file: /cvs/xorg/xc/programs/xedit/Xedit.ad,v retrieving revision 1.3 diff -u -2 -0 -r1.3 Xedit.ad --- a/xc/programs/xedit/Xedit.ad 30 May 2004 22:44:00 -0000 1.3 +++ b/xc/programs/xedit/Xedit.ad 8 Jun 2004 02:40:50 -0000 @@ -449,50 +449,111 @@ *columns*Text.translations: #override \ cS: no-op(r)\n\ cR: no-op(r)\n\ mI: no-op(r)\n\ Return: set-columns(ok)\n\ Tab: change-field()\n\ cG: set-columns(cancel)\n\ Escape: set-columns(cancel)\n\ : no-op()\n\ : no-op()\n\ : set-keyboard-focus() select-start() *columns.translations: #override \ WM_PROTOCOLS: set-columns(cancel) ! Use "white" as background for printing *printshell*background: white ! Print dialog -*printdialogshell*geometry: 600x120 -*printdialogshell*setup*geometry: 600x400 -*printdialogshell*printerselection*geometry: 400x150 -*printdialog*main*ok.tip: Print -*printdialog*main*cancel.tip: Cancel printing -*printdialog*main*setup.tip: Configure printer options (page size, orientation, etc.) -*printdialog*main*desclabel.tip: Short description of printer -*printdialog*main*desc.tip: Short description of printer -*printdialog*main*info.tip: Display additional information about this printer -*printdialog*main*namelabel.tip: Name of selected printer -*printdialog*main*name.tip: Name of selected printer -*printdialog*main*selectprinter.tip: Select a different printer -*printdialog*main*filenamelabel.tip: File where the output should be stored -*printdialog*main*filename.tip: File where the output should be stored -*printdialog*main*selectfile.tip: Select file where the output should be stored -*printdialog*main*printtoprinter.tip: Send print job to printer -*printdialog*main*printtofile.tip: Save print job in a file -*printdialog*setup*ok.tip: Commit changes -*printdialog*setup*cancel.tip: Cancel and reset to defaults -*printdialog*setup*paperlist.tip: Select paper size -*printdialog*setup*resolutionlist.tip: Select page resolution -*printdialog*setup*orientationlist.tip: Select page orientation -*printdialog*setup*plexlist.tip: Select page plex mode (simplex, duplex, etc.) -*printdialog*setup*jobcopieslabel.tip: Set number of job copies -*printdialog*setup*jobcopies.tip: Set number of job copies -*printdialog*printerselection*ok.tip: Switch printer -*printdialog*printerselection*cancel.tip: Cancel printer selection -*printdialog*printerselection*list.tip: Select printer name from list +*printdialogshell*geometry: 600x120 +*printdialogshell*title: Print +*printdialogshell*main*ok.fromVert: innerform +*printdialogshell*main*ok.label: Print +*printdialogshell*main*ok.tip: Print +*printdialogshell*main*setup.fromHoriz: ok +*printdialogshell*main*setup.fromVert: innerform +*printdialogshell*main*setup.label: Setup... +*printdialogshell*main*setup.tip: Configure print job options (page size, orientation, etc.) +*printdialogshell*main*cancel.fromHoriz: setup +*printdialogshell*main*cancel.fromVert: innerform +*printdialogshell*main*cancel.label: Cancel +*printdialogshell*main*cancel.tip: Cancel printing +*printdialogshell*main*desclabel.label: Printer Description: +*printdialogshell*main*desclabel.tip: Short description of printer +*printdialogshell*main*desc.fromHoriz: desclabel +*printdialogshell*main*desc.tip: Short description of printer +*printdialogshell*main*info.fromHoriz: desc +*printdialogshell*main*info.label: Printer info... +*printdialogshell*main*info.tip: Display additional information about this printer +*printdialogshell*main*namelabel.fromVert: desclabel +*printdialogshell*main*namelabel.label: Printer Name: +*printdialogshell*main*namelabel.tip: Name of selected printer +*printdialogshell*main*name.fromHoriz: namelabel +*printdialogshell*main*name.fromVert: desclabel +*printdialogshell*main*name.tip: Name of selected printer +*printdialogshell*main*selectprinter.fromHoriz: name +*printdialogshell*main*selectprinter.fromVert: desclabel +*printdialogshell*main*selectprinter.label: Select Printer... +*printdialogshell*main*selectprinter.label: Select Printer... +*printdialogshell*main*selectprinter.tip: Select a different printer +*printdialogshell*main*filenamelabel.fromVert: namelabel +*printdialogshell*main*filenamelabel.label: File Name: +*printdialogshell*main*filenamelabel.tip: File where the output should be stored +*printdialogshell*main*filename.fromHoriz: filenamelabel +*printdialogshell*main*filename.fromVert: namelabel +*printdialogshell*main*filename.tip: File where the output should be stored +*printdialogshell*main*selectfile.fromHoriz: filename +*printdialogshell*main*selectfile.fromVert: namelabel +*printdialogshell*main*selectfile.label: Select File... +*printdialogshell*main*selectfile.tip: Select file where the output should be stored +*printdialogshell*main*printtoprinter.fromVert: filenamelabel +*printdialogshell*main*printtoprinter.label: Print to Printer +*printdialogshell*main*printtoprinter.tip: Send print job to printer +*printdialogshell*main*printtofile.fromVert: filenamelabel +*printdialogshell*main*printtofile.fromHoriz: printtoprinter +*printdialogshell*main*printtofile.label: Print to File +*printdialogshell*main*printtofile.tip: Save print job in a file + +! Print job options dialog +*printdialogshell*setup*geometry: 600x400 +*printdialogshell*setup*title: Print: Print job options +*printdialogshell*setup*ok.fromVert: list +*printdialogshell*setup*ok.label: OK +*printdialogshell*setup*ok.tip: Commit changes +*printdialogshell*setup*cancel.fromHoriz: ok +*printdialogshell*setup*cancel.fromVert: list +*printdialogshell*setup*cancel.label: Cancel +*printdialogshell*setup*cancel.tip: Cancel and reset to defaults +*printdialogshell*setup*paperlist.tip: Select paper size +*printdialogshell*setup*resolutionlist.fromHoriz: paperlist +*printdialogshell*setup*resolutionlist.tip: Select page resolution +*printdialogshell*setup*orientationlist.fromHoriz: resolutionlist +*printdialogshell*setup*orientationlist.tip: Select page orientation +*printdialogshell*setup*plexlist.fromHoriz: orientationlist +*printdialogshell*setup*plexlist.tip: Select page plex mode (simplex, duplex, etc.) +*printdialogshell*setup*jobcopieslabel.fromVert: paperlist +*printdialogshell*setup*jobcopieslabel.tip: Set number of job copies +*printdialogshell*setup*jobcopieslabel.label: Job Copies: +*printdialogshell*setup*jobcopies.fromHoriz: jobcopieslabel +*printdialogshell*setup*jobcopies.fromVert: paperlist +*printdialogshell*setup*jobcopies.tip: Set number of job copies + +! Printer selection +*printdialogshell*printerselection*geometry: 400x150 +*printdialogshell*printerselection*title: Print: Select printer +*printdialogshell*printerselection*ok.fromVert: list +*printdialogshell*printerselection*ok.label: OK +*printdialogshell*printerselection*ok.tip: Switch printer +*printdialogshell*printerselection*cancel.fromHoriz: ok +*printdialogshell*printerselection*cancel.fromVert: list +*printdialogshell*printerselection*cancel.label: Cancel +*printdialogshell*printerselection*cancel.tip: Cancel printer selection +*printdialogshell*printerselection*list.tip: Select printer name from list + +! Select job file +*printdialogshell*selectfile*geometry: 400x80 +*printdialogshell*selectfile*title: Print: Select job file +*printdialogshell*selectfile*dialog.label: Select Filename: ! EOF. Index: xc/programs/xman/Imakefile =================================================================== RCS file: /cvs/xorg/xc/programs/xman/Imakefile,v retrieving revision 1.2 diff -u -2 -0 -r1.2 Imakefile --- a/xc/programs/xman/Imakefile 23 Apr 2004 19:54:58 -0000 1.2 +++ b/xc/programs/xman/Imakefile 8 Jun 2004 02:40:50 -0000 @@ -37,30 +37,36 @@ MANCONF = -DMANCONF=\"/etc/man.conf\" #endif #if HasGroff GROFF = -DHAS_GROFF #endif #if HasSnprintf SNPDEFINES = -DHAS_SNPRINTF #else SNPDEFINES = -Dsnprintf=XmuSnprintf #endif OSMAJORVERSION = OSMajorVersion OSMINORVERSION = OSMinorVersion DEFINES = -DOSMAJORVERSION=$(OSMAJORVERSION) \ -DOSMINORVERSION=$(OSMINORVERSION) \ $(SNPDEFINES) $(HELPFILE) $(MANPATHS) $(MKSTEMP) $(GROFF) \ $(MANCONFIGSTYLE) $(MANCONF) DEPLIBS = XawClientDepLibs -LOCAL_LIBRARIES = XawClientLibs +LOCAL_LIBRARIES = XawClientLibs -lXprintUtil SRCS = ScrollByL.c handler.c man.c buttons.c help.c \ - search.c globals.c main.c misc.c tkfuncs.c vendor.c + printdialog.c print.c search.c globals.c main.c \ + misc.c tkfuncs.c vendor.c OBJS = ScrollByL.o handler.o man.o buttons.o help.o \ - search.o globals.o main.o misc.o tkfuncs.o vendor.o + printdialog.o print.o search.o globals.o main.o \ + misc.o tkfuncs.o vendor.o + +LinkSourceFile(printdialog.c,../xmore) +LinkSourceFile(printdialog.h,../xmore) +LinkSourceFile(printdialogprivates.h,../xmore) ComplexProgramTarget(xman) InstallNonExecFile(xman.help,$(LIBDIR)) InstallAppDefaults(Xman) Index: xc/programs/xman/ScrollByL.c =================================================================== RCS file: /cvs/xorg/xc/programs/xman/ScrollByL.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 ScrollByL.c --- a/xc/programs/xman/ScrollByL.c 23 Apr 2004 19:54:58 -0000 1.2 +++ b/xc/programs/xman/ScrollByL.c 8 Jun 2004 02:41:00 -0000 @@ -76,51 +76,56 @@ CoreOffset(height), XtRImmediate, (caddr_t) 700}, {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), Offset(foreground), XtRString, "XtDefaultForeground"}, {XtNforceVert, XtCBoolean, XtRBoolean, sizeof(Boolean), Offset(force_vert), XtRImmediate, (caddr_t) FALSE}, {XtNindent, XtCIndent, XtRDimension, sizeof(Dimension), Offset(indent), XtRImmediate, (caddr_t) 15}, {XtNuseRight, XtCBoolean, XtRBoolean, sizeof(Boolean), Offset(use_right), XtRImmediate, (caddr_t) FALSE}, {XtNmanualFontNormal, XtCFont, XtRFontStruct, sizeof(XFontStruct *), Offset(normal_font), XtRString, MANPAGE_NORMAL}, {XtNmanualFontBold, XtCFont, XtRFontStruct, sizeof(XFontStruct *), Offset(bold_font), XtRString, MANPAGE_BOLD}, {XtNmanualFontItalic, XtCFont, XtRFontStruct, sizeof(XFontStruct *), Offset(italic_font), XtRString, MANPAGE_ITALIC}, {XtNmanualFontSymbol, XtCFont, XtRFontStruct, sizeof(XFontStruct *), Offset(symbol_font), XtRString, MANPAGE_SYMBOL}, {XtNfile, XtCFile, XtRFile, sizeof(FILE *), Offset(file), XtRImmediate, (caddr_t) NULL}, + {XtNNumTotalLines, XtCNumTotalLines, XtRInt, sizeof(int), + Offset(lines), XtRImmediate, (caddr_t) 0}, + {XtNNumVisibleLines, XtCNumVisibleLines, XtRInt, sizeof(int), + Offset(num_visible_lines), XtRImmediate, (caddr_t) 0}, }; #undef Offset #undef CoreOffset /**************************************************************** * * Full class record constant * ****************************************************************/ +static void CreateScrollbar(Widget w); static Boolean ScrollVerticalText(Widget w, int new_line, Boolean force_redisp); static void Layout(Widget w); static void LoadFile(Widget w); static void MoveAndClearText(Widget w, int old_y, int height, int new_y); static void PaintText(Widget w, int y_loc, int height); static void PrintText(Widget w, int start_line, int num_lines, int location); static void SetThumbHeight(Widget w); static void VerticalJump(Widget w, XtPointer junk, XtPointer percent_ptr); static void VerticalScroll(Widget w, XtPointer client_data, XtPointer call_data); /* semi - public functions. */ static void Realize(Widget w, Mask *valueMask, XSetWindowAttributes *attributes); static void Initialize(Widget req, Widget new, ArgList args, Cardinal *num_args); static void Destroy(Widget w); static void Redisplay(Widget w, XEvent *event, Region region); static void Page(Widget w, XEvent * event, String * params, Cardinal *num_params); static Boolean SetValuesHook(Widget w, ArgList args, Cardinal *num_args); static XtActionsRec actions[] = { @@ -180,65 +185,69 @@ * Private Routines * ****************************************************************/ /* Function Name: Layout * Description: This function lays out the scroll widget. * Arguments: w - the scroll widget. * key - a boolean: if true then resize the widget to the child * if false the resize children to fit widget. * Returns: TRUE if successful. */ static void Layout(Widget w) { ScrollByLineWidget sblw = (ScrollByLineWidget) w; Dimension width, height; Widget bar; Position bar_bw; + CreateScrollbar(w); + /* * For now always show the bar. */ bar = sblw->scroll.bar; height = sblw->core.height; width = sblw->core.width; bar_bw = bar->core.border_width; /* Move child and v_bar to correct location. */ if (sblw->scroll.use_right) { XtMoveWidget(bar, width - (bar->core.width + bar_bw), - bar_bw); sblw->scroll.offset = 0; } else { XtMoveWidget(bar, - bar_bw, - bar_bw); sblw->scroll.offset = bar->core.width + bar_bw; } /* resize the scrollbar to be the correct height or width. */ XtResizeWidget(bar, bar->core.width, height, bar->core.border_width); SetThumbHeight(w); + + sblw->scroll.num_visible_lines = height / sblw->scroll.font_height + 1; } /* ARGSUSED */ static void GExpose(Widget w, XtPointer junk, XEvent *event, Boolean *cont) { /* * Graphics exposure events are not currently sent to exposure proc. */ if (event->type == GraphicsExpose) Redisplay(w, event, NULL); } /* ChildExpose */ /* * Repaint the widget's child Window Widget. */ @@ -260,56 +269,54 @@ } else { top = event->xgraphicsexpose.y; height = event->xgraphicsexpose.height; } PaintText(w, top, height); } /* redisplay (expose) */ /* Function Name: PaintText * Description: paints the text at the give location for a given height. * Arguments: w - the sbl widget. * y_loc, height - location and size of area to paint. * Returns: none */ static void PaintText(Widget w, int y_loc, int height) { ScrollByLineWidget sblw = (ScrollByLineWidget) w; - int start_line, num_lines, location; + int start_line, location; start_line = y_loc / sblw->scroll.font_height + sblw->scroll.line_pointer; if (start_line >= sblw->scroll.lines) return; - num_lines = height / sblw->scroll.font_height + 1; - /* * Only integer arithmetic makes this possible. */ location = y_loc / sblw->scroll.font_height * sblw->scroll.font_height; - PrintText(w, start_line, num_lines, location); + PrintText(w, start_line, sblw->scroll.num_visible_lines, location); } /* Function Name: Page * Description: This function pages the widget, by the amount it recieves * from the translation Manager. * Arguments: w - the ScrollByLineWidget. * event - the event that caused this return. * params - the parameters passed to it. * num_params - the number of parameters. * Returns: none. */ /* ARGSUSED */ static void Page(Widget w, XEvent * event, String * params, Cardinal *num_params) { ScrollByLineWidget sblw = (ScrollByLineWidget) w; Widget bar = sblw->scroll.bar; if (*num_params < 1) @@ -367,41 +374,41 @@ XtAddCallback(sblw->scroll.bar, XtNscrollProc, VerticalScroll, NULL); XtAddCallback(sblw->scroll.bar, XtNjumpProc, VerticalJump, NULL); } /* Function Name: ScrollVerticalText * Description: This accomplished the actual movement of the text. * Arguments: w - the ScrollByLine Widget. * new_line - the new location for the line pointer * force_redisplay - should we force this window to get * redisplayed? * Returns: True if the thumb needs to be moved. */ static Boolean ScrollVerticalText( Widget w, int new_line, Boolean force_redisp) { ScrollByLineWidget sblw = (ScrollByLineWidget) w; - int num_lines = (int)w->core.height / sblw->scroll.font_height + 1; + int num_lines = sblw->scroll.num_visible_lines; int max_lines, old_line; Boolean move_thumb = FALSE; /* * Do not let the window extend out of bounds. */ if ( new_line < 0) { new_line = 0; move_thumb = TRUE; } else { max_lines = sblw->scroll.lines - (int)w->core.height / sblw->scroll.font_height; AssignMax(max_lines, 0); if ( new_line > max_lines ) { new_line = max_lines; move_thumb = TRUE; } } @@ -581,67 +588,62 @@ * as the vertical scroll bar is moved. * Arguments: w - the scrollbar widget. * junk - not used. * pos - the position of the cursor. * Returns: none. */ /* ARGSUSED */ static void VerticalScroll(Widget w, XtPointer client_data, XtPointer call_data) { int pos = (int)(long) call_data; int new_line; /* The new location for the line pointer. */ ScrollByLineWidget sblw = (ScrollByLineWidget) XtParent(w); new_line = sblw->scroll.line_pointer + (pos / sblw->scroll.font_height); (void) ScrollVerticalText( (Widget) sblw, new_line, FALSE); SetThumb( (Widget) sblw); } -int h_width; /* main font width */ - /* ARGSUSED */ static void Initialize(Widget req, Widget new, ArgList args, Cardinal *num_args) { ScrollByLineWidget sblw = (ScrollByLineWidget) new; unsigned long figWidth; Atom atomNum; sblw->scroll.top_line = NULL; sblw->scroll.line_pointer = 0; LoadFile(new); sblw->scroll.bar = (Widget) NULL; sblw->scroll.font_height = (sblw->scroll.normal_font->max_bounds.ascent + sblw->scroll.normal_font->max_bounds.descent); atomNum = XInternAtom(XtDisplay(req), "FIGURE_WIDTH", False); if (XGetFontProperty(sblw->scroll.normal_font, atomNum, &figWidth)) - h_width = figWidth; + sblw->scroll.h_width = figWidth; else - h_width = XTextWidth(sblw->scroll.normal_font, "$", 1); - - - + sblw->scroll.h_width = XTextWidth(sblw->scroll.normal_font, "$", 1); } /* Initialize. */ /* Function Name: CreateGCs * Description: Creates the graphics contexts that we need. * Arguments: w - the sblw. * Returns: none */ static void CreateGCs(Widget w) { ScrollByLineWidget sblw = (ScrollByLineWidget) w; XtGCMask mask; XGCValues values; values.graphics_exposures = TRUE; sblw->scroll.move_gc = XtGetGC(w, GCGraphicsExposures, &values); mask = GCForeground | GCFont; @@ -704,41 +706,41 @@ ScrollByLineWidget sblw = (ScrollByLineWidget) w; if (sblw->scroll.bar != NULL) XtDestroyWidget(sblw->scroll.bar); /* Destroy scrollbar. */ if (sblw->scroll.file != NULL) fclose(sblw->scroll.file); DestroyGCs(w); } /* * * Set Values * */ /* ARGSUSED */ static Boolean SetValuesHook(Widget w, ArgList args, Cardinal *num_args) { Boolean ret = TRUE; - int i; + Cardinal i; for (i = 0; i < *num_args; i++) { if (strcmp(XtNfile, args[i].name) == 0) { LoadFile(w); ret = TRUE; } } /* * Changing anthing else will have strange effects, I don't need it so * I didn't code it. */ return(ret); } /* Set Values */ /* * A little design philosophy is probabally wise to include at this point. * @@ -802,40 +804,41 @@ */ if (fstat(fileno(file), &fileinfo)) XtAppError(XtWidgetToApplicationContext(w), "SBLW LoadFile: Failure in fstat."); /* * Allocate a space for a list of pointer to the beginning of each line. */ if ( (nlines = fileinfo.st_size/CHAR_PER_LINE) == 0) return; page = XtMalloc(fileinfo.st_size + 1); /* leave space for the NULL */ top_line = line_pointer = (char**) XtMalloc( nlines * sizeof(char *) ); /* * Copy the file into memory. */ + fseek(file, 0L, SEEK_SET); if (fread(page, sizeof(char), fileinfo.st_size, file) == 0) XtAppError(XtWidgetToApplicationContext(w), "SBLW LoadFile: Failure in fread."); /* put NULL at end of buffer. */ *(page + fileinfo.st_size) = '\0'; /* * Go through the file setting a line pointer to the character after each * new line. If we run out of line pointer space then realloc that space * with space for more lines. */ *line_pointer++ = page; /* first line points to first char in buffer.*/ while (*page != '\0') { if ( *page == '\n' ) { *line_pointer++ = page + 1; @@ -1004,62 +1007,62 @@ italicflag = FALSE; x_loc = sblw->scroll.offset + sblw->scroll.indent; h_col = 0; y_loc += sblw->scroll.font_height; break; /* * This tab handling code is not very clever it moves the cursor over * to the next boundry of eight (8) spaces, as calculated in width just * before the printing loop started. */ case '\t': /* TAB */ x_loc = DumpText(w, x_loc, y_loc, buf, bufp - buf, WHICH(italicflag, first)); h_col += bufp - buf; bufp = buf; italicflag = FALSE; x_loc = sblw->scroll.offset + sblw->scroll.indent; h_col = h_col + 8 - (h_col%8); - x_loc += h_width * h_col; + x_loc += sblw->scroll.h_width * h_col; break; case ' ': h_c = c + 1; while (*h_c == ' ') h_c++; if (h_c - c < 4) { *bufp++ = *c; break; } x_loc = DumpText(w, x_loc, y_loc, buf, bufp - buf, WHICH(italicflag, first)); h_col += bufp - buf; bufp = buf; italicflag = FALSE; x_loc = sblw->scroll.offset + sblw->scroll.indent; h_col += (h_c - c); - x_loc += h_width * h_col; + x_loc += sblw->scroll.h_width * h_col; c = h_c - 1; break; case '\033': /* ignore esc sequences for now */ c++; /* should always be esc-x */ break; /* * Overstrike code supplied by: cs.utexas.edu!ut-emx!clyde@rutgers.edu * Since my manual pages do not have overstrike I couldn't test this. */ case BACKSPACE: /* Backspacing for nroff bolding */ if (c[-1] == c[1] && c[1] != BACKSPACE) { /* overstriking one char */ if (bufp > buf) { bufp--; /* Zap 1st instance of char to bolden */ x_loc = DumpText(w, x_loc, y_loc, buf, bufp - buf, WHICH(italicflag, FALSE)); h_col += bufp - buf; } Index: xc/programs/xman/ScrollByL.h =================================================================== RCS file: /cvs/xorg/xc/programs/xman/ScrollByL.h,v retrieving revision 1.2 diff -u -2 -0 -r1.2 ScrollByL.h --- a/xc/programs/xman/ScrollByL.h 23 Apr 2004 19:54:58 -0000 1.2 +++ b/xc/programs/xman/ScrollByL.h 8 Jun 2004 02:41:00 -0000 @@ -43,31 +43,35 @@ */ #ifdef ATHENA #define MANPAGE_NORMAL "fixed" #define MANPAGE_BOLD "helvetica-bold12" #define MANPAGE_ITALIC "helvetica-boldoblique12" #define MANPAGE_SYMBOL "symbol-medium12" #else #define MANPAGE_NORMAL "*-new century schoolbook-medium-r-normal--*-120-*" #define MANPAGE_BOLD "*-new century schoolbook-bold-r-normal--*-120-*" #define MANPAGE_ITALIC "*-new century schoolbook-bold-i-normal--*-120-*" #define MANPAGE_SYMBOL "*-symbol-medium-r-normal--*-120-*" #endif /* ATHENA */ #define XtNindent "indent" #define XtNforceVert "forceVert" #define XtNmanualFontNormal "manualFontNormal" #define XtNmanualFontBold "manualFontBold" #define XtNmanualFontItalic "manualFontItalic" #define XtNmanualFontSymbol "manualFontSymbol" +#define XtNNumTotalLines "numTotalLines" +#define XtNNumVisibleLines "numVisibleLines" #define XtCIndent "Indent" +#define XtCNumTotalLines "NumTotalLines" +#define XtCNumVisibleLines "NumVisibleLines" /* Class record constants */ extern WidgetClass scrollByLineWidgetClass; typedef struct _ScrollByLineClassRec *ScrollByLineWidgetClass; typedef struct _ScrollByLineRec *ScrollByLineWidget; #endif /* _XtScrollByLine_h --- DON'T ADD STUFF AFTER THIS LINE */ Index: xc/programs/xman/ScrollByLP.h =================================================================== RCS file: /cvs/xorg/xc/programs/xman/ScrollByLP.h,v retrieving revision 1.2 diff -u -2 -0 -r1.2 ScrollByLP.h --- a/xc/programs/xman/ScrollByLP.h 23 Apr 2004 19:54:58 -0000 1.2 +++ b/xc/programs/xman/ScrollByLP.h 8 Jun 2004 02:41:00 -0000 @@ -51,48 +51,50 @@ /* Full class record declaration */ typedef struct _ScrollByLineClassRec { CoreClassPart core_class; SimpleClassPart simple_class; ScrollByLineClassPart scrolled_widget_class; } ScrollByLineClassRec; extern ScrollByLineClassRec scrollByLineClassRec; /* New fields for the ScrollByLine widget record */ typedef struct _ScrollByLinePart { Pixel foreground; /* The color for the forground of the text. */ Boolean force_vert, /* Must have scrollbar visable */ use_right; /* put scroll bar on right side of window. */ FILE * file; /* The file to display. */ Dimension indent; /* amount to indent the file. */ XFontStruct * bold_font, /* The four fonts. */ * normal_font, * italic_font, * symbol_font; + int h_width; /* Main font width */ /* variables not in resource list. */ Widget bar; /* The scrollbar. */ int font_height; /* the height of the font. */ int line_pointer; /* The line that currently is at the top of the window being displayed. */ Dimension offset; /* Drawing offset because of scrollbar. */ GC move_gc; /* GC to use when moving the text. */ GC bold_gc, normal_gc, italic_gc, symbol_gc; /* gc for drawing. */ char ** top_line; /* The top line of the file. */ - int lines; /* number of line in the file. */ + int lines; /* Total number of line in the file. */ + int num_visible_lines; /* Number of lines visible */ } ScrollByLinePart; /**************************************************************** * * Full instance record declaration * ****************************************************************/ typedef struct _ScrollByLineRec { CorePart core; SimplePart simple; ScrollByLinePart scroll; } ScrollByLineRec; #endif /* _XtScrollByLinePrivate_h --- DON'T ADD STUFF AFTER THIS LINE */ Index: xc/programs/xman/Xman.ad =================================================================== RCS file: /cvs/xorg/xc/programs/xman/Xman.ad,v retrieving revision 1.2 diff -u -2 -0 -r1.2 Xman.ad --- a/xc/programs/xman/Xman.ad 23 Apr 2004 19:54:58 -0000 1.2 +++ b/xc/programs/xman/Xman.ad 8 Jun 2004 02:41:00 -0000 @@ -18,58 +18,62 @@ !*SimpleMenu.BackingStore: Always !*SimpleMenu.SaveUnder: Off *horizPane.orientation: horizontal *horizPane*showGrip: False *horizPane.min: 22 *horizPane.max: 22 *topLabel.BorderWidth: 0 *search*label.BorderWidth: 0 *search*dialog*value: Xman !*optionMenu.Label: Options !*sectionMenu.Label: Sections *horizPane*options.Label: Options *horizPane*sections.Label: Sections *helpButton.Label: Help +*helpButton.Tip: Open help browser *quitButton.Label: Quit +*quitButton.Tip: Quit Xman *manpageButton.Label: Manual Page +*manpageButton.Tip: Open new manpage browser *topLabel.Label: Manual Browser !*SimpleMenu*menuLabel*vertSpace: 100 !*SimpleMenu*menuLabel*leftMargin: 20 *displayDirectory.Label: Display Directory *displayManualPage.Label: Display Manual Page *help.Label: Help *help.geometry: 600x600 *search.Label: Search *removeThisManpage.Label: Remove This Manpage *help*removeThisManpage.Label: Remove Help *openNewManpage.Label: Open New Manpage +*printManualPage.Label: Print This Manpage *showVersion.Label: Show Version *quit.Label: Quit *pleaseStandBy*Label: Formatting Manual Page, Please Stand By... *search*dialog.Label: Type string to search for: *search*apropos.Label: Apropos *search*manualPage.Label: Manual Page *search*cancel.Label: Cancel *likeToSave*dialog.Label: Would you like to save this formatted Manual Page? *likeToSave*yes.Label: Yes *likeToSave*no.Label: No *translations: #override \ Ctrlq: Quit() \n\ Ctrlc: Quit() \n\ Ctrln: CreateNewManpage() \n\ Ctrlh: PopupHelp() \n\ Ctrls: PopupSearch() @@ -171,20 +175,116 @@ y: SaveFormattedPage(Save) \n\ n: SaveFormattedPage(Cancel) *manualBrowser*likeToSave*no.translations: #override \ ,: SaveFormattedPage(Cancel) reset() \n\ y: SaveFormattedPage(Save) \n\ n: SaveFormattedPage(Cancel) *manualBrowser*likeToSave*translations: #override \ y: SaveFormattedPage(Save) \n\ n: SaveFormattedPage(Cancel) *helpButton.translations: #augment \ ,: PopupHelp() reset() *quitButton.translations: #augment \ ,: Quit() reset() *manpageButton.translations: #augment \ ,: CreateNewManpage() reset() + +! Use "white" as background for printing +*printshell*background: white + +! Print dialog +*printdialogshell*geometry: 600x120 +*printdialogshell*title: Print +*printdialogshell*main*ok.fromVert: innerform +*printdialogshell*main*ok.label: Print +*printdialogshell*main*ok.tip: Print +*printdialogshell*main*setup.fromHoriz: ok +*printdialogshell*main*setup.fromVert: innerform +*printdialogshell*main*setup.label: Setup... +*printdialogshell*main*setup.tip: Configure print job options (page size, orientation, etc.) +*printdialogshell*main*cancel.fromHoriz: setup +*printdialogshell*main*cancel.fromVert: innerform +*printdialogshell*main*cancel.label: Cancel +*printdialogshell*main*cancel.tip: Cancel printing +*printdialogshell*main*desclabel.label: Printer Description: +*printdialogshell*main*desclabel.tip: Short description of printer +*printdialogshell*main*desc.fromHoriz: desclabel +*printdialogshell*main*desc.tip: Short description of printer +*printdialogshell*main*info.fromHoriz: desc +*printdialogshell*main*info.label: Printer info... +*printdialogshell*main*info.tip: Display additional information about this printer +*printdialogshell*main*namelabel.fromVert: desclabel +*printdialogshell*main*namelabel.label: Printer Name: +*printdialogshell*main*namelabel.tip: Name of selected printer +*printdialogshell*main*name.fromHoriz: namelabel +*printdialogshell*main*name.fromVert: desclabel +*printdialogshell*main*name.tip: Name of selected printer +*printdialogshell*main*selectprinter.fromHoriz: name +*printdialogshell*main*selectprinter.fromVert: desclabel +*printdialogshell*main*selectprinter.label: Select Printer... +*printdialogshell*main*selectprinter.label: Select Printer... +*printdialogshell*main*selectprinter.tip: Select a different printer +*printdialogshell*main*filenamelabel.fromVert: namelabel +*printdialogshell*main*filenamelabel.label: File Name: +*printdialogshell*main*filenamelabel.tip: File where the output should be stored +*printdialogshell*main*filename.fromHoriz: filenamelabel +*printdialogshell*main*filename.fromVert: namelabel +*printdialogshell*main*filename.tip: File where the output should be stored +*printdialogshell*main*selectfile.fromHoriz: filename +*printdialogshell*main*selectfile.fromVert: namelabel +*printdialogshell*main*selectfile.label: Select File... +*printdialogshell*main*selectfile.tip: Select file where the output should be stored +*printdialogshell*main*printtoprinter.fromVert: filenamelabel +*printdialogshell*main*printtoprinter.label: Print to Printer +*printdialogshell*main*printtoprinter.tip: Send print job to printer +*printdialogshell*main*printtofile.fromVert: filenamelabel +*printdialogshell*main*printtofile.fromHoriz: printtoprinter +*printdialogshell*main*printtofile.label: Print to File +*printdialogshell*main*printtofile.tip: Save print job in a file + +! Print job options dialog +*printdialogshell*setup*geometry: 600x400 +*printdialogshell*setup*title: Print: Print job options +*printdialogshell*setup*ok.fromVert: list +*printdialogshell*setup*ok.label: OK +*printdialogshell*setup*ok.tip: Commit changes +*printdialogshell*setup*cancel.fromHoriz: ok +*printdialogshell*setup*cancel.fromVert: list +*printdialogshell*setup*cancel.label: Cancel +*printdialogshell*setup*cancel.tip: Cancel and reset to defaults +*printdialogshell*setup*paperlist.tip: Select paper size +*printdialogshell*setup*resolutionlist.fromHoriz: paperlist +*printdialogshell*setup*resolutionlist.tip: Select page resolution +*printdialogshell*setup*orientationlist.fromHoriz: resolutionlist +*printdialogshell*setup*orientationlist.tip: Select page orientation +*printdialogshell*setup*plexlist.fromHoriz: orientationlist +*printdialogshell*setup*plexlist.tip: Select page plex mode (simplex, duplex, etc.) +*printdialogshell*setup*jobcopieslabel.fromVert: paperlist +*printdialogshell*setup*jobcopieslabel.tip: Set number of job copies +*printdialogshell*setup*jobcopieslabel.label: Job Copies: +*printdialogshell*setup*jobcopies.fromHoriz: jobcopieslabel +*printdialogshell*setup*jobcopies.fromVert: paperlist +*printdialogshell*setup*jobcopies.tip: Set number of job copies + +! Printer selection +*printdialogshell*printerselection*geometry: 400x150 +*printdialogshell*printerselection*title: Print: Select printer +*printdialogshell*printerselection*ok.fromVert: list +*printdialogshell*printerselection*ok.label: OK +*printdialogshell*printerselection*ok.tip: Switch printer +*printdialogshell*printerselection*cancel.fromHoriz: ok +*printdialogshell*printerselection*cancel.fromVert: list +*printdialogshell*printerselection*cancel.label: Cancel +*printdialogshell*printerselection*cancel.tip: Cancel printer selection +*printdialogshell*printerselection*list.tip: Select printer name from list + +! Select job file +*printdialogshell*selectfile*geometry: 400x80 +*printdialogshell*selectfile*title: Print: Select job file +*printdialogshell*selectfile*dialog.label: Select Filename: + +! EOF. Index: xc/programs/xman/buttons.c =================================================================== RCS file: /cvs/xorg/xc/programs/xman/buttons.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 buttons.c --- a/xc/programs/xman/buttons.c 23 Apr 2004 19:54:58 -0000 1.2 +++ b/xc/programs/xman/buttons.c 8 Jun 2004 02:41:00 -0000 @@ -104,47 +104,41 @@ arglist, num_args); /* use same vertical as help widget. */ XtSetArg(arglist[num_args], XtNfromHoriz, command); num_args++; command = XtCreateManagedWidget(QUIT_BUTTON, commandWidgetClass, form, arglist, num_args); num_args = 0; XtSetArg(arglist[num_args], XtNfromVert, command); num_args++; command = XtCreateManagedWidget(MANPAGE_BUTTON, commandWidgetClass, form, arglist, num_args); help_widget = NULL; /* We have not seen the help yet. */ FormUpWidgets(form, full_size, half_size); XtRealizeWidget(top); /* add WM_COMMAND property */ XSetCommand(XtDisplay(top), XtWindow(top), saved_argv, saved_argc); - man_globals = (ManpageGlobals*) XtMalloc( (Cardinal) sizeof(ManpageGlobals)); - man_globals->label = NULL; - man_globals->search_widget = NULL; - man_globals->manpagewidgets.directory = NULL; - man_globals->manpagewidgets.manpage = NULL; - man_globals->manpagewidgets.box = NULL; - man_globals->current_directory = 0; + man_globals = (ManpageGlobals*) XtCalloc(ONE, (Cardinal) sizeof(ManpageGlobals)); MakeSearchWidget(man_globals, top); MakeSaveWidgets(man_globals, top); SaveGlobals( (man_globals->This_Manpage = top), man_globals); XtMapWidget(top); AddCursor(top, resources.cursors.top); /* * Set up ICCCM delete window. */ XtOverrideTranslations (top, XtParseTranslationTable ("WM_PROTOCOLS: Quit()")); (void) XSetWMProtocols (XtDisplay(top), XtWindow(top), &wm_delete_window, 1); } /* Function Name: CreateManpage * Description: Creates a new manpage. @@ -418,81 +412,86 @@ /* Function Name: CreateOptionMenu * Description: Create the option menu. * Arguments: man_globals - the manual page globals. * parent - the button that activates the menu. * Returns: none. */ static void CreateOptionMenu(ManpageGlobals * man_globals, Widget parent) { Widget menu, entry; int i; static char * option_names[] = { /* Names of the buttons. */ DIRECTORY, MANPAGE, HELP, SEARCH, BOTH_SCREENS, REMOVE_MANPAGE, OPEN_MANPAGE, + PRINT_MANPAGE, SHOW_VERSION, QUIT }; menu = XtCreatePopupShell(OPTION_MENU, simpleMenuWidgetClass, parent, NULL, (Cardinal) 0); man_globals->option_menu = menu; for (i = 0 ; i < NUM_OPTIONS ; i++) { entry = XtCreateManagedWidget(option_names[i], smeBSBObjectClass, menu, NULL, ZERO); XtAddCallback(entry, XtNcallback, OptionCallback, (caddr_t) man_globals); switch (i) { case 0: man_globals->dir_entry = entry; break; case 1: man_globals->manpage_entry = entry; break; case 2: man_globals->help_entry = entry; break; case 3: man_globals->search_entry = entry; break; case 4: man_globals->both_screens_entry = entry; break; case 5: man_globals->remove_entry = entry; break; case 6: man_globals->open_entry = entry; break; case 7: - man_globals->version_entry = entry; + man_globals->print_entry = entry; break; case 8: + man_globals->version_entry = entry; + break; + case 9: man_globals->quit_entry = entry; break; default: + Error(("CreateOptionMenu: Unknown id=%d\n", i)); break; } } } /* Function Name: CreateSectionMenu * Description: Create the Section menu. * Arguments: man_globals - the manual page globals. * parent - the button that activates the menu. * Returns: none. */ static void CreateSectionMenu(ManpageGlobals * man_globals, Widget parent) { Widget menu, entry; int i; MenuStruct * menu_struct; Arg args[1]; Cardinal num_args; Index: xc/programs/xman/defs.h =================================================================== RCS file: /cvs/xorg/xc/programs/xman/defs.h,v retrieving revision 1.2 diff -u -2 -0 -r1.2 defs.h --- a/xc/programs/xman/defs.h 23 Apr 2004 19:54:58 -0000 1.2 +++ b/xc/programs/xman/defs.h 8 Jun 2004 02:41:00 -0000 @@ -50,49 +50,50 @@ #define DIRECTORY_NORMAL "fixed" /* The default dir font */ #define OPTION_MENU "optionMenu" /* Name of the Option Menu. */ #define SECTION_MENU "sectionMenu" /* Name of the Section Menu. */ #define HELP_BUTTON "helpButton" /* Name of top help button */ #define QUIT_BUTTON "quitButton" /* Name of top quit button */ #define MANPAGE_BUTTON "manpageButton" /* Name of top manpage button */ #define TOPBOXNAME "topBox" /* Name of the Top Box. */ #define MANNAME "manualBrowser" /* name for each manual page widget. */ #define SEARCHNAME "search" /* The name for the search widget. */ #define HELPNAME "help" /* The name of the help widget. */ #define DIRECTORY_NAME "directory" /* name of the directory widget. */ #define MANUALPAGE "manualPage" /* name of the Scrollbyline widget that contains the man page. */ #define DIALOG "dialog" /* Names of the menu buttons */ -#define NUM_OPTIONS 9 /* Number of menu options. */ +#define NUM_OPTIONS 10 /* Number of menu options. */ #define DIRECTORY "displayDirectory" #define MANPAGE "displayManualPage" #define HELP "help" #define SEARCH "search" #define BOTH_SCREENS "showBothScreens" #define REMOVE_MANPAGE "removeThisManpage" #define OPEN_MANPAGE "openNewManpage" +#define PRINT_MANPAGE "printManualPage" #define SHOW_VERSION "showVersion" #define QUIT "quit" /* definitions of string to use for show both and show one. */ #define SHOW_BOTH "Show Both Screens" #define SHOW_ONE "Show One Screen" /* * Things will not look right if you change these names to make * MANUALSEARCH longer APROPOSSEARCH, see search.c for details. */ #define MANUALSEARCH "manualPage" #define APROPOSSEARCH "apropos" #define CANCEL "cancel" #define MANUAL 0 #define APROPOS 1 Index: xc/programs/xman/handler.c =================================================================== RCS file: /cvs/xorg/xc/programs/xman/handler.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 handler.c --- a/xc/programs/xman/handler.c 23 Apr 2004 19:54:58 -0000 1.2 +++ b/xc/programs/xman/handler.c 8 Jun 2004 02:41:00 -0000 @@ -23,79 +23,83 @@ OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the X Consortium. */ /* $XFree86: xc/programs/xman/handler.c,v 1.6 2003/01/19 04:44:45 paulo Exp $ */ /* * xman - X window system manual page display program. * Author: Chris D. Peterson, MIT Project Athena * Created: October 29, 1987 */ #include #include #include "globals.h" #include "vendor.h" +#include "printdialog.h" +#include "print.h" static void PutUpManpage(ManpageGlobals * man_globals, FILE * file); static void ToggleBothShownState(ManpageGlobals * man_globals); /* Function Name: OptionCallback * Description: This is the callback function for the callback menu. * Arguments: w - the widget we are calling back from. * globals_pointer - a pointer to the psuedo globals structure * for this manpage. * junk - (call data) not used. * Returns: none. */ /*ARGSUSED*/ void OptionCallback(Widget w, XtPointer pointer, XtPointer junk) { ManpageGlobals * man_globals = (ManpageGlobals *) pointer; String params; Cardinal num_params = 1; if ( w == man_globals->search_entry ) PopupSearch(XtParent(w), NULL, NULL, NULL); else if (w == man_globals->dir_entry) { /* Put Up Directory */ params = "Directory"; GotoPage(XtParent(w), NULL, ¶ms, &num_params); } else if (w == man_globals->manpage_entry ) { /* Put Up Man Page */ params = "ManualPage"; GotoPage(XtParent(w), NULL, ¶ms, &num_params); } else if ( w == man_globals->help_entry ) /* Help */ PopupHelp(XtParent(w), NULL, NULL, NULL); else if ( w == man_globals->both_screens_entry ) /*Toggle Both_Shown State.*/ ToggleBothShownState(man_globals); else if ( w == man_globals->remove_entry) /* Kill the manpage */ RemoveThisManpage(XtParent(w), NULL, NULL, NULL); else if ( w == man_globals->open_entry) /* Open new manpage */ CreateNewManpage(XtParent(w), NULL, NULL, NULL); + else if ( w == man_globals->print_entry) /* Print current manpage */ + PrintThisManpage(man_globals); else if ( w == man_globals->version_entry) /* Get version */ ShowVersion(XtParent(w), NULL, NULL, NULL); else if ( w == man_globals->quit_entry) /* Quit. */ Quit(XtParent(w), NULL, NULL, NULL); } /* Function Name: ToggleBothShownState; * Description: toggles the state of the both shown feature. * Arguments: man_globals - the man globals structure. * Returns: none. */ /* * I did not have a two state widget, which is the way this * should really be done. 1/22/88 - CDP. */ static void ToggleBothShownState(ManpageGlobals * man_globals) { @@ -198,41 +202,43 @@ /* Function Name: DirectoryHandler * Description: This is the callback function for the directory listings. * Arguments: w - the widget we are calling back from. * global_pointer - the pointer to the psuedo global structure * associated with this manpage. * ret_val - return value from the list widget. * Returns: none. */ void DirectoryHandler(Widget w, XtPointer global_pointer, XtPointer ret_val) { FILE * file; /* The manpage file. */ ManpageGlobals * man_globals = (ManpageGlobals *) global_pointer; XawListReturnStruct * ret_struct = (XawListReturnStruct *) ret_val; file = FindManualFile(man_globals, man_globals->current_directory, ret_struct->list_index); PutUpManpage(man_globals, file); - fclose(file); + if ((file != NULL) && (file != man_globals->curr_file)) { + fclose(file); + } } /* Function Name: DirPopupCallback * Description: This is the callback function for the callback menu. * Arguments: w - the widget we are calling back from. * pointer - a pointer to the psuedo globals structure * for this manpage. * junk - (call data) not used. * Returns: none. */ /*ARGSUSED*/ void DirPopupCallback(Widget w, XtPointer pointer, XtPointer junk) { ManpageGlobals * man_globals; MenuStruct * menu_struct; Widget parent; int number; int current_box; @@ -572,39 +578,141 @@ w = CreateManpage(file); man_pages_shown++; /* Put title into new manual page. */ label = man_globals->manpage_title; man_globals = GetGlobals(w); strcpy(man_globals->manpage_title, label); ChangeLabel(man_globals->label, label); } break; default: XtAppWarning(XtWidgetToApplicationContext(w), "Xman - Search: Second parameter unknown."); break; } else { PutUpManpage(man_globals, file); } - if (file != NULL) - fclose(file); + if ((file != NULL) && (file != man_globals->curr_file)) { + fclose(file); + } +} + +static void +printshellDestroyXtProc(Widget w, XtPointer client_data, XtPointer callData) +{ + ManpageGlobals *mg = GetGlobals(w); + XawPrintDialogClosePrinterConnection(mg->printdialog, False); +} + +static void +printOKXtProc(Widget w, XtPointer client_data, XtPointer callData) +{ + XawPrintDialogCallbackStruct *pdcs = (XawPrintDialogCallbackStruct *)callData; + Cardinal n; + Arg args[2]; + ManpageGlobals *mg = GetGlobals(w); + Widget topwindow = mg->This_Manpage; + FILE *file; + + Log(("printOKXtProc: OK.\n")); + + /* Get file object */ + n = 0; + XtSetArg(args[n], XtNfile, &file); n++; + XtGetValues(mg->manpagewidgets.manpage, args, n); + Assertion(file != NULL, (("printOKXtProc: file == NULL.\n"))); + + DoPrintManpage("Xman", + file, topwindow, + pdcs->pdpy, pdcs->pcontext, printshellDestroyXtProc, + mg->manpage_title, + pdcs->printToFile?pdcs->printToFileName:NULL); + + XtPopdown(mg->printdialog_shell); +} + +static void +printCancelXtProc(Widget w, XtPointer client_data, XtPointer callData) +{ + ManpageGlobals * mg = GetGlobals(w); + + Log(("printCancelXtProc: cancel.\n")); + XtPopdown(mg->printdialog_shell); + + Log(("destroying print dialog shell...\n")); + XtDestroyWidget(mg->printdialog_shell); + mg->printdialog_shell = NULL; + mg->printdialog = NULL; + Log(("... done\n")); } +/* Function Name: PrintThisManpage + * Description: Print the current manual page. + * Arguments: mg - manpage globals + * Returns: none. + */ + +/*ARGSUSED*/ +void +PrintThisManpage(ManpageGlobals *mg) +{ + Dimension width, height; + Position x, y; + Widget parent = mg->This_Manpage; + Widget topwindow = mg->This_Manpage; + Log(("print!\n")); + + if (!mg->printdialog) { + int n; + Arg args[20]; + + n = 0; + XtSetArg(args[n], XtNallowShellResize, True); n++; + mg->printdialog_shell = XtCreatePopupShell("printdialogshell", + transientShellWidgetClass, + topwindow, args, n); + n = 0; + mg->printdialog = XtCreateManagedWidget("printdialog", printDialogWidgetClass, + mg->printdialog_shell, args, n); + XtAddCallback(mg->printdialog, XawNOkCallback, printOKXtProc, NULL); + XtAddCallback(mg->printdialog, XawNCancelCallback, printCancelXtProc, NULL); + + XtRealizeWidget(mg->printdialog_shell); + } + + /* Center dialog */ + XtVaGetValues(mg->printdialog_shell, + XtNwidth, &width, + XtNheight, &height, + NULL); + + x = (Position)(XWidthOfScreen( XtScreen(parent)) - width) / 2; + y = (Position)(XHeightOfScreen(XtScreen(parent)) - height) / 3; + + XtVaSetValues(mg->printdialog_shell, + XtNx, x, + XtNy, y, + NULL); + + XtPopup(mg->printdialog_shell, XtGrabNonexclusive); +} + + /* Function Name: ShowVersion * Description: Show current version. * Arguments: w - any widget in the manpage. * event - NOT USED. * params, num_params - NOT USED. * Returns: none. */ /*ARGSUSED*/ void ShowVersion(Widget w, XEvent * event, String * params, Cardinal * num_params) { ManpageGlobals * man_globals = GetGlobals(w); ChangeLabel(man_globals->label, XMAN_VERSION); } Index: xc/programs/xman/man.h =================================================================== RCS file: /cvs/xorg/xc/programs/xman/man.h,v retrieving revision 1.3 diff -u -2 -0 -r1.3 man.h --- a/xc/programs/xman/man.h 22 May 2004 19:20:06 -0000 1.3 +++ b/xc/programs/xman/man.h 8 Jun 2004 02:41:00 -0000 @@ -26,69 +26,77 @@ Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the X Consortium. */ /* $XFree86: xc/programs/xman/man.h,v 1.4 2001/07/25 15:05:27 dawes Exp $ */ /* X toolkit header files */ #include #include #include #include /* Std system and C header files */ #include +#include #include #include /* X include files */ #include /* Widget header files. */ #include #include #include #include #include #include #include #include #include #include #include /* program specific header files. */ #include "ScrollByL.h" #include "version.h" #include "defs.h" +/* Turn a NULL pointer string into an empty string */ +#define NULLSTR(x) (((x)!=NULL)?(x):("")) + +#define Error(x) { printf x ; exit(EXIT_FAILURE); } +#define Assertion(expr, msg) { if (!(expr)) { Error msg } } +#define Log(x) { if (True) printf x; } + /* * Assigning values here allows the user of Bitwise Or. */ typedef struct _XmanFonts { XFontStruct * directory; /* The font for the directory. */ } XmanFonts; typedef struct _XmanCursors { Cursor top, /* The top Cursor, default for xman. */ help, /* The top cursor for the help menu. */ manpage, /* The cursor for the Manpage. */ search_entry; /* The cursor for the text widget in the search box.*/ Pixel fg_color; /* foreground color of cursors. */ Pixel bg_color; /* background color of cursors. */ } XmanCursors; typedef struct _ManPageWidgets { Widget manpage, /* The manual page window (scrolled) */ @@ -120,60 +128,67 @@ typedef struct _ManpageGlobals{ int current_directory; /* The directory currently being shown on this manpage. */ Boolean dir_shown, /* True if the directory is then current visable screen */ both_shown; /* If true then both the manpage and the directory are to be shown.*/ Widget label, /* The label widget at the top of the page. */ standby, /* The please standby widget. */ save, /* The "would you like to save?" widget. */ search_widget, /* The search widget popup. */ help_button, /* The help button. */ option_menu, /* The option menu. */ text_widget; /* text widget containing search string. */ /* Widgets (Objects really) for the command menu entries. */ Widget dir_entry, manpage_entry, help_entry, search_entry, both_screens_entry, remove_entry, open_entry, - version_entry, quit_entry; + print_entry, version_entry, quit_entry; + + /* Print objects and data */ + Widget printdialog_shell; /* Shell for the print dialog */ + Widget printdialog; /* Print dialog */ + + /* Misc. */ char manpage_title[80]; /* The label to use for the current manpage. */ char save_file[80]; /* the name of the file to save fomatted page into. */ char tempfile[80]; /* the name of the file to copy the formatted page from. */ Boolean compress; /* Compress file on save? */ Boolean gzip; /* Gzip file on save? */ Boolean deletetempfile; /* Need to delete tempfile when done? */ char ** section_name; /* The name of each of the sections */ ManPageWidgets manpagewidgets; /* The manpage widgets. */ /* Things to remember when cleaning up when killing manpage. */ Widget This_Manpage; /* a pointer to the root of this manpage. */ + FILE *curr_file; /* Current file shown in manpage widget */ } ManpageGlobals; /* Resource manager sets these. */ typedef struct _Xman_Resources { XmanFonts fonts; /* The fonts used for the man pages. */ XmanCursors cursors; /* The cursors for xman. */ Boolean show_help_syntax; /* True if syntax message should be dumped to stdout. */ Boolean both_shown_initial; /* The initial state of the manual pages show two screens or only one. */ Boolean top_box_active; /* Put up the Top Box. */ Boolean clear_search_string; /* clear the search string each time it is popped down? */ int directory_height; /* The default height of directory in both_shown mode. */ char * help_file; /* The name of the help file. */ char * title; /* The title for topBox */ Boolean iconic; /* Should topBox come up in an iconic state */ @@ -204,40 +219,41 @@ void MakeSaveWidgets(ManpageGlobals *man_globals, Widget parent); void MakeTopBox(void); /* handler.c */ void DirPopupCallback(Widget w, XtPointer pointer, XtPointer junk); void DirectoryHandler(Widget w, XtPointer global_pointer, XtPointer ret_val); void OptionCallback(Widget w, XtPointer pointer, XtPointer junk); void Popup(Widget w, XtGrabKind grab_kind); /* Action Routines. */ void CreateNewManpage(Widget w, XEvent * event, String * params, Cardinal * num_params); void GotoPage(Widget w, XEvent * event, String * params, Cardinal * num_params); void PopupHelp(Widget w, XEvent * event, String * params, Cardinal * num_params); void PopupSearch(Widget w, XEvent * event, String * params, Cardinal * num_params); void Quit(Widget w, XEvent * event, String * params, Cardinal * num_params); void RemoveThisManpage(Widget w, XEvent * event, String * params, Cardinal * num_params); void SaveFormattedPage(Widget w, XEvent * event, String * params, Cardinal * num_params); void Search(Widget w, XEvent * event, String * params, Cardinal * num_params); +void PrintThisManpage(ManpageGlobals *mg); void ShowVersion(Widget w, XEvent * event, String * params, Cardinal * num_params); /* help.c */ Boolean MakeHelpWidget(void); Boolean OpenHelpfile(ManpageGlobals * man_globals); /* man.c */ Bool ReadManConfig(char manpath[]); int Man(void); /* misc.c */ FILE * DoSearch(ManpageGlobals * man_globals, int type); FILE * FindManualFile(ManpageGlobals * man_globals, int section_num, int entry_num); ManpageGlobals * GetGlobals(Widget w); void AddCursor(Widget w, Cursor cursor); void ChangeLabel(Widget w, char * str); void OpenFile(ManpageGlobals * man_globals, FILE * file); void PopupWarning(ManpageGlobals * man_globals, char * string); void PositionCenter(Widget widget, int x, int y, int above, int left, int v_space, int h_space); Index: xc/programs/xman/misc.c =================================================================== RCS file: /cvs/xorg/xc/programs/xman/misc.c,v retrieving revision 1.3 diff -u -2 -0 -r1.3 misc.c --- a/xc/programs/xman/misc.c 22 May 2004 19:20:06 -0000 1.3 +++ b/xc/programs/xman/misc.c 8 Jun 2004 02:41:00 -0000 @@ -136,42 +136,49 @@ void PrintError(char * string) { fprintf(stderr,"Xman Error: %s\n",string); exit(1); } /* Function Name: OpenFile * Description: Assignes a file to the manpage. * Arguments: man_globals - global structure. * file - the file pointer. * Returns: none */ void OpenFile(ManpageGlobals * man_globals, FILE * file) { Arg arglist[1]; Cardinal num_args = 0; + + if (man_globals->curr_file) { +#if 0 /* Ownership rules need to be fixed first */ + fclose(man_globals->curr_file); +#endif + } + man_globals->curr_file = file; - XtSetArg(arglist[num_args], XtNfile, file); num_args++; + XtSetArg(arglist[num_args], XtNfile, man_globals->curr_file); num_args++; XtSetValues(man_globals->manpagewidgets.manpage, arglist, num_args); } /* Function Name: FindManualFile * Description: Opens the manual page file given the entry information. * Arguments: man_globals - the globals info for this manpage. * section_num - section number of the man page. * entry_num - entry number of the man page. * Returns: fp - the file pointer * * NOTES: * * If there is a uncompressed section it will look there for uncompresed * manual pages first and then for individually compressed file in the * uncompressed section. * * If there is a compressed directory then it will also look there for * the manual pages. * Index: xc/programs/xman/print.c =================================================================== RCS file: xc/programs/xman/print.c diff -N xc/programs/xman/print.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xman/print.c 8 Jun 2004 02:41:00 -0000 @@ -0,0 +1,377 @@ +/* + * $Xorg: print.c,v 1.1 2004/04/30 02:05:54 gisburn Exp $ + * +Copyright 2004 Roland Mainz + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + * + */ + +/* Turn a NULL pointer string into an empty string */ +#define NULLSTR(x) (((x)!=NULL)?(x):("")) + +#define Error(x) { printf x ; exit(EXIT_FAILURE); } +#define Assertion(expr, msg) { if (!(expr)) { Error msg } } +#define Log(x) { if(True) printf x; } + +#include "print.h" +#include "ScrollByL.h" +#include +#include +#include +#include + +static Widget +CreatePrintShell(Widget videoshell, + Screen *pscreen, + String printshell_name, + ArgList args, + Cardinal numargs) +{ + String videoname, + videoclass; + Widget pappshell, + printshell; + Display *pdpy = XDisplayOfScreen(pscreen); + int dummyc = 0; + String dummys = ""; + XtGetApplicationNameAndClass(XtDisplay(videoshell), + &videoname, &videoclass); + + /* XXX: Why is the |dummyc|&&|dummys| stuff needed here ? */ + XtDisplayInitialize(XtWidgetToApplicationContext(videoshell), pdpy, + videoname, videoclass, + NULL, 0, + &dummyc, &dummys); + + pappshell = XtVaAppCreateShell(videoname, videoclass, + applicationShellWidgetClass, + pdpy, + XtNscreen, pscreen, + NULL); + printshell = XtCreatePopupShell(printshell_name, + xawPrintShellWidgetClass, + pappshell, args, numargs); + + + /* we're mapping/unmapping at start/end page time */ + XtSetMappedWhenManaged(printshell, False); + + /* We realise the widget when we're done with building the widget tree... */ + + return printshell; +} + +typedef struct +{ + const char *programname; + Widget toplevel; + Bool isPrinting; + Widget printshell; + struct + { + Widget form; + Widget pageheaderlabel; + Widget manpage; + } content; /* content to print */ + int numpages; + Display *pdpy; + Screen *pscreen; + XPContext pcontext; + XtCallbackProc pdpyDestroyCallback; + void *printtofile_handle; + const char *jobtitle; +} AppPrintData; + +static AppPrintData apdx; +static AppPrintData *apd = &apdx; + +/* "Count" pages in a scrollByLineWidgetClass widget */ +static +long CountPages(Widget sblw) +{ + long num_pages = 0; + Cardinal n; + Arg args[3]; + int num_total_lines = 0, + num_visible_lines = 0; + + n = 0; + XtSetArg(args[n], XtNNumTotalLines, &num_total_lines); n++; + XtSetArg(args[n], XtNNumVisibleLines, &num_visible_lines); n++; + XtGetValues(sblw, args, n); + +#define DIV_ROUND_UP(a, b) (((a)+((b)-1)) / (b)) + /* scrollByLineWidgetClass's "Page(forward)" always overlaps by one + * line so we use |num_visible_lines-1| instead of |num_visible_lines| */ + num_pages = DIV_ROUND_UP(num_total_lines, num_visible_lines-1); +#undef DIV_ROUND_UP + + return num_pages; +} + +static void +PageSetupCB(Widget widget, XtPointer client_data, XtPointer call_data) +{ + Widget pshell = widget; + XawPrintShellCallbackStruct *psp = (XawPrintShellCallbackStruct *)call_data; + AppPrintData *p = (AppPrintData *)client_data; + + Log(("--> PageSetupCB\n")); + + if (!psp->last_page_in_job) { + int currpage; + char buffer[256]; + + XtVaGetValues(pshell, XawNcurrPageNumInJob, &currpage, NULL); + + sprintf(buffer, "Title: %s / Page: %d/%d", p->jobtitle, currpage, p->numpages); + XtVaSetValues(apd->content.pageheaderlabel, XtNlabel, buffer, NULL); + + /* Note: XawPrintShell's pagecount starts with '1' + * (=first page is page no. '1') */ + if (currpage > 1) { + String params[] = { "Forward" }; + Log(("pagedown %d\n", currpage)); + /* "Page(Forward)" is scrollByLineWidgetClass's way to + * move one page forward */ + XtCallActionProc(p->content.manpage, "Page", NULL, params, ONE); + } + else + { + Log(("first page\n")); + } + + if (currpage >= p->numpages) { + psp->last_page_in_job = True; + } + } +} + +static +void FinishPrinting(AppPrintData *p) +{ + /* Wait for the job to finish */ + if (p->printtofile_handle) { + if (XpuWaitForPrintFileChild(p->printtofile_handle) != XPGetDocFinished) { + fprintf(stderr, "%s: Error while printing to file.\n", apd->programname); + } + p->printtofile_handle = NULL; + } + + /* Avoid that the manpage object tries to close the |FILE *|-handle at destruction time */ + XtVaSetValues(p->content.manpage, XtNfile, NULL, NULL); + + if (p->printshell) { + XtDestroyWidget(p->printshell); + p->printshell = NULL; + } + + /* Two issues here: + * 1. The print display connection is owned by the print dialog + * To avoid any problems with that use a callback back to the main + * application which calls + * |XawPrintDialogClosePrinterConnection(w, False)| to ask the + * print dialog widget to close all print display resources and + * disown the object. + * 2. We have to use XpDestroyContext() and XtCloseDisplay() + * instead of XpuClosePrinterDisplay() to make libXt happy... + * + * Call callback... */ + (*apd->pdpyDestroyCallback)(p->toplevel, NULL, NULL); /* HACK! */ + + /* ... and then get rid of the display */ + if (p->pcontext != None) { + XpDestroyContext(p->pdpy, p->pcontext); + } + XtCloseDisplay(p->pdpy); + + p->toplevel = NULL; + p->isPrinting = False; + p->pdpy = NULL; + p->pscreen = NULL; + p->pcontext = None; +} + +static +void PrintEndJobCB(Widget pshell, XtPointer client_data, XtPointer call_data) +{ + AppPrintData *p = (AppPrintData *)client_data; + + Log(("--> PrintEndJobCB\n")); + + /* Finish printing and destroy print shell (it's legal to destroy Xt + * widgets from within it's own callbacks) */ + FinishPrinting(p); +} + +static +XFontStruct *GetPrintTextFont(Display *pdpy, const char *fontprefix, long dpi) +{ + XFontStruct *font; + char fontname[1024]; + + sprintf(fontname, "%s--*-120-%ld-%ld-*-*-iso8859-1", fontprefix, dpi, dpi); + font = XLoadQueryFont(pdpy, fontname); + if (!font) { + sprintf(fontname, "-adobe-courier-medium-r-normal--*-120-%ld-%ld-*-*-iso8859-1", dpi, dpi); + font = XLoadQueryFont(pdpy, fontname); + } + if (!font) { + sprintf(fontname, "-*-*-*-*-*-*-*-120-%ld-%ld-*-*-iso8859-1", dpi, dpi); + font = XLoadQueryFont(pdpy, fontname); + } + if (!font) + Error(("XLoadQueryFont failure.\n")); + return font; + +} + +void DoPrintManpage(const char *programname, + FILE *manpagefile, Widget toplevel, + Display *pdpy, XPContext pcontext, + XtCallbackProc pdpyDestroyCB, + const char *jobtitle, const char *toFile) +{ + long dpi = 0; + int n; + Arg args[20]; + XFontStruct *printFontNormal; + XFontStruct *printFontBold; + XFontStruct *printFontItalic; + XFontStruct *printFontSymbol; + + if (!manpagefile) { + Error(("DoPrintManpage: No FILE given.")); + } + + apd->programname = programname; + apd->pdpyDestroyCallback = pdpyDestroyCB; + + if (apd->isPrinting) { + fprintf(stderr, "%s: Already busy with printing.\n", apd->programname); + return; + } + + /* Configure the print context (paper size, title etc.) + * We must do this before creating any Xt widgets - otherwise they will + * make wrong assuptions about fonts, resultions etc. ... + */ + XpuSetJobTitle(pdpy, pcontext, jobtitle); + + /* Configuration done, set the context */ + XpSetContext(pdpy, pcontext); + + /* Get default printer resolution */ + if (XpuGetResolution(pdpy, pcontext, &dpi) != 1) { + fprintf(stderr, "%s: No default resolution for printer.\n", apd->programname); + XpuClosePrinterDisplay(pdpy, pcontext); + return; + } + + apd->toplevel = toplevel; + apd->pdpy = pdpy; + apd->pcontext = pcontext; + apd->pscreen = XpGetScreenOfContext(pdpy, pcontext); + apd->jobtitle = jobtitle; + + n = 0; + XtSetArg(args[n], XawNlayoutMode, XawPrintLAYOUTMODE_DRAWABLEAREA); n++; + apd->printshell = CreatePrintShell(toplevel, apd->pscreen, "printshell", args, n); + + n = 0; + XtSetArg(args[n], XtNresizable, True); n++; + XtSetArg(args[n], XtNright, XtChainRight); n++; + apd->content.form = XtCreateManagedWidget("form", formWidgetClass, apd->printshell, args, n); + + printFontNormal = GetPrintTextFont(pdpy, "-*-courier-medium-r-*", dpi); + printFontBold = GetPrintTextFont(pdpy, "-*-courier-bold-r-*", dpi); + printFontItalic = GetPrintTextFont(pdpy, "-*-courier-medium-o-*", dpi); + printFontSymbol = GetPrintTextFont(pdpy, "-*-symbol-*-*-*", dpi); + + n = 0; + XtSetArg(args[n], XtNfromHoriz, NULL); n++; + XtSetArg(args[n], XtNfromVert, NULL); n++; + XtSetArg(args[n], XtNtop, XtChainTop); n++; + XtSetArg(args[n], XtNright, XtChainRight); n++; + XtSetArg(args[n], XtNresizable, True); n++; + XtSetArg(args[n], XtNfont, printFontNormal); n++; /* fontset would be better */ + XtSetArg(args[n], XtNlabel, "Page: n/n"); n++; + XtSetArg(args[n], XtNjustify, XtJustifyRight); n++; + apd->content.pageheaderlabel = XtCreateManagedWidget("pageinfo", labelWidgetClass, apd->content.form, args, n); + + n = 0; + XtSetArg(args[n], XtNfile, manpagefile); n++; + +/* Usually I would expect that using |XtNfromVert, apd->content.pageheaderlabel| + * would be the correct way to place the text widget with the main content below + * the page header widget - but for an unknown reason this doesn not work: The + * text widget squishes itself into the bottom half of the page and only occupies + * 1/2 of the page's with... ;-(( */ +#define WORKAROUND_FOR_SOMETHING_IS_WRONG 1 +#ifdef WORKAROUND_FOR_SOMETHING_IS_WRONG + XtSetArg(args[n], XtNtop, XtChainTop); n++; + XtSetArg(args[n], XtNright, XtChainRight); n++; + XtSetArg(args[n], XtNvertDistance, (printFontNormal->ascent+printFontNormal->descent+2)*2); n++; +#else + XtSetArg(args[n], XtNfromHoriz, NULL); n++; + XtSetArg(args[n], XtNfromVert, apd->content.pageheaderlabel); n++; +#endif + + XtSetArg(args[n], XtNmanualFontNormal, printFontNormal); n++; + XtSetArg(args[n], XtNmanualFontBold, printFontBold); n++; + XtSetArg(args[n], XtNmanualFontItalic, printFontItalic); n++; + XtSetArg(args[n], XtNmanualFontSymbol, printFontSymbol); n++; + apd->content.manpage = XtCreateManagedWidget("manpage", scrollByLineWidgetClass, apd->content.form, args, n); + + XtAddCallback(apd->printshell, XawNpageSetupCallback, PageSetupCB, (XtPointer)apd); + XtAddCallback(apd->printshell, XawNendJobCallback, PrintEndJobCB, (XtPointer)apd); + + /* Realise print shell (which will set position+size of the child + * widgets based on the current page size) */ + XtRealizeWidget(apd->printshell); + + /* Count number of pages in the manpage widget */ + apd->numpages = CountPages(apd->content.manpage); + + /* Make sure that the Xt machinery is really using the right screen (assertion) */ + if (XpGetScreenOfContext(XtDisplay(apd->printshell), apd->pcontext) != XtScreen(apd->printshell)) + Error(("Widget's screen != print screen. BAD.\n")); + + apd->isPrinting = True; + + if (toFile) { + printf("%s: Printing to file '%s'...\n", apd->programname, toFile); + apd->printtofile_handle = XpuStartJobToFile(pdpy, pcontext, toFile); + if (!apd->printtofile_handle) { + perror("XpuStartJobToFile failure"); + apd->isPrinting = False; + return; + } + } + else + { + printf("%s: Printing to printer...\n", apd->programname); + XpuStartJobToSpooler(pdpy); + } +} + + Index: xc/programs/xman/print.h =================================================================== RCS file: xc/programs/xman/print.h diff -N xc/programs/xman/print.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xman/print.h 8 Jun 2004 02:41:00 -0000 @@ -0,0 +1,47 @@ +/* + * $Xorg: print.h,v 1.1 2004/04/30 02:05:54 gisburn Exp $ + * +Copyright 2004 Roland Mainz + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + * + */ + +#ifndef XMAN_PRINT_H +#define XMAN_PRINT_H 1 + +#include +#include +#include +#include +#include +#include + +/* Prototypes */ +void DoPrintManpage(const char *programname, + FILE *manpage, + Widget toplevel, + Display *pdpy, XPContext pcontext, + XtCallbackProc printDisplayDestroyCallback, + const char *jobTitle, + const char *toFile); + +#endif /* !XMAN_PRINT_H */ Index: xc/programs/xman/search.c =================================================================== RCS file: /cvs/xorg/xc/programs/xman/search.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 search.c --- a/xc/programs/xman/search.c 23 Apr 2004 19:54:58 -0000 1.2 +++ b/xc/programs/xman/search.c 8 Jun 2004 02:41:00 -0000 @@ -248,41 +248,41 @@ flag = TRUE; break; } count++; } /* * If the file is less than this number of lines then assume that there is * nothing apropriate found. This does not confuse the apropos filter. */ if (flag) { fclose(file); file = NULL; ChangeLabel(man_globals->label,string_buf); return(NULL); } strcpy(man_globals->manpage_title,label); ChangeLabel(man_globals->label,label); - fseek(file, 0L, 0); /* reset file to point at top. */ + fseek(file, 0L, SEEK_SET); /* reset file to point at top. */ } else { /* MANUAL SEACH */ file = DoManualSearch(man_globals, search_string); if (file == NULL) { sprintf(string_buf,"No manual entry for %s.", search_string); ChangeLabel(man_globals->label, string_buf); if (man_globals->label == NULL) PopupWarning(man_globals, string_buf); return(NULL); } } if (resources.clear_search_string) { Arg arglist[1]; Widget dialog; dialog = XtNameToWidget(man_globals->search_widget, DIALOG); if (dialog == NULL) PopupWarning(man_globals, "Could not clear the search string."); Index: xc/programs/xman/version.h =================================================================== RCS file: /cvs/xorg/xc/programs/xman/version.h,v retrieving revision 1.1.1.1 diff -u -2 -0 -r1.1.1.1 version.h --- a/xc/programs/xman/version.h 14 Nov 2003 16:49:23 -0000 1.1.1.1 +++ b/xc/programs/xman/version.h 8 Jun 2004 02:41:00 -0000 @@ -12,21 +12,21 @@ the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the X Consortium. */ -#define XMAN_VERSION "Xman Version 3.1.6 - X11R6." +#define XMAN_VERSION "Xman Version 3.2.0 - X11R6.7.1" Index: xc/programs/xmore/XMore.ad =================================================================== RCS file: /cvs/xorg/xc/programs/xmore/XMore.ad,v retrieving revision 1.2 diff -u -2 -0 -r1.2 XMore.ad --- a/xc/programs/xmore/XMore.ad 30 May 2004 22:44:00 -0000 1.2 +++ b/xc/programs/xmore/XMore.ad 8 Jun 2004 02:41:00 -0000 @@ -18,49 +18,111 @@ *text.baseTranslations: #override\n\ space: next-page()\n\ F: next-page()\n\ CtrlB: previous-page()\n\ K: scroll-one-line-down()\n\ Y: scroll-one-line-down()\n\ Return: scroll-one-line-up()\n\ J: scroll-one-line-up()\n\ E: scroll-one-line-up()\n\ p: print()\n\ q: quit()\n ! tip messages *quit.tip: Quit application *print.tip: Print file ! Use "white" as background for printing *printshell*background: white ! Print dialog -*printdialogshell*geometry: 600x120 -*printdialogshell*setup*geometry: 600x400 -*printdialogshell*printerselection*geometry: 400x150 -*printdialog*main*ok.tip: Print -*printdialog*main*cancel.tip: Cancel printing -*printdialog*main*setup.tip: Configure printer options (page size, orientation, etc.) -*printdialog*main*desclabel.tip: Short description of printer -*printdialog*main*desc.tip: Short description of printer -*printdialog*main*info.tip: Display additional information about this printer -*printdialog*main*namelabel.tip: Name of selected printer -*printdialog*main*name.tip: Name of selected printer -*printdialog*main*selectprinter.tip: Select a different printer -*printdialog*main*filenamelabel.tip: File where the output should be stored -*printdialog*main*filename.tip: File where the output should be stored -*printdialog*main*selectfile.tip: Select file where the output should be stored -*printdialog*main*printtoprinter.tip: Send print job to printer -*printdialog*main*printtofile.tip: Save print job in a file -*printdialog*setup*ok.tip: Commit changes -*printdialog*setup*cancel.tip: Cancel and reset to defaults -*printdialog*setup*paperlist.tip: Select paper size -*printdialog*setup*resolutionlist.tip: Select page resolution -*printdialog*setup*orientationlist.tip: Select page orientation -*printdialog*setup*plexlist.tip: Select page plex mode (simplex, duplex, etc.) -*printdialog*setup*jobcopieslabel.tip: Set number of job copies -*printdialog*setup*jobcopies.tip: Set number of job copies -*printdialog*printerselection*ok.tip: Switch printer -*printdialog*printerselection*cancel.tip: Cancel printer selection -*printdialog*printerselection*list.tip: Select printer name from list +*printdialogshell*geometry: 600x120 +*printdialogshell*title: Print +*printdialogshell*main*ok.fromVert: innerform +*printdialogshell*main*ok.label: Print +*printdialogshell*main*ok.tip: Print +*printdialogshell*main*setup.fromHoriz: ok +*printdialogshell*main*setup.fromVert: innerform +*printdialogshell*main*setup.label: Setup... +*printdialogshell*main*setup.tip: Configure print job options (page size, orientation, etc.) +*printdialogshell*main*cancel.fromHoriz: setup +*printdialogshell*main*cancel.fromVert: innerform +*printdialogshell*main*cancel.label: Cancel +*printdialogshell*main*cancel.tip: Cancel printing +*printdialogshell*main*desclabel.label: Printer Description: +*printdialogshell*main*desclabel.tip: Short description of printer +*printdialogshell*main*desc.fromHoriz: desclabel +*printdialogshell*main*desc.tip: Short description of printer +*printdialogshell*main*info.fromHoriz: desc +*printdialogshell*main*info.label: Printer info... +*printdialogshell*main*info.tip: Display additional information about this printer +*printdialogshell*main*namelabel.fromVert: desclabel +*printdialogshell*main*namelabel.label: Printer Name: +*printdialogshell*main*namelabel.tip: Name of selected printer +*printdialogshell*main*name.fromHoriz: namelabel +*printdialogshell*main*name.fromVert: desclabel +*printdialogshell*main*name.tip: Name of selected printer +*printdialogshell*main*selectprinter.fromHoriz: name +*printdialogshell*main*selectprinter.fromVert: desclabel +*printdialogshell*main*selectprinter.label: Select Printer... +*printdialogshell*main*selectprinter.label: Select Printer... +*printdialogshell*main*selectprinter.tip: Select a different printer +*printdialogshell*main*filenamelabel.fromVert: namelabel +*printdialogshell*main*filenamelabel.label: File Name: +*printdialogshell*main*filenamelabel.tip: File where the output should be stored +*printdialogshell*main*filename.fromHoriz: filenamelabel +*printdialogshell*main*filename.fromVert: namelabel +*printdialogshell*main*filename.tip: File where the output should be stored +*printdialogshell*main*selectfile.fromHoriz: filename +*printdialogshell*main*selectfile.fromVert: namelabel +*printdialogshell*main*selectfile.label: Select File... +*printdialogshell*main*selectfile.tip: Select file where the output should be stored +*printdialogshell*main*printtoprinter.fromVert: filenamelabel +*printdialogshell*main*printtoprinter.label: Print to Printer +*printdialogshell*main*printtoprinter.tip: Send print job to printer +*printdialogshell*main*printtofile.fromVert: filenamelabel +*printdialogshell*main*printtofile.fromHoriz: printtoprinter +*printdialogshell*main*printtofile.label: Print to File +*printdialogshell*main*printtofile.tip: Save print job in a file + +! Print job options dialog +*printdialogshell*setup*geometry: 600x400 +*printdialogshell*setup*title: Print: Print job options +*printdialogshell*setup*ok.fromVert: list +*printdialogshell*setup*ok.label: OK +*printdialogshell*setup*ok.tip: Commit changes +*printdialogshell*setup*cancel.fromHoriz: ok +*printdialogshell*setup*cancel.fromVert: list +*printdialogshell*setup*cancel.label: Cancel +*printdialogshell*setup*cancel.tip: Cancel and reset to defaults +*printdialogshell*setup*paperlist.tip: Select paper size +*printdialogshell*setup*resolutionlist.fromHoriz: paperlist +*printdialogshell*setup*resolutionlist.tip: Select page resolution +*printdialogshell*setup*orientationlist.fromHoriz: resolutionlist +*printdialogshell*setup*orientationlist.tip: Select page orientation +*printdialogshell*setup*plexlist.fromHoriz: orientationlist +*printdialogshell*setup*plexlist.tip: Select page plex mode (simplex, duplex, etc.) +*printdialogshell*setup*jobcopieslabel.fromVert: paperlist +*printdialogshell*setup*jobcopieslabel.tip: Set number of job copies +*printdialogshell*setup*jobcopieslabel.label: Job Copies: +*printdialogshell*setup*jobcopies.fromHoriz: jobcopieslabel +*printdialogshell*setup*jobcopies.fromVert: paperlist +*printdialogshell*setup*jobcopies.tip: Set number of job copies + +! Printer selection +*printdialogshell*printerselection*geometry: 400x150 +*printdialogshell*printerselection*title: Print: Select printer +*printdialogshell*printerselection*ok.fromVert: list +*printdialogshell*printerselection*ok.label: OK +*printdialogshell*printerselection*ok.tip: Switch printer +*printdialogshell*printerselection*cancel.fromHoriz: ok +*printdialogshell*printerselection*cancel.fromVert: list +*printdialogshell*printerselection*cancel.label: Cancel +*printdialogshell*printerselection*cancel.tip: Cancel printer selection +*printdialogshell*printerselection*list.tip: Select printer name from list + +! Select job file +*printdialogshell*selectfile*geometry: 400x80 +*printdialogshell*selectfile*title: Print: Select job file +*printdialogshell*selectfile*dialog.label: Select Filename: + ! EOF. Index: xc/programs/xmore/print.c =================================================================== RCS file: /cvs/xorg/xc/programs/xmore/print.c,v retrieving revision 1.3 diff -u -2 -0 -r1.3 print.c --- a/xc/programs/xmore/print.c 30 May 2004 22:44:01 -0000 1.3 +++ b/xc/programs/xmore/print.c 8 Jun 2004 02:41:00 -0000 @@ -22,42 +22,40 @@ Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. * */ /* Turn a NULL pointer string into an empty string */ #define NULLSTR(x) (((x)!=NULL)?(x):("")) #define Error(x) { printf x ; exit(EXIT_FAILURE); } #define Assertion(expr, msg) { if (!(expr)) { Error msg } } #define Log(x) { if(True) printf x; } #include "print.h" #include #include #include #include #include -#define PRINT_PAGEHEADER 1 - static Widget CreatePrintShell(Widget videoshell, Screen *pscreen, String printshell_name, ArgList args, Cardinal numargs) { String videoname, videoclass; Widget pappshell, printshell; Display *pdpy = XDisplayOfScreen(pscreen); int dummyc = 0; String dummys = ""; XtGetApplicationNameAndClass(XtDisplay(videoshell), &videoname, &videoclass); /* XXX: Why is the |dummyc|&&|dummys| stuff needed here ? */ XtDisplayInitialize(XtWidgetToApplicationContext(videoshell), pdpy, videoname, videoclass, @@ -114,74 +112,63 @@ { long numpages = 0; XawTextPosition prevpagepos = -1, currpos = 0; /* Move to the top of the file... */ XtCallActionProc(textWidget, "beginning-of-file", NULL, NULL, 0); /* ... count pages ...*/ do { prevpagepos = XawTextTopPosition(textWidget); XtCallActionProc(textWidget, "next-page", NULL, NULL, 0); currpos = XawTextTopPosition(textWidget); numpages++; } while(prevpagepos != currpos); /* ... and move to the top of the file... */ XtCallActionProc(textWidget, "beginning-of-file", NULL, NULL, 0); - - return numpages; -} - -static -int GetCurrPageNum(Widget printshell) -{ - Cardinal n; - Arg args[2]; - int pagenum = -666; /* bah! */ - n = 0; - XtSetArg(args[n], XawNcurrPageNumInJob, &pagenum); n++; - XtGetValues(printshell, args, n); + Log(("CountPages() found %ld pages.\n", numpages)) - return pagenum; + return numpages; } static void PageSetupCB(Widget widget, XtPointer client_data, XtPointer call_data) { Widget pshell = widget; XawPrintShellCallbackStruct *psp = (XawPrintShellCallbackStruct *)call_data; AppPrintData *p = (AppPrintData *)client_data; Log(("--> PageSetupCB\n")); if (!psp->last_page_in_job) { - int currpage = GetCurrPageNum(pshell); -#ifdef PRINT_PAGEHEADER - char buffer[256]; + int currpage; + char buffer[256]; + + XtVaGetValues(pshell, XawNcurrPageNumInJob, &currpage, NULL); + sprintf(buffer, "Title: %s / Page: %d/%d", p->jobtitle, currpage, p->numpages); XtVaSetValues(apd->content.pageheaderlabel, XtNlabel, buffer, NULL); -#endif /* PRINT_PAGEHEADER */ /* Note: XawPrintShell's pagecount starts with '1' * (=first page is page no. '1') */ if (currpage > 1) { Log(("pagedown %d\n", currpage)); XtCallActionProc(p->content.text, "next-page", NULL, NULL, 0); } else { Log(("first page\n")); } if (currpage >= p->numpages) { psp->last_page_in_job = True; } } } static void FinishPrinting(AppPrintData *p) @@ -196,81 +183,87 @@ if (p->printshell) { XtDestroyWidget(p->printshell); p->printshell = NULL; } /* Two issues here: * 1. The print display connection is owned by the print dialog * To avoid any problems with that use a callback back to the main * application which calls * |XawPrintDialogClosePrinterConnection(w, False)| to ask the * print dialog widget to close all print display resources and * disown the object. * 2. We have to use XpDestroyContext() and XtCloseDisplay() * instead of XpuClosePrinterDisplay() to make libXt happy... * * Call callback... */ (*apd->pdpyDestroyCallback)(NULL, NULL, NULL); /* HACK! */ /* ... and then get rid of the display */ if (p->pcontext != None) { - XpDestroyContext(p->pdpy, p->pcontext); + XpDestroyContext(p->pdpy, p->pcontext); } XtCloseDisplay(p->pdpy); p->toplevel = NULL; p->isPrinting = False; p->pdpy = NULL; p->pscreen = NULL; p->pcontext = None; } static void PrintEndJobCB(Widget pshell, XtPointer client_data, XtPointer call_data) { AppPrintData *p = (AppPrintData *)client_data; Log(("--> PrintEndJobCB\n")); /* Finish printing and destroy print shell (it's legal to destroy Xt * widgets from within it's own callbacks) */ FinishPrinting(p); } static XFontSet GetPrintTextFontSet(const char *appname, Display *pdpy, long dpi) { XFontSet fontset; char fontname[1024]; char **missing_charset_list_return; int missing_charset_count_return; char *def_string_return; int i; - long font_size; - - /* Scale font size with DPI */ - font_size = (40L * dpi) / 300L; - sprintf(fontname, "-adobe-courier-medium-r-normal--%ld-*-%ld-%ld-*-*," - "-*-*-*-*-*-*-%ld-*-%ld-%ld-*-*", - font_size, dpi, dpi, - font_size, dpi, dpi); + sprintf(fontname, /* Default font for CDE */ + "-dt-interface user-medium-r-normal-s*-*-120-%ld-%ld-*-*," + /* Default font */ + "-adobe-courier-medium-r-normal--*-120-%ld-%ld-*-*," + /* Default font for Linux/Japanese locales (ja_JP.SJIS) */ + "-watanabe-mincho-medium-r-normal--*-120-%ld-%ld-*-*," + "-wadalab-gothic-medium-r-normal--*-120-%ld-%ld-*-*," + /* Fallback */ + "-*-*-*-*-*--*-120-%ld-%ld-*-*", + dpi, dpi, + dpi, dpi, + dpi, dpi, + dpi, dpi, + dpi, dpi); fontset = XCreateFontSet(pdpy, fontname, &missing_charset_list_return, &missing_charset_count_return, &def_string_return); for( i=0 ; i < missing_charset_count_return ; i++ ) { fprintf(stderr, "%s: warning: font for charset %s is lacking.\n", appname, missing_charset_list_return[i]); } if (!fontset) Error(("GetPrintTextFontSet: XCreateFontSet() failure.\n")); return fontset; } void DoPrintTextSource(const char *programname, Widget textsource, Widget toplevel, Display *pdpy, XPContext pcontext, XtCallbackProc pdpyDestroyCB, const char *jobtitle, const char *toFile) @@ -305,53 +298,51 @@ return; } apd->toplevel = toplevel; apd->pdpy = pdpy; apd->pcontext = pcontext; apd->pscreen = XpGetScreenOfContext(pdpy, pcontext); apd->jobtitle = jobtitle; n = 0; XtSetArg(args[n], XawNlayoutMode, XawPrintLAYOUTMODE_DRAWABLEAREA); n++; apd->printshell = CreatePrintShell(toplevel, apd->pscreen, "printshell", args, n); n = 0; XtSetArg(args[n], XtNresizable, True); n++; XtSetArg(args[n], XtNright, XtChainRight); n++; apd->content.form = XtCreateManagedWidget("form", formWidgetClass, apd->printshell, args, n); textfontset = GetPrintTextFontSet(apd->programname, pdpy, dpi); -#ifdef PRINT_PAGEHEADER n = 0; XtSetArg(args[n], XtNinternational, True); n++; XtSetArg(args[n], XtNfromHoriz, NULL); n++; XtSetArg(args[n], XtNfromVert, NULL); n++; XtSetArg(args[n], XtNtop, XtChainTop); n++; XtSetArg(args[n], XtNright, XtChainRight); n++; XtSetArg(args[n], XtNresizable, True); n++; XtSetArg(args[n], XtNfontSet, textfontset); n++; XtSetArg(args[n], XtNlabel, "Page: n/n"); n++; XtSetArg(args[n], XtNjustify, XtJustifyRight); n++; apd->content.pageheaderlabel = XtCreateManagedWidget("pageinfo", labelWidgetClass, apd->content.form, args, n); -#endif /* PRINT_PAGEHEADER */ font_extents = XExtentsOfFontSet(textfontset); n = 0; XtSetArg(args[n], XtNinternational, True); n++; XtSetArg(args[n], XtNtextSource, textsource); n++; XtSetArg(args[n], XtNscrollHorizontal, XawtextScrollNever); n++; XtSetArg(args[n], XtNscrollVertical, XawtextScrollNever); n++; /* Usually I would expect that using |XtNfromVert, apd->content.pageheaderlabel| * would be the correct way to place the text widget with the main content below * the page header widget - but for an unknown reason this doesn not work: The * text widget squishes itself into the bottom half of the page and only occupies * 1/2 of the page's with... ;-(( */ #define WORKAROUND_FOR_SOMETHING_IS_WRONG 1 #ifdef WORKAROUND_FOR_SOMETHING_IS_WRONG XtSetArg(args[n], XtNtop, XtChainTop); n++; XtSetArg(args[n], XtNright, XtChainRight); n++; XtSetArg(args[n], XtNvertDistance, (font_extents->max_logical_extent.height+2)*2); n++; #else Index: xc/programs/xmore/printdialog.c =================================================================== RCS file: /cvs/xorg/xc/programs/xmore/printdialog.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 printdialog.c --- a/xc/programs/xmore/printdialog.c 30 May 2004 00:52:30 -0000 1.2 +++ b/xc/programs/xmore/printdialog.c 8 Jun 2004 02:41:00 -0000 @@ -36,41 +36,45 @@ #include #include #include #include #include #include #include "printdialog.h" #include "printdialogprivates.h" #include "print.h" #include #include #include /* Turn a NULL pointer string into an empty string */ #define NULLSTR(x) (((x)!=NULL)?(x):("")) #define Error(x) { printf x ; exit(EXIT_FAILURE); } #define Assertion(expr, msg) { if (!(expr)) { Error msg } } -#define Log(x) { if(True) printf x; } +#ifdef DEBUG +# define Log(x) { if(True) printf x; } +#else +# define Log(x) { if(False) printf x; } +#endif /* DEBUG */ /* Local prototypes */ static void do_beep(PrintDialogWidget pdw); static void center_popup(Widget parent, Widget popup); static void updateWidgetStates(PrintDialogWidget pdw); static void printSetupClose(PrintDialogWidget pdw); static void printSetupOKXtProc(Widget w, XtPointer client_data, XtPointer callData); static void printSetupCancelXtProc(Widget w, XtPointer client_data, XtPointer callData); static void printSetupJobCopiesXtProc(Widget w, XtPointer client_data, XtPointer callData); static void printDialogDestXtProc(Widget w, XtPointer client_data, XtPointer callData); static void printSelectFileXtProc(Widget w, XtPointer client_data, XtPointer callData); static void printOKXtProc(Widget w, XtPointer client_data, XtPointer callData); static void printSetupXtProc(Widget w, XtPointer client_data, XtPointer callData); static void printFileSelectedXtProc(Widget w, XtPointer client_data, XtPointer callData); static void buildFileDialog(PrintDialogWidget pdw); static void closePrinterConnection(PrintDialogWidget pdw, Bool closeDisplay); static Bool openPrinterConnection(PrintDialogWidget pdw); static void destroyPrintSetupDialog(PrintDialogWidget pdw); static Widget buildPrintSetupDialog(PrintDialogWidget pdw); static String *xpprinterlist_to_widget_printerlist(XPPrinterList printerlist, int num_printers); @@ -287,60 +291,60 @@ isValidNumber = False; } if (!isValidNumber) { do_beep(pdw); XtVaSetValues(pdp->setup.jobcopies, XtNstring, "1", NULL); Log(("## printSetupJobCopiesXtProc: not a valid number\n")); } } } static void printCancelXtProc(Widget w, XtPointer client_data, XtPointer callData) { PrintDialogWidget pdw = (PrintDialogWidget)client_data; PrintDialogPart *pdp = &pdw->printdialog; printSetupClose(pdw); if (pdp->cancel_callback) { - Log(("printCancelXtProc: calling callback")); + Log(("printCancelXtProc: calling callback\n")); XtCallCallbackList((Widget)pdw, pdp->cancel_callback, NULL); } } static void printDialogDestXtProc(Widget w, XtPointer client_data, XtPointer callData) { PrintDialogWidget pdw = (PrintDialogWidget)client_data; PrintDialogPart *pdp = &pdw->printdialog; if (w == pdp->main.printtoprinter) { pdp->printToFile = False; } else if (w == pdp->main.printtofile) { pdp->printToFile = True; } else { - Log(("printDialogDestXtProc: ERROR: Unknown widget.")); + Log(("printDialogDestXtProc: ERROR: Unknown widget.\n")); } updateWidgetStates(pdw); } static void printSelectFileXtProc(Widget w, XtPointer client_data, XtPointer callData) { PrintDialogWidget pdw = (PrintDialogWidget)client_data; PrintDialogPart *pdp = &pdw->printdialog; Log(("## printSelectFileXtProc!\n")); if (!pdp->selectFile.shell) { buildFileDialog(pdw); } center_popup((Widget)pdw, pdp->selectFile.shell); XtPopup(pdp->selectFile.shell, XtGrabExclusive); @@ -413,41 +417,40 @@ free(pdp->filename); pdp->filename = strdup(filename); XtPopdown(pdp->selectFile.shell); updateWidgetStates(pdw); } static void buildFileDialog(PrintDialogWidget pdw) { PrintDialogPart *pdp = &pdw->printdialog; int n; Arg args[20]; pdp->selectFile.shell = XtCreatePopupShell("selectfile", transientShellWidgetClass, (Widget)pdw, NULL, 0); n = 0; XtSetArg(args[n], XtNvalue, pdp->filename?pdp->filename:""); n++; - XtSetArg(args[n], XtNlabel, "Select Filename:"); n++; pdp->selectFile.dialog = XtCreateManagedWidget("dialog", dialogWidgetClass, pdp->selectFile.shell, args, n); XawDialogAddButton(pdp->selectFile.dialog, "Accept", printFileSelectedXtProc, pdw); XtRealizeWidget(pdp->selectFile.shell); } static void closePrinterConnection(PrintDialogWidget pdw, Bool closeDisplay) { PrintDialogPart *pdp = &pdw->printdialog; Log(("# closePrinterConnection\n")); destroyPrintSetupDialog(pdw); if (pdp->paperlist) { XpuFreeMediumSourceSizeList(pdp->paperlist); pdp->paperlist = NULL; } @@ -592,112 +595,93 @@ canChangeJobCopies = (jobflags & XPUATTRIBUTESUPPORTED_COPY_COUNT) == XPUATTRIBUTESUPPORTED_COPY_COUNT; canChangePaperSize = (docflags & XPUATTRIBUTESUPPORTED_DEFAULT_MEDIUM) == XPUATTRIBUTESUPPORTED_DEFAULT_MEDIUM; canChangeResolution = (docflags & XPUATTRIBUTESUPPORTED_DEFAULT_PRINTER_RESOLUTION) == XPUATTRIBUTESUPPORTED_DEFAULT_PRINTER_RESOLUTION; canChangeOrientation = (docflags & XPUATTRIBUTESUPPORTED_CONTENT_ORIENTATION) == XPUATTRIBUTESUPPORTED_CONTENT_ORIENTATION; canChangePlex = (docflags & XPUATTRIBUTESUPPORTED_PLEX) == XPUATTRIBUTESUPPORTED_PLEX; n = 0; XtSetArg(args[n], XtNallowShellResize, True); n++; pdp->setup.popup = XtCreatePopupShell("setup", transientShellWidgetClass, (Widget)pdw, args, n); n = 0; pdp->setup.form = XtCreateManagedWidget("form", formWidgetClass, pdp->setup.popup, args, n); n = 0; listform = XtCreateManagedWidget("list", formWidgetClass, pdp->setup.form, args, n); n = 0; XtSetArg(args[n], XtNresizable, True); n++; XtSetArg(args[n], XtNforceColumns, True); n++; XtSetArg(args[n], XtNdefaultColumns, 1); n++; - XtSetArg(args[n], XtNfromHoriz, NULL); n++; - XtSetArg(args[n], XtNfromVert, NULL); n++; XtSetArg(args[n], XtNsensitive, canChangePaperSize); n++; XtSetArg(args[n], XtNlist, pdp->widget_paperlist); n++; XtSetArg(args[n], XtNwidth, DEFAULT_WIDTH); n++; pdp->setup.paperlist = XtCreateManagedWidget("paperlist", listWidgetClass, listform, args, n); n = 0; XtSetArg(args[n], XtNresizable, True); n++; XtSetArg(args[n], XtNforceColumns, True); n++; XtSetArg(args[n], XtNdefaultColumns, 1); n++; - XtSetArg(args[n], XtNfromHoriz, pdp->setup.paperlist); n++; - XtSetArg(args[n], XtNfromVert, NULL); n++; XtSetArg(args[n], XtNsensitive, canChangeResolution); n++; XtSetArg(args[n], XtNlist, pdp->widget_resolutionlist); n++; XtSetArg(args[n], XtNwidth, DEFAULT_WIDTH); n++; pdp->setup.resolutionlist = XtCreateManagedWidget("resolutionlist", listWidgetClass, listform, args, n); n = 0; XtSetArg(args[n], XtNresizable, True); n++; XtSetArg(args[n], XtNforceColumns, True); n++; XtSetArg(args[n], XtNdefaultColumns, 1); n++; - XtSetArg(args[n], XtNfromHoriz, pdp->setup.resolutionlist); n++; - XtSetArg(args[n], XtNfromVert, NULL); n++; XtSetArg(args[n], XtNsensitive, canChangeOrientation); n++; XtSetArg(args[n], XtNlist, pdp->widget_orientationlist); n++; XtSetArg(args[n], XtNwidth, DEFAULT_WIDTH); n++; pdp->setup.orientationlist = XtCreateManagedWidget("orientationlist", listWidgetClass, listform, args, n); n = 0; XtSetArg(args[n], XtNresizable, True); n++; XtSetArg(args[n], XtNforceColumns, True); n++; XtSetArg(args[n], XtNdefaultColumns, 1); n++; - XtSetArg(args[n], XtNfromHoriz, pdp->setup.orientationlist); n++; - XtSetArg(args[n], XtNfromVert, NULL); n++; XtSetArg(args[n], XtNsensitive, canChangePlex); n++; XtSetArg(args[n], XtNlist, pdp->widget_plexlist); n++; XtSetArg(args[n], XtNwidth, DEFAULT_WIDTH); n++; pdp->setup.plexlist = XtCreateManagedWidget("plexlist", listWidgetClass, listform, args, n); n = 0; - XtSetArg(args[n], XtNfromHoriz, NULL); n++; - XtSetArg(args[n], XtNfromVert, pdp->setup.paperlist); n++; XtSetArg(args[n], XtNborderWidth, 0); n++; XtSetArg(args[n], XtNresizable, False); n++; XtSetArg(args[n], XtNjustify, XtJustifyRight); n++; XtSetArg(args[n], XtNwidth, DEFAULT_WIDTH); n++; - XtSetArg(args[n], XtNlabel, "Job Copies:"); n++; XtSetArg(args[n], XtNsensitive, canChangeJobCopies); n++; pdp->setup.jobcopieslabel = XtCreateManagedWidget("jobcopieslabel", labelWidgetClass, listform, args, n); n = 0; - XtSetArg(args[n], XtNfromHoriz, pdp->setup.jobcopieslabel); n++; - XtSetArg(args[n], XtNfromVert, pdp->setup.paperlist); n++; XtSetArg(args[n], XtNstring, "1"); n++; XtSetArg(args[n], XtNresizable, True); n++; XtSetArg(args[n], XtNeditType, XawtextEdit); n++; XtSetArg(args[n], XtNsensitive, canChangeJobCopies); n++; pdp->setup.jobcopies = XtCreateManagedWidget("jobcopies", asciiTextWidgetClass, listform, args, n); XtAddCallback(pdp->setup.jobcopies, XtNpositionCallback, printSetupJobCopiesXtProc, pdw); n = 0; - XtSetArg(args[n], XtNfromHoriz, NULL); n++; - XtSetArg(args[n], XtNfromVert, listform); n++; - XtSetArg(args[n], XtNlabel, "OK"); n++; pdp->setup.ok = XtCreateManagedWidget("ok", commandWidgetClass, pdp->setup.form, args, n); XtAddCallback(pdp->setup.ok, XtNcallback, printSetupOKXtProc, pdw); n = 0; - XtSetArg(args[n], XtNfromHoriz, pdp->setup.ok); n++; - XtSetArg(args[n], XtNfromVert, listform); n++; - XtSetArg(args[n], XtNlabel, "Cancel"); n++; pdp->setup.cancel = XtCreateManagedWidget("cancel", commandWidgetClass, pdp->setup.form, args, n); XtAddCallback(pdp->setup.cancel, XtNcallback, printSetupCancelXtProc, pdw); XtRealizeWidget(pdp->setup.popup); return pdp->setup.popup; } #undef DEFAULT_WIDTH #define DEFAULT_WIDTH 150 static String *xpprinterlist_to_widget_printerlist(XPPrinterList printerlist, int num_printers) { int i; String *names; names = malloc(sizeof(String *) * (num_printers+1)); if(!names) return NULL; @@ -788,41 +772,41 @@ for(i = 0 ; i < num_plex ; i++) names[i] = (char *)plexlist[i].plex; names[i] = NULL; /* Terminate the list */ return names; } static void printerSelectionPrinterSelectedXtProc(Widget w, XtPointer client_data, XtPointer callData) { PrintDialogWidget pdw = (PrintDialogWidget)client_data; PrintDialogPart *pdp = &pdw->printdialog; XawListReturnStruct *lrs = (XawListReturnStruct *)callData; int list_index; Log(("## user selected a printer\n")); list_index = lrs->list_index; if (list_index == XAW_LIST_NONE) { - Log(("printerSelectionPrinterSelectedXtProc: Nothing selected.")); + Log(("printerSelectionPrinterSelectedXtProc: Nothing selected.\n")); return; } Log(("selected printer is '%d'/'%s'/'%s'\n", list_index, lrs->string, NULLSTR(pdp->printerlist[list_index].name))); /* Enable OK button */ XtVaSetValues(pdp->selectPrinter.ok, XtNsensitive, True, NULL); } static void printSelectPrinterXtProc(Widget w, XtPointer client_data, XtPointer callData) { PrintDialogWidget pdw = (PrintDialogWidget)client_data; PrintDialogPart *pdp = &pdw->printdialog; Log(("## select printer!\n")); if (!pdp->selectPrinter.popup) { if (!buildPrinterSelectionDialog(pdw)) { @@ -898,59 +882,51 @@ static Bool buildPrinterSelectionDialog(PrintDialogWidget pdw) { PrintDialogPart *pdp = &pdw->printdialog; int n; Arg args[20]; n = 0; XtSetArg(args[n], XtNallowShellResize, True); n++; pdp->selectPrinter.popup = XtCreatePopupShell("printerselection", transientShellWidgetClass, (Widget)pdw, args, n); n = 0; pdp->selectPrinter.form = XtCreateManagedWidget("form", formWidgetClass, pdp->selectPrinter.popup, args, n); n = 0; XtSetArg(args[n], XtNresizable, True); n++; XtSetArg(args[n], XtNforceColumns, True); n++; XtSetArg(args[n], XtNdefaultColumns, 1); n++; - XtSetArg(args[n], XtNfromHoriz, NULL); n++; - XtSetArg(args[n], XtNfromVert, NULL); n++; XtSetArg(args[n], XtNlist, pdp->widget_printerlist); n++; XtSetArg(args[n], XtNwidth, DEFAULT_WIDTH); n++; pdp->selectPrinter.list = XtCreateManagedWidget("list", listWidgetClass, pdp->selectPrinter.form, args, n); XtAddCallback(pdp->selectPrinter.list, XtNcallback, printerSelectionPrinterSelectedXtProc, pdw); n = 0; - XtSetArg(args[n], XtNfromHoriz, NULL); n++; - XtSetArg(args[n], XtNfromVert, pdp->selectPrinter.list); n++; - XtSetArg(args[n], XtNlabel, "OK"); n++; XtSetArg(args[n], XtNsensitive, False); n++; pdp->selectPrinter.ok = XtCreateManagedWidget("ok", commandWidgetClass, pdp->selectPrinter.form, args, n); XtAddCallback(pdp->selectPrinter.ok, XtNcallback, printerSelectionOKXtProc, pdw); n = 0; - XtSetArg(args[n], XtNfromHoriz, pdp->selectPrinter.ok); n++; - XtSetArg(args[n], XtNfromVert, pdp->selectPrinter.list); n++; - XtSetArg(args[n], XtNlabel, "Cancel"); n++; pdp->selectPrinter.cancel = XtCreateManagedWidget("cancel", commandWidgetClass, pdp->selectPrinter.form, args, n); XtAddCallback(pdp->selectPrinter.cancel, XtNcallback, printerSelectionCancelXtProc, pdw); XtRealizeWidget(pdp->selectPrinter.popup); return True; } static void destroyPrinterSelectionDialog(PrintDialogWidget pdw) { PrintDialogPart *pdp = &pdw->printdialog; if (pdp->selectPrinter.popup) { XtDestroyWidget(pdp->selectPrinter.popup); } /* |XtDestroyWidget(pdp->setup.popup);| above will recursively destroy * all children so we only have to reset the pointers here... */ pdp->selectPrinter.popup = NULL; @@ -988,166 +964,127 @@ pdp->widget_printerlist = xpprinterlist_to_widget_printerlist(pdp->printerlist, pdp->num_printers); if (pdp->num_printers > 0) { if (pdp->printerlist[0].name && strlen(pdp->printerlist[0].name)) { /* XprintUtils moves the default printer to the top */ default_printername = pdp->printerlist[0].name; default_printerdesc = pdp->printerlist[0].desc; pdp->printer_name = strdup(pdp->printerlist[0].name); has_default_printer = True; } } n = 0; XtSetArg(args[n], XtNborderWidth, 0); n++; pdp->main.form = XtCreateManagedWidget("main", formWidgetClass, (Widget)pdw, args, n); n = 0; pdp->main.innerform = XtCreateManagedWidget("innerform", formWidgetClass, pdp->main.form, args, n); n = 0; - XtSetArg(args[n], XtNfromHoriz, NULL); n++; - XtSetArg(args[n], XtNfromVert, NULL); n++; XtSetArg(args[n], XtNborderWidth, 0); n++; XtSetArg(args[n], XtNresizable, False); n++; XtSetArg(args[n], XtNjustify, XtJustifyRight); n++; XtSetArg(args[n], XtNwidth, DEFAULT_WIDTH); n++; - XtSetArg(args[n], XtNlabel, "Printer Description:"); n++; pdp->main.desclabel = XtCreateManagedWidget("desclabel", labelWidgetClass, pdp->main.innerform, args, n); n = 0; - XtSetArg(args[n], XtNfromHoriz, pdp->main.desclabel); n++; - XtSetArg(args[n], XtNfromVert, NULL); n++; XtSetArg(args[n], XtNborderWidth, 0); n++; XtSetArg(args[n], XtNresizable, False); n++; XtSetArg(args[n], XtNjustify, XtJustifyLeft); n++; XtSetArg(args[n], XtNwidth, DEFAULT_INFOLABEL_WIDTH); n++; XtSetArg(args[n], XtNlabel, default_printerdesc?default_printerdesc:"-"); n++; pdp->main.desc = XtCreateManagedWidget("desc", labelWidgetClass, pdp->main.innerform, args, n); n = 0; - XtSetArg(args[n], XtNfromHoriz, pdp->main.desc); n++; - XtSetArg(args[n], XtNfromVert, NULL); n++; XtSetArg(args[n], XtNsensitive, has_default_printer); n++; - XtSetArg(args[n], XtNlabel, "Printer info..."); n++; pdp->main.info = XtCreateManagedWidget("info", commandWidgetClass, pdp->main.innerform, args, n); /* XtAddCallback(pdp->main.info, XtNcallback, printerInfoXtProc, pdw); */ n = 0; - XtSetArg(args[n], XtNfromHoriz, NULL); n++; - XtSetArg(args[n], XtNfromVert, pdp->main.desclabel); n++; XtSetArg(args[n], XtNborderWidth, 0); n++; XtSetArg(args[n], XtNresizable, False); n++; XtSetArg(args[n], XtNjustify, XtJustifyRight); n++; XtSetArg(args[n], XtNwidth, DEFAULT_WIDTH); n++; - XtSetArg(args[n], XtNlabel, "Printer Name:"); n++; pdp->main.namelabel = XtCreateManagedWidget("namelabel", labelWidgetClass, pdp->main.innerform, args, n); n = 0; - XtSetArg(args[n], XtNfromHoriz, pdp->main.namelabel); n++; - XtSetArg(args[n], XtNfromVert, pdp->main.desclabel); n++; XtSetArg(args[n], XtNborderWidth, 0); n++; XtSetArg(args[n], XtNresizable, False); n++; XtSetArg(args[n], XtNjustify, XtJustifyLeft); n++; XtSetArg(args[n], XtNlabel, default_printername?default_printername:"-"); n++; XtSetArg(args[n], XtNwidth, DEFAULT_INFOLABEL_WIDTH); n++; pdp->main.name = XtCreateManagedWidget("name", labelWidgetClass, pdp->main.innerform, args, n); n = 0; - XtSetArg(args[n], XtNfromHoriz, pdp->main.name); n++; - XtSetArg(args[n], XtNfromVert, pdp->main.desclabel); n++; - XtSetArg(args[n], XtNlabel, "Select Printer..."); n++; pdp->main.selectprinter = XtCreateManagedWidget("selectprinter", commandWidgetClass, pdp->main.innerform, args, n); XtAddCallback(pdp->main.selectprinter, XtNcallback, printSelectPrinterXtProc, pdw); /* Line: "File selection" */ n = 0; - XtSetArg(args[n], XtNfromHoriz, NULL); n++; - XtSetArg(args[n], XtNfromVert, pdp->main.namelabel); n++; XtSetArg(args[n], XtNborderWidth, 0); n++; XtSetArg(args[n], XtNresizable, False); n++; XtSetArg(args[n], XtNjustify, XtJustifyRight); n++; XtSetArg(args[n], XtNwidth, DEFAULT_WIDTH); n++; - XtSetArg(args[n], XtNlabel, "File Name:"); n++; XtSetArg(args[n], XtNsensitive, False); n++; pdp->main.filenamelabel = XtCreateManagedWidget("filenamelabel", labelWidgetClass, pdp->main.innerform, args, n); n = 0; - XtSetArg(args[n], XtNfromHoriz, pdp->main.filenamelabel); n++; - XtSetArg(args[n], XtNfromVert, pdp->main.namelabel); n++; XtSetArg(args[n], XtNborderWidth, 0); n++; XtSetArg(args[n], XtNresizable, False); n++; XtSetArg(args[n], XtNjustify, XtJustifyLeft); n++; XtSetArg(args[n], XtNlabel, "-"); n++; XtSetArg(args[n], XtNwidth, DEFAULT_INFOLABEL_WIDTH); n++; XtSetArg(args[n], XtNsensitive, False); n++; pdp->main.filename = XtCreateManagedWidget("filename", labelWidgetClass, pdp->main.innerform, args, n); n = 0; - XtSetArg(args[n], XtNfromHoriz, pdp->main.filename); n++; - XtSetArg(args[n], XtNfromVert, pdp->main.namelabel); n++; XtSetArg(args[n], XtNsensitive, False); n++; - XtSetArg(args[n], XtNlabel, "Select File..."); n++; pdp->main.selectfile = XtCreateManagedWidget("selectfile", commandWidgetClass, pdp->main.innerform, args, n); XtAddCallback(pdp->main.selectfile, XtNcallback, printSelectFileXtProc, pdw); /* Line: Misc (Print destination toggles, copy-count etc.)*/ n = 0; - XtSetArg(args[n], XtNfromHoriz, NULL); n++; - XtSetArg(args[n], XtNfromVert, pdp->main.filenamelabel); n++; - XtSetArg(args[n], XtNlabel, "Print to Printer"); n++; XtSetArg(args[n], XtNstate, True); n++; pdp->main.printtoprinter = XtCreateManagedWidget("printtoprinter", toggleWidgetClass, pdp->main.innerform, args, n); XtAddCallback(pdp->main.printtoprinter, XtNcallback, printDialogDestXtProc, pdw); n = 0; - XtSetArg(args[n], XtNfromHoriz, pdp->main.printtoprinter); n++; - XtSetArg(args[n], XtNfromVert, pdp->main.filenamelabel); n++; - XtSetArg(args[n], XtNlabel, "Print to File"); n++; XtSetArg(args[n], XtNstate, False); n++; pdp->main.printtofile = XtCreateManagedWidget("printtofile", toggleWidgetClass, pdp->main.innerform, args, n); XtAddCallback(pdp->main.printtofile, XtNcallback, printDialogDestXtProc, pdw); /* End-of-Inner-Form-Content */ n = 0; - XtSetArg(args[n], XtNfromHoriz, NULL); n++; - XtSetArg(args[n], XtNfromVert, pdp->main.innerform); n++; - XtSetArg(args[n], XtNlabel, "Print"); n++; XtSetArg(args[n], XtNsensitive, has_default_printer); n++; pdp->main.ok = XtCreateManagedWidget("ok", commandWidgetClass, pdp->main.form, args, n); XtAddCallback(pdp->main.ok, XtNcallback, printOKXtProc, pdw); n = 0; - XtSetArg(args[n], XtNfromHoriz, pdp->main.ok); n++; - XtSetArg(args[n], XtNfromVert, pdp->main.innerform); n++; - XtSetArg(args[n], XtNlabel, "Setup..."); n++; XtSetArg(args[n], XtNsensitive, has_default_printer); n++; pdp->main.setup = XtCreateManagedWidget("setup", commandWidgetClass, pdp->main.form, args, n); XtAddCallback(pdp->main.setup, XtNcallback, printSetupXtProc, pdw); n = 0; - XtSetArg(args[n], XtNfromHoriz, pdp->main.setup); n++; - XtSetArg(args[n], XtNfromVert, pdp->main.innerform); n++; - XtSetArg(args[n], XtNlabel, "Cancel"); n++; pdp->main.cancel = XtCreateManagedWidget("cancel", commandWidgetClass, pdp->main.form, args, n); XtAddCallback(pdp->main.cancel, XtNcallback, printCancelXtProc, pdw); } /* * Class Methods */ static void XawPrintDialogConstraintInitialize(Widget, Widget, ArgList, Cardinal *); static void XawPrintDialogGetValuesHook(Widget, ArgList, Cardinal*); static void XawPrintDialogInitialize(Widget, Widget, ArgList, Cardinal*); static void XawPrintDialogDestroy(Widget); static Boolean XawPrintDialogSetValues(Widget, Widget, Widget, ArgList, Cardinal *); /* * Initialization */ static XtResource resources[] = { { XtNicon, XtCIcon,