[PATCH] libXt: add example to XtCreateApplicationContext man page

walter harms wharms at bfs.de
Sun Jan 23 08:17:43 PST 2011


[PATCH] add example for XtCreateApplicationContext man page

 Signed-off-by: walter harms <wharms at bfs.de>

---
 man/XtCreateApplicationContext.man |   50 +++++++++++++++++++++++++++++++++++-
 1 files changed, 49 insertions(+), 1 deletions(-)

diff --git a/man/XtCreateApplicationContext.man b/man/XtCreateApplicationContext.man
index ba447a4..ea0c9f3 100644
--- a/man/XtCreateApplicationContext.man
+++ b/man/XtCreateApplicationContext.man
@@ -1,3 +1,5 @@
+.\" $Xorg: XtCreACon.man,v 1.3 2000/08/17 19:41:59 cpqbld Exp $
+.\"
 .\" Copyright 1993 X Consortium
 .\"
 .\" Permission is hereby granted, free of charge, to any person obtaining
@@ -24,6 +26,8 @@
 .\" other dealings in this Software without prior written authorization
 .\" from the X Consortium.
 .\"
+.\" $XFree86: xc/doc/man/Xt/XtCreACon.man,v 1.3 2003/04/28 22:18:18 herrb Exp $
+.\"
 .ds tk X Toolkit
 .ds xT X Toolkit Intrinsics \- C Language Interface
 .ds xI Intrinsics
@@ -167,8 +171,52 @@ If
 .ZN XtToolkitInitialize
 was previously called it returns immediately.
 .LP
+.SH EXAMPLE
+Every program should have an application context and it is normaly
+generated by the init function. The example below destroys the
+context at exit.
+.nf
+
+#include <stdlib.h>
+#include <Intrinsic.h>
+#include <StringDefs.h>
+#include <Xaw/Command.h>
+
+/* gcc -I /usr/include/X11/ sample.c -lX11 -lXaw */
+
+static void
+quit_cb(Widget w, XtPointer closure, XtPointer call_data)
+{
+  XtAppContext app=XtWidgetToApplicationContext(w);
+  XtDestroyApplicationContext(app);
+  exit(0);
+}
+
+int main(int argc, char *argv[])
+{
+  Widget  widget,toplevel;
+  XtAppContext app;
+
+  toplevel=XtOpenApplication(&app,"Xtdemo",
+                         NULL,0,
+                         &argc,argv,
+                         NULL,
+                         applicationShellWidgetClass,
+                         NULL,0);
+
+
+  widget=XtVaCreateManagedWidget("Ausgang",commandWidgetClass,toplevel,NULL);
+  XtAddCallback(widget, XtNcallback, quit_cb , NULL);
+
+  XtRealizeWidget(toplevel);
+  XtAppMainLoop(app);
+  return 0;
+}
+
+.fi
+
 .SH "SEE ALSO"
-XtDisplayInitialize(3Xt)
+.BR XtDisplayInitialize (3Xt)
 .br
 \fI\*(xT\fP
 .br
-- 
1.6.0.2



More information about the xorg-devel mailing list