void ChannelEditEditThread::run() { ChannelEditEditWindow edit_window(this, window, channel_picker); edit_window.create_objects(&new_channel); this->edit_window = &edit_window; int result = edit_window.run_window(); this->edit_window = 0; // Done editing channel. Keep channel. if(!result) { output_channel->copy_settings(&new_channel); window->lock_window(); window->update_list(output_channel); window->unlock_window(); } else { // Discard channel. if(!editing) { window->lock_window(); window->delete_channel(output_channel); window->unlock_window(); } } editing = 0; completion->unlock(); in_progress = 0; }
static int s_box_event_loop(STRING_BOX *sb, int *pos, int *col, SCROLLBOX *scrb) { XEvent ev; int status = -1, inew; int nn = sb->n; int done = 0, i, j; int item; char ch; int ihot = sb->hot; Window wt; Window w = sb->win[ihot]; /* active window */ char *s; s = sb->value[ihot]; XNextEvent(display, &ev); switch (ev.type) { case ConfigureNotify: case Expose: case MapNotify: do_expose(ev); /* menus and graphs etc */ expose_sbox(*sb, ev.xany.window, *pos, *col); if (scrb->exist) expose_scroll_box(ev.xany.window, *scrb); break; case MotionNotify: if (scrb->exist) scroll_box_motion(ev, scrb); break; case ButtonPress: if (scrb->exist) { item = select_scroll_item(ev.xbutton.window, *scrb); if (item >= 0) { set_sbox_item(sb, item); new_editable(sb, sb->hot, pos, col, &done, &w); destroy_scroll_box(scrb); } } if (ev.xbutton.window == sb->ok) { destroy_scroll_box(scrb); status = DONE_ALL; break; } if (ev.xbutton.window == sb->cancel) { status = FORGET_ALL; break; destroy_scroll_box(scrb); } for (i = 0; i < nn; i++) { if (ev.xbutton.window == sb->win[i]) { XSetInputFocus(display, sb->win[i], RevertToParent, CurrentTime); if (i != sb->hot) { destroy_scroll_box(scrb); new_editable(sb, i, pos, col, &done, &w); } else { /* i==sb->hot */ if (ev.xbutton.x < DCURX) { j = sb->hot; if (sb->hh[j] >= 0) { scroll_popup(sb, scrb); } } } break; } } break; case EnterNotify: wt = ev.xcrossing.window; if (scrb->exist) crossing_scroll_box(wt, 1, *scrb); if (wt == sb->ok || wt == sb->cancel) XSetWindowBorderWidth(display, wt, 2); break; case LeaveNotify: wt = ev.xcrossing.window; if (scrb->exist) crossing_scroll_box(wt, 0, *scrb); if (wt == sb->ok || wt == sb->cancel) XSetWindowBorderWidth(display, wt, 1); break; case KeyPress: ch = get_key_press(&ev); edit_window(w, pos, s, col, &done, ch); if (done != 0) { if (done == DONE_ALL) { status = DONE_ALL; break; } inew = (sb->hot + 1) % nn; new_editable(sb, inew, pos, col, &done, &w); } break; } return (status); }
static void edit_box_event(void *cookie, const XEvent *ev) { EDIT_BOX *sb = cookie; int inew; int nn = sb->n; int done = 0, i; char ch; int ihot = sb->hot; Window wt; Window w = sb->win[ihot]; /* active window */ char *s = sb->value[ihot]; switch (ev->type) { case ConfigureNotify: case Expose: case MapNotify: expose_ebox(sb, ev->xany.window); break; case ButtonRelease: if (ev->xbutton.window == sb->ok) { if (!sb->commit_func(sb->cookie, (char *)sb->value, sb->n)) { edit_box_destroy(sb); return; } } else if (ev->xbutton.window == sb->cancel) { edit_box_destroy(sb); return; } else if (ev->xbutton.window == sb->reset) { reset_ebox(sb); } break; case ButtonPress: for (i = 0; i < nn; i++) { if (ev->xbutton.window == sb->win[i]) { XSetInputFocus(display, sb->win[i], RevertToParent, CurrentTime); if (i != sb->hot) enew_editable(sb, i, &done, &w); break; } } break; case EnterNotify: wt = ev->xcrossing.window; if (wt == sb->ok || wt == sb->cancel || wt == sb->reset) XSetWindowBorderWidth(display, wt, 2); break; case LeaveNotify: wt = ev->xcrossing.window; if (wt == sb->ok || wt == sb->cancel || wt == sb->reset) XSetWindowBorderWidth(display, wt, 1); break; case KeyPress: ch = get_key_press(ev); edit_window(w, &sb->pos, s, &sb->col, &done, ch); if (done != 0) { if (done == 2) { edit_box_destroy(sb); return; } inew = (sb->hot + 1) % nn; enew_editable(sb, inew, &done, &w); } break; } }