diff options
author | Roland Mainz <roland.mainz@nrubsig.org> | 2004-06-08 02:44:35 +0000 |
---|---|---|
committer | Roland Mainz <roland.mainz@nrubsig.org> | 2004-06-08 02:44:35 +0000 |
commit | d88d25361d5c03e126f040d08c4e005494ca9bfe (patch) | |
tree | 117f980abbf1a0e28ce076d40c4b9d9e7ab0f4ab | |
parent | cf44083fa20c4f39a89a63ced16974c832039325 (diff) |
Fix for http://freedesktop.org/bugzilla/show_bug.cgi?id=668 - Add print
support to xman
-rw-r--r-- | print.c | 53 | ||||
-rw-r--r-- | printdialog.c | 79 |
2 files changed, 30 insertions, 102 deletions
@@ -39,8 +39,6 @@ in this Software without prior written authorization from The Open Group. #include <stdio.h> #include <stdlib.h> -#define PRINT_PAGEHEADER 1 - static Widget CreatePrintShell(Widget videoshell, Screen *pscreen, @@ -131,22 +129,10 @@ long CountPages(Widget textWidget) /* ... 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 @@ -159,12 +145,13 @@ PageSetupCB(Widget widget, XtPointer client_data, XtPointer call_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') */ @@ -213,7 +200,7 @@ void FinishPrinting(AppPrintData *p) /* ... and then get rid of the display */ if (p->pcontext != None) { - XpDestroyContext(p->pdpy, p->pcontext); + XpDestroyContext(p->pdpy, p->pcontext); } XtCloseDisplay(p->pdpy); @@ -245,15 +232,21 @@ XFontSet GetPrintTextFontSet(const char *appname, Display *pdpy, long dpi) 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, @@ -322,7 +315,6 @@ void DoPrintTextSource(const char *programname, textfontset = GetPrintTextFontSet(apd->programname, pdpy, dpi); -#ifdef PRINT_PAGEHEADER n = 0; XtSetArg(args[n], XtNinternational, True); n++; XtSetArg(args[n], XtNfromHoriz, NULL); n++; @@ -334,7 +326,6 @@ void DoPrintTextSource(const char *programname, 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); diff --git a/printdialog.c b/printdialog.c index 8d31020..615734f 100644 --- a/printdialog.c +++ b/printdialog.c @@ -53,7 +53,11 @@ in this Software without prior written authorization from The Open Group. #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); @@ -304,7 +308,7 @@ printCancelXtProc(Widget w, XtPointer client_data, XtPointer callData) printSetupClose(pdw); if (pdp->cancel_callback) { - Log(("printCancelXtProc: calling callback")); + Log(("printCancelXtProc: calling callback\n")); XtCallCallbackList((Widget)pdw, pdp->cancel_callback, NULL); } } @@ -323,7 +327,7 @@ printDialogDestXtProc(Widget w, XtPointer client_data, XtPointer callData) } else { - Log(("printDialogDestXtProc: ERROR: Unknown widget.")); + Log(("printDialogDestXtProc: ERROR: Unknown widget.\n")); } updateWidgetStates(pdw); @@ -430,7 +434,6 @@ void buildFileDialog(PrintDialogWidget pdw) (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); @@ -609,8 +612,6 @@ Widget buildPrintSetupDialog(PrintDialogWidget pdw) 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++; @@ -620,8 +621,6 @@ Widget buildPrintSetupDialog(PrintDialogWidget pdw) 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++; @@ -631,8 +630,6 @@ Widget buildPrintSetupDialog(PrintDialogWidget pdw) 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++; @@ -642,27 +639,20 @@ Widget buildPrintSetupDialog(PrintDialogWidget pdw) 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++; @@ -671,16 +661,10 @@ Widget buildPrintSetupDialog(PrintDialogWidget pdw) 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); @@ -805,7 +789,7 @@ printerSelectionPrinterSelectedXtProc(Widget w, XtPointer client_data, XtPointer list_index = lrs->list_index; if (list_index == XAW_LIST_NONE) { - Log(("printerSelectionPrinterSelectedXtProc: Nothing selected.")); + Log(("printerSelectionPrinterSelectedXtProc: Nothing selected.\n")); return; } @@ -915,25 +899,17 @@ Bool buildPrinterSelectionDialog(PrintDialogWidget pdw) 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); @@ -1005,18 +981,13 @@ createprintdialogchildren(Widget w) 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++; @@ -1025,27 +996,19 @@ createprintdialogchildren(Widget w) 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++; @@ -1054,28 +1017,20 @@ createprintdialogchildren(Widget w) 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++; @@ -1085,26 +1040,17 @@ createprintdialogchildren(Widget w) 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); @@ -1112,25 +1058,16 @@ createprintdialogchildren(Widget w) /* 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); } |