Added deletable member to WListbox structure.

Added deletable member to WListbox structure to enable
delete some list entries.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2010-01-08 13:46:13 +03:00
parent 1695465594
commit 1947d842a5
13 changed files with 27 additions and 29 deletions

View File

@ -268,7 +268,7 @@ do_enter_key (Dlg_head * h, int f_pos)
"[Advanced Chown]", title, DLG_COMPACT | DLG_REVERSE);
/* get new listboxes */
chl_list = listbox_new (1, 1, 11, 15, NULL);
chl_list = listbox_new (1, 1, 11, 15, FALSE, NULL);
listbox_add_item (chl_list, LISTBOX_APPEND_AT_END, 0,
"<Unknown>", NULL);

View File

@ -952,7 +952,7 @@ jobs_cmd (void)
"[Background jobs]", _("Background Jobs"),
DLG_CENTER | DLG_REVERSE);
bg_list = listbox_new (2, 3, JOBS_Y - 9, JOBS_X - 7, NULL);
bg_list = listbox_new (2, 3, JOBS_Y - 9, JOBS_X - 7, FALSE, NULL);
add_widget (jobs_dlg, bg_list);
i = n_buttons;

View File

@ -181,8 +181,8 @@ init_chown (void)
}
/* get new listboxes */
l_user = listbox_new (UY + 1, UX + 1, 10, 19, NULL);
l_group = listbox_new (GY + 1, GX + 1, 10, 19, NULL);
l_user = listbox_new (UY + 1, UX + 1, 10, 19, FALSE, NULL);
l_group = listbox_new (GY + 1, GX + 1, 10, 19, FALSE, NULL);
/* add fields for unknown names (numbers) */
listbox_add_item (l_user, LISTBOX_APPEND_AT_END, 0, _("<Unknown user>"), NULL);

View File

@ -1106,7 +1106,7 @@ complete_engine (WInput *in, int what_to_do)
query_dlg = create_dlg (y, x, query_height, query_width,
dialog_colors, query_callback,
"[Completion]", NULL, DLG_COMPACT);
query_list = listbox_new (1, 1, h - 2, w - 2, NULL);
query_list = listbox_new (1, 1, h - 2, w - 2, FALSE, NULL);
add_widget (query_dlg, query_list);
for (p = in->completions + 1; *p; p++)
listbox_add_item (query_list, LISTBOX_APPEND_AT_END, 0, *p, NULL);

View File

@ -51,21 +51,19 @@
#include "lib/mcconfig.h"
#include "lib/skin.h"
#include "lib/strutil.h" /* utf string functions */
#include "lib/vfs/mc-vfs/vfs.h"
#include "src/history.h"
#include "src/widget.h" /* listbox_new() */
#include "src/layout.h" /* clr_scr() */
#include "src/main.h" /* mc_home source_codepage */
#include "src/help.h" /* interactive_display() */
#include "src/wtools.h" /* message() */
#include "src/widget.h" /* listbox_new() */
#include "src/layout.h" /* clr_scr() */
#include "src/main.h" /* mc_home source_codepage */
#include "src/help.h" /* interactive_display() */
#include "src/wtools.h" /* message() */
#include "src/charsets.h"
#include "src/selcodepage.h"
#include "src/cmddef.h"
#include "lib/vfs/mc-vfs/vfs.h"
#include "src/editor/edit-impl.h"
#include "src/editor/edit.h"
#include "src/editor/editlock.h"
#include "src/editor/edit-widget.h"
#include "src/editor/editcmd_dialogs.h"

View File

@ -340,7 +340,7 @@ editcmd_dialog_completion_show (WEdit * edit, int max_len, int word_len,
dialog_colors, NULL, "[Completion]", NULL, DLG_COMPACT);
/* create the listbox */
compl_list = listbox_new (1, 1, compl_dlg_h - 2, compl_dlg_w - 2, NULL);
compl_list = listbox_new (1, 1, compl_dlg_h - 2, compl_dlg_w - 2, FALSE, NULL);
/* add the dialog */
add_widget (compl_dlg, compl_list);
@ -425,12 +425,11 @@ editcmd_dialog_select_definition_show (WEdit * edit, char *match_expr, int max_l
dialog_colors, NULL, "[Definitions]", match_expr, DLG_COMPACT);
/* create the listbox */
def_list = listbox_new (1, 1, def_dlg_h - 2, def_dlg_w - 2, NULL);
def_list = listbox_new (1, 1, def_dlg_h - 2, def_dlg_w - 2, FALSE, NULL);
/* add the dialog */
add_widget (def_dlg, def_list);
/* fill the listbox with the completions */
for (i = 0; i < num_lines; i++) {
label_def =
@ -439,11 +438,9 @@ editcmd_dialog_select_definition_show (WEdit * edit, char *match_expr, int max_l
listbox_add_item (def_list, LISTBOX_APPEND_AT_END, 0, label_def, &def_hash[i]);
g_free (label_def);
}
/* pop up the dialog */
run_dlg (def_dlg);
/* apply the choosen completion */
if (def_dlg->ret_value == B_ENTER) {
/* pop up the dialog and apply the choosen completion */
if (run_dlg (def_dlg) == B_ENTER) {
char *tmp_curr_def = (char *) curr_def;
int do_moveto = 0;
@ -460,6 +457,7 @@ editcmd_dialog_select_definition_show (WEdit * edit, char *match_expr, int max_l
} else {
do_moveto = 1;
}
if (curr && do_moveto) {
if (edit_stack_iterator + 1 < MAX_HISTORY_MOVETO) {
g_free (edit_history_moveto[edit_stack_iterator].filename);

View File

@ -1192,7 +1192,7 @@ setup_gui (void)
add_widget (find_dlg, found_num_label);
find_list =
listbox_new (2, 2, FIND2_Y - 10, FIND2_X - 4, NULL);
listbox_new (2, 2, FIND2_Y - 10, FIND2_X - 4, FALSE, NULL);
add_widget (find_dlg, find_list);
}

View File

@ -701,7 +701,7 @@ init_hotlist (int list_type)
/* get new listbox */
l_hotlist =
listbox_new (UY + 1, UX + 1, LINES - 14, COLS - 2 * UX - 8,
l_call);
FALSE, l_call);
/* Fill the hotlist with the active VFS or the hotlist */
#ifdef ENABLE_VFS
@ -749,7 +749,7 @@ init_movelist (int list_type, struct hotlist *item)
/* get new listbox */
l_movelist =
listbox_new (UY + 1, UX + 1, movelist_dlg->lines - 8,
movelist_dlg->cols - 2 * UX - 2, l_call);
movelist_dlg->cols - 2 * UX - 2, FALSE, l_call);
fill_listbox ();

View File

@ -207,7 +207,7 @@ init_listmode (char *oldlistformat)
radio_justify->sel = 1;
/* get new listbox */
l_listmode = listbox_new (UY + 5, UX + 1, 9, 16, NULL);
l_listmode = listbox_new (UY + 5, UX + 1, 9, 16, FALSE, NULL);
if (strncmp (oldlistformat, "full ", 5) == 0) {
format_width = 1;

View File

@ -180,7 +180,7 @@ init_panelize (void)
/* get new listbox */
l_panelize =
listbox_new (UY + 1, UX + 1, 10, panelize_dlg->cols - 12, NULL);
listbox_new (UY + 1, UX + 1, 10, panelize_dlg->cols - 12, FALSE, NULL);
while (current) {
listbox_add_item (l_panelize, LISTBOX_APPEND_AT_END, 0, current->label, current);

View File

@ -1187,7 +1187,7 @@ show_hist (GList *history, Widget *widget)
"[History-query]", i18n_htitle (), DLG_COMPACT);
query_dlg->data = &hist_data;
query_list = listbox_new (1, 1, 2, 2, NULL);
query_list = listbox_new (1, 1, 2, 2, TRUE, NULL);
/* this call makes list stick to all sides of dialog, effectively make
it be resized with dialog */
@ -2454,7 +2454,7 @@ listbox_event (Gpm_Event *event, void *data)
}
WListbox *
listbox_new (int y, int x, int height, int width, lcback callback)
listbox_new (int y, int x, int height, int width, gboolean deletable, lcback callback)
{
WListbox *l = g_new (WListbox, 1);
@ -2467,6 +2467,7 @@ listbox_new (int y, int x, int height, int width, lcback callback)
l->list = NULL;
l->top = l->pos = 0;
l->count = 0;
l->deletable = deletable;
l->cback = callback;
l->allow_duplicates = TRUE;
l->scrollbar = !tty_is_slow ();

View File

@ -152,6 +152,7 @@ struct WListbox {
int count; /* Number of items in the listbox */
gboolean allow_duplicates; /* Do we allow duplicates on the list? */
gboolean scrollbar; /* Draw a scrollbar? */
gboolean deletable; /* Can list entries be deleted? */
lcback cback; /* The callback function */
int cursor_x, cursor_y; /* Cache the values */
};
@ -187,7 +188,7 @@ WCheck *check_new (int y, int x, int state, const char *text);
WInput *input_new (int y, int x, int color, int len, const char *text, const char *histname, INPUT_COMPLETE_FLAGS completion_flags);
WLabel *label_new (int y, int x, const char *text);
WGauge *gauge_new (int y, int x, int shown, int max, int current);
WListbox *listbox_new (int y, int x, int height, int width, lcback callback);
WListbox *listbox_new (int y, int x, int height, int width, gboolean deletable, lcback callback);
WButtonBar *buttonbar_new (gboolean visible);
WGroupbox *groupbox_new (int y, int x, int height, int width, const char *title);

View File

@ -101,7 +101,7 @@ create_listbox_window_centered (int center_y, int center_x, int lines, int cols,
listbox_colors, NULL,
help, title, DLG_REVERSE | DLG_TRYUP);
listbox->list = listbox_new (2, 2, lines, cols, NULL);
listbox->list = listbox_new (2, 2, lines, cols, FALSE, NULL);
add_widget (listbox->dlg, listbox->list);
return listbox;