mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
WListbox: renames:
WListbox::pos -> WListbox::current listbox_select_entry() -> listbox_set_current() listbox_get_nth_item() -> listbox_get_nth_entry() Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
e6cb6591b3
commit
35b5d8e2f2
@ -252,13 +252,13 @@ history_show (history_descriptor_t * hd)
|
||||
if (hd->current < 0 || (size_t) hd->current >= count)
|
||||
listbox_select_last (hd->listbox);
|
||||
else
|
||||
listbox_select_entry (hd->listbox, count - 1 - (size_t) hd->current);
|
||||
listbox_set_current (hd->listbox, count - 1 - (size_t) hd->current);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* history is below base widget -- keep order to place recent item on top */
|
||||
if (hd->current > 0)
|
||||
listbox_select_entry (hd->listbox, hd->current);
|
||||
listbox_set_current (hd->listbox, hd->current);
|
||||
}
|
||||
|
||||
dlg_ret = dlg_run (query_dlg);
|
||||
|
@ -1078,7 +1078,7 @@ complete_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void
|
||||
|
||||
if (strncmp (input->buffer->str + start, le->text, new_end - start) == 0)
|
||||
{
|
||||
listbox_select_entry (LISTBOX (g->current->data), i);
|
||||
listbox_set_current (LISTBOX (g->current->data), i);
|
||||
end = new_end;
|
||||
input_handle_char (input, parm);
|
||||
widget_draw (WIDGET (g->current->data));
|
||||
@ -1136,7 +1136,7 @@ complete_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void
|
||||
if (need_redraw == 0)
|
||||
{
|
||||
need_redraw = 1;
|
||||
listbox_select_entry (LISTBOX (g->current->data), i);
|
||||
listbox_set_current (LISTBOX (g->current->data), i);
|
||||
last_text = le->text;
|
||||
}
|
||||
else
|
||||
|
@ -131,7 +131,7 @@ listbox_run (Listbox * l)
|
||||
int val = -1;
|
||||
|
||||
if (dlg_run (l->dlg) != B_CANCEL)
|
||||
val = l->list->pos;
|
||||
val = l->list->current;
|
||||
widget_destroy (WIDGET (l->dlg));
|
||||
g_free (l);
|
||||
return val;
|
||||
@ -152,12 +152,13 @@ listbox_run_with_data (Listbox * l, const void *select)
|
||||
void *val = NULL;
|
||||
|
||||
if (select != NULL)
|
||||
listbox_select_entry (l->list, listbox_search_data (l->list, select));
|
||||
listbox_set_current (l->list, listbox_search_data (l->list, select));
|
||||
|
||||
if (dlg_run (l->dlg) != B_CANCEL)
|
||||
{
|
||||
WLEntry *e;
|
||||
e = listbox_get_nth_item (l->list, l->list->pos);
|
||||
|
||||
e = listbox_get_nth_entry (l->list, l->list->current);
|
||||
if (e != NULL)
|
||||
{
|
||||
/* The assert guards against returning a soon-to-be deallocated
|
||||
|
@ -116,7 +116,7 @@ listbox_drawscroll (const WListbox * l)
|
||||
|
||||
/* Now draw the nice relative pointer */
|
||||
if (!g_queue_is_empty (l->list))
|
||||
line = 1 + ((l->pos * (w->lines - 2)) / length);
|
||||
line = 1 + ((l->current * (w->lines - 2)) / length);
|
||||
|
||||
for (i = 1; i < max_line; i++)
|
||||
{
|
||||
@ -164,7 +164,7 @@ listbox_draw (WListbox * l, gboolean focused)
|
||||
const char *text = "";
|
||||
|
||||
/* Display the entry */
|
||||
if (pos == l->pos && sel_line == -1)
|
||||
if (pos == l->current && sel_line == -1)
|
||||
{
|
||||
sel_line = i;
|
||||
tty_setcolor (selc);
|
||||
@ -233,8 +233,8 @@ listbox_fwd (WListbox * l, gboolean wrap)
|
||||
{
|
||||
if (!listbox_is_empty (l))
|
||||
{
|
||||
if ((guint) l->pos + 1 < g_queue_get_length (l->list))
|
||||
listbox_select_entry (l, l->pos + 1);
|
||||
if ((guint) l->current + 1 < g_queue_get_length (l->list))
|
||||
listbox_set_current (l, l->current + 1);
|
||||
else if (wrap)
|
||||
listbox_select_first (l);
|
||||
}
|
||||
@ -245,7 +245,7 @@ listbox_fwd (WListbox * l, gboolean wrap)
|
||||
static void
|
||||
listbox_fwd_n (WListbox * l, int n)
|
||||
{
|
||||
listbox_select_entry (l, MIN (l->pos + n, LISTBOX_LAST (l)));
|
||||
listbox_set_current (l, MIN (l->current + n, LISTBOX_LAST (l)));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -255,8 +255,8 @@ listbox_back (WListbox * l, gboolean wrap)
|
||||
{
|
||||
if (!listbox_is_empty (l))
|
||||
{
|
||||
if (l->pos > 0)
|
||||
listbox_select_entry (l, l->pos - 1);
|
||||
if (l->current > 0)
|
||||
listbox_set_current (l, l->current - 1);
|
||||
else if (wrap)
|
||||
listbox_select_last (l);
|
||||
}
|
||||
@ -267,7 +267,7 @@ listbox_back (WListbox * l, gboolean wrap)
|
||||
static void
|
||||
listbox_back_n (WListbox * l, int n)
|
||||
{
|
||||
listbox_select_entry (l, MAX (l->pos - n, 0));
|
||||
listbox_set_current (l, MAX (l->current - n, 0));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -309,7 +309,7 @@ listbox_execute_cmd (WListbox * l, long command)
|
||||
|
||||
length = g_queue_get_length (l->list);
|
||||
|
||||
is_last = (l->pos + 1 >= length);
|
||||
is_last = (l->current + 1 >= length);
|
||||
is_more = (l->top + w->lines >= length);
|
||||
|
||||
listbox_remove_current (l);
|
||||
@ -351,7 +351,7 @@ listbox_key (WListbox * l, int key)
|
||||
/* focus on listbox item N by '0'..'9' keys */
|
||||
if (key >= '0' && key <= '9')
|
||||
{
|
||||
listbox_select_entry (l, key - '0');
|
||||
listbox_set_current (l, key - '0');
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
|
||||
@ -365,7 +365,7 @@ listbox_key (WListbox * l, int key)
|
||||
|
||||
/* Listbox item adding function */
|
||||
static inline void
|
||||
listbox_append_item (WListbox * l, WLEntry * e, listbox_append_t pos)
|
||||
listbox_add_entry (WListbox * l, WLEntry * e, listbox_append_t pos)
|
||||
{
|
||||
if (l->list == NULL)
|
||||
{
|
||||
@ -380,11 +380,11 @@ listbox_append_item (WListbox * l, WLEntry * e, listbox_append_t pos)
|
||||
break;
|
||||
|
||||
case LISTBOX_APPEND_BEFORE:
|
||||
g_queue_insert_before (l->list, g_queue_peek_nth_link (l->list, (guint) l->pos), e);
|
||||
g_queue_insert_before (l->list, g_queue_peek_nth_link (l->list, (guint) l->current), e);
|
||||
break;
|
||||
|
||||
case LISTBOX_APPEND_AFTER:
|
||||
g_queue_insert_after (l->list, g_queue_peek_nth_link (l->list, (guint) l->pos), e);
|
||||
g_queue_insert_after (l->list, g_queue_peek_nth_link (l->list, (guint) l->current), e);
|
||||
break;
|
||||
|
||||
case LISTBOX_APPEND_SORTED:
|
||||
@ -435,7 +435,7 @@ listbox_do_action (WListbox * l)
|
||||
static void
|
||||
listbox_run_hotkey (WListbox * l, int pos)
|
||||
{
|
||||
listbox_select_entry (l, pos);
|
||||
listbox_set_current (l, pos);
|
||||
listbox_on_change (l);
|
||||
listbox_do_action (l);
|
||||
}
|
||||
@ -506,15 +506,15 @@ static void
|
||||
listbox_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
|
||||
{
|
||||
WListbox *l = LISTBOX (w);
|
||||
int old_pos;
|
||||
int old_current;
|
||||
|
||||
old_pos = l->pos;
|
||||
old_current = l->current;
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
case MSG_MOUSE_DOWN:
|
||||
widget_select (w);
|
||||
listbox_select_entry (l, listbox_y_pos (l, event->y));
|
||||
listbox_set_current (l, listbox_y_pos (l, event->y));
|
||||
break;
|
||||
|
||||
case MSG_MOUSE_SCROLL_UP:
|
||||
@ -527,11 +527,11 @@ listbox_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
|
||||
|
||||
case MSG_MOUSE_DRAG:
|
||||
event->result.repeat = TRUE; /* It'd be functional even without this. */
|
||||
listbox_select_entry (l, listbox_y_pos (l, event->y));
|
||||
listbox_set_current (l, listbox_y_pos (l, event->y));
|
||||
break;
|
||||
|
||||
case MSG_MOUSE_CLICK:
|
||||
/* We don't call listbox_select_entry() here: MSG_MOUSE_DOWN/DRAG did this already. */
|
||||
/* We don't call listbox_set_current() here: MSG_MOUSE_DOWN/DRAG did this already. */
|
||||
if (event->count == GPM_DOUBLE) /* Double click */
|
||||
listbox_do_action (l);
|
||||
break;
|
||||
@ -541,7 +541,7 @@ listbox_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
|
||||
}
|
||||
|
||||
/* If the selection has changed, we redraw the widget and notify the dialog. */
|
||||
if (l->pos != old_pos)
|
||||
if (l->current != old_current)
|
||||
listbox_on_change (l);
|
||||
}
|
||||
|
||||
@ -564,7 +564,7 @@ listbox_new (int y, int x, int height, int width, gboolean deletable, lcback_fn
|
||||
w->keymap = listbox_map;
|
||||
|
||||
l->list = NULL;
|
||||
l->top = l->pos = 0;
|
||||
l->top = l->current = 0;
|
||||
l->deletable = deletable;
|
||||
l->callback = callback;
|
||||
l->allow_duplicates = TRUE;
|
||||
@ -625,11 +625,11 @@ listbox_search_data (WListbox * l, const void *data)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* Selects the first entry and scrolls the list to the top */
|
||||
/* Select the first entry and scrolls the list to the top */
|
||||
void
|
||||
listbox_select_first (WListbox * l)
|
||||
{
|
||||
l->pos = l->top = 0;
|
||||
l->current = l->top = 0;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -643,14 +643,14 @@ listbox_select_last (WListbox * l)
|
||||
|
||||
length = listbox_get_length (l);
|
||||
|
||||
l->pos = DOZ (length, 1);
|
||||
l->current = DOZ (length, 1);
|
||||
l->top = DOZ (length, lines);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
listbox_select_entry (WListbox * l, int dest)
|
||||
listbox_set_current (WListbox * l, int dest)
|
||||
{
|
||||
GList *le;
|
||||
int pos;
|
||||
@ -667,22 +667,22 @@ listbox_select_entry (WListbox * l, int dest)
|
||||
|
||||
if (pos == dest)
|
||||
{
|
||||
l->pos = dest;
|
||||
l->current = dest;
|
||||
if (!top_seen)
|
||||
l->top = l->pos;
|
||||
l->top = l->current;
|
||||
else
|
||||
{
|
||||
int lines = WIDGET (l)->rect.lines;
|
||||
|
||||
if (l->pos - l->top >= lines)
|
||||
l->top = l->pos - lines + 1;
|
||||
if (l->current - l->top >= lines)
|
||||
l->top = l->current - lines + 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* If we are unable to find it, set decent values */
|
||||
l->pos = l->top = 0;
|
||||
l->current = l->top = 0;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -703,7 +703,7 @@ listbox_get_current (WListbox * l, char **string, void **extra)
|
||||
gboolean ok;
|
||||
|
||||
if (l != NULL)
|
||||
e = listbox_get_nth_item (l, l->pos);
|
||||
e = listbox_get_nth_entry (l, l->current);
|
||||
|
||||
ok = (e != NULL);
|
||||
|
||||
@ -717,7 +717,7 @@ listbox_get_current (WListbox * l, char **string, void **extra)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
WLEntry *
|
||||
listbox_get_nth_item (const WListbox * l, int pos)
|
||||
listbox_get_nth_entry (const WListbox * l, int pos)
|
||||
{
|
||||
if (!listbox_is_empty (l) && pos >= 0)
|
||||
{
|
||||
@ -749,16 +749,16 @@ listbox_remove_current (WListbox * l)
|
||||
GList *current;
|
||||
int length;
|
||||
|
||||
current = g_queue_peek_nth_link (l->list, (guint) l->pos);
|
||||
current = g_queue_peek_nth_link (l->list, (guint) l->current);
|
||||
listbox_entry_free (current->data);
|
||||
g_queue_delete_link (l->list, current);
|
||||
|
||||
length = g_queue_get_length (l->list);
|
||||
|
||||
if (length == 0)
|
||||
l->top = l->pos = 0;
|
||||
else if (l->pos >= length)
|
||||
l->pos = length - 1;
|
||||
l->top = l->current = 0;
|
||||
else if (l->current >= length)
|
||||
l->current = length - 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -800,7 +800,7 @@ listbox_remove_list (WListbox * l)
|
||||
l->list = NULL;
|
||||
}
|
||||
|
||||
l->pos = l->top = 0;
|
||||
l->current = l->top = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -824,7 +824,7 @@ listbox_add_item (WListbox * l, listbox_append_t pos, int hotkey, const char *te
|
||||
entry->free_data = free_data;
|
||||
entry->hotkey = hotkey;
|
||||
|
||||
listbox_append_item (l, entry, pos);
|
||||
listbox_add_entry (l, entry, pos);
|
||||
|
||||
return entry->text;
|
||||
}
|
||||
|
@ -45,8 +45,8 @@ typedef struct WListbox
|
||||
{
|
||||
Widget widget;
|
||||
GQueue *list; /* Pointer to the list of WLEntry */
|
||||
int pos; /* The current element displayed */
|
||||
int top; /* The first element displayed */
|
||||
int current; /* The current element displayed */
|
||||
gboolean allow_duplicates; /* Do we allow duplicates on the list? */
|
||||
gboolean scrollbar; /* Draw a scrollbar? */
|
||||
gboolean deletable; /* Can list entries be deleted? */
|
||||
@ -65,10 +65,10 @@ int listbox_search_text (WListbox * l, const char *text);
|
||||
int listbox_search_data (WListbox * l, const void *data);
|
||||
void listbox_select_first (WListbox * l);
|
||||
void listbox_select_last (WListbox * l);
|
||||
void listbox_select_entry (WListbox * l, int dest);
|
||||
void listbox_set_current (WListbox * l, int dest);
|
||||
int listbox_get_length (const WListbox * l);
|
||||
void listbox_get_current (WListbox * l, char **string, void **extra);
|
||||
WLEntry *listbox_get_nth_item (const WListbox * l, int pos);
|
||||
WLEntry *listbox_get_nth_entry (const WListbox * l, int pos);
|
||||
GList *listbox_get_first_link (const WListbox * l);
|
||||
void listbox_remove_current (WListbox * l);
|
||||
gboolean listbox_is_empty (const WListbox * l);
|
||||
|
@ -1436,7 +1436,7 @@ exec_edit_syntax_dialog (const GPtrArray * names, const char *current_syntax)
|
||||
name = g_ptr_array_index (names, i);
|
||||
LISTBOX_APPEND_TEXT (syntaxlist, 0, name, NULL, FALSE);
|
||||
if (current_syntax != NULL && strcmp (name, current_syntax) == 0)
|
||||
listbox_select_entry (syntaxlist->list, i + N_DFLT_ENTRIES);
|
||||
listbox_set_current (syntaxlist->list, i + N_DFLT_ENTRIES);
|
||||
}
|
||||
|
||||
return listbox_run (syntaxlist);
|
||||
|
@ -531,7 +531,7 @@ user_group_button_cb (WButton * button, int action)
|
||||
|
||||
gboolean is_owner = (f_pos == BUTTONS_PERM - 2);
|
||||
const char *title;
|
||||
int lxx, b_pos;
|
||||
int lxx, b_current;
|
||||
WDialog *chl_dlg;
|
||||
WListbox *chl_list;
|
||||
int result;
|
||||
@ -582,16 +582,16 @@ user_group_button_cb (WButton * button, int action)
|
||||
fe = listbox_search_text (chl_list, get_group (sf_stat.st_gid));
|
||||
}
|
||||
|
||||
listbox_select_entry (chl_list, fe);
|
||||
listbox_set_current (chl_list, fe);
|
||||
|
||||
b_pos = chl_list->pos;
|
||||
b_current = chl_list->current;
|
||||
group_add_widget (GROUP (chl_dlg), chl_list);
|
||||
|
||||
result = dlg_run (chl_dlg);
|
||||
|
||||
if (result != B_CANCEL)
|
||||
{
|
||||
if (b_pos != chl_list->pos)
|
||||
if (b_current != chl_list->current)
|
||||
{
|
||||
gboolean ok = FALSE;
|
||||
char *text;
|
||||
|
@ -234,7 +234,7 @@ sel_skin_button (WButton * button, int action)
|
||||
(void *) skin_name, FALSE);
|
||||
|
||||
if (strcmp (skin_name, current_skin_name) == 0)
|
||||
listbox_select_entry (skin_list, 0);
|
||||
listbox_set_current (skin_list, 0);
|
||||
|
||||
for (i = 0; i < skin_names->len; i++)
|
||||
{
|
||||
@ -244,7 +244,7 @@ sel_skin_button (WButton * button, int action)
|
||||
listbox_add_item (skin_list, LISTBOX_APPEND_AT_END, 0, skin_name_to_label (skin_name),
|
||||
(void *) skin_name, FALSE);
|
||||
if (strcmp (skin_name, current_skin_name) == 0)
|
||||
listbox_select_entry (skin_list, pos);
|
||||
listbox_set_current (skin_list, pos);
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
|
@ -436,8 +436,8 @@ chown_cmd (WPanel * panel)
|
||||
ch_dlg = chown_dlg_create (panel);
|
||||
|
||||
/* select in listboxes */
|
||||
listbox_select_entry (l_user, listbox_search_text (l_user, get_owner (sf_stat.st_uid)));
|
||||
listbox_select_entry (l_group, listbox_search_text (l_group, get_group (sf_stat.st_gid)));
|
||||
listbox_set_current (l_user, listbox_search_text (l_user, get_owner (sf_stat.st_uid)));
|
||||
listbox_set_current (l_group, listbox_search_text (l_group, get_group (sf_stat.st_gid)));
|
||||
|
||||
chown_label (0, str_trunc (fname->str, GW - 4));
|
||||
chown_label (1, str_trunc (get_owner (sf_stat.st_uid), GW - 4));
|
||||
|
@ -993,7 +993,7 @@ add2hotlist (char *label, char *directory, enum HotListType type, listbox_append
|
||||
}
|
||||
else
|
||||
listbox_add_item (l_hotlist, pos, 0, new->label, new, FALSE);
|
||||
listbox_select_entry (l_hotlist, l_hotlist->pos);
|
||||
listbox_set_current (l_hotlist, l_hotlist->current);
|
||||
}
|
||||
|
||||
return new;
|
||||
|
@ -302,7 +302,7 @@ collect_new_format (void)
|
||||
last = NULL;
|
||||
for (i = 0;; i++)
|
||||
{
|
||||
listbox_select_entry (l_listmode, i);
|
||||
listbox_set_current (l_listmode, i);
|
||||
listbox_get_current (l_listmode, &text, &extra);
|
||||
if (text == last)
|
||||
break;
|
||||
|
@ -121,11 +121,11 @@ panelize_entry_add_to_listbox (gpointer data, gpointer user_data)
|
||||
static void
|
||||
update_command (void)
|
||||
{
|
||||
if (l_panelize->pos != last_listitem)
|
||||
if (l_panelize->current != last_listitem)
|
||||
{
|
||||
panelize_entry_t *data = NULL;
|
||||
|
||||
last_listitem = l_panelize->pos;
|
||||
last_listitem = l_panelize->current;
|
||||
listbox_get_current (l_panelize, NULL, (void **) &data);
|
||||
input_assign_text (pname, data->command);
|
||||
pname->point = 0;
|
||||
@ -210,7 +210,7 @@ external_panelize_init (void)
|
||||
|
||||
l_panelize = listbox_new (y, UX + 1, 10, panelize_cols - UX * 2 - 2, FALSE, NULL);
|
||||
g_slist_foreach (panelize, panelize_entry_add_to_listbox, NULL);
|
||||
listbox_select_entry (l_panelize, listbox_search_text (l_panelize, _("Other command")));
|
||||
listbox_set_current (l_panelize, listbox_search_text (l_panelize, _("Other command")));
|
||||
group_add_widget (g, l_panelize);
|
||||
|
||||
y += WIDGET (l_panelize)->rect.lines + 1;
|
||||
|
@ -109,7 +109,7 @@ select_charset (int center_y, int center_x, int current_charset, gboolean seldis
|
||||
? ((current_charset < 0) ? codepages->len : (size_t) current_charset)
|
||||
: ((size_t) current_charset + 1);
|
||||
|
||||
listbox_select_entry (listbox->list, i);
|
||||
listbox_set_current (listbox->list, i);
|
||||
|
||||
listbox_result = listbox_run (listbox);
|
||||
|
||||
|
@ -1151,7 +1151,7 @@ user_menu_cmd (const Widget * edit_widget, const char *menu_file, int selected_e
|
||||
extract_line (p, p + MAX_ENTRY_LEN), p, FALSE);
|
||||
}
|
||||
/* Select the default entry */
|
||||
listbox_select_entry (listbox->list, selected);
|
||||
listbox_set_current (listbox->list, selected);
|
||||
|
||||
selected = listbox_run (listbox);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user