static cb_ret_t listbox_execute_cmd (WListbox * l, long command) { cb_ret_t ret = MSG_HANDLED; Widget *w = WIDGET (l); if (l->list == NULL || g_queue_is_empty (l->list)) return MSG_NOT_HANDLED; switch (command) { case CK_Up: listbox_back (l, TRUE); break; case CK_Down: listbox_fwd (l, TRUE); break; case CK_Top: listbox_select_first (l); break; case CK_Bottom: listbox_select_last (l); break; case CK_PageUp: listbox_back_n (l, w->lines - 1); break; case CK_PageDown: listbox_fwd_n (l, w->lines - 1); break; case CK_Delete: if (l->deletable) { gboolean is_last, is_more; int length; length = g_queue_get_length (l->list); is_last = (l->pos + 1 >= length); is_more = (l->top + w->lines >= length); listbox_remove_current (l); if ((l->top > 0) && (is_last || is_more)) l->top--; } break; case CK_Clear: if (l->deletable && mc_global.widget.confirm_history_cleanup /* TRANSLATORS: no need to translate 'DialogTitle', it's just a context prefix */ && (query_dialog (Q_ ("DialogTitle|History cleanup"), _("Do you want clean this history?"), D_ERROR, 2, _("&Yes"), _("&No")) == 0)) listbox_remove_list (l); break; default: ret = MSG_NOT_HANDLED; } return ret; }
void listbox_set_list (WListbox * l, GList * list) { listbox_remove_list (l); if (l != NULL) { GList *ll; l->list = g_queue_new (); for (ll = list; ll != NULL; ll = g_list_next (ll)) g_queue_push_tail (l->list, ll->data); g_list_free (list); } }
static int task_cb (WButton * button, int action) { TaskList *tl; int sig = 0; (void) button; if (bg_list->list == NULL) return 0; /* Get this instance information */ listbox_get_current (bg_list, NULL, (void **) &tl); #ifdef SIGTSTP if (action == B_STOP) { sig = SIGSTOP; tl->state = Task_Stopped; } else if (action == B_RESUME) { sig = SIGCONT; tl->state = Task_Running; } else #endif if (action == B_KILL) { sig = SIGKILL; } if (sig == SIGKILL) unregister_task_running (tl->pid, tl->fd); kill (tl->pid, sig); listbox_remove_list (bg_list); jobs_fill_listbox (); /* This can be optimized to just redraw this widget :-) */ dlg_redraw (jobs_dlg); return 0; }
static inline void listbox_destroy (WListbox * l) { listbox_remove_list (l); }