From 2ac586a621e9d20667838df367ce5c3b4b428500 Mon Sep 17 00:00:00 2001 From: "Leandro A. F. Pereira" Date: Mon, 1 Jan 2007 17:46:52 +0000 Subject: Cleanups. --- hardinfo2/report.c | 106 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 66 insertions(+), 40 deletions(-) (limited to 'hardinfo2/report.c') diff --git a/hardinfo2/report.c b/hardinfo2/report.c index 0e17a852..0a486228 100644 --- a/hardinfo2/report.c +++ b/hardinfo2/report.c @@ -21,6 +21,7 @@ #include #include #include +#include static ReportDialog *report_dialog_new(GtkTreeModel *model, GtkWidget *parent); static void set_all_active(ReportDialog *rd, gboolean setting); @@ -67,6 +68,21 @@ report_key_value(ReportContext *ctx, gchar *key, gchar *value) ctx->keyvalue(ctx, key, value); } +void +report_context_configure(ReportContext *ctx, GKeyFile *keyfile) +{ + /* FIXME: sometime in the future we'll save images in the report. this + flag will be set if we should support that. + + so i don't forget how to encode the images inside the html files: + http://en.wikipedia.org/wiki/Data:_URI_scheme */ + + ctx->is_image_enabled = (g_key_file_get_boolean(keyfile, + "$ShellParam$", + "ViewType", + NULL) == SHELL_VIEW_PROGRESS); +} + void report_table(ReportContext *ctx, gchar *text) { @@ -82,46 +98,56 @@ report_table(ReportContext *ctx, gchar *text) gchar **keys; gint j; - if (groups[i][0] == '$') + if (groups[i][0] == '$') { + report_context_configure(ctx, key_file); continue; + } group = groups[i]; - keys = g_key_file_get_keys(key_file, group, NULL, NULL); tmpgroup = g_strdup(group); strend(group, '#'); report_subsubtitle(ctx, group); - for (j = 0; keys[j]; j++) { - gchar *key = keys[j]; - gchar *value; - - value = g_key_file_get_value(key_file, tmpgroup, key, NULL); - - if (g_utf8_validate(key, -1, NULL) && g_utf8_validate(value, -1, NULL)) { - strend(key, '#'); - - if (g_str_equal(value, "...")) { - g_free(value); - if (!(value = ctx->entry->fieldfunc(key))) { - value = g_strdup("..."); +#if 0 + if (ctx->is_image_enabled) { + report_embed_image(ctx, key_file, group); + } else { +#endif + keys = g_key_file_get_keys(key_file, tmpgroup, NULL, NULL); + for (j = 0; keys[j]; j++) { + gchar *key = keys[j]; + gchar *value; + + value = g_key_file_get_value(key_file, tmpgroup, key, NULL); + + if (g_utf8_validate(key, -1, NULL) && g_utf8_validate(value, -1, NULL)) { + strend(key, '#'); + + if (g_str_equal(value, "...")) { + g_free(value); + if (!(value = ctx->entry->fieldfunc(key))) { + value = g_strdup("..."); + } } - } - - if (*key == '$') { - report_key_value(ctx, strchr(key + 1, '$') + 1, value); - } else { - report_key_value(ctx, key, value); - } - + + if (*key == '$') { + report_key_value(ctx, strchr(key + 1, '$') + 1, value); + } else { + report_key_value(ctx, key, value); + } + + } + + g_free(value); } - g_free(value); - } - + g_strfreev(keys); +#if 0 + } +#endif g_free(tmpgroup); - g_strfreev(keys); } g_strfreev(groups); @@ -134,19 +160,19 @@ report_html_header(ReportContext *ctx) if (ctx->output) g_free(ctx->output); - ctx->output = g_strdup("\n" \ - "\n" \ - "HardInfo System Report\n" \ - "\n" \ - "\n" \ - ""); + ctx->output = g_strdup_printf("\n" \ + "\n" \ + "HardInfo (%s) System Report\n" \ + "\n" \ + "\n" \ + "
", VERSION); } static void -- cgit v1.2.3