18108eb18Smrg/* $Xorg: log.c,v 1.4 2001/02/09 02:06:01 xorgcvs Exp $ */ 28108eb18Smrg/****************************************************************************** 38108eb18Smrg 48108eb18SmrgCopyright 1994, 1998 The Open Group 58108eb18Smrg 68108eb18SmrgPermission to use, copy, modify, distribute, and sell this software and its 78108eb18Smrgdocumentation for any purpose is hereby granted without fee, provided that 88108eb18Smrgthe above copyright notice appear in all copies and that both that 98108eb18Smrgcopyright notice and this permission notice appear in supporting 108108eb18Smrgdocumentation. 118108eb18Smrg 128108eb18SmrgThe above copyright notice and this permission notice shall be included in 138108eb18Smrgall copies or substantial portions of the Software. 148108eb18Smrg 158108eb18SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 168108eb18SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 178108eb18SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 188108eb18SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 198108eb18SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 208108eb18SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 218108eb18Smrg 228108eb18SmrgExcept as contained in this notice, the name of The Open Group shall not be 238108eb18Smrgused in advertising or otherwise to promote the sale, use or other dealings 248108eb18Smrgin this Software without prior written authorization from The Open Group. 258108eb18Smrg******************************************************************************/ 268108eb18Smrg/* $XFree86: xc/programs/xsm/log.c,v 1.4 2001/01/17 23:46:29 dawes Exp $ */ 278108eb18Smrg 288108eb18Smrg#include "xsm.h" 298108eb18Smrg#include "save.h" 308108eb18Smrg#include "popup.h" 318108eb18Smrg#include "log.h" 328108eb18Smrg 338108eb18Smrg#include <X11/Shell.h> 348108eb18Smrg#include <X11/Xaw/Form.h> 358108eb18Smrg#include <X11/Xaw/Command.h> 368108eb18Smrg#include <X11/Xaw/AsciiText.h> 378108eb18Smrg 381a650d1eSmrgstatic Widget logPopup; 391a650d1eSmrgstatic Widget logForm; 401a650d1eSmrgstatic Widget logText; 411a650d1eSmrgstatic Widget logOkButton; 428108eb18Smrg 438108eb18Smrg 448108eb18Smrg 458108eb18Smrgvoid 468108eb18SmrgDisplayLogXtProc(Widget w, XtPointer client_data, XtPointer callData) 478108eb18Smrg{ 488108eb18Smrg static int first_time = 1; 498108eb18Smrg 508108eb18Smrg if (client_log_visible) 518108eb18Smrg { 528108eb18Smrg /* Make sure it is visible */ 538108eb18Smrg 548108eb18Smrg XMapRaised (XtDisplay (topLevel), XtWindow (logPopup)); 558108eb18Smrg } 568108eb18Smrg else 578108eb18Smrg { 588108eb18Smrg PopupPopup (mainWindow, logPopup, 598108eb18Smrg False, first_time, 50, 50, "DelLogWinAction()"); 608108eb18Smrg 618108eb18Smrg client_log_visible = 1; 628108eb18Smrg 638108eb18Smrg if (first_time) 648108eb18Smrg first_time = 0; 658108eb18Smrg } 668108eb18Smrg} 678108eb18Smrg 688108eb18Smrg 698108eb18Smrg 708108eb18Smrgstatic void 718108eb18SmrglogOkXtProc(Widget w, XtPointer client_data, XtPointer callData) 728108eb18Smrg{ 738108eb18Smrg XtPopdown (logPopup); 748108eb18Smrg client_log_visible = 0; 758108eb18Smrg} 768108eb18Smrg 778108eb18Smrg 788108eb18Smrg 798108eb18Smrgvoid 808108eb18Smrgadd_log_text(char *str) 818108eb18Smrg{ 828108eb18Smrg XawTextPosition pos = XawTextGetInsertionPoint (logText); 838108eb18Smrg XawTextBlock text; 848108eb18Smrg 858108eb18Smrg text.firstPos = 0; 868108eb18Smrg text.length = strlen (str); 878108eb18Smrg text.ptr = str; 888108eb18Smrg text.format = XawFmt8Bit; 898108eb18Smrg 908108eb18Smrg XawTextReplace (logText, pos, pos, &text); 918108eb18Smrg} 928108eb18Smrg 938108eb18Smrg 948108eb18Smrg 958108eb18Smrgstatic void 968108eb18SmrgDelLogWinAction(Widget w, XEvent *event, String *params, Cardinal *num_params) 978108eb18Smrg{ 988108eb18Smrg XtCallCallbacks (logOkButton, XtNcallback, NULL); 998108eb18Smrg} 1008108eb18Smrg 1018108eb18Smrg 1028108eb18Smrg 1038108eb18Smrgvoid 1048108eb18Smrgcreate_log_popup(void) 1058108eb18Smrg 1068108eb18Smrg{ 1078108eb18Smrg /* 1088108eb18Smrg * Pop up for session log 1098108eb18Smrg */ 1108108eb18Smrg 1118108eb18Smrg static XtActionsRec actions[] = { 1128108eb18Smrg {"DelLogWinAction", DelLogWinAction} 1138108eb18Smrg }; 1148108eb18Smrg 1158108eb18Smrg XtAppAddActions (appContext, actions, XtNumber (actions)); 1168108eb18Smrg 1178108eb18Smrg logPopup = XtVaCreatePopupShell ("logPopup", 1188108eb18Smrg topLevelShellWidgetClass, topLevel, 1198108eb18Smrg XtNallowShellResize, True, 1208108eb18Smrg NULL); 1218108eb18Smrg 1228108eb18Smrg logForm = XtVaCreateManagedWidget ( 1238108eb18Smrg "logForm", formWidgetClass, logPopup, 1248108eb18Smrg NULL); 1258108eb18Smrg 1268108eb18Smrg logText = XtVaCreateManagedWidget ( 1278108eb18Smrg "logText", asciiTextWidgetClass, logForm, 1288108eb18Smrg XtNfromHoriz, NULL, 1298108eb18Smrg XtNfromVert, NULL, 1308108eb18Smrg XtNeditType, XawtextAppend, 1318108eb18Smrg XtNdisplayCaret, False, 1328108eb18Smrg XtNscrollVertical, XawtextScrollAlways, 1338108eb18Smrg XtNscrollHorizontal, XawtextScrollWhenNeeded, 1348108eb18Smrg XtNresizable, True, 1358108eb18Smrg XtNtop, XawChainTop, 1368108eb18Smrg XtNbottom, XawChainBottom, 1378108eb18Smrg NULL); 1388108eb18Smrg 1398108eb18Smrg logOkButton = XtVaCreateManagedWidget ( 1408108eb18Smrg "logOkButton", commandWidgetClass, logForm, 1418108eb18Smrg XtNfromHoriz, NULL, 1428108eb18Smrg XtNfromVert, logText, 1438108eb18Smrg XtNtop, XawChainBottom, 1448108eb18Smrg XtNbottom, XawChainBottom, 1458108eb18Smrg XtNleft, XawChainLeft, 1468108eb18Smrg XtNright, XawChainLeft, 1478108eb18Smrg NULL); 1488108eb18Smrg 1491a650d1eSmrg XtAddCallback (logOkButton, XtNcallback, logOkXtProc, NULL); 1508108eb18Smrg} 151