mirror of
https://github.com/flatpak/flatpak.git
synced 2026-03-17 22:49:36 -04:00
table printer: Add a decimal cell setter
The download column really hsold be decimal, and we want to update it while the download is running. Closes: #2371 Approved by: alexlarsson
This commit is contained in:
committed by
Atomic Bot
parent
11532d3f5b
commit
3fe15ef665
@@ -357,16 +357,18 @@ flatpak_table_printer_get_current_row (FlatpakTablePrinter *printer)
|
||||
return printer->rows->len;
|
||||
}
|
||||
|
||||
void
|
||||
flatpak_table_printer_set_cell (FlatpakTablePrinter *printer,
|
||||
int r,
|
||||
int c,
|
||||
const char *text)
|
||||
static void
|
||||
set_cell (FlatpakTablePrinter *printer,
|
||||
int r,
|
||||
int c,
|
||||
const char *text,
|
||||
int align)
|
||||
{
|
||||
GPtrArray *row;
|
||||
Cell *cell;
|
||||
|
||||
row = (GPtrArray *)g_ptr_array_index (printer->rows, r);
|
||||
|
||||
g_assert (row);
|
||||
|
||||
cell = (Cell *)g_ptr_array_index (row, c);
|
||||
@@ -374,4 +376,29 @@ flatpak_table_printer_set_cell (FlatpakTablePrinter *printer,
|
||||
|
||||
g_free (cell->text);
|
||||
cell->text = g_strdup (text);
|
||||
cell->align = align;
|
||||
}
|
||||
|
||||
void
|
||||
flatpak_table_printer_set_cell (FlatpakTablePrinter *printer,
|
||||
int r,
|
||||
int c,
|
||||
const char *text)
|
||||
{
|
||||
set_cell (printer, r, c, text, -1);
|
||||
}
|
||||
|
||||
void
|
||||
flatpak_table_printer_set_decimal_cell (FlatpakTablePrinter *printer,
|
||||
int r,
|
||||
int c,
|
||||
const char *text)
|
||||
{
|
||||
int align = -1;
|
||||
const char *decimal = find_decimal_point (text);
|
||||
|
||||
if (decimal)
|
||||
align = decimal - text;
|
||||
|
||||
set_cell (printer, r, c, text, align);
|
||||
}
|
||||
|
||||
@@ -61,5 +61,9 @@ void flatpak_table_printer_set_cell (FlatpakTablePrinter *printer
|
||||
int row,
|
||||
int col,
|
||||
const char *cell);
|
||||
void flatpak_table_printer_set_decimal_cell (FlatpakTablePrinter *printer,
|
||||
int row,
|
||||
int col,
|
||||
const char *cell);
|
||||
|
||||
#endif /* __FLATPAK_TABLE_PRINTER_H__ */
|
||||
|
||||
Reference in New Issue
Block a user