aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBurt P <pburt0@gmail.com>2017-08-20 10:50:04 -0500
committerLeandro A. F. Pereira <leandro@hardinfo.org>2017-08-21 05:47:00 -0700
commit573e8cd1ecb6a74751931a93f75d71102952afc0 (patch)
tree3da5abdf7c81212339bd0902cdf56c8094c281b5
parent72cd4f205211b7fffc6c5cd8926921d4eef6ab6a (diff)
Add ability to specify selected row, use it in benchmark results
Signed-off-by: Burt P <pburt0@gmail.com>
-rw-r--r--modules/benchmark.c9
-rw-r--r--shell/shell.c29
2 files changed, 33 insertions, 5 deletions
diff --git a/modules/benchmark.c b/modules/benchmark.c
index 2159fffb..76c36ecf 100644
--- a/modules/benchmark.c
+++ b/modules/benchmark.c
@@ -204,13 +204,14 @@ gchar *hi_get_field(gchar * field)
return g_strdup(field);
}
-static void br_mi_add(char **results_list, bench_result *b) {
+static void br_mi_add(char **results_list, bench_result *b, gboolean select) {
gchar *ckey, *rkey;
ckey = hardinfo_clean_label(b->machine->cpu_name, 0);
rkey = strdup(b->machine->mid);
- *results_list = h_strdup_cprintf("$%s$%s=%.2f|%s\n", *results_list, rkey, ckey,
+ *results_list = h_strdup_cprintf("$%s%s$%s=%.2f|%s\n", *results_list,
+ select ? "*" : "", rkey, ckey,
b->result, b->machine->cpu_config);
moreinfo_add_with_prefix("BENCH", rkey, bench_result_more_info(b) );
@@ -237,7 +238,7 @@ static gchar *__benchmark_include_results(gdouble result,
g_free(temp); temp = NULL;
b = bench_result_this_machine(benchmark, result, n_threads);
- br_mi_add(&results, b);
+ br_mi_add(&results, b, 1);
temp = bench_result_benchmarkconf_line(b);
printf("[%s]\n%s", benchmark, temp);
@@ -264,7 +265,7 @@ static gchar *__benchmark_include_results(gdouble result,
values = g_key_file_get_string_list(conf, benchmark, machines[i], NULL, NULL);
sbr = bench_result_benchmarkconf(benchmark, machines[i], values);
- br_mi_add(&results, sbr);
+ br_mi_add(&results, sbr, 0);
bench_result_free(sbr);
g_strfreev(values);
diff --git a/shell/shell.c b/shell/shell.c
index b81e77b6..ee031bfd 100644
--- a/shell/shell.c
+++ b/shell/shell.c
@@ -1389,6 +1389,30 @@ select_first_item(gpointer data)
return FALSE;
}
+static gboolean
+select_marked_or_first_item(gpointer data)
+{
+ GtkTreeIter first, it;
+ gboolean found_selection = FALSE;
+ gchar *datacol;
+
+ if ( gtk_tree_model_get_iter_first(shell->info->model, &first) ) {
+ it = first;
+ while ( gtk_tree_model_iter_next(shell->info->model, &it) ) {
+ gtk_tree_model_get(shell->info->model, &it, INFO_TREE_COL_DATA, &datacol, -1);
+ if (datacol != NULL && *datacol == '*') {
+ gtk_tree_selection_select_iter(shell->info->selection, &it);
+ found_selection = TRUE;
+ }
+ g_free(datacol);
+ }
+
+ if (!found_selection)
+ gtk_tree_selection_select_iter(shell->info->selection, &first);
+ }
+ return FALSE;
+}
+
static void
module_selected_show_info(ShellModuleEntry * entry, gboolean reload)
{
@@ -1491,7 +1515,7 @@ module_selected_show_info(ShellModuleEntry * entry, gboolean reload)
case SHELL_VIEW_DUAL:
case SHELL_VIEW_LOAD_GRAPH:
case SHELL_VIEW_PROGRESS_DUAL:
- g_idle_add(select_first_item, NULL);
+ g_idle_add(select_marked_or_first_item, NULL);
}
}
}
@@ -1507,6 +1531,9 @@ static void info_selected_show_extra(gchar * data)
return;
if (data) {
+ /* skip the select marker */
+ if (*data == '*')
+ data++;
GKeyFile *key_file = g_key_file_new();
gchar *key_data = shell->selected->morefunc(data);
gchar **groups;