From eb244bb6e76d023f16d1bf6fb1204d7233a9bd11 Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Wed, 29 Oct 2008 12:48:44 -0200 Subject: Start working on a better benchmark visualization --- hardinfo2/benchmark.c | 5 ++++ hardinfo2/shell.c | 74 +++++++++++++++++++++++++++++++++++++++++++-------- hardinfo2/shell.h | 4 ++- 3 files changed, 71 insertions(+), 12 deletions(-) diff --git a/hardinfo2/benchmark.c b/hardinfo2/benchmark.c index 1efe34ba..f9d7926b 100644 --- a/hardinfo2/benchmark.c +++ b/hardinfo2/benchmark.c @@ -184,6 +184,11 @@ static gchar *__benchmark_include_results(gdouble result, "Zebra=1\n" "OrderType=%d\n" "ViewType=3\n" + "ColumnTitle$Extra1=CPU Clock\n" + "ColumnTitle$Extra2=Memory\n" + "ColumnTitle$Progress=Results\n" + "ColumnTitle$TextValue=CPU\n" + "ShowColumnHeaders=true\n" "[%s]\n" "This Machine=%.3f\n" "%s", order_type, benchmark, result, results); diff --git a/hardinfo2/shell.c b/hardinfo2/shell.c index cf3b776d..3dd106e2 100644 --- a/hardinfo2/shell.c +++ b/hardinfo2/shell.c @@ -724,7 +724,12 @@ static void set_view_type(ShellViewType viewtype) gtk_tree_view_set_model(GTK_TREE_VIEW(shell->info->view), shell->info->model); + /* reset to the default header values */ + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(shell->info->view), FALSE); + /* reset to the default view columns */ + gtk_tree_view_column_set_visible(shell->info->col_extra1, FALSE); + gtk_tree_view_column_set_visible(shell->info->col_extra2, FALSE); gtk_tree_view_column_set_visible(shell->info->col_progress, FALSE); gtk_tree_view_column_set_visible(shell->info->col_value, TRUE); @@ -811,6 +816,34 @@ group_handle_special(GKeyFile * key_file, ShellModuleEntry * entry, ms = g_key_file_get_integer(key_file, group, key, NULL); g_timeout_add(ms, rescan_section, entry); + } else if (g_str_equal(key, "ShowColumnHeaders")) { + gboolean show; + + show = g_key_file_get_boolean(key_file, group, key, NULL); + + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(shell->info->view), show); + } else if (g_str_has_prefix(key, "ColumnTitle")) { + GtkTreeViewColumn *column; + gchar *value, *title = strchr(key, '$') + 1; + + value = g_key_file_get_value(key_file, group, key, NULL); + + if (g_str_equal(title, "Extra1")) { + column = shell->info->col_extra1; + } else if (g_str_equal(title, "Extra2")) { + column = shell->info->col_extra2; + } else if (g_str_equal(title, "Value")) { + column = shell->info->col_value; + } else if (g_str_equal(title, "TextValue")) { + column = shell->info->col_textvalue; + } else if (g_str_equal(title, "Progress")) { + column = shell->info->col_progress; + } + + gtk_tree_view_column_set_title(column, value); + gtk_tree_view_column_set_visible(column, TRUE); + + g_free(value); } else if (g_str_equal(key, "OrderType")) { shell->_order_type = g_key_file_get_integer(key_file, group, @@ -1249,12 +1282,26 @@ static ShellInfoTree *info_tree_new(gboolean extra) store = gtk_tree_store_new(INFO_TREE_NCOL, G_TYPE_STRING, G_TYPE_STRING, - G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_FLOAT); + G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_FLOAT, + G_TYPE_STRING, G_TYPE_STRING); model = GTK_TREE_MODEL(store); treeview = gtk_tree_view_new_with_model(model); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); - column = gtk_tree_view_column_new(); + info->col_progress = column = gtk_tree_view_column_new(); + gtk_tree_view_column_set_title(column, "Results"); + gtk_tree_view_column_set_min_width(column, 240); + gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); + + cr_progress = gtk_cell_renderer_progress_new(); + gtk_tree_view_column_pack_start(column, cr_progress, TRUE); + gtk_tree_view_column_add_attribute(column, cr_progress, "value", + INFO_TREE_COL_PROGRESS); + gtk_tree_view_column_add_attribute(column, cr_progress, "text", + INFO_TREE_COL_VALUE); + gtk_tree_view_column_set_visible(column, FALSE); + + info->col_textvalue = column = gtk_tree_view_column_new(); gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); cr_pbuf = gtk_cell_renderer_pixbuf_new(); @@ -1267,24 +1314,29 @@ static ShellInfoTree *info_tree_new(gboolean extra) gtk_tree_view_column_add_attribute(column, cr_text, "markup", INFO_TREE_COL_NAME); - info->col_value = column = gtk_tree_view_column_new(); + info->col_extra1 = column = gtk_tree_view_column_new(); gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); cr_text = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(column, cr_text, FALSE); gtk_tree_view_column_add_attribute(column, cr_text, "markup", - INFO_TREE_COL_VALUE); + INFO_TREE_COL_EXTRA1); - info->col_progress = column = gtk_tree_view_column_new(); + info->col_extra2 = column = gtk_tree_view_column_new(); gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); - cr_progress = gtk_cell_renderer_progress_new(); - gtk_tree_view_column_pack_start(column, cr_progress, TRUE); - gtk_tree_view_column_add_attribute(column, cr_progress, "value", - INFO_TREE_COL_PROGRESS); - gtk_tree_view_column_add_attribute(column, cr_progress, "text", + cr_text = gtk_cell_renderer_text_new(); + gtk_tree_view_column_pack_start(column, cr_text, FALSE); + gtk_tree_view_column_add_attribute(column, cr_text, "markup", + INFO_TREE_COL_EXTRA2); + + info->col_value = column = gtk_tree_view_column_new(); + gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); + + cr_text = gtk_cell_renderer_text_new(); + gtk_tree_view_column_pack_start(column, cr_text, FALSE); + gtk_tree_view_column_add_attribute(column, cr_text, "markup", INFO_TREE_COL_VALUE); - gtk_tree_view_column_set_visible(column, FALSE); sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); diff --git a/hardinfo2/shell.h b/hardinfo2/shell.h index f8f3afed..2fa2f968 100644 --- a/hardinfo2/shell.h +++ b/hardinfo2/shell.h @@ -65,6 +65,8 @@ typedef enum { INFO_TREE_COL_DATA, INFO_TREE_COL_PBUF, INFO_TREE_COL_PROGRESS, + INFO_TREE_COL_EXTRA1, + INFO_TREE_COL_EXTRA2, INFO_TREE_NCOL } ShellInfoTreeColumns; @@ -104,7 +106,7 @@ struct _ShellInfoTree { GtkTreeModel *model; GtkTreeSelection *selection; - GtkTreeViewColumn *col_progress, *col_value; + GtkTreeViewColumn *col_progress, *col_value, *col_extra1, *col_extra2, *col_textvalue; }; struct _ShellNote { -- cgit v1.2.3 From 635ad794d064ca921e791b7f8ed654239b3325b6 Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Wed, 29 Oct 2008 15:39:33 -0200 Subject: Cleanups --- hardinfo2/computer.c | 22 ++++++++++++++++++++-- hardinfo2/shell.c | 4 +++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/hardinfo2/computer.c b/hardinfo2/computer.c index 0ae68be3..84e87610 100644 --- a/hardinfo2/computer.c +++ b/hardinfo2/computer.c @@ -282,18 +282,30 @@ gchar *callback_modules() { return g_strdup_printf("[Loaded Modules]\n" "%s" - "[$ShellParam$]\n" "ViewType=1", module_list); + "[$ShellParam$]\n" + "ViewType=1\n" + "ColumnTitle$TextValue=Name\n" + "ColumnTitle$Value=Full Name\n" + "ShowColumnHeaders=true\n", module_list); } gchar *callback_boots() { - return g_strdup(computer->os->boots); + return g_strdup_printf("[$ShellParam$]\n" + "ColumnTitle$TextValue=Date\n" + "ColumnTitle$Value=Kernel Version\n" + "ShowColumnHeaders=true\n" + "\n" + "%s", computer->os->boots); } gchar *callback_locales() { return g_strdup_printf("[$ShellParam$]\n" "ViewType=1\n" + "ColumnTitle$TextValue=Language Code\n" + "ColumnTitle$Value=Name\n" + "ShowColumnHeaders=true\n" "[Available Languages]\n" "%s", computer->os->languages); } @@ -303,6 +315,9 @@ gchar *callback_fs() return g_strdup_printf("[$ShellParam$]\n" "ViewType=1\n" "ReloadInterval=5000\n" + "ColumnTitle$TextValue=Mount Point\n" + "ColumnTitle$Value=Total / Free Space\n" + "ShowColumnHeaders=true\n" "[Mounted File Systems]\n%s\n", fs_list); } @@ -347,6 +362,9 @@ gchar *callback_network() "[$ShellParam$]\n" "ReloadInterval=3000\n" "ViewType=1\n" + "ColumnTitle$TextValue=Device\n" + "ColumnTitle$Value=Statistics\n" + "ShowColumnHeaders=true\n" "%s", network_interfaces, network_icons); } diff --git a/hardinfo2/shell.c b/hardinfo2/shell.c index 3dd106e2..7487bf13 100644 --- a/hardinfo2/shell.c +++ b/hardinfo2/shell.c @@ -1289,7 +1289,7 @@ static ShellInfoTree *info_tree_new(gboolean extra) gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); info->col_progress = column = gtk_tree_view_column_new(); - gtk_tree_view_column_set_title(column, "Results"); + gtk_tree_view_column_set_visible(column, FALSE); gtk_tree_view_column_set_min_width(column, 240); gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); @@ -1315,6 +1315,7 @@ static ShellInfoTree *info_tree_new(gboolean extra) INFO_TREE_COL_NAME); info->col_extra1 = column = gtk_tree_view_column_new(); + gtk_tree_view_column_set_visible(column, FALSE); gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); cr_text = gtk_cell_renderer_text_new(); @@ -1323,6 +1324,7 @@ static ShellInfoTree *info_tree_new(gboolean extra) INFO_TREE_COL_EXTRA1); info->col_extra2 = column = gtk_tree_view_column_new(); + gtk_tree_view_column_set_visible(column, FALSE); gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); cr_text = gtk_cell_renderer_text_new(); -- cgit v1.2.3