diff options
author | Burt P <pburt0@gmail.com> | 2019-07-06 14:33:30 -0500 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2019-07-06 13:08:54 -0700 |
commit | 8bc6f1d869eaf14b2340176318d3cf6b45eff3cb (patch) | |
tree | bf3af15276f06f451c6dfcfd3bca7eb2142a6559 /includes/info.h | |
parent | 1d22dffebc3ef27b0fd3cf6fc7f0a47124ca5e5d (diff) |
struct info: add field sort option to InfoGroup
Fields are sorted on flatten.
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'includes/info.h')
-rw-r--r-- | includes/info.h | 18 |
1 files changed, 14 insertions, 4 deletions
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 <stdarg.h> #include <glib.h> +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) { |