1 /*---------------------------------------------------------------------------- 2 -- 3 -- Module: xitBusyDia 4 -- 5 -- Project: xit - X Internal Toolkit 6 -- System: xit - X Internal Toolkit 7 -- Subsystem: <> 8 -- Function block: <> 9 -- 10 -- Description: 11 -- Display a busy dialog with a 'Cancel' button. When the user 12 -- presses Cancel, the dialog is removed. 13 -- 14 -- Filename: xitBusyDia.c 15 -- 16 -- Authors: Roger Larsson, Ulrika Bornetun 17 -- Creation date: 1992-01-15 18 -- 19 -- 20 -- (C) Copyright Ulrika Bornetun, Roger Larsson (1995) 21 -- All rights reserved 22 -- 23 -- Permission to use, copy, modify, and distribute this software and its 24 -- documentation for any purpose and without fee is hereby granted, 25 -- provided that the above copyright notice appear in all copies. Ulrika 26 -- Bornetun and Roger Larsson make no representations about the usability 27 -- of this software for any purpose. It is provided "as is" without express 28 -- or implied warranty. 29 ----------------------------------------------------------------------------*/ 30 31 /* SCCS module identifier. */ 32 static char SCCSID[] = "@(#) Module: xitBusyDia.c, Version: 1.1, Date: 95/02/18 15:10:19"; 33 34 35 /*---------------------------------------------------------------------------- 36 -- Include files 37 ----------------------------------------------------------------------------*/ 38 39 #include <X11/Intrinsic.h> 40 #include <X11/Shell.h> 41 42 #include <Xm/Xm.h> 43 #include <Xm/MessageB.h> 44 45 #include "System.h" 46 47 #include "xitTools.h" 48 49 50 /*---------------------------------------------------------------------------- 51 -- Macro definitions 52 ----------------------------------------------------------------------------*/ 53 54 55 /*---------------------------------------------------------------------------- 56 -- Type declarations 57 ----------------------------------------------------------------------------*/ 58 59 60 /*---------------------------------------------------------------------------- 61 -- Global definitions 62 ----------------------------------------------------------------------------*/ 63 64 65 /*---------------------------------------------------------------------------- 66 -- Function prototypes 67 ----------------------------------------------------------------------------*/ 68 69 static void 70 cancelCB( Widget widget, 71 XtPointer client_data, 72 XtPointer call_data ); 73 74 75 76 /*---------------------------------------------------------------------------- 77 -- Functions 78 ----------------------------------------------------------------------------*/ 79 80 Widget xitCreateBusyDialog(Widget parent,char * dialog_name,char * title,char * message)81 xitCreateBusyDialog( Widget parent, 82 char *dialog_name, 83 char *title, 84 char *message ) 85 { 86 87 /* Variables. */ 88 Arg args[ 5 ]; 89 Cardinal n; 90 Widget workW; 91 92 93 /* Code. */ 94 95 /* Create a working dialog. */ 96 workW = xitCreateWorkingDialog( parent, dialog_name, 97 title, message, 98 NULL, NULL, 99 cancelCB, NULL ); 100 101 n = 0; 102 XtSetArg( args[ n ], XmNautoUnmanage, False ); n++; 103 XtSetValues( workW, args, n ); 104 105 /* Use user data to indicate that the dialog is done. */ 106 n = 0; 107 XtSetArg( args[ n ], XmNuserData, 0 ); n++; 108 XtSetValues( workW, args, n ); 109 110 111 return( workW ); 112 113 } /* xitCreateBusyDialog */ 114 115 116 /*----------------------------------------------------------------------*/ 117 118 Boolean xitBusyDialogCancelled(Widget workW,XtAppContext context)119 xitBusyDialogCancelled( Widget workW, 120 XtAppContext context ) 121 { 122 123 /* Variables. */ 124 int cancel_flag; 125 Arg args[ 5 ]; 126 Cardinal n; 127 128 129 /* Code. */ 130 131 if( workW == NULL ) 132 return( True ); 133 134 /* Process pending X events. */ 135 while( XtAppPending( context ) ) { 136 137 XEvent event; 138 139 XtAppNextEvent( context, &event ); 140 XtDispatchEvent( &event ); 141 142 } /* while */ 143 144 145 /* Was the cancel callback called? */ 146 n = 0; 147 XtSetArg( args[ n ], XmNuserData, &cancel_flag ); n++; 148 XtGetValues( workW, args, n ); 149 150 if( cancel_flag == 1 ) 151 return( True ); 152 153 154 return( False ); 155 156 } /* xitBusyDialogCancelled */ 157 158 159 /*----------------------------------------------------------------------*/ 160 161 void xitBusyDialogRemove(Widget workW)162 xitBusyDialogRemove( Widget workW ) 163 { 164 165 /* Code. */ 166 167 if( workW != NULL ) 168 XtDestroyWidget( workW ); 169 170 171 return; 172 173 } /* xitBusyDialogRemove */ 174 175 176 /*----------------------------------------------------------------------*/ 177 178 static void cancelCB(Widget widget,XtPointer client_data,XtPointer call_data)179 cancelCB( Widget widget, 180 XtPointer client_data, 181 XtPointer call_data ) 182 { 183 184 /* Variables. */ 185 Arg args[ 5 ]; 186 Cardinal n; 187 188 189 /* Code. */ 190 191 n = 0; 192 XtSetArg( args[ n ], XmNuserData, 1 ); n++; 193 XtSetValues( widget, args, n ); 194 195 196 return; 197 198 } /* cancelCB */ 199