diff options
-rw-r--r-- | hardinfo/info.c | 33 | ||||
-rw-r--r-- | includes/info.h | 2 | ||||
-rw-r--r-- | modules/computer.c | 4 |
3 files changed, 37 insertions, 2 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; diff --git a/includes/info.h b/includes/info.h index 6aa510dc..14e1b9eb 100644 --- a/includes/info.h +++ b/includes/info.h @@ -76,7 +76,9 @@ struct InfoField { struct Info *info_new(void); struct InfoGroup *info_add_group(struct Info *info, const gchar *group_name, ...); + void info_add_computed_group(struct Info *info, const gchar *name, const gchar *value); +void info_add_computed_group_wo_extra(struct Info *info, const gchar *name, const gchar *value); void info_group_add_field(struct InfoGroup *group, struct InfoField field); void info_group_add_fields(struct InfoGroup *group, ...); diff --git a/modules/computer.c b/modules/computer.c index 9e905c5c..284e44a7 100644 --- a/modules/computer.c +++ b/modules/computer.c @@ -563,11 +563,11 @@ gchar *callback_summary(void) info_add_computed_group(info, _("Audio Devices"), idle_free(computer_get_alsacards(computer))); - info_add_computed_group(info, _("Input Devices"), + info_add_computed_group_wo_extra(info, _("Input Devices"), idle_free(module_call_method("devices::getInputDevices"))); info_add_computed_group(info, NULL, /* getPrinters provides group headers */ idle_free(module_call_method("devices::getPrinters"))); - info_add_computed_group(info, NULL, /* getStorageDevices provides group headers */ + info_add_computed_group_wo_extra(info, NULL, /* getStorageDevices provides group headers */ idle_free(module_call_method("devices::getStorageDevices"))); return info_flatten(info); |