2
* $Xorg: xlogo.c,v 1.4 2001/02/09 02:05:54 xorgcvs Exp $
4
Copyright 1989, 1998 The Open Group
6
Permission to use, copy, modify, distribute, and sell this software and its
7
documentation for any purpose is hereby granted without fee, provided that
8
the above copyright notice appear in all copies and that both that
9
copyright notice and this permission notice appear in supporting
12
The above copyright notice and this permission notice shall be included in
13
all copies or substantial portions of the Software.
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
Except as contained in this notice, the name of The Open Group shall not be
23
used in advertising or otherwise to promote the sale, use or other dealings
24
in this Software without prior written authorization from The Open Group.
28
/* $XFree86: xc/programs/xlogo/xlogo.c,v 3.7 2001/07/25 15:05:26 dawes Exp $ */
30
#include <X11/Intrinsic.h>
31
#include <X11/StringDefs.h>
32
#include <X11/Shell.h>
35
#include <X11/Xaw/Cardinals.h>
36
#ifdef INCLUDE_XPRINT_SUPPORT
38
#endif /* INCLUDE_XPRINT_SUPPORT */
40
#include <X11/extensions/XKBbells.h>
46
const char *ProgramName; /* program name (from argv[0]) */
48
static void quit(Widget w, XEvent *event, String *params, Cardinal *num_params);
49
#ifdef INCLUDE_XPRINT_SUPPORT
50
static void print(Widget w, XEvent *event, String *params, Cardinal *num_params);
51
#endif /* INCLUDE_XPRINT_SUPPORT */
53
static XrmOptionDescRec options[] = {
54
{ "-shape", "*shapeWindow", XrmoptionNoArg, (XPointer) "on" },
56
{"-render", "*render",XrmoptionNoArg, "TRUE"},
57
{"-sharp", "*sharp", XrmoptionNoArg, "TRUE"},
59
{"-v", "Verbose", XrmoptionNoArg, "TRUE"},
60
{"-q", "Quiet", XrmoptionNoArg, "TRUE"},
61
#ifdef INCLUDE_XPRINT_SUPPORT
62
{"-print", "Print", XrmoptionNoArg, "TRUE"},
63
{"-printer", "printer", XrmoptionSepArg, NULL},
64
{"-printfile", "printFile", XrmoptionSepArg, NULL},
65
#endif /* INCLUDE_XPRINT_SUPPORT */
68
static XtActionsRec actions[] = {
70
#ifdef INCLUDE_XPRINT_SUPPORT
72
#endif /* INCLUDE_XPRINT_SUPPORT */
75
static Atom wm_delete_window;
78
XLogoResourceData userOptions;
80
#define Offset(field) XtOffsetOf(XLogoResourceData, field)
82
XtResource resources[] = {
83
{"verbose", "Verbose", XtRBoolean, sizeof(Boolean), Offset(verbose), XtRImmediate, (XtPointer)False},
84
{"quiet", "Quiet", XtRBoolean, sizeof(Boolean), Offset(quiet), XtRImmediate, (XtPointer)False},
85
#ifdef INCLUDE_XPRINT_SUPPORT
86
{"print", "Print", XtRBoolean, sizeof(Boolean), Offset(printAndExit), XtRImmediate, (XtPointer)False},
87
{"printer", "Printer", XtRString, sizeof(String), Offset(printername), XtRImmediate, (XtPointer)NULL},
88
{"printFile", "PrintFile", XtRString, sizeof(String), Offset(printfile), XtRImmediate, (XtPointer)NULL}
89
#endif /* INCLUDE_XPRINT_SUPPORT */
93
String fallback_resources[] = {
94
"*iconPixmap: xlogo32",
96
"*baseTranslations: #override \\"
97
#ifdef INCLUDE_XPRINT_SUPPORT
98
"\t<Key>q: quit()\\n\\"
100
#else /* !INCLUDE_XPRINT_SUPPORT */
102
#endif /* !INCLUDE_XPRINT_SUPPORT */
107
die(Widget w, XtPointer client_data, XtPointer call_data)
109
XtAppSetExitFlag(XtWidgetToApplicationContext(w));
113
save(Widget w, XtPointer client_data, XtPointer call_data)
119
* Report the syntax for calling xlogo.
123
Syntax(Widget toplevel)
130
reasons[n++] = "Usage: ";
131
reasons[n++] = (String)ProgramName;
132
reasons[n++] = " [-fg <color>] [-bg <color>] [-rv] [-bw <pixels>] [-bd <color>]\n";
133
reasons[n++] = " [-v] [-q]\n";
134
reasons[n++] = " [-d [<host>]:[<vs>]]\n";
135
reasons[n++] = " [-g [<width>][x<height>][<+-><xoff>[<+-><yoff>]]]\n";
136
#ifdef INCLUDE_XPRINT_SUPPORT
137
reasons[n++] = " [-print] [-printname <name>] [-printfile <file>]\n";
138
#endif /* INCLUDE_XPRINT_SUPPORT */
140
reasons[n++] = " [-render] [-sharp]\n";
142
reasons[n++] = " [-shape]\n\n";
144
XtSetArg(arg, XtNconnection, &connection);
145
XtGetValues(toplevel, &arg, (Cardinal)1);
147
SmcCloseConnection(connection, n, reasons);
149
for (i=0; i < n; i++)
156
main(int argc, char *argv[])
159
XtAppContext app_con;
161
ProgramName = argv[0];
163
toplevel = XtOpenApplication(&app_con, "XLogo",
164
options, XtNumber(options),
165
&argc, argv, fallback_resources,
166
sessionShellWidgetClass, NULL, ZERO);
170
XtGetApplicationResources(toplevel, (XtPointer)&userOptions, resources,
171
XtNumber(resources), NULL, 0);
173
XtAppAddActions(app_con, actions, XtNumber(actions));
175
#ifdef INCLUDE_XPRINT_SUPPORT
176
if (userOptions.printAndExit) {
177
XtCallActionProc(toplevel, "print", NULL, NULL, 0);
180
#endif /* INCLUDE_XPRINT_SUPPORT */
182
XtAddCallback(toplevel, XtNsaveCallback, save, NULL);
183
XtAddCallback(toplevel, XtNdieCallback, die, NULL);
184
XtOverrideTranslations
185
(toplevel, XtParseTranslationTable ("<Message>WM_PROTOCOLS: quit()"));
186
XtCreateManagedWidget("xlogo", logoWidgetClass, toplevel, NULL, ZERO);
187
XtRealizeWidget(toplevel);
188
wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW",
190
(void) XSetWMProtocols (XtDisplay(toplevel), XtWindow(toplevel),
191
&wm_delete_window, 1);
194
XtAppMainLoop(app_con);
201
quit(Widget w, XEvent *event, String *params, Cardinal *num_params)
205
if (event->type == ClientMessage &&
206
(Atom)event->xclient.data.l[0] != wm_delete_window) {
208
XkbStdBell(XtDisplay(w), XtWindow(w), 0, XkbBI_BadValue);
210
XBell(XtDisplay(w), 0);
213
/* resign from the session */
214
XtSetArg(arg, XtNjoinSession, False);
215
XtSetValues(w, &arg, ONE);
220
#ifdef INCLUDE_XPRINT_SUPPORT
223
print(Widget w, XEvent *event, String *params, Cardinal *num_params)
225
DoPrint(w, userOptions.printername, userOptions.printfile);
227
#endif /* INCLUDE_XPRINT_SUPPORT */