diff options
-rw-r--r-- | hardinfo/info.c | 15 | ||||
-rw-r--r-- | includes/info.h | 21 |
2 files changed, 34 insertions, 2 deletions
diff --git a/hardinfo/info.c b/hardinfo/info.c index 90a86148..368470b4 100644 --- a/hardinfo/info.c +++ b/hardinfo/info.c @@ -170,16 +170,27 @@ static void flatten_group(GString *output, const struct InfoGroup *group, guint if (group->fields) { for (i = 0; i < group->fields->len; i++) { struct InfoField field; + gchar tag[256] = ""; field = g_array_index(group->fields, struct InfoField, i); - if (field.icon) - g_string_append_printf(output, "$ITEM%d-%d$", group_count, i); + if (field.tag) + strncpy(tag, field.tag, 255); + else + snprintf(tag, 255, "ITEM%d-%d", group_count, i); + + if (*tag != 0 || field.flags) + g_string_append_printf(output, "$%s%s%s$", + field.flags & INFO_FIELD_SELECTED ? "*" : "", + field.flags & INFO_FIELD_SELECTED ? "!" : "", + tag); g_string_append_printf(output, "%s=%s\n", field.name, field.value); if (field.free_value_on_flatten) g_free((gchar *)field.value); + + g_free(field.tag); } } else if (group->computed) { g_string_append_printf(output, "%s\n", group->computed); diff --git a/includes/info.h b/includes/info.h index f244ceb4..da4c12e4 100644 --- a/includes/info.h +++ b/includes/info.h @@ -21,6 +21,13 @@ #include <stdarg.h> #include <glib.h> +enum { + INFO_NONE = 0, + INFO_FIELD_SELECTED = 1, /* '*' */ + INFO_FIELD_REPORT_DETAILS + = 1<<1, /* '!' */ +}; + struct Info { GArray *groups; @@ -48,8 +55,10 @@ struct InfoField { const gchar *name; const gchar *value; const gchar *icon; + gchar *tag; /* moreinfo() lookup tag */ int update_interval; + unsigned int flags; gboolean free_value_on_flatten; }; @@ -73,6 +82,18 @@ static inline struct InfoField info_field_with_icon(struct InfoField field, cons field.icon = icon; return field; } +static inline struct InfoField info_field_set_flags(struct InfoField field, int flags) +{ + field.flags |= flags; + return field; +} +#define info_field_selected(field, INFO_FIELD_SELECTED); +#define info_field_report_details(field, INFO_FIELD_REPORT_DETAILS); +static inline struct InfoField info_field_with_tag(struct InfoField field, const gchar *tag) +{ + field.tag = g_strdup(tag); + return field; +} void info_set_column_title(struct Info *info, const gchar *column, const gchar *title); void info_set_column_headers_visible(struct Info *info, gboolean setting); |