Use listbox_add_item_take() in obvious cases.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2024-04-20 21:29:08 +03:00
parent 401cd4a16c
commit 75ee44db20
4 changed files with 9 additions and 19 deletions

View File

@ -252,9 +252,8 @@ dialog_switch_list (void)
else else
title = g_strdup (""); title = g_strdup ("");
listbox_add_item (listbox->list, LISTBOX_APPEND_BEFORE, get_hotkey (i++), title, h, FALSE); listbox_add_item_take (listbox->list, LISTBOX_APPEND_BEFORE, get_hotkey (i++), title, h,
FALSE);
g_free (title);
} }
selected = listbox_run_with_data (listbox, mc_current); selected = listbox_run_with_data (listbox, mc_current);

View File

@ -303,9 +303,8 @@ editcmd_dialog_select_definition_add (gpointer data, gpointer user_data)
label_def = label_def =
g_strdup_printf ("%s -> %s:%ld", def_hash->short_define, def_hash->filename, g_strdup_printf ("%s -> %s:%ld", def_hash->short_define, def_hash->filename,
def_hash->line); def_hash->line);
listbox_add_item (def_list, LISTBOX_APPEND_AT_END, 0, label_def, def_hash, FALSE); listbox_add_item_take (def_list, LISTBOX_APPEND_AT_END, 0, label_def, def_hash, FALSE);
def_width = str_term_width1 (label_def); def_width = str_term_width1 (label_def);
g_free (label_def);
def_max_width = MAX (def_max_width, def_width); def_max_width = MAX (def_max_width, def_width);
} }

View File

@ -474,8 +474,7 @@ jobs_fill_listbox (WListbox * list)
char *s; char *s;
s = g_strconcat (state_str[tl->state], " ", tl->info, (char *) NULL); s = g_strconcat (state_str[tl->state], " ", tl->info, (char *) NULL);
listbox_add_item (list, LISTBOX_APPEND_AT_END, 0, s, (void *) tl, FALSE); listbox_add_item_take (list, LISTBOX_APPEND_AT_END, 0, s, (void *) tl, FALSE);
g_free (s);
} }
} }

View File

@ -271,20 +271,16 @@ static void
fill_listbox (WListbox * list) fill_listbox (WListbox * list)
{ {
struct hotlist *current; struct hotlist *current;
GString *buff;
buff = g_string_new ("");
for (current = current_group->head; current != NULL; current = current->next) for (current = current_group->head; current != NULL; current = current->next)
switch (current->type) switch (current->type)
{ {
case HL_TYPE_GROUP: case HL_TYPE_GROUP:
{ {
/* buff clean up */ char *lbl;
g_string_truncate (buff, 0);
g_string_append (buff, "->"); lbl = g_strconcat ("->", current->label, (char *) NULL);
g_string_append (buff, current->label); listbox_add_item_take (list, LISTBOX_APPEND_AT_END, 0, lbl, current, FALSE);
listbox_add_item (list, LISTBOX_APPEND_AT_END, 0, buff->str, current, FALSE);
} }
break; break;
case HL_TYPE_DOTDOT: case HL_TYPE_DOTDOT:
@ -294,8 +290,6 @@ fill_listbox (WListbox * list)
default: default:
break; break;
} }
g_string_free (buff, TRUE);
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -988,8 +982,7 @@ add2hotlist (char *label, char *directory, enum HotListType type, listbox_append
char *lbl; char *lbl;
lbl = g_strconcat ("->", new->label, (char *) NULL); lbl = g_strconcat ("->", new->label, (char *) NULL);
listbox_add_item (l_hotlist, pos, 0, lbl, new, FALSE); listbox_add_item_take (l_hotlist, pos, 0, lbl, new, FALSE);
g_free (lbl);
} }
else else
listbox_add_item (l_hotlist, pos, 0, new->label, new, FALSE); listbox_add_item (l_hotlist, pos, 0, new->label, new, FALSE);