diff options
author | Leandro Pereira <leandro@hardinfo.org> | 2017-08-14 09:48:34 -0700 |
---|---|---|
committer | Leandro Pereira <leandro@hardinfo.org> | 2017-08-14 09:48:34 -0700 |
commit | a461a29bd60928e14cc8ff311734ccd1dae5ffd4 (patch) | |
tree | b5083378cef3749bc66cf4fdec90376af8465d79 /includes/info.h | |
parent | 3d38d4bb4a68a3e0d7529d0f537ad9d33588db42 (diff) |
Begin getting rid of callbacks returning strings
Strings were never a good choice to begin with. However, with the efforts
to improve translatability, they became even worse. This is an attempt to
clean up the current mess and provide a more structured way for modules to
commmunicate with the shell.
The Computer module has been partially converted and changes will be
provided next. It's partially converted since some of its information is
still stored as strings.
The Shell still only understands strings; that's why the structured data is
converted to a string the way it is. Once all modules are converted, the
Shell can be modified to handle struct Info directly without having to parse
the .ini-like strings.
Diffstat (limited to 'includes/info.h')
-rw-r--r-- | includes/info.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/includes/info.h b/includes/info.h new file mode 100644 index 00000000..78ee935c --- /dev/null +++ b/includes/info.h @@ -0,0 +1,69 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2017 Leandro A. F. Pereira <leandro@hardinfo.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#pragma once + +#include <glib.h> + +struct Info { + GArray *groups; + + const gchar *column_titles[5]; + + ShellViewType view_type; + + int reload_interval; + + gboolean column_headers_visible; + gboolean zebra_visible; + gboolean normalize_percentage; +}; + +struct InfoGroup { + const gchar *name; + + GArray *fields; + + /* scaffolding fields */ + const gchar *computed; +}; + +struct InfoField { + const gchar *name; + const gchar *value; + + int update_interval; +}; + +struct Info *info_new(void); + +void info_add_group(struct Info *info, const gchar *group_name, ...); +void info_add_computed_group(struct Info *info, const gchar *name, const gchar *value); + +struct InfoField info_field(const gchar *name, const gchar *value); +struct InfoField info_field_update(const gchar *name, int update_interval); +struct InfoField info_field_last(void); + +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); +void info_set_zebra_visible(struct Info *info, gboolean setting); +void info_set_normalize_percentage(struct Info *info, gboolean setting); +void info_set_view_type(struct Info *info, ShellViewType setting); +void info_set_reload_interval(struct Info *info, int setting); + +gchar *info_flatten(struct Info *info); |