mirror of
https://github.com/flatpak/flatpak.git
synced 2026-04-27 10:37:37 -04:00
table-printer: Add append_with_comma_unique
This means we can ensure a flag is only added once
This commit is contained in:
committed by
Alexander Larsson
parent
cbe8e8ca36
commit
bf5329aa69
@@ -787,6 +787,37 @@ flatpak_table_printer_append_cell_with_comma (FlatpakTablePrinter *printer,
|
||||
set_cell (printer, r, c, text, -1, 2);
|
||||
}
|
||||
|
||||
void
|
||||
flatpak_table_printer_append_cell_with_comma_unique (FlatpakTablePrinter *printer,
|
||||
int r,
|
||||
int c,
|
||||
const char *text)
|
||||
{
|
||||
Row *row;
|
||||
Cell *cell;
|
||||
|
||||
row = (Row *) g_ptr_array_index (printer->rows, r);
|
||||
g_assert (row);
|
||||
cell = (Cell *) g_ptr_array_index (row->cells, c);
|
||||
g_assert (cell);
|
||||
|
||||
/* Look for existing text in comma separated text */
|
||||
if (cell->text != NULL && *text != 0)
|
||||
{
|
||||
gsize len = strlen (text);
|
||||
const char *match = cell->text;
|
||||
while ((match = strstr (match, text)) != NULL)
|
||||
{
|
||||
if (match[len] == 0 || match[len] == ',' )
|
||||
return; /* Already in string, do nothing */
|
||||
/* Look for next match */
|
||||
match = match + len;
|
||||
}
|
||||
}
|
||||
|
||||
set_cell (printer, r, c, text, -1, 2);
|
||||
}
|
||||
|
||||
void
|
||||
flatpak_table_printer_set_decimal_cell (FlatpakTablePrinter *printer,
|
||||
int r,
|
||||
|
||||
@@ -79,6 +79,10 @@ void flatpak_table_printer_append_cell_with_comma (FlatpakTablePr
|
||||
int row,
|
||||
int col,
|
||||
const char *cell);
|
||||
void flatpak_table_printer_append_cell_with_comma_unique (FlatpakTablePrinter *printer,
|
||||
int row,
|
||||
int col,
|
||||
const char *cell);
|
||||
void flatpak_table_printer_set_decimal_cell (FlatpakTablePrinter *printer,
|
||||
int row,
|
||||
int col,
|
||||
|
||||
Reference in New Issue
Block a user