diff options
author | Ondrej Čerman <ondrej.cerman@gmail.com> | 2019-12-28 21:14:06 +0100 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2019-12-29 21:46:38 -0800 |
commit | 7eabf4bd2085f664e0997503d9d17cb1e19cab44 (patch) | |
tree | 8d92dfe0aac195a86c870f756f03d2669c68fd81 /hardinfo | |
parent | dac822a7840997bf3ceebadfcc0915ef98053879 (diff) |
summary: remove extra columns from storage/input dev. values
Diffstat (limited to 'hardinfo')
-rw-r--r-- | hardinfo/info.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/hardinfo/info.c b/hardinfo/info.c index 49c44e2e..af3af60f 100644 --- a/hardinfo/info.c +++ b/hardinfo/info.c @@ -109,6 +109,25 @@ struct InfoField info_field_printf(const gchar *name, const gchar *format, ...) }; } +static void info_group_strip_extra(struct InfoGroup *group) +{ + guint fi; + char *val, *oldval; + struct InfoField *field; + + for (fi = 0; fi < group->fields->len; fi++) { + field = &g_array_index(group->fields, struct InfoField, fi); + if (field->value){ + val = strrchr(field->value, '|'); + if (val) { + oldval = field->value; + field->value = strdup(val + 1); + g_free(oldval); + } + } + } +} + void info_add_computed_group(struct Info *info, const gchar *name, const gchar *value) { /* This is a scaffolding method: HardInfo should move away from pre-computing @@ -137,6 +156,20 @@ void info_add_computed_group(struct Info *info, const gchar *name, const gchar * g_free(tmp_str); } +void info_add_computed_group_wo_extra(struct Info *info, const gchar *name, const gchar *value) +{ + /* This is a scaffolding method: HardInfo should move away from pre-computing + * the strings in favor of storing InfoGroups instead; while modules are not + * fully converted, use this instead. */ + struct InfoGroup *agroup; + + info_add_computed_group(info, name, value); + if (info->groups->len > 0) { + agroup = &g_array_index(info->groups, struct InfoGroup, info->groups->len - 1); + info_group_strip_extra(agroup); + } +} + void info_set_column_title(struct Info *info, const gchar *column, const gchar *title) { int i; |