diff options
author | Burt P <pburt0@gmail.com> | 2019-12-27 18:39:46 -0600 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2019-12-27 22:16:36 -0800 |
commit | e7dd39f9d227c5507e3789b18c7385bd3ea3cb8c (patch) | |
tree | f9b0e8115d8a2ab67f1d14f957879531459cd426 | |
parent | 2d626b13c6180a1b3319c4dc9da57b4649063daa (diff) |
fmt_opts param for pango/html/text formatting
Signed-off-by: Burt P <pburt0@gmail.com>
-rw-r--r-- | deps/sysobj_early/include/format_early.h | 1 | ||||
-rw-r--r-- | hardinfo/util.c | 3 | ||||
-rw-r--r-- | includes/hardinfo.h | 2 | ||||
-rw-r--r-- | modules/devices/dmi_memory.c | 3 | ||||
-rw-r--r-- | modules/devices/pci.c | 6 | ||||
-rw-r--r-- | shell/report.c | 5 | ||||
-rw-r--r-- | shell/shell.c | 3 |
7 files changed, 16 insertions, 7 deletions
diff --git a/deps/sysobj_early/include/format_early.h b/deps/sysobj_early/include/format_early.h index 81a5fa37..871d173f 100644 --- a/deps/sysobj_early/include/format_early.h +++ b/deps/sysobj_early/include/format_early.h @@ -27,6 +27,7 @@ #include "util_sysobj.h" enum { + FMT_OPT_NONE = 0, FMT_OPT_ATERM = 1<<16, /* ANSI color terminal */ FMT_OPT_PANGO = 1<<17, /* pango markup for gtk */ FMT_OPT_HTML = 1<<18, /* html */ diff --git a/hardinfo/util.c b/hardinfo/util.c index 764415df..b1db6922 100644 --- a/hardinfo/util.c +++ b/hardinfo/util.c @@ -535,6 +535,9 @@ void parameters_init(int *argc, char ***argv, ProgramParameters * param) if (param->create_report && param->report_format != REPORT_FORMAT_HTML) param->markup_ok = FALSE; + // TODO: fmt_opts: FMT_OPT_ATERM, FMT_OPT_HTML, FMT_OPT_PANGO... + param->fmt_opts = FMT_OPT_NONE; + gchar *confdir = g_build_filename(g_get_user_config_dir(), "hardinfo", NULL); if (!g_file_test(confdir, G_FILE_TEST_EXISTS)) { mkdir(confdir, 0744); diff --git a/includes/hardinfo.h b/includes/hardinfo.h index 24cf81a0..d8ff20d6 100644 --- a/includes/hardinfo.h +++ b/includes/hardinfo.h @@ -29,6 +29,7 @@ #include "vendor.h" #include "gettext.h" #include "info.h" +#include "format_early.h" #define HARDINFO_COPYRIGHT_LATEST_YEAR 2019 @@ -65,6 +66,7 @@ struct _ProgramParameters { * https://developer.gnome.org/pango/stable/PangoMarkupFormat.html */ gboolean markup_ok; + int fmt_opts; gint report_format; gint max_bench_results; diff --git a/modules/devices/dmi_memory.c b/modules/devices/dmi_memory.c index 19fafa80..86829216 100644 --- a/modules/devices/dmi_memory.c +++ b/modules/devices/dmi_memory.c @@ -787,7 +787,7 @@ gchar *memory_devices_get_info() { ); g_free(spd); moreinfo_add_with_prefix(tag_prefix, tag, details); /* moreinfo now owns *details */ - const gchar *mfgr = s->mfgr ? vendor_get_shortest_name(s->mfgr) : NULL; + gchar *mfgr = s->mfgr ? vendor_match_tag(s->mfgr, params.fmt_opts) : NULL; ret = h_strdup_cprintf("$!%s$%s=%s|%s|%s\n", ret, tag, @@ -796,6 +796,7 @@ gchar *memory_devices_get_info() { ); icons = h_strdup_cprintf("Icon$%s$=%s\n", icons, tag, mem_icon); g_free(size_str); + g_free(mfgr); } else { gchar *details = g_strdup_printf("[%s]\n" "%s=0x%"PRIx32", 0x%"PRIx32"\n" diff --git a/modules/devices/pci.c b/modules/devices/pci.c index bdff87d3..6efb425c 100644 --- a/modules/devices/pci.c +++ b/modules/devices/pci.c @@ -59,8 +59,6 @@ static const gchar *find_icon_for_class(uint32_t class) return "devices.png"; } -#include "format_early.h" - static gchar *_pci_dev(const pcid *p, gchar *icons) { gchar *str; gchar *class, *vendor, *svendor, *product, *sproduct; @@ -74,8 +72,8 @@ static gchar *_pci_dev(const pcid *p, gchar *icons) { product = UNKIFNULL_AC(p->device_id_str); sproduct = UNKIFNULL_AC(p->sub_device_id_str); - gchar *ven_tag = vendor_match_tag(p->vendor_id_str, FMT_OPT_PANGO); /* TODO:FIX FOR REPORT! */ - gchar *sven_tag = vendor_match_tag(p->sub_vendor_id_str, FMT_OPT_PANGO); /* TODO:FIX FOR REPORT! */ + gchar *ven_tag = vendor_match_tag(p->vendor_id_str, params.fmt_opts); + gchar *sven_tag = vendor_match_tag(p->sub_vendor_id_str, params.fmt_opts); if (ven_tag) { if (sven_tag && !vendor_is_svendor) { name = g_strdup_printf("%s %s %s", sven_tag, ven_tag, product); diff --git a/shell/report.c b/shell/report.c index 5bb60e0d..cbe4b4d6 100644 --- a/shell/report.c +++ b/shell/report.c @@ -929,6 +929,9 @@ static gboolean report_generate(ReportDialog * rd) gchar *file; FILE *stream; + int old_fmt_opts = params.fmt_opts; + params.fmt_opts = FMT_OPT_NONE; // FIXME: FMT_OPT_HTML for HTML + if (!(file = report_get_filename())) return FALSE; @@ -943,6 +946,7 @@ static gboolean report_generate(ReportDialog * rd) g_warning(_("Cannot create ReportContext. Programming bug?")); g_free(file); fclose(stream); + params.fmt_opts = old_fmt_opts; return FALSE; } @@ -984,6 +988,7 @@ static gboolean report_generate(ReportDialog * rd) report_context_free(ctx); g_free(file); + params.fmt_opts = old_fmt_opts; return TRUE; } diff --git a/shell/shell.c b/shell/shell.c index 3ece6a84..9f31b80f 100644 --- a/shell/shell.c +++ b/shell/shell.c @@ -747,6 +747,7 @@ void shell_init(GSList * modules) DEBUG("initializing shell"); uri_set_function(hardinfo_link); + params.fmt_opts = FMT_OPT_PANGO; create_window(); @@ -1524,8 +1525,6 @@ static gboolean detail_activate_link (GtkLabel *label, gchar *uri, gpointer user return uri_open(uri); } -#include "format_early.h" - static gchar *vendor_info_markup(const Vendor *v) { if (!v) return NULL; gchar *ven_mt = NULL; |