1/* $Xorg: mainwin.c,v 1.4 2001/02/09 02:06:01 xorgcvs Exp $ */
2/******************************************************************************
3
4Copyright 1993, 1998  The Open Group
5
6Permission to use, copy, modify, distribute, and sell this software and its
7documentation for any purpose is hereby granted without fee, provided that
8the above copyright notice appear in all copies and that both that
9copyright notice and this permission notice appear in supporting
10documentation.
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
18OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22Except as contained in this notice, the name of The Open Group shall not be
23used in advertising or otherwise to promote the sale, use or other dealings
24in this Software without prior written authorization from The Open Group.
25******************************************************************************/
26/* $XFree86: xc/programs/xsm/mainwin.c,v 1.4 2001/01/17 23:46:29 dawes Exp $ */
27
28#include "xsm.h"
29#include "info.h"
30#include "save.h"
31#include "log.h"
32#include "mainwin.h"
33
34#include <X11/Shell.h>
35#include <X11/Xaw/Form.h>
36#include <X11/Xaw/Command.h>
37#include <X11/Xaw/SimpleMenu.h>
38#include <X11/Xaw/MenuButton.h>
39#include <X11/Xaw/SmeBSB.h>
40
41Widget mainWindow;
42Widget   clientInfoButton;
43Widget   logButton;
44Widget   checkPointButton;
45Widget   shutdownButton;
46static Widget     shutdownMenu;
47static Widget       shutdownSave;
48Widget       shutdownDontSave;
49
50
51
52static void
53DelMainWinAction(Widget w, XEvent *event, String *params, Cardinal *num_params)
54{
55    XtCallCallbacks (shutdownSave, XtNcallback, NULL);
56}
57
58
59
60void
61create_main_window (void)
62{
63    /*
64     * Main window
65     */
66
67    static XtActionsRec actions[] = {
68        {"DelMainWinAction", DelMainWinAction}
69    };
70
71    mainWindow = XtVaCreateManagedWidget (
72	"mainWindow", formWidgetClass, topLevel,
73	NULL);
74
75    clientInfoButton = XtVaCreateManagedWidget (
76	"clientInfoButton", commandWidgetClass, mainWindow,
77        XtNfromHoriz, NULL,
78        XtNfromVert, NULL,
79	XtNresizable, True,
80	XtNjustify, XtJustifyLeft,
81	NULL);
82
83    XtAddCallback (clientInfoButton, XtNcallback, ClientInfoXtProc, NULL);
84
85    logButton = XtVaCreateManagedWidget (
86	"logButton", commandWidgetClass, mainWindow,
87        XtNfromHoriz, clientInfoButton,
88        XtNfromVert, NULL,
89	XtNresizable, True,
90	XtNjustify, XtJustifyLeft,
91	NULL);
92
93    XtAddCallback (logButton, XtNcallback, DisplayLogXtProc, NULL);
94
95    checkPointButton = XtVaCreateManagedWidget (
96	"checkPointButton", commandWidgetClass, mainWindow,
97        XtNfromHoriz, NULL,
98        XtNfromVert, clientInfoButton,
99	XtNresizable, True,
100	XtNjustify, XtJustifyLeft,
101	NULL);
102
103    XtAddCallback (checkPointButton, XtNcallback, CheckPointXtProc, NULL);
104
105    shutdownButton = XtVaCreateManagedWidget (
106	"shutdownButton", menuButtonWidgetClass, mainWindow,
107	XtNmenuName, "shutdownMenu",
108        XtNfromHoriz, checkPointButton,
109        XtNfromVert, clientInfoButton,
110	XtNresizable, True,
111	XtNjustify, XtJustifyLeft,
112	NULL);
113
114    shutdownMenu = XtVaCreatePopupShell (
115	"shutdownMenu", simpleMenuWidgetClass, mainWindow,
116	NULL);
117
118    shutdownSave = XtVaCreateManagedWidget (
119	"shutdownSave", smeBSBObjectClass, shutdownMenu,
120	NULL);
121
122    shutdownDontSave = XtVaCreateManagedWidget (
123	"shutdownDontSave", smeBSBObjectClass, shutdownMenu,
124	NULL);
125
126    XtAddCallback (shutdownSave, XtNcallback, ShutdownSaveXtProc, NULL);
127    XtAddCallback (shutdownDontSave, XtNcallback, ShutdownDontSaveXtProc, NULL);
128
129    XtAppAddActions (appContext, actions, XtNumber (actions));
130}
131