Example #1
0
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;
}
Example #2
0
static void
listbox_fwd (WListbox * l)
{
    if ((guint) l->pos + 1 >= g_queue_get_length (l->list))
        listbox_select_first (l);
    else
        listbox_select_entry (l, l->pos + 1);
}
Example #3
0
static void
listbox_fwd (WListbox * l, gboolean wrap)
{
    if ((guint) l->pos + 1 < g_queue_get_length (l->list))
        listbox_select_entry (l, l->pos + 1);
    else if (wrap)
        listbox_select_first (l);
}