// Swallow again after window has gone. This happens while printing. static void SwallowAgainCB(Widget swallower, XtPointer client_data, XtPointer) { PlotWindowInfo *plot = (PlotWindowInfo *)client_data; assert(plot->swallower == swallower); XtAddCallback(swallower, XtNwindowCreatedCallback, SwallowCB, XtPointer(plot)); if (plot->swallow_timer != 0) XtRemoveTimeOut(plot->swallow_timer); plot->swallow_timer = XtAppAddTimeOut(XtWidgetToApplicationContext(plot->swallower), app_data.plot_window_delay, SwallowTimeOutCB, XtPointer(plot)); }
static void fontglide_free (Display *dpy, Window window, void *closure) { state *s = (state *) closure; if (s->pipe_id) XtRemoveInput (s->pipe_id); if (s->pipe) pclose (s->pipe); if (s->timer_id) XtRemoveTimeOut (s->timer_id); /* #### there's more to free here */ free (s); }
void textclient_close (text_data *d) { # ifdef DEBUG fprintf (stderr, "%s: textclient: free\n", progname); # endif close_pipe (d); if (d->program) free (d->program); if (d->pipe_timer) XtRemoveTimeOut (d->pipe_timer); d->pipe_timer = 0; memset (d, 0, sizeof (*d)); free (d); }
static void start_timer (text_data *d) { XtAppContext app = XtDisplayToApplicationContext (d->dpy); # ifdef DEBUG fprintf (stderr, "%s: textclient: relaunching in %d\n", progname, (int) d->subproc_relaunch_delay); # endif if (d->pipe_timer) XtRemoveTimeOut (d->pipe_timer); d->pipe_timer = XtAppAddTimeOut (app, d->subproc_relaunch_delay, relaunch_generator_timer, (XtPointer) d); }
/*! \reimp */ bool QXtEventLoop::processEvents( ProcessEventsFlags flags ) { // Qt uses posted events to do lots of delayed operations, like repaints... these // need to be delivered before we go to sleep TQApplication::sendPostedEvents(); // make sure we fire off Qt's timers int ttw = timeToWait(); if ( d->timerid != 0 ) { XtRemoveTimeOut( d->timerid ); } d->timerid = 0; if ( ttw != -1 ) { d->timerid = XtAppAddTimeOut( d->appContext, ttw, qmotif_timeout_handler, 0 ); } // get the pending event mask from Xt and process the next event XtInputMask pendingmask = XtAppPending( d->appContext ); XtInputMask mask = pendingmask; if ( pendingmask & XtIMTimer ) { mask &= ~XtIMTimer; // zero timers will starve the Xt X event dispatcher... so process // something *instead* of a timer first... if ( mask != 0 ) XtAppProcessEvent( d->appContext, mask ); // and process a timer afterwards mask = pendingmask & XtIMTimer; } if ( ( flags & WaitForMore ) ) XtAppProcessEvent( d->appContext, XtIMAll ); else XtAppProcessEvent( d->appContext, mask ); int nevents = 0; if ( ! ( flags & ExcludeSocketNotifiers ) ) nevents += activateSocketNotifiers(); if ( d->activate_timers ) { nevents += activateTimers(); } d->activate_timers = FALSE; return ( (flags & WaitForMore) || ( pendingmask != 0 ) || nevents > 0 ); }
static void balloon_help_destroy (void) { assert (b_dpy != NULL); b_dpy = NULL; destroy_window (b_dpy, b_win); destroy_gc (b_dpy, b_gc); destroy_gc (b_dpy, b_shineGC); destroy_gc (b_dpy, b_shadowGC); destroy_pixmap_mask (); destroy_gc (b_dpy, b_maskGC); if (b_timer) XtRemoveTimeOut (b_timer); }
static void lock_timer_init(double timsec, void (*funccall)() ) { unsigned long msec; if(lock_timer_id != 0) { XtRemoveTimeOut(lock_timer_id); lock_timer_id = 0; } lock_timer_func = funccall; if(funccall != NULL) { msec = timsec * 1000; /* milliseconds */ lock_timer_id = XtAddTimeOut(msec, lock_timer_proc, NULL); } }
static void NotifierExitHandler( ClientData clientData) /* Not used. */ { if (notifier.currentTimeout != 0) { XtRemoveTimeOut(notifier.currentTimeout); } for (; notifier.firstFileHandlerPtr != NULL; ) { Tcl_DeleteFileHandler(notifier.firstFileHandlerPtr->fd); } if (notifier.appContextCreated) { XtDestroyApplicationContext(notifier.appContext); notifier.appContextCreated = 0; notifier.appContext = NULL; } initialized = 0; }
/* ARGSUSED */ XtCallbackProc plot1d_cycle_cback(Widget w, xgobidata *xg, XtPointer callback_data) /* * Turn on cycling. */ { if (!xg->is_plot1d_cycle && cycle_timeout_id == 0L) { xg->is_plot1d_cycle = True; (void) XtAppAddWorkProc(app_con, RunWorkProcs, (XtPointer) NULL); } else { XtRemoveTimeOut(cycle_timeout_id); cycle_timeout_id = 0L; xg->is_plot1d_cycle = False; } setToggleBitmap(plot1d_cycle_cmd, xg->is_plot1d_cycle); }
// Swallow WINDOW static void swallow(PlotWindowInfo *plot, Window window) { assert(window != None); // We have the window XtRemoveCallback(plot->swallower, XtNwindowCreatedCallback, SwallowCB, XtPointer(plot)); if (plot->swallow_timer != 0) { XtRemoveTimeOut(plot->swallow_timer); plot->swallow_timer = 0; } XtVaSetValues(plot->swallower, XtNwindow, window, XtPointer(0)); popup_plot_shell(plot); }
static void ArmAndActivate(Widget w, XEvent *event, String *params, Cardinal *num_params) { XmDrawnButtonCallbackStruct cbs; DEBUGOUT(_LtDebug(__FILE__, w, "ArmAndActivate\n")); /* Arm, Activate, and Disarm now, but draw the disarmed state later */ Arm(w, event, params, num_params); if (!Lab_SkipCallback(w) && DB_ActivateCallback(w)) { XFlush(XtDisplay(w)); cbs.reason = XmCR_ACTIVATE; cbs.event = event; cbs.window = XtWindow(w); cbs.click_count = 1; XtCallCallbackList(w, DB_ActivateCallback(w), (XtPointer)&cbs); } DB_Armed(w) = False; if (DB_DisarmCallback(w)) { XFlush(XtDisplay(w)); cbs.reason = XmCR_DISARM; cbs.event = event; cbs.window = XtWindow(w); cbs.click_count = 1; XtCallCallbackList(w, DB_DisarmCallback(w), (XtPointer)&cbs); } if (DB_Timer(w) != 0) { XtRemoveTimeOut(DB_Timer(w)); DB_Timer(w) = 0; } DB_Timer(w) = XtAppAddTimeOut(XtWidgetToApplicationContext(w), ACTIVATE_DELAY, ArmTimeout, (XtPointer)w); }
// // Destroys a foe instance. // Destroys the widget and frees allocated memory for the // context. // void WFoeMotif::destroy() { if ( set_focus_disabled) XtRemoveTimeOut( focus_timerid); gre->wind->hw.foe = 0; /* Delete controled modules */ delete gre; delete node_palctx; delete con_palctx; delete navctx; /* Destroy the widget */ XtDestroyWidget( parent_wid); /* Delete the context */ delete this; }
void _XmToolTipEnter (Widget wid, XEvent * event, String * params, Cardinal * num_params) { XmToolTipConfigTrait ttp; /* ToolTip pointer */ ttp = ToolTipGetData (wid); if (ttp == NULL) { XtWarning ("ToolTipGetData() returned NULL in _XmToolTipEnter()"); return; } if ((XmIsPrimitive (wid) || XmIsGadget(wid)) && XmGetToolTipString(wid)) { if (ttp->enable && !ttp->timer) { unsigned long delay; if (event && (event->xcrossing.time - ttp->leave_time < ttp->post_delay)) { delay = 0; } else { delay = (unsigned long) ttp->post_delay; } if (ttp->duration_timer) { XtRemoveTimeOut (ttp->duration_timer); ttp->duration_timer = (XtIntervalId) NULL; } ttp->timer = XtAppAddTimeOut (XtWidgetToApplicationContext (wid), delay, (XtTimerCallbackProc) ToolTipPost, wid); } } }
ENTRYPOINT void release_sws (ModeInfo *mi) { if (scs) { int screen; for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) { sws_configuration *sc = &scs[screen]; if (sc->pipe_id) XtRemoveInput (sc->pipe_id); if (sc->pipe) pclose (sc->pipe); if (sc->pipe_timer) XtRemoveTimeOut (sc->pipe_timer); /* #### there's more to free here */ } free (scs); scs = 0; } FreeAllGL(mi); }
// // Delete a nav context // SubGraphsMotif::~SubGraphsMotif() { subgraphs_tAttr attrlist_p, next_p; if ( trace_started) XtRemoveTimeOut( trace_timerid); // Delete all attr-widgets in attrlist attrlist_p = attrlist; next_p = NULL; while( attrlist_p) { next_p = attrlist_p->next; delete attrlist_p->attrctx; free( (char *) attrlist_p); attrlist_p = next_p; } delete brow; XtDestroyWidget( parent_wid); }
static void set_alarm (void * alarm, ilu_FineTime t, void (*proc) (ilu_private rock), ilu_private rock) { ilu_FineTime t2; iluXtAlarm al = (iluXtAlarm) alarm; XtAppContext app = _XtDefaultAppContext(); if (al->id != 0) /* alarm already set */ XtRemoveTimeOut (al->id); /* clear current setting */ al->proc = proc; al->rock = rock; t2 = ilu_FineTime_Sub(t, ilu_FineTime_Now()); al->timeout = t2.ft_s * 1000 + (t2.ft_t * (1000/ilu_FineTimeRate)); al->id = XtAppAddTimeOut (app, al->timeout, (XtTimerCallbackProc)handle_timer, (void *) al); return; }
/* JJU: void StartStop(Widget widget, caddr_t data, XEvent *event) */ void StartStop(Widget widget, XtPointer data, XtPointer event) { /* Toggle propagation of display */ if (working) { XtRemoveTimeOut(timer); working = False; XtSetArg(arg[0], XtNlabel, "Start"); /* Reset button label */ XtSetValues(start_stop_button,arg,1); XFlush(display); } else { XtSetArg(arg[0], XtNlabel, "Stop"); /* Reset button label */ XtSetValues(start_stop_button,arg,1); timer = XtAppAddTimeOut(xregion_app, interval, TimeOutCallback, NULL); working = True; XFlush(display); } }
static void SetTimer( const Tcl_Time *timePtr) /* Timeout value, may be NULL. */ { long timeout; if (!initialized) { InitNotifier(); } TclSetAppContext(NULL); if (notifier.currentTimeout != 0) { XtRemoveTimeOut(notifier.currentTimeout); } if (timePtr) { timeout = timePtr->sec * 1000 + timePtr->usec / 1000; notifier.currentTimeout = XtAppAddTimeOut(notifier.appContext, (unsigned long) timeout, TimerProc, NULL); } else { notifier.currentTimeout = 0; } }
static void Throttle(Widget W, Boolean state) { Host_Throttle(W) = state; if (state) { if (Host_OutputId(W)) { XtRemoveTimeOut(Host_OutputId(W)); Host_OutputId(W) = 0; } } else { if (Host_OutputSize(W) > 0 && Host_OutputId(W) == (XtIntervalId)NULL) { Host_OutputId(W) = XtAppAddTimeOut(XtWidgetToApplicationContext(W), Host_Delay(W), (XtTimerCallbackProc)SendByte, W); } } }
/* * Uses a busy timer to check for new input. Private method. */ int check_for_input(void * ignored) { fd_set rread; int changed; struct timeval tv; int needs_redraw = FALSE; while(TRUE) { FD_ZERO(&rread); FD_SET(fileno(file),&rread); tv.tv_sec = 0; tv.tv_usec = 100; changed = select(fileno(file)+1, &rread, NULL, NULL, &tv); if (changed > 0) { read_from_file(); needs_redraw = TRUE; } else if (changed < 0) { perror("select()"); exit(1); } else { break; } } if (needs_redraw) { if (redraw_interval != NULL) { XtRemoveTimeOut(redraw_interval); } redraw_interval = XtAppAddTimeOut(app, 10, schedule_redraw, NULL); } return FALSE; }
/* Frees anything created by make_passwd_window */ static void cleanup_passwd_window (saver_info *si) { passwd_dialog_data *pw; if (!(pw = si->pw_data)) return; memset (pw->typed_passwd, 0, sizeof(pw->typed_passwd)); memset (pw->passwd_string, 0, strlen(pw->passwd_string)); if (pw->timer) { XtRemoveTimeOut (pw->timer); pw->timer = 0; } if (pw->user_entry_pixmap) { XFreePixmap(si->dpy, pw->user_entry_pixmap); pw->user_entry_pixmap = 0; } }
/* ** NPP_Shutdown is called when your DLL is being unloaded to do any ** DLL-specific shut-down. You should be a good citizen and declare that ** you're not using your java class any more. This allows java to unload ** it, freeing up memory. */ extern "C" void NPP_Shutdown(void) { if (qNP) { if (plugin_java_class) qNP->unuseJavaClass(); delete qNP; qNP = 0; } if (piApp) { #ifdef _WS_X11_ qt_np_remove_timeoutcb(np_do_timers); qt_np_remove_timer_setter(np_set_timer); qt_np_remove_event_proc(np_event_proc); qt_np_count--; if (qt_np_leave_cb == PluginSDK_QApplication::removeXtEventFiltersIfOutsideQNPWidget) qt_np_leave_cb = 0; if ( qt_np_count == 0) { // We are the last Qt-based plugin to leave removeXtEventFilters(Safe); removeXtEventFilters(Dangerous); if (qt_np_timerid) XtRemoveTimeOut( qt_np_timerid ); qt_np_timerid = 0; qt_np_leave_cb = 0; } delete piApp; #endif piApp = 0; // delete qApp; ### Crashes under X11. Waste memory until we can fix this. #ifdef _WS_WIN_ delete qApp; #endif } }
void _DtTermPrimPointerOn(Widget w) { DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w; DtTermPrimData tpd = tw->term.tpd; if (tpd->pointerFirst) InitPointerBlank(w) ; if (!tpd->pointerOn) { /* ** define the window's cursor... */ XDefineCursor(XtDisplay(tw), XtWindow(tw), tw->term.pointerShape); /* ** set a motion timeout... */ if (tw->term.pointerBlankDelay) { if (tpd->pointerTimeoutID) /* ** remove old timeout... */ XtRemoveTimeOut(tpd->pointerTimeoutID); tpd->pointerTimeoutID = XtAppAddTimeOut(XtWidgetToApplicationContext((Widget)tw), (unsigned long) (1000 * tw->term.pointerBlankDelay), (XtTimerCallbackProc)_DtTermPrimPointerOff, (XtPointer)tw); } /* ** and set the pointer on flag... */ tpd->pointerOn = True; } return; }
PixelImageFormat::~PixelImageFormat() { if (this->size_val) delete this->size_val; if (this->size_timer) XtRemoveTimeOut (this->size_timer); }
void PixelImageFormat::setCommandActivation() { int x,y,height; double hd, aspect; char size_val[64]; ImageNode *node = this->dialog->getNode(); // // Flags which will tell use what to do... // boolean rescon = node->isRecordResolutionConnected(); boolean resset = rescon || node->isRecordResolutionSet(); boolean aspcon = node->isRecordAspectConnected(); boolean aspset = aspcon || node->isRecordAspectSet(); boolean dirty_res = (this->dirty & PixelImageFormat::DirtyResolution); boolean dirty_asp = (this->dirty & PixelImageFormat::DirtyAspect); boolean rerender = this->dialog->isRerenderAllowed(); // // What are the node's values? // boolean resfetched = FALSE; boolean aspfetched = FALSE; if (rescon) { node->getRecordResolution(x,y); resfetched = TRUE; } if (aspcon) { node->getRecordAspect(aspect); aspfetched = TRUE; } if ((rerender) && (!resfetched) && (resset)) { node->getRecordResolution(x,y); resfetched = TRUE; } if ((rerender) && (!aspfetched) && (aspset)) { node->getRecordAspect(aspect); aspfetched = TRUE; } if (!resfetched) node->getResolution(x,y); if (!aspfetched) node->getAspect(aspect); // // Do we use the node's value or our own? // this->use_nodes_resolution = (rescon || !rerender || (resset && !dirty_res)); this->use_nodes_aspect = (aspcon || !rerender || (aspset && !dirty_asp)); // // If we know we're using the node's value, then disable the text widget so // that the user sees she can't enter her own value. // if (this->size_text) { if (((rescon) && (aspcon)) || (!rerender)) this->setTextSensitive (this->size_text, False); else this->setTextSensitive (this->size_text, True); } // // Based on what we already know, lets put a value into the text widget. // if ((this->use_nodes_resolution) && (this->use_nodes_aspect)) { this->aspect = aspect; this->width = x; hd = (double)this->width * this->aspect; this->dirty = 0; // // Only use the node's resolution value, use a stored // aspect to compute the height. // } else if (this->use_nodes_resolution) { this->width = x; hd = (double)this->width * this->aspect; this->dirty&= ~PixelImageFormat::DirtyResolution; // // Use the node's apsect value. Use a stored resolution value to // compute the height. // } else if (this->use_nodes_aspect) { this->aspect = aspect; hd = (double)this->width * this->aspect; this->dirty&= ~PixelImageFormat::DirtyAspect; // // Use only the values store here. // } else { hd = (double)this->width * this->aspect; } // // Round the float value for height and put the result into // the text widget. // height = (int)hd; if ((hd - height) >= 0.5) height++; sprintf (size_val, "%dx%d", this->width, height); if (this->size_val) delete this->size_val; this->size_val = DuplicateString(size_val); if (this->size_text) { if (this->size_timer) XtRemoveTimeOut (this->size_timer); this->size_timer = 0; XtRemoveCallback (this->size_text, XmNmodifyVerifyCallback, (XtCallbackProc)PixelImageFormat_ModifyCB, (XtPointer)this); XmTextSetString (this->size_text, this->size_val); XtAddCallback (this->size_text, XmNmodifyVerifyCallback, (XtCallbackProc)PixelImageFormat_ModifyCB, (XtPointer)this); } }
int ui_sync_display_of_widget(Widget widget) { int return_value = 0; XtAppContext appContext = XtWidgetToApplicationContext(widget); XEvent eventRec, *event = &eventRec; SyncDataRec syncData; Bool ignore_event = FALSE; Widget ancestor = widget; Widget last_ancestor = ancestor; Widget sync_widget = NULL; Screen *screen = NULL; syncData.timerId = 0; syncData.synced = FALSE; syncData.start_time = time(NULL); syncData.last_expose_ticks = 0; syncData.timeout_ticks = 0; syncData.display = NULL; syncData.window = NULL; #define last_expose_ticks (syncData.last_expose_ticks) #define synced (syncData.synced) #define timeout_ticks (syncData.timeout_ticks) syncData.display = XtDisplay(widget); screen = XtScreen(widget); syncData.window = RootWindowOfScreen(screen); /* * Find topmost parent of this widget that belongs to application. * This is in case this widget is destroyed (common for popups) */ last_ancestor = ancestor = widget; while ((ancestor != NULL) && (XtWidgetToApplicationContext(ancestor) == appContext)) { last_ancestor = ancestor; ancestor = XtParent(ancestor); } sync_widget = last_ancestor; syncData.window = XtWindow(sync_widget); syncData.timerId = XtAppAddTimeOut(appContext, 100, sync_timeout_proc, (XtPointer)&syncData); while (!synced) { XtAppNextEvent(appContext, event); ignore_event = ( (event->type == ClientMessage) && (event->xclient.data.l[0] == sync_notify_value)); if (!ignore_event) { XtDispatchEvent(event); } if (event_is_expose(event)) { last_expose_ticks = timeout_ticks; } if (difftime(time(NULL), syncData.start_time) >= 5) { /* we've done this long enough - give up */ synced = TRUE; } } /* while !synced */ XtRemoveTimeOut(syncData.timerId); syncData.timerId = 0; return return_value; #undef last_expose_ticks #undef synced #undef timeout_ticks }
static void CancelTimer(Widget, XtPointer client_data, XtPointer) { XtIntervalId id = XtIntervalId(client_data); XtRemoveTimeOut(id); }
static void destroy_splash_window (saver_info *si) { splash_dialog_data *sp = si->sp_data; saver_screen_info *ssi = sp->prompt_screen; Colormap cmap = DefaultColormapOfScreen (ssi->screen); Pixel black = BlackPixelOfScreen (ssi->screen); Pixel white = WhitePixelOfScreen (ssi->screen); if (sp->timer) XtRemoveTimeOut (sp->timer); if (si->splash_dialog) { XDestroyWindow (si->dpy, si->splash_dialog); si->splash_dialog = 0; } if (sp->heading_label) free (sp->heading_label); if (sp->body_label) free (sp->body_label); if (sp->body2_label) free (sp->body2_label); if (sp->demo_label) free (sp->demo_label); #ifdef PREFS_BUTTON if (sp->prefs_label) free (sp->prefs_label); #endif /* PREFS_BUTTON */ if (sp->help_label) free (sp->help_label); if (sp->heading_font) XFreeFont (si->dpy, sp->heading_font); if (sp->body_font) XFreeFont (si->dpy, sp->body_font); if (sp->button_font) XFreeFont (si->dpy, sp->button_font); if (sp->foreground != black && sp->foreground != white) XFreeColors (si->dpy, cmap, &sp->foreground, 1, 0L); if (sp->background != black && sp->background != white) XFreeColors (si->dpy, cmap, &sp->background, 1, 0L); if (sp->button_foreground != black && sp->button_foreground != white) XFreeColors (si->dpy, cmap, &sp->button_foreground, 1, 0L); if (sp->button_background != black && sp->button_background != white) XFreeColors (si->dpy, cmap, &sp->button_background, 1, 0L); if (sp->shadow_top != black && sp->shadow_top != white) XFreeColors (si->dpy, cmap, &sp->shadow_top, 1, 0L); if (sp->shadow_bottom != black && sp->shadow_bottom != white) XFreeColors (si->dpy, cmap, &sp->shadow_bottom, 1, 0L); if (sp->logo_pixmap) XFreePixmap (si->dpy, sp->logo_pixmap); if (sp->logo_clipmask) XFreePixmap (si->dpy, sp->logo_clipmask); if (sp->logo_pixels) { if (sp->logo_npixels) XFreeColors (si->dpy, cmap, sp->logo_pixels, sp->logo_npixels, 0L); free (sp->logo_pixels); sp->logo_pixels = 0; sp->logo_npixels = 0; } memset (sp, 0, sizeof(*sp)); free (sp); si->sp_data = 0; }
/* ** Clean up after the execution of a shell command sub-process and present ** the output/errors to the user as requested in the initial issueCommand ** call. If "terminatedOnError" is true, don't bother trying to read the ** output, just close the i/o descriptors, free the memory, and restore the ** user interface state. */ static void finishCmdExecution(WindowInfo *window, int terminatedOnError) { shellCmdInfo *cmdData = window->shellCmdData; textBuffer *buf; int status, failure, errorReport, reselectStart, outTextLen, errTextLen; int resp, cancel = False, fromMacro = cmdData->fromMacro; char *outText, *errText = NULL; /* Cancel any pending i/o on the file descriptors */ if (cmdData->stdoutInputID != 0) XtRemoveInput(cmdData->stdoutInputID); if (cmdData->stdinInputID != 0) XtRemoveInput(cmdData->stdinInputID); if (cmdData->stderrInputID != 0) XtRemoveInput(cmdData->stderrInputID); /* Close any file descriptors remaining open */ close(cmdData->stdoutFD); if (cmdData->flags & ERROR_DIALOGS) close(cmdData->stderrFD); if (cmdData->inPtr != NULL) close(cmdData->stdinFD); /* Free the provided input text */ if (cmdData->input != NULL) XtFree(cmdData->input); /* Cancel pending timeouts */ if (cmdData->flushTimeoutID != 0) XtRemoveTimeOut(cmdData->flushTimeoutID); if (cmdData->bannerTimeoutID != 0) XtRemoveTimeOut(cmdData->bannerTimeoutID); /* Clean up waiting-for-shell-command-to-complete mode */ if (!cmdData->fromMacro) { EndWait(window->shell); SetSensitive(window, window->cancelShellItem, False); if (cmdData->bannerIsUp) ClearModeMessage(window); } /* If the process was killed or became inaccessable, give up */ if (terminatedOnError) { freeBufList(&cmdData->outBufs); freeBufList(&cmdData->errBufs); waitpid(cmdData->childPid, &status, 0); goto cmdDone; } /* Assemble the output from the process' stderr and stdout streams into null terminated strings, and free the buffer lists used to collect it */ outText = coalesceOutput(&cmdData->outBufs, &outTextLen); if (cmdData->flags & ERROR_DIALOGS) errText = coalesceOutput(&cmdData->errBufs, &errTextLen); /* Wait for the child process to complete and get its return status */ waitpid(cmdData->childPid, &status, 0); /* Present error and stderr-information dialogs. If a command returned error output, or if the process' exit status indicated failure, present the information to the user. */ if (cmdData->flags & ERROR_DIALOGS) { failure = WIFEXITED(status) && WEXITSTATUS(status) != 0; errorReport = *errText != '\0'; if (failure && errorReport) { removeTrailingNewlines(errText); truncateString(errText, DF_MAX_MSG_LENGTH); resp = DialogF(DF_WARN, window->shell, 2, "Warning", "%s", "Cancel", "Proceed", errText); cancel = resp == 1; } else if (failure) { truncateString(outText, DF_MAX_MSG_LENGTH-70); resp = DialogF(DF_WARN, window->shell, 2, "Command Failure", "Command reported failed exit status.\n" "Output from command:\n%s", "Cancel", "Proceed", outText); cancel = resp == 1; } else if (errorReport) { removeTrailingNewlines(errText); truncateString(errText, DF_MAX_MSG_LENGTH); resp = DialogF(DF_INF, window->shell, 2, "Information", "%s", "Proceed", "Cancel", errText); cancel = resp == 2; } XtFree(errText); if (cancel) { XtFree(outText); goto cmdDone; } } /* If output is to a dialog, present the dialog. Otherwise insert the (remaining) output in the text widget as requested, and move the insert point to the end */ if (cmdData->flags & OUTPUT_TO_DIALOG) { removeTrailingNewlines(outText); if (*outText != '\0') createOutputDialog(window->shell, outText); } else if (cmdData->flags & OUTPUT_TO_STRING) { ReturnShellCommandOutput(window,outText, WEXITSTATUS(status)); } else { buf = TextGetBuffer(cmdData->textW); if (!BufSubstituteNullChars(outText, outTextLen, buf)) { fprintf(stderr,"NEdit: Too much binary data in shell cmd output\n"); outText[0] = '\0'; } if (cmdData->flags & REPLACE_SELECTION) { reselectStart = buf->primary.rectangular ? -1 : buf->primary.start; BufReplaceSelected(buf, outText); TextSetCursorPos(cmdData->textW, buf->cursorPosHint); if (reselectStart != -1) BufSelect(buf, reselectStart, reselectStart + strlen(outText)); } else { safeBufReplace(buf, &cmdData->leftPos, &cmdData->rightPos, outText); TextSetCursorPos(cmdData->textW, cmdData->leftPos+strlen(outText)); } } /* If the command requires the file to be reloaded afterward, reload it */ if (cmdData->flags & RELOAD_FILE_AFTER) RevertToSaved(window); /* Command is complete, free data structure and continue macro execution */ XtFree(outText); cmdDone: XtFree((char *)cmdData); window->shellCmdData = NULL; if (fromMacro) ResumeMacroExecution(window); }
XAttOneMotif::~XAttOneMotif() { if ( set_focus_disabled) XtRemoveTimeOut( focus_timerid); XtDestroyWidget( parent_wid); }