mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Initial import of the CDE 2.1.30 sources from the Open Group.
This commit is contained in:
commit
83b6996daa
18978 changed files with 3945623 additions and 0 deletions
45
cde/examples/dtsession/Makefile.hp
Normal file
45
cde/examples/dtsession/Makefile.hp
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# $XConsortium: Makefile.hp /main/2 1996/05/13 11:49:37 drk $
|
||||
##########################################################################
|
||||
#
|
||||
# Makefile for dtsession examples (HP)
|
||||
#
|
||||
# (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
# (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
# (c) Copyright 1993, 1994 Novell, Inc.
|
||||
#
|
||||
##########################################################################
|
||||
|
||||
CC = cc
|
||||
RM = rm -f
|
||||
|
||||
PROGRAM = session
|
||||
SOURCES = session.c
|
||||
OBJECTS = session.o
|
||||
|
||||
DEFINES =
|
||||
CDEBUGFLAGS = -O
|
||||
CFLAGS = -Aa -z $(DEFINES) $(CDEBUGFLAGS)
|
||||
|
||||
DTINCLUDE = -I/usr/dt/include
|
||||
X11INCLUDE = -I/usr/include/X11R5
|
||||
|
||||
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
|
||||
|
||||
DTLIBS = -L/usr/dt/lib -lDtSvc -lXm
|
||||
X11LIBS = -L/usr/lib/X11R5 -lXt -lX11
|
||||
SYSLIBS =
|
||||
|
||||
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
|
||||
LDFLAGS =
|
||||
|
||||
.c.o:
|
||||
${CC} -c $(CFLAGS) $(INCLUDES) $<
|
||||
|
||||
all:: $(PROGRAM)
|
||||
|
||||
$(PROGRAM):: $(OBJECTS)
|
||||
${CC} -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
|
||||
|
||||
clean::
|
||||
${RM} $(PROGRAM) $(OBJECTS)
|
||||
45
cde/examples/dtsession/Makefile.ibm
Normal file
45
cde/examples/dtsession/Makefile.ibm
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# $XConsortium: Makefile.ibm /main/2 1996/05/13 11:49:55 drk $
|
||||
##########################################################################
|
||||
#
|
||||
# Makefile for dtsession examples (IBM)
|
||||
#
|
||||
# (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
# (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
# (c) Copyright 1993, 1994 Novell, Inc.
|
||||
#
|
||||
##########################################################################
|
||||
|
||||
CC = cc
|
||||
RM = rm -f
|
||||
|
||||
PROGRAM = session
|
||||
SOURCES = session.c
|
||||
OBJECTS = session.o
|
||||
|
||||
DEFINES =
|
||||
CDEBUGFLAGS = -O
|
||||
CFLAGS = $(DEFINES) $(CDEBUGFLAGS)
|
||||
|
||||
DTINCLUDE = -I/usr/dt/include
|
||||
X11INCLUDE = -I/usr/include
|
||||
|
||||
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
|
||||
|
||||
DTLIBS = -L/usr/dt/lib -lDtSvc -lXm
|
||||
X11LIBS = -L/usr/lib -lXt -lX11
|
||||
SYSLIBS =
|
||||
|
||||
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
|
||||
LDFLAGS =
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $<
|
||||
|
||||
all:: $(PROGRAM)
|
||||
|
||||
$(PROGRAM):: $(OBJECTS)
|
||||
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
|
||||
|
||||
clean::
|
||||
$(RM) $(PROGRAM) $(OBJECTS)
|
||||
45
cde/examples/dtsession/Makefile.novell
Normal file
45
cde/examples/dtsession/Makefile.novell
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# $XConsortium: Makefile.novell /main/2 1996/05/13 11:50:10 drk $
|
||||
##########################################################################
|
||||
#
|
||||
# Makefile for dtsession examples (Novell)
|
||||
#
|
||||
# (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
# (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
# (c) Copyright 1993, 1994 Novell, Inc.
|
||||
#
|
||||
##########################################################################
|
||||
|
||||
CC = cc
|
||||
RM = rm -f
|
||||
|
||||
PROGRAM = session
|
||||
SOURCES = session.c
|
||||
OBJECTS = session.o
|
||||
|
||||
DEFINES =
|
||||
CDEBUGFLAGS = -O
|
||||
CFLAGS = -Xc $(DEFINES) $(CDEBUGFLAGS)
|
||||
|
||||
DTINCLUDE = -I/usr/dt/include
|
||||
X11INCLUDE = -I/usr/X/include
|
||||
|
||||
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
|
||||
|
||||
DTLIBS = -L/usr/dt/lib -lDtSvc -lXm
|
||||
X11LIBS = -L/usr/X/lib -lXt -lX11
|
||||
SYSLIBS = -lw -lgen -lnsl -lresolv -lsocket -lXIM
|
||||
|
||||
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
|
||||
LDFLAGS =
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $<
|
||||
|
||||
all:: $(PROGRAM)
|
||||
|
||||
$(PROGRAM):: $(OBJECTS)
|
||||
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
|
||||
|
||||
clean::
|
||||
$(RM) $(PROGRAM) $(OBJECTS)
|
||||
45
cde/examples/dtsession/Makefile.sun
Normal file
45
cde/examples/dtsession/Makefile.sun
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# $XConsortium: Makefile.sun /main/2 1996/05/13 11:50:27 drk $
|
||||
##########################################################################
|
||||
#
|
||||
# Makefile for dtsession examples (SUN)
|
||||
#
|
||||
# (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
# (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
# (c) Copyright 1993, 1994 Novell, Inc.
|
||||
#
|
||||
##########################################################################
|
||||
|
||||
CC = cc
|
||||
RM = rm -f
|
||||
|
||||
PROGRAM = session
|
||||
SOURCES = session.c
|
||||
OBJECTS = session.o
|
||||
|
||||
DEFINES =
|
||||
CDEBUGFLAGS = -O
|
||||
CFLAGS = $(DEFINES) $(CDEBUGFLAGS)
|
||||
|
||||
DTINCLUDE = -I/usr/dt/include
|
||||
X11INCLUDE = -I/usr/openwin/include
|
||||
|
||||
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
|
||||
|
||||
DTLIBS = -L/usr/dt/lib -lDtSvc -lXm
|
||||
X11LIBS = -L/usr/openwin/lib -lXt -lX11
|
||||
SYSLIBS = -ldl -lw -lgen
|
||||
|
||||
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
|
||||
LDFLAGS = -R/usr/dt/lib:/usr/openwin/lib
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $<
|
||||
|
||||
all:: $(PROGRAM)
|
||||
|
||||
$(PROGRAM):: $(OBJECTS)
|
||||
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
|
||||
|
||||
clean::
|
||||
$(RM) $(PROGRAM) $(OBJECTS)
|
||||
46
cde/examples/dtsession/Makefile.uxp
Normal file
46
cde/examples/dtsession/Makefile.uxp
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
# $XConsortium: Makefile.uxp /main/2 1996/05/13 11:50:42 drk $
|
||||
##########################################################################
|
||||
#
|
||||
# Makefile for dtsession examples (UXP)
|
||||
#
|
||||
# (Fujitsu.patch applied)
|
||||
#
|
||||
# (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
# (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
# (c) Copyright 1993, 1994 Novell, Inc.
|
||||
#
|
||||
##########################################################################
|
||||
|
||||
CC = cc
|
||||
RM = rm -f
|
||||
|
||||
PROGRAM = session
|
||||
SOURCES = session.c
|
||||
OBJECTS = session.o
|
||||
|
||||
DEFINES =
|
||||
CDEBUGFLAGS = -O
|
||||
CFLAGS = -Xc $(DEFINES) $(CDEBUGFLAGS)
|
||||
|
||||
DTINCLUDE = -I/usr/dt/include
|
||||
|
||||
INCLUDES = $(DTINCLUDE)
|
||||
|
||||
DTLIBS = -L/usr/dt/lib -lDtSvc -ltt -lXm
|
||||
X11LIBS = -lXt -lX11
|
||||
SYSLIBS = -lw -lgen -lnsl -lresolv -lsocket
|
||||
|
||||
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
|
||||
LDFLAGS =
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $<
|
||||
|
||||
all:: $(PROGRAM)
|
||||
|
||||
$(PROGRAM):: $(OBJECTS)
|
||||
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
|
||||
|
||||
clean::
|
||||
$(RM) $(PROGRAM) $(OBJECTS)
|
||||
22
cde/examples/dtsession/README
Normal file
22
cde/examples/dtsession/README
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/* $XConsortium: README /main/2 1996/07/15 14:01:36 drk $ */
|
||||
|
||||
This directory contains demonstrations of the Dt Session mechanism and API.
|
||||
|
||||
session - Example of an application which supports the Dt
|
||||
session management protocol using the DtSession
|
||||
API.
|
||||
The application saves it's current state (the value
|
||||
of a toggle button) when the session is terminated.
|
||||
When the session is restarted, the toggle button
|
||||
state is restored.
|
||||
|
||||
The application state saved and restored across sessions
|
||||
is state information related to the dynamic state of
|
||||
the application(e.g. current file being edited), as opposed
|
||||
to static application state (e.g. user preferences.)
|
||||
|
||||
To allow the Session Manager to locate this application when
|
||||
the session is restarted, start the application with its
|
||||
full pathname as follows:
|
||||
|
||||
/usr/dt/examples/dtsession/session &
|
||||
214
cde/examples/dtsession/session.c
Normal file
214
cde/examples/dtsession/session.c
Normal file
|
|
@ -0,0 +1,214 @@
|
|||
/* $XConsortium: session.c /main/3 1995/10/27 10:40:33 rswiston $ */
|
||||
/*
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994 Novell, Inc.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* session.c
|
||||
*
|
||||
* Example code for Dt Session Manager conventions and API
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <Xm/RowColumn.h>
|
||||
#include <Xm/ToggleB.h>
|
||||
#include <Xm/Protocols.h>
|
||||
#include <Dt/Session.h>
|
||||
|
||||
|
||||
/*
|
||||
* Define '-session' command line option
|
||||
*/
|
||||
|
||||
typedef struct _ApplicationArgs {
|
||||
String session;
|
||||
} ApplicationArgs;
|
||||
|
||||
static XtResource applicationResources[] = {
|
||||
{
|
||||
"session",
|
||||
"Session",
|
||||
XmRString,
|
||||
sizeof(String),
|
||||
XtOffsetOf(ApplicationArgs,session),
|
||||
XmRImmediate,
|
||||
NULL
|
||||
},
|
||||
};
|
||||
|
||||
static XrmOptionDescRec commandLineOpts[] = {
|
||||
{ "-session", "session", XrmoptionSepArg, NULL },
|
||||
};
|
||||
|
||||
static ApplicationArgs applicationArgs;
|
||||
|
||||
/*
|
||||
* Simple application state to be preserved across sessions
|
||||
*/
|
||||
|
||||
static int lightState = False;
|
||||
|
||||
/*
|
||||
* miscellaneous global data
|
||||
*/
|
||||
|
||||
static XtAppContext appContext;
|
||||
static Widget toplevel;
|
||||
static int savedArgc;
|
||||
static char **savedArgv;
|
||||
|
||||
static void PreserveCommandLine(int, char **);
|
||||
static void SetWmCommand(char *);
|
||||
static void SaveSessionCb(Widget, XtPointer, XtPointer);
|
||||
static void RestoreSession(Widget, char*);
|
||||
static void SaveApplicationState(char *);
|
||||
static void RestoreApplicationState(char *);
|
||||
|
||||
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
Widget mainWindow, toggle;
|
||||
XmString labelString;
|
||||
Arg args[1];
|
||||
|
||||
/* Save the command line before Xt parses out the standard options */
|
||||
PreserveCommandLine(argc, argv);
|
||||
|
||||
/* Create the application UI */
|
||||
|
||||
toplevel = XtAppInitialize(&appContext, "Session",
|
||||
commandLineOpts, XtNumber(commandLineOpts),
|
||||
&argc, argv,
|
||||
NULL,
|
||||
NULL, 0);
|
||||
|
||||
XtGetApplicationResources(toplevel, &applicationArgs,
|
||||
applicationResources,
|
||||
XtNumber(applicationResources),
|
||||
NULL, 0);
|
||||
|
||||
mainWindow = XmCreateWorkArea(toplevel, "mainWindow", NULL, 0);
|
||||
XtManageChild(mainWindow);
|
||||
|
||||
labelString = XmStringCreateLocalized("Lights");
|
||||
XtSetArg(args[0], XmNlabelString, labelString);
|
||||
toggle = XmCreateToggleButton(mainWindow, "lightsToggle", args, 1);
|
||||
XtManageChild(toggle);
|
||||
XmStringFree(labelString);
|
||||
|
||||
/* Add callback to detect session manager messages */
|
||||
|
||||
XmAddWMProtocolCallback(toplevel,
|
||||
XInternAtom(XtDisplay(toplevel), "WM_SAVE_YOURSELF", False),
|
||||
SaveSessionCb, (XtPointer)toplevel);
|
||||
|
||||
/* Restore state if application was restarted by session manager */
|
||||
|
||||
if (applicationArgs.session != NULL) {
|
||||
RestoreSession(toplevel, applicationArgs.session);
|
||||
}
|
||||
|
||||
XtRealizeWidget(toplevel);
|
||||
XtAppMainLoop(appContext);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Save session state
|
||||
*/
|
||||
|
||||
static void SaveSessionCb(Widget w, XtPointer cd, XtPointer cb)
|
||||
{
|
||||
Widget toplevel = (Widget)cd;
|
||||
char *savePath = NULL;
|
||||
char *saveFile = NULL;
|
||||
|
||||
DtSessionSavePath(toplevel, &savePath, &saveFile);
|
||||
|
||||
if (savePath != NULL) {
|
||||
SaveApplicationState(savePath);
|
||||
SetWmCommand(saveFile);
|
||||
XtFree(savePath);
|
||||
XtFree(saveFile);
|
||||
}
|
||||
}
|
||||
|
||||
static void SaveApplicationState(char *path)
|
||||
{
|
||||
Widget toggle = XtNameToWidget(toplevel, "*lightsToggle");
|
||||
FILE *fp;
|
||||
|
||||
lightState = XmToggleButtonGetState(toggle);
|
||||
|
||||
if ((fp = fopen(path, "w")) != NULL) {
|
||||
fprintf(fp, "%d", lightState);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
static void PreserveCommandLine(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
savedArgv = (char **)XtMalloc(argc*sizeof(char *));
|
||||
savedArgc = argc;
|
||||
for (i=0; i < argc; i++) savedArgv[i] = XtNewString(argv[i]);
|
||||
}
|
||||
|
||||
|
||||
static void SetWmCommand(char *sessionId)
|
||||
{
|
||||
char **wm_command;
|
||||
int i, j;
|
||||
|
||||
wm_command = (char **) XtMalloc((savedArgc+2) * sizeof(char*));
|
||||
wm_command[0] = XtNewString(savedArgv[0]);
|
||||
wm_command[1] = XtNewString("-session");
|
||||
wm_command[2] = XtNewString(sessionId);
|
||||
|
||||
for (i = 1, j = 3; i < savedArgc; i++) {
|
||||
if (strcmp(savedArgv[i], "-session") == 0) { i++; continue; }
|
||||
wm_command[j] = XtNewString(savedArgv[i]);
|
||||
j++;
|
||||
}
|
||||
|
||||
XSetCommand(XtDisplay(toplevel), XtWindow(toplevel), wm_command, j);
|
||||
|
||||
for (i=0; i < j; i++) XtFree(wm_command[i]);
|
||||
XtFree((char*)wm_command);
|
||||
}
|
||||
|
||||
/*
|
||||
* Restore previously saved state
|
||||
*/
|
||||
|
||||
static void RestoreSession(Widget w, char *restoreFile)
|
||||
{
|
||||
char *restorePath = NULL;
|
||||
|
||||
DtSessionRestorePath(w, &restorePath, restoreFile);
|
||||
|
||||
if (restorePath != NULL) {
|
||||
RestoreApplicationState(restorePath);
|
||||
XtFree(restorePath);
|
||||
}
|
||||
}
|
||||
|
||||
static void RestoreApplicationState(char *path)
|
||||
{
|
||||
Widget toggle = XtNameToWidget(toplevel, "*lightsToggle");
|
||||
FILE *fp;
|
||||
|
||||
if ((fp = fopen(path, "r")) != NULL) {
|
||||
fscanf(fp, "%d", &lightState);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
XmToggleButtonSetState(toggle, lightState, False);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue