From 8bc6f1d869eaf14b2340176318d3cf6b45eff3cb Mon Sep 17 00:00:00 2001 From: Burt P Date: Sat, 6 Jul 2019 14:33:30 -0500 Subject: struct info: add field sort option to InfoGroup Fields are sorted on flatten. Signed-off-by: Burt P --- includes/info.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'includes') diff --git a/includes/info.h b/includes/info.h index 4e86c146..f2d442f4 100644 --- a/includes/info.h +++ b/includes/info.h @@ -21,6 +21,16 @@ #include #include +enum { + INFO_GROUP_SORT_NONE, + INFO_GROUP_SORT_NAME_ASCENDING, + INFO_GROUP_SORT_NAME_DESCENDING, + INFO_GROUP_SORT_VALUE_ASCENDING, + INFO_GROUP_SORT_VALUE_DESCENDING, + INFO_GROUP_SORT_TAG_ASCENDING, + INFO_GROUP_SORT_TAG_DESCENDING, +}; + struct Info { GArray *groups; @@ -37,6 +47,7 @@ struct Info { struct InfoGroup { const gchar *name; + int sort; GArray *fields; @@ -55,7 +66,7 @@ struct InfoField { gboolean report_details; /* show moreinfo() in report (flag:!) */ gboolean free_value_on_flatten; - int magic; + int some_member_with_default_value; }; struct Info *info_new(void); @@ -69,14 +80,13 @@ void info_group_add_fieldsv(struct InfoGroup *group, va_list ap); struct InfoField info_field_printf(const gchar *name, const gchar *format, ...) __attribute__((format(printf, 2, 3))); -#define INFO_LAST_MARKER 102 #define info_field_full(...) (struct InfoField) { \ - .magic = 3, \ + .some_member_with_default_value = 3, \ __VA_ARGS__ \ } #define info_field(n, v) info_field_full(.name = (n), .value = (v)) #define info_field_update(n, ui) info_field_full(.name = (n), .value = "...", .update_interval = (ui)) -#define info_field_last() (struct InfoField){.magic = INFO_LAST_MARKER} +#define info_field_last() (struct InfoField) {} static inline struct InfoField info_field_with_icon(struct InfoField field, const gchar *icon) { -- cgit v1.2.3