(listbox_get_length): new WListbox API.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2019-07-06 19:36:56 +03:00
parent 2ed7abc3fe
commit 883e7b17b5
2 changed files with 11 additions and 3 deletions

View File

@ -639,10 +639,9 @@ void
listbox_select_last (WListbox * l) listbox_select_last (WListbox * l)
{ {
int lines = WIDGET (l)->lines; int lines = WIDGET (l)->lines;
int length = 0; int length;
if (!listbox_is_empty (l)) length = listbox_get_length (l);
length = g_queue_get_length (l->list);
l->pos = length > 0 ? length - 1 : 0; l->pos = length > 0 ? length - 1 : 0;
l->top = length > lines ? length - lines : 0; l->top = length > lines ? length - lines : 0;
@ -688,6 +687,14 @@ listbox_select_entry (WListbox * l, int dest)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
int
listbox_get_length (const WListbox * l)
{
return listbox_is_empty (l) ? 0 : (int) g_queue_get_length (l->list);
}
/* --------------------------------------------------------------------------------------------- */
/* Returns the current string text as well as the associated extra data */ /* Returns the current string text as well as the associated extra data */
void void
listbox_get_current (WListbox * l, char **string, void **extra) listbox_get_current (WListbox * l, char **string, void **extra)

View File

@ -68,6 +68,7 @@ int listbox_search_data (WListbox * l, const void *data);
void listbox_select_first (WListbox * l); void listbox_select_first (WListbox * l);
void listbox_select_last (WListbox * l); void listbox_select_last (WListbox * l);
void listbox_select_entry (WListbox * l, int dest); void listbox_select_entry (WListbox * l, int dest);
int listbox_get_length (const WListbox * l);
void listbox_get_current (WListbox * l, char **string, void **extra); void listbox_get_current (WListbox * l, char **string, void **extra);
WLEntry *listbox_get_nth_item (const WListbox * l, int pos); WLEntry *listbox_get_nth_item (const WListbox * l, int pos);
GList *listbox_get_first_link (const WListbox * l); GList *listbox_get_first_link (const WListbox * l);