@@ -26,13 +26,15 @@ static Ihandle *filterText, *filterButton;
26
26
Ihandle * filterSelectList ;
27
27
// timer to update icons
28
28
static Ihandle * stateIcon ;
29
- static Ihandle * timer ;
29
+ static Ihandle * timer = NULL ;
30
+ static Ihandle * timeout = NULL ;
30
31
31
32
void showStatus (const char * line );
32
33
static int uiOnDialogShow (Ihandle * ih , int state );
33
34
static int uiStopCb (Ihandle * ih );
34
35
static int uiStartCb (Ihandle * ih );
35
36
static int uiTimerCb (Ihandle * ih );
37
+ static int uiTimeoutCb (Ihandle * ih );
36
38
static int uiListSelectCb (Ihandle * ih , char * text , int item , int state );
37
39
static int uiFilterTextCb (Ihandle * ih );
38
40
static void uiSetupModule (Module * module , Ihandle * parent );
@@ -120,6 +122,7 @@ void init(int argc, char* argv[]) {
120
122
UINT ix ;
121
123
Ihandle * topVbox , * bottomVbox , * dialogVBox , * controlHbox ;
122
124
Ihandle * noneIcon , * doingIcon , * errorIcon ;
125
+ char * arg_value = NULL ;
123
126
124
127
// fill in config
125
128
loadConfig ();
@@ -242,6 +245,18 @@ void init(int argc, char* argv[]) {
242
245
IupSetAttribute (timer , "TIME" , STR (ICON_UPDATE_MS ));
243
246
IupSetCallback (timer , "ACTION_CB" , uiTimerCb );
244
247
248
+ // setup timeout of program
249
+ arg_value = IupGetGlobal ("timeout" );
250
+ if (arg_value != NULL )
251
+ {
252
+ char valueBuf [16 ];
253
+ sprintf (valueBuf , "%s000" , arg_value ); // convert from seconds to milliseconds
254
+
255
+ timeout = IupTimer ();
256
+ IupStoreAttribute (timeout , "TIME" , valueBuf );
257
+ IupSetCallback (timeout , "ACTION_CB" , uiTimeoutCb );
258
+ IupSetAttribute (timeout , "RUN" , "YES" );
259
+ }
245
260
}
246
261
247
262
void startup () {
@@ -255,7 +270,10 @@ void startup() {
255
270
}
256
271
257
272
void cleanup () {
258
- IupDestroy (timer );
273
+
274
+ if (timeout ) { IupDestroy (timeout ); }
275
+ if (timer ) { IupDestroy (timer ); }
276
+
259
277
IupClose ();
260
278
endTimePeriod (); // try close if not closing
261
279
}
@@ -382,6 +400,11 @@ static int uiTimerCb(Ihandle *ih) {
382
400
return IUP_DEFAULT ;
383
401
}
384
402
403
+ static int uiTimeoutCb (Ihandle * ih ) {
404
+ UNREFERENCED_PARAMETER (ih );
405
+ return IUP_CLOSE ;
406
+ }
407
+
385
408
static int uiListSelectCb (Ihandle * ih , char * text , int item , int state ) {
386
409
UNREFERENCED_PARAMETER (text );
387
410
UNREFERENCED_PARAMETER (ih );
0 commit comments