summaryrefslogtreecommitdiff
path: root/printdialog.c
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
commit550802b584f89279d8af35ee8a9221dc24ea1f27 (patch)
tree7ef2a9e4d201a333bab6fecb6ed92b9019d15ee1 /printdialog.c
parent11d508e4bfec3ecd749123e043768ea3fb21ce12 (diff)
xc/lib/XprintAppUtil/xpapputil.c
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>.
Diffstat (limited to 'printdialog.c')
-rw-r--r--printdialog.c71
1 files changed, 56 insertions, 15 deletions
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)
{