diff options
author | Burt P <pburt0@gmail.com> | 2018-03-02 14:33:55 -0600 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2018-03-12 09:17:41 -0700 |
commit | c9f34d357168e3c9bd6c5dc7ad97e2c05edb39df (patch) | |
tree | 2da9e2b30f4ad41ea46275e3f08c538f1c3a94b0 | |
parent | 1906d3027dc3ad8b9b5533712299d48e265c852c (diff) |
report: highlight "selected" items
For benchmark results, the current machine will be highlighted in the list
by using the shell's select marker.
Signed-off-by: Burt P <pburt0@gmail.com>
-rw-r--r-- | includes/report.h | 14 | ||||
-rw-r--r-- | shell/report.c | 28 |
2 files changed, 23 insertions, 19 deletions
diff --git a/includes/report.h b/includes/report.h index 782621cb..c04d2073 100644 --- a/includes/report.h +++ b/includes/report.h @@ -15,7 +15,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - + #ifndef __REPORT_H__ #define __REPORT_H__ #include <gtk/gtk.h> @@ -41,16 +41,16 @@ typedef struct _ReportContext ReportContext; struct _ReportContext { ShellModuleEntry *entry; gchar *output; - + void (*header) (ReportContext *ctx); void (*footer) (ReportContext *ctx); void (*title) (ReportContext *ctx, gchar *text); void (*subtitle) (ReportContext *ctx, gchar *text); void (*subsubtitle) (ReportContext *ctx, gchar *text); - void (*keyvalue) (ReportContext *ctx, gchar *key, gchar *value); - + void (*keyvalue) (ReportContext *ctx, gchar *key, gchar *value, gboolean highlight); + ReportFormat format; - + gboolean is_image_enabled; gboolean first_table; @@ -67,7 +67,7 @@ struct _ReportDialog { GtkWidget *btn_sel_all; GtkWidget *btn_sel_none; GtkWidget *treeview; - + GtkTreeModel *model; }; @@ -81,7 +81,7 @@ void report_footer (ReportContext *ctx); void report_title (ReportContext *ctx, gchar *text); void report_subtitle (ReportContext *ctx, gchar *text); void report_subsubtitle (ReportContext *ctx, gchar *text); -void report_key_value (ReportContext *ctx, gchar *key, gchar *value); +void report_key_value (ReportContext *ctx, gchar *key, gchar *value, gboolean highlight); void report_table (ReportContext *ctx, gchar *text); void report_create_from_module_list(ReportContext *ctx, GSList *modules); diff --git a/shell/report.c b/shell/report.c index 6abb03a0..4485faf5 100644 --- a/shell/report.c +++ b/shell/report.c @@ -59,9 +59,9 @@ void report_subsubtitle(ReportContext * ctx, gchar * text) ctx->subsubtitle(ctx, text); } -void report_key_value(ReportContext * ctx, gchar * key, gchar * value) +void report_key_value(ReportContext * ctx, gchar * key, gchar * value, gboolean highlight) { - ctx->keyvalue(ctx, key, value); + ctx->keyvalue(ctx, key, value, highlight); } gint report_get_visible_columns(ReportContext *ctx) @@ -211,10 +211,12 @@ void report_table(ReportContext * ctx, gchar * text) } if (*key == '$') { - report_key_value(ctx, strchr(key + 1, '$') + 1, - value); + if (*(key+1) == '*') /* check for selected/highlighted */ + report_key_value(ctx, strchr(key + 1, '$') + 1, value, TRUE); + else + report_key_value(ctx, strchr(key + 1, '$') + 1, value, FALSE); } else { - report_key_value(ctx, key, value); + report_key_value(ctx, key, value, FALSE); } } @@ -248,6 +250,7 @@ static void report_html_header(ReportContext * ctx) " .sstitle{ font: bold 80%% serif; color: #000000; background: #efefef }\n" " .field { font: 80%% sans-serif; color: #000000; padding: 2px; padding-left: 50px }\n" " .value { font: 80%% sans-serif; color: #505050 }\n" + " .hilight { font: bold 110%% sans-serif; color: #000000; background: #ffff66 }\n" "</style>\n" "</head><body>\n", VERSION); } @@ -296,22 +299,23 @@ static void report_html_subsubtitle(ReportContext * ctx, gchar * text) } static void -report_html_key_value(ReportContext * ctx, gchar * key, gchar * value) +report_html_key_value(ReportContext * ctx, gchar * key, gchar * value, gboolean highlight) { gint columns = report_get_visible_columns(ctx); gchar **values; gint i, mc; if (columns == 2) { - ctx->output = h_strdup_cprintf("<tr><td class=\"field\">%s</td>" + ctx->output = h_strdup_cprintf("<tr%s><td class=\"field\">%s</td>" "<td class=\"value\">%s</td></tr>\n", ctx->output, + highlight ? " class=\"hilight\"" : "", key, value); } else { values = g_strsplit(value, "|", columns); mc = g_strv_length(values) - 1; - ctx->output = h_strdup_cprintf("\n<tr>\n<td class=\"field\">%s</td>", ctx->output, key); + ctx->output = h_strdup_cprintf("\n<tr%s>\n<td class=\"field\">%s</td>", ctx->output, highlight ? " class=\"hilight\"" : "", key); for (i = mc; i >= 0; i--) { ctx->output = h_strdup_cprintf("<td class=\"value\">%s</td>", @@ -368,7 +372,7 @@ static void report_text_subsubtitle(ReportContext * ctx, gchar * text) } static void -report_text_key_value(ReportContext * ctx, gchar * key, gchar * value) +report_text_key_value(ReportContext * ctx, gchar * key, gchar * value, gboolean highlight) { gint columns = report_get_visible_columns(ctx); gchar **values; @@ -376,14 +380,14 @@ report_text_key_value(ReportContext * ctx, gchar * key, gchar * value) if (columns == 2) { if (strlen(value)) - ctx->output = h_strdup_cprintf("%s\t\t: %s\n", ctx->output, key, value); + ctx->output = h_strdup_cprintf("%s%s\t\t: %s\n", ctx->output, highlight ? "* " : "", key, value); else - ctx->output = h_strdup_cprintf("%s\n", ctx->output, key); + ctx->output = h_strdup_cprintf("%s%s\n", ctx->output, highlight ? "* " : "", key); } else { values = g_strsplit(value, "|", columns); mc = g_strv_length(values) - 1; - ctx->output = h_strdup_cprintf("%s\t", ctx->output, key); + ctx->output = h_strdup_cprintf("%s%s\t", ctx->output, highlight ? "* " : "", key); for (i = mc; i >= 0; i--) { ctx->output = h_strdup_cprintf("%s\t", |