summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland Mainz <roland.mainz@nrubsig.org>2005-01-03 01:06:36 +0000
committerRoland Mainz <roland.mainz@nrubsig.org>2005-01-03 01:06:36 +0000
commitdfb0b2dac20f575a7be260895f2847daeeacb819 (patch)
treeb9c17ac887e3d989386545886b4e022609dbceb0
parent5581ed55c6918f69786d63e9a401f9d8b33a66d2 (diff)
xc/lib/XprintAppUtil/xpapputil.cXORG-6_8_99_1
xc/lib/XprintAppUtil/xpapputil.h xc/lib/XprintUtil/xprintutil.c xc/lib/XprintUtil/xprintutil.h xc/programs/glxgears/glxgears.c xc/programs/xdbedizzy/xdbedizzy.c xc/programs/xedit/Xedit-xprint.ad xc/programs/xedit/commands.c xc/programs/xlogo/print.c xc/programs/xlsfonts/xlsfonts.c xc/programs/xlsfonts/xlsfonts.man xc/programs/xlsfonts/xlsfonts.sgml xc/programs/xman/Xman-xprint.ad xc/programs/xman/handler.c xc/programs/xman/print.c xc/programs/xman/print.h xc/programs/xmore/XMore.ad xc/programs/xmore/print.c xc/programs/xmore/print.h xc/programs/xmore/printdialog.c xc/programs/xmore/printdialog.h xc/programs/xmore/printdialogprivates.h xc/programs/xmore/xmore.c xc/programs/xphelloworld/xpawhelloworld/xpawhelloworld.c xc/programs/xphelloworld/xphelloworld/xphelloworld.c xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.c xc/programs/xphelloworld/xpxmhelloworld/xpxmhelloworld.c xc/programs/xphelloworld/xpxthelloworld/xpxthelloworld.c xc/programs/xplsprinters/xplsprinters.c //bugs.freedesktop.org/show_bug.cgi?id=1706) attachment #1615 (https://bugs.freedesktop.org/attachment.cgi?id=1615): XprintUtils 2004/Q3 update. This adds various new features to the XprintUtils library including support for page resolutions where X_resolution!=Y_resolution, listfonts-mode control and initial framework for the COLORSPACE extension. Patch by Roland Mainz <roland.mainz@nrubsig.org> and Julien Lafon <julien.lafon@gmail.com>.
-rw-r--r--Xedit-xprint.ad2
-rw-r--r--commands.c3
-rw-r--r--print.c44
-rw-r--r--print.h1
-rw-r--r--printdialog.c71
-rw-r--r--printdialog.h9
-rw-r--r--printdialogprivates.h6
7 files changed, 101 insertions, 35 deletions
diff --git a/Xedit-xprint.ad b/Xedit-xprint.ad
index f6ef6dc..8c1d398 100644
--- a/Xedit-xprint.ad
+++ b/Xedit-xprint.ad
@@ -532,6 +532,8 @@ c<Key>G: set-columns(cancel)\n\
*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*colorspacelist.fromHoriz: plexlist
+*printdialogshell*setup*colorspacelist.tip: Select color space (color, grayscale, CYMK, etc.)
*printdialogshell*setup*jobcopieslabel.fromVert: paperlist
*printdialogshell*setup*jobcopieslabel.tip: Set number of job copies
*printdialogshell*setup*jobcopieslabel.label: Job Copies:
diff --git a/commands.c b/commands.c
index 9e63158..7fa14d1 100644
--- a/commands.c
+++ b/commands.c
@@ -549,7 +549,8 @@ printOKXtProc(Widget w, XtPointer client_data, XtPointer callData)
DoPrintTextSource("Xedit",
textsource, topwindow,
- pdcs->pdpy, pdcs->pcontext, printshellDestroyXtProc,
+ pdcs->pdpy, pdcs->pcontext, pdcs->colorspace,
+ printshellDestroyXtProc,
printJobNameBuffer,
pdcs->printToFile?pdcs->printToFileName:NULL);
diff --git a/print.c b/print.c
index 54f5a29..dad23e5 100644
--- a/print.c
+++ b/print.c
@@ -41,7 +41,8 @@ in this Software without prior written authorization from The Open Group.
static Widget
CreatePrintShell(Widget videoshell,
- Screen *pscreen,
+ Screen *pscreen,
+ Visual *pvisual,
String printshell_name,
ArgList args,
Cardinal numargs)
@@ -53,6 +54,9 @@ CreatePrintShell(Widget videoshell,
Display *pdpy = XDisplayOfScreen(pscreen);
int dummyc = 0;
String dummys = "";
+ Cardinal shell_n;
+ Arg shell_args[5];
+
XtGetApplicationNameAndClass(XtDisplay(videoshell),
&videoname, &videoclass);
@@ -62,11 +66,15 @@ CreatePrintShell(Widget videoshell,
NULL, 0,
&dummyc, &dummys);
- pappshell = XtVaAppCreateShell(videoname, videoclass,
+ shell_n = 0;
+ XtSetArg(shell_args[shell_n], XtNscreen, pscreen); shell_n++;
+ if (pvisual) {
+ XtSetArg(shell_args[shell_n], XtNvisual, pvisual); shell_n++;
+ }
+ pappshell = XtAppCreateShell(videoname, videoclass,
applicationShellWidgetClass,
pdpy,
- XtNscreen, pscreen,
- NULL);
+ shell_args, shell_n);
printshell = XtCreatePopupShell(printshell_name,
xawPrintShellWidgetClass,
pappshell, args, numargs);
@@ -224,7 +232,7 @@ void PrintEndJobCB(Widget pshell, XtPointer client_data, XtPointer call_data)
}
static
-XFontSet GetPrintTextFontSet(const char *appname, Display *pdpy, long dpi)
+XFontSet GetPrintTextFontSet(const char *appname, Display *pdpy, long dpi_x, long dpi_y)
{
XFontSet fontset;
char fontname[1024];
@@ -242,11 +250,11 @@ XFontSet GetPrintTextFontSet(const char *appname, Display *pdpy, long dpi)
"-wadalab-gothic-medium-r-normal--*-120-%ld-%ld-*-*,"
/* Fallback */
"-*-*-*-*-*--*-120-%ld-%ld-*-*",
- dpi, dpi,
- dpi, dpi,
- dpi, dpi,
- dpi, dpi,
- dpi, dpi);
+ dpi_x, dpi_y,
+ dpi_x, dpi_y,
+ dpi_x, dpi_y,
+ dpi_x, dpi_y,
+ dpi_x, dpi_y);
fontset = XCreateFontSet(pdpy, fontname,
&missing_charset_list_return,
&missing_charset_count_return,
@@ -265,10 +273,12 @@ XFontSet GetPrintTextFontSet(const char *appname, Display *pdpy, long dpi)
void DoPrintTextSource(const char *programname,
Widget textsource, Widget toplevel,
Display *pdpy, XPContext pcontext,
+ XpuColorspaceRec *colorspace,
XtCallbackProc pdpyDestroyCB,
const char *jobtitle, const char *toFile)
{
- long dpi = 0;
+ long dpi_x = 0L,
+ dpi_y = 0L;
int n;
Arg args[20];
XFontSet textfontset = NULL;
@@ -292,7 +302,7 @@ void DoPrintTextSource(const char *programname,
XpSetContext(pdpy, pcontext);
/* Get default printer resolution */
- if (XpuGetResolution(pdpy, pcontext, &dpi) != 1) {
+ if (XpuGetResolution(pdpy, pcontext, &dpi_x, &dpi_y) != 1) {
fprintf(stderr, "%s: No default resolution for printer.\n", apd->programname);
XpuClosePrinterDisplay(pdpy, pcontext);
return;
@@ -310,14 +320,18 @@ void DoPrintTextSource(const char *programname,
* |XawPrintLAYOUTMODE_PAGESIZE| are used. */
XtSetArg(args[n], XtNgeometry, "+0+0"); n++;
XtSetArg(args[n], XawNlayoutMode, XawPrintLAYOUTMODE_DRAWABLEAREA); n++;
- apd->printshell = CreatePrintShell(toplevel, apd->pscreen, "printshell", args, n);
-
+ if (colorspace) {
+ printf("Setting visual to id=0x%lx.\n", colorspace->visualinfo.visualid);
+ }
+ apd->printshell = CreatePrintShell(toplevel, apd->pscreen,
+ (colorspace?(colorspace->visualinfo.visual):(NULL)),
+ "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);
+ textfontset = GetPrintTextFontSet(apd->programname, pdpy, dpi_x, dpi_y);
n = 0;
XtSetArg(args[n], XtNinternational, True); n++;
diff --git a/print.h b/print.h
index 69321a1..d1ecbf6 100644
--- a/print.h
+++ b/print.h
@@ -40,6 +40,7 @@ void DoPrintTextSource(const char *programname,
Widget textsource,
Widget toplevel,
Display *pdpy, XPContext pcontext,
+ XpuColorspaceRec *colorspace,
XtCallbackProc printDisplayDestroyCallback,
const char *jobTitle,
const char *toFile);
diff --git a/printdialog.c b/printdialog.c
index 97cf4c9..3642c07 100644
--- a/printdialog.c
+++ b/printdialog.c
@@ -86,6 +86,7 @@ static String *xppaperlist_to_widget_paperlist(XpuMediumSourceSizeList paperlis
static String *xpresolutionlist_to_widget_resolutionlist(XpuResolutionList reslist, int num_resolutions);
static String *xporientationlist_to_widget_orientationlist(XpuOrientationList orientationlist, int num_orientations);
static String *xpplexlist_to_widget_plexlist(XpuPlexList plexlist, int num_plex);
+static String *xpcolorspacelist_to_widget_colorspacelist(XpuColorspaceList colorspacelist, int num_colorspaces);
static void printerSelectionPrinterSelectedXtProc(Widget w, XtPointer client_data, XtPointer callData);
static void printSelectPrinterXtProc(Widget w, XtPointer client_data, XtPointer callData);
static void printerSelectionClose(PrintDialogWidget pdw);
@@ -258,6 +259,15 @@ printSetupOKXtProc(Widget w, XtPointer client_data, XtPointer callData)
}
XtFree((char *)lrs);
+ /* Set colorspace */
+ lrs = XawListShowCurrent(pdp->setup.colorspacelist);
+ if (lrs->list_index != XAW_LIST_NONE) {
+ Log(("selected colorspace is '%s'/'%d'\n", lrs->string, lrs->list_index));
+ Assertion(lrs->list_index < pdp->num_colorspaces, (("Error: lrs->list_index < pdp->num_colorspaces\n")));
+ pdp->selected_colorspace = &pdp->colorspacelist[lrs->list_index];
+ }
+ XtFree((char *)lrs);
+
printSetupClose(pdw);
}
@@ -386,6 +396,7 @@ printOKXtProc(Widget w, XtPointer client_data, XtPointer callData)
pdcs.pcontext = pdp->pcontext;
pdcs.printToFile = pdp->printToFile;
pdcs.printToFileName = (const char *)pdp->filename;
+ pdcs.colorspace = pdp->selected_colorspace;
XtCallCallbackList((Widget)pdw, pdp->ok_callback, &pdcs);
}
@@ -500,6 +511,17 @@ void closePrinterConnection(PrintDialogWidget pdw, Bool closeDisplay)
pdp->widget_plexlist = NULL;
}
+ if (pdp->colorspacelist) {
+ XpuFreeColorspaceList(pdp->colorspacelist);
+ pdp->colorspacelist = NULL;
+ }
+
+ if (pdp->widget_colorspacelist) {
+ free(pdp->widget_colorspacelist);
+ pdp->widget_colorspacelist = NULL;
+ }
+ pdp->selected_colorspace = NULL;
+
if (pdp->pdpy) {
if (closeDisplay) {
XpuClosePrinterDisplay(pdp->pdpy, pdp->pcontext);
@@ -535,11 +557,13 @@ Bool openPrinterConnection(PrintDialogWidget pdw)
pdp->resolutionlist = XpuGetResolutionList(pdp->pdpy, pdp->pcontext, &pdp->num_resolutions);
pdp->orientationlist = XpuGetOrientationList(pdp->pdpy, pdp->pcontext, &pdp->num_orientations);
pdp->plexlist = XpuGetPlexList(pdp->pdpy, pdp->pcontext, &pdp->num_plex);
+ pdp->colorspacelist = XpuGetColorspaceList(pdp->pdpy, pdp->pcontext, &pdp->num_colorspaces);
pdp->widget_paperlist = xppaperlist_to_widget_paperlist(pdp->paperlist, pdp->num_papers);
pdp->widget_resolutionlist = xpresolutionlist_to_widget_resolutionlist(pdp->resolutionlist, pdp->num_resolutions);
pdp->widget_orientationlist = xporientationlist_to_widget_orientationlist(pdp->orientationlist, pdp->num_orientations);
pdp->widget_plexlist = xpplexlist_to_widget_plexlist(pdp->plexlist, pdp->num_plex);
+ pdp->widget_colorspacelist = xpcolorspacelist_to_widget_colorspacelist(pdp->colorspacelist, pdp->num_colorspaces);
updateWidgetStates(pdw);
@@ -568,6 +592,7 @@ void destroyPrintSetupDialog(PrintDialogWidget pdw)
pdp->setup.resolutionlist = NULL;
pdp->setup.orientationlist = NULL;
pdp->setup.plexlist = NULL;
+ pdp->setup.colorspacelist = NULL;
pdp->setup.ok = NULL;
pdp->setup.cancel = NULL;
}
@@ -654,6 +679,15 @@ Widget buildPrintSetupDialog(PrintDialogWidget pdw)
pdp->setup.plexlist = XtCreateManagedWidget("plexlist", 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], XtNsensitive, True); n++;
+ XtSetArg(args[n], XtNlist, pdp->widget_colorspacelist); n++;
+ XtSetArg(args[n], XtNwidth, DEFAULT_WIDTH); n++;
+ pdp->setup.colorspacelist = XtCreateManagedWidget("colorspacelist", listWidgetClass, listform, args, n);
+
+ n = 0;
XtSetArg(args[n], XtNborderWidth, 0); n++;
XtSetArg(args[n], XtNresizable, False); n++;
XtSetArg(args[n], XtNjustify, XtJustifyRight); n++;
@@ -726,24 +760,13 @@ String *xpresolutionlist_to_widget_resolutionlist(XpuResolutionList reslist, int
{
int i;
String *names;
- char *mem;
-
- /* Allocate a chunk of memory... */
- mem = malloc((sizeof(String *)+32) * (num_resolutions+2));
- /* ... which has enougth space for the list pointers... */
- names = (String *)mem;
+ names = malloc(sizeof(String *) * (num_resolutions+1));
if (!names)
- return NULL;
-
- /* ... and the numbers (assuming one number isn't longer than 32-1 chars) */
- mem += sizeof(String *) * (num_resolutions+2);
+ return NULL;
- for(i = 0 ; i < num_resolutions ; i++) {
- sprintf(mem, "%d", (int)reslist[i].dpi);
- names[i] = mem;
- mem += strlen(mem) + 1;
- }
+ for(i = 0 ; i < num_resolutions ; i++)
+ names[i] = (char *)reslist[i].name;
names[i] = NULL; /* Terminate the list */
@@ -786,6 +809,24 @@ String *xpplexlist_to_widget_plexlist(XpuPlexList plexlist, int num_plex)
return names;
}
+static
+String *xpcolorspacelist_to_widget_colorspacelist(XpuColorspaceList colorspacelist, int num_colorspaces)
+{
+ int i;
+ String *names;
+
+ names = malloc(sizeof(String *) * (num_colorspaces+1));
+ if(!names)
+ return NULL;
+
+ for(i = 0 ; i < num_colorspaces ; i++)
+ names[i] = (char *)colorspacelist[i].name;
+
+ names[i] = NULL; /* Terminate the list */
+
+ return names;
+}
+
static void
printerSelectionPrinterSelectedXtProc(Widget w, XtPointer client_data, XtPointer callData)
{
diff --git a/printdialog.h b/printdialog.h
index e963847..f166a27 100644
--- a/printdialog.h
+++ b/printdialog.h
@@ -48,10 +48,11 @@ in this Software without prior written authorization from The Open Group.
typedef struct
{
- Display *pdpy;
- XPContext pcontext;
- const char *printToFileName;
- Boolean printToFile;
+ Display *pdpy;
+ XPContext pcontext;
+ const char *printToFileName;
+ Boolean printToFile;
+ XpuColorspaceRec *colorspace;
} XawPrintDialogCallbackStruct;
typedef struct _PrintDialogClassRec *PrintDialogWidgetClass;
diff --git a/printdialogprivates.h b/printdialogprivates.h
index 314a91c..1e66eb8 100644
--- a/printdialogprivates.h
+++ b/printdialogprivates.h
@@ -100,6 +100,7 @@ typedef struct _PrintDialogPart {
char *filename;
Bool canPrint, /* can we print ? */
canReallyPrint; /* is it really save to print ? */
+ XpuColorspaceRec *selected_colorspace;
struct
{
@@ -118,6 +119,7 @@ typedef struct _PrintDialogPart {
resolutionlist,
orientationlist,
plexlist,
+ colorspacelist,
jobcopieslabel,
jobcopies,
ok,
@@ -153,6 +155,10 @@ typedef struct _PrintDialogPart {
XpuPlexList plexlist;
int num_plex;
String *widget_plexlist;
+
+ XpuColorspaceList colorspacelist;
+ int num_colorspaces;
+ String *widget_colorspacelist;
} PrintDialogPart;
typedef struct _PrintDialogRec {