Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / programs / dtmail / MotifApp / QuitCmd.C
1 /* $XConsortium: QuitCmd.C /main/4 1995/12/07 15:27:45 rswiston $ */
2 /*
3  *+SNOTICE
4  *
5  *      RESTRICTED CONFIDENTIAL INFORMATION:
6  *      
7  *      The information in this document is subject to special
8  *      restrictions in a confidential disclosure agreement bertween
9  *      HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
10  *      document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
11  *      Sun's specific written approval.  This documment and all copies
12  *      and derivative works thereof must be returned or destroyed at
13  *      Sun's request.
14  *
15  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
16  *
17  *+ENOTICE
18  */
19 ///////////////////////////////////////////////////////////////////////////////
20 //////////////////////////////////////////////////////////////////////////////
21 //         This example code is from the book:
22 //
23 //           Object-Oriented Programming with C++ and OSF/Motif
24 //         by
25 //           Douglas Young
26 //           Prentice Hall, 1992
27 //           ISBN 0-13-630252-1 
28 //
29 //         Copyright 1991 by Prentice Hall
30 //         All Rights Reserved
31 //
32 //  Permission to use, copy, modify, and distribute this software for 
33 //  any purpose except publication and without fee is hereby granted, provided 
34 //  that the above copyright notice appear in all copies of the software.
35 ///////////////////////////////////////////////////////////////////////////////
36 //////////////////////////////////////////////////////////////////////////////
37
38
39 ///////////////////////////////////////////////////////////
40 // QuitCmd.C: Exit an application after checking with user.
41 //////////////////////////////////////////////////////////
42 #include "QuitCmd.h"
43 #include <stdlib.h>
44 #include "MainWindow.h"
45 #include "Application.h"
46
47 #include <nl_types.h>
48 extern nl_catd catd;
49
50 #include "NLS.hh"
51
52 QuitCmd::QuitCmd ( char *name, char *label, int active, MainWindow *mywindow) : 
53                  WarnNoUndoCmd ( name, label, active ) 
54 {
55     _mywindow = mywindow;
56     _dialogParentWidget = _mywindow->baseWidget();
57     setQuestion ( GETMSG(catd, 1, 9, "Close this folder?") );
58 }
59
60 void QuitCmd::doit()
61 {
62     _mywindow->quit();
63     
64 //    exit(status);
65 }       
66
67
68 // If there are no windows in the application (say, none have been created!)
69 // or if its the last window and the user wants to close it, enquire whether
70 // the user intends to quit the session since that is what closing the last
71 // window means!
72 //
73
74
75 // HI wants the Quit to "just happen" -- they don't want any dialog
76 // to come up when user chooses to Close a container.
77 // Just call doit().  
78 // Retain code in case they change their mind and later decide to 
79 // have a confirm dialog...
80 // void 
81 // QuitCmd::execute()
82 // {
83 //     if (theApplication->num_windows() <= 1) {
84 //      char *qq = "Exit this session?";
85 //      setQuestion(qq);
86 //      this->AskFirstCmd::execute();
87 //     }
88 //     else {
89 //      this->AskFirstCmd::execute();
90 //     }
91 // }
92
93 void
94 QuitCmd::execute()
95 {
96     this->doit();
97 }
98
99