From 437e43308bc69e6d40d8252bd932276e2ba68a8e Mon Sep 17 00:00:00 2001 From: 05356787 <05356787@localhost.localdomain> Date: Thu, 30 Oct 2008 08:48:41 -0200 Subject: Allow adding more information per column --- hardinfo2/shell.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'hardinfo2/shell.c') diff --git a/hardinfo2/shell.c b/hardinfo2/shell.c index 7487bf13..01b56fa5 100644 --- a/hardinfo2/shell.c +++ b/hardinfo2/shell.c @@ -907,16 +907,28 @@ group_handle_normal(GKeyFile * key_file, ShellModuleEntry * entry, value = entry->fieldfunc(key); } - if ((key && value) && - g_utf8_validate(key, -1, NULL) - && g_utf8_validate(value, -1, NULL)) { + if ((key && value) && g_utf8_validate(key, -1, NULL) && g_utf8_validate(value, -1, NULL)) { if (ngroups == 1) { gtk_tree_store_append(store, &child, NULL); } else { gtk_tree_store_append(store, &child, &parent); } - gtk_tree_store_set(store, &child, INFO_TREE_COL_VALUE, value, - -1); + + if (strchr(value, '|')) { + gchar **columns = g_strsplit(value, "|", 0); + + gtk_tree_store_set(store, &child, INFO_TREE_COL_VALUE, columns[0], -1); + if (columns[1]) { + gtk_tree_store_set(store, &child, INFO_TREE_COL_EXTRA1, columns[1], -1); + if (columns[2]) { + gtk_tree_store_set(store, &child, INFO_TREE_COL_EXTRA2, columns[2], -1); + } + } + + g_strfreev(columns); + } else { + gtk_tree_store_set(store, &child, INFO_TREE_COL_VALUE, value, -1); + } strend(key, '#'); @@ -1094,6 +1106,10 @@ module_selected_show_info(ShellModuleEntry * entry, gboolean reload) } store = GTK_TREE_STORE(shell->info->model); + + g_object_ref(shell->info->model); + gtk_tree_view_set_model(GTK_TREE_VIEW(shell->info->view), NULL); + gtk_tree_store_clear(store); g_key_file_load_from_data(key_file, key_data, strlen(key_data), 0, @@ -1117,6 +1133,8 @@ module_selected_show_info(ShellModuleEntry * entry, gboolean reload) g_strfreev(keys); } + g_object_unref(shell->info->model); + gtk_tree_view_set_model(GTK_TREE_VIEW(shell->info->view), shell->info->model); gtk_tree_view_expand_all(GTK_TREE_VIEW(shell->info->view)); if (shell->view_type == SHELL_VIEW_PROGRESS) { -- cgit v1.2.3 From ff03a5d1bf53392f324e4653764b3079bd94c4bf Mon Sep 17 00:00:00 2001 From: 05356787 <05356787@localhost.localdomain> Date: Thu, 30 Oct 2008 09:17:45 -0200 Subject: Cleanups --- hardinfo2/arch/linux/common/filesystem.h | 4 ++-- hardinfo2/arch/linux/common/net.h | 5 ++--- hardinfo2/computer.c | 3 ++- hardinfo2/shell.c | 2 ++ 4 files changed, 8 insertions(+), 6 deletions(-) (limited to 'hardinfo2/shell.c') diff --git a/hardinfo2/arch/linux/common/filesystem.h b/hardinfo2/arch/linux/common/filesystem.h index 3581ccbb..b3008387 100644 --- a/hardinfo2/arch/linux/common/filesystem.h +++ b/hardinfo2/arch/linux/common/filesystem.h @@ -81,9 +81,9 @@ scan_filesystems(void) stravail); g_hash_table_insert(moreinfo, g_strdup_printf("FS%d", ++count), strhash); - fs_list = h_strdup_cprintf("$FS%d$%s=%s total, %s free\n", + fs_list = h_strdup_cprintf("$FS%d$%s=%s|%s\n", fs_list, - count, tmp[0], strsize, stravail); + count, tmp[0], stravail, strsize); g_free(strsize); g_free(stravail); diff --git a/hardinfo2/arch/linux/common/net.h b/hardinfo2/arch/linux/common/net.h index 23cfa9da..8c083a9e 100644 --- a/hardinfo2/arch/linux/common/net.h +++ b/hardinfo2/arch/linux/common/net.h @@ -342,12 +342,11 @@ static void scan_net_interfaces_24(void) network_interfaces = h_strdup_cprintf - ("$%s$%s=%s|Sent %.2lfMiB, received %.2lfMiB|%s\n", + ("$%s$%s=%s|Sent %.2lfMiB, received %.2lfMiB\n", network_interfaces, devid, ifacename, ni.ip[0] ? ni.ip : "", trans_mb, recv_mb); - net_get_iface_type(ifacename, &iface_type, &iface_icon, &ni); - + network_icons = h_strdup_cprintf("Icon$%s$%s=%s.png\n", network_icons, devid, ifacename, iface_icon); diff --git a/hardinfo2/computer.c b/hardinfo2/computer.c index 379a091c..74244762 100644 --- a/hardinfo2/computer.c +++ b/hardinfo2/computer.c @@ -316,7 +316,8 @@ gchar *callback_fs() "ViewType=1\n" "ReloadInterval=5000\n" "ColumnTitle$TextValue=Mount Point\n" - "ColumnTitle$Value=Total / Free Space\n" + "ColumnTitle$Value=Free\n" + "ColumnTitle$Extra1=Total\n" "ShowColumnHeaders=true\n" "[Mounted File Systems]\n%s\n", fs_list); } diff --git a/hardinfo2/shell.c b/hardinfo2/shell.c index 01b56fa5..2a61246b 100644 --- a/hardinfo2/shell.c +++ b/hardinfo2/shell.c @@ -1109,6 +1109,7 @@ module_selected_show_info(ShellModuleEntry * entry, gboolean reload) g_object_ref(shell->info->model); gtk_tree_view_set_model(GTK_TREE_VIEW(shell->info->view), NULL); + gdk_window_freeze_updates(shell->window->window); gtk_tree_store_clear(store); @@ -1141,6 +1142,7 @@ module_selected_show_info(ShellModuleEntry * entry, gboolean reload) update_progress(); } + gdk_window_thaw_updates(shell->window->window); shell_set_note_from_entry(entry); g_strfreev(groups); -- cgit v1.2.3 From 0fa6067111faa2ce69ed8275b06ef8d5ab669a56 Mon Sep 17 00:00:00 2001 From: 05356787 <05356787@localhost.localdomain> Date: Thu, 30 Oct 2008 09:54:35 -0200 Subject: Cleanups --- hardinfo2/benchmark.c | 33 ++++++++++++++++++--------------- hardinfo2/shell.c | 3 ++- 2 files changed, 20 insertions(+), 16 deletions(-) (limited to 'hardinfo2/shell.c') diff --git a/hardinfo2/benchmark.c b/hardinfo2/benchmark.c index b1438fce..79d3d2d4 100644 --- a/hardinfo2/benchmark.c +++ b/hardinfo2/benchmark.c @@ -150,7 +150,7 @@ static gchar *__benchmark_include_results(gdouble result, { GKeyFile *conf; gchar **machines; - gchar *path, *results = g_strdup(""); + gchar *path, *results = g_strdup(""), *return_value, *processor_frequency; int i; conf = g_key_file_new(); @@ -178,22 +178,25 @@ static gchar *__benchmark_include_results(gdouble result, g_free(path); g_key_file_free(conf); - DEBUG("results = %s", results); - - return g_strdup_printf("[$ShellParam$]\n" - "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|extra1|extra2\n" - "%s", order_type, benchmark, result, results); + processor_frequency = module_call_method("devices::getProcessorFrequency"); + return_value = g_strdup_printf("[$ShellParam$]\n" + "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|%s MHz|extra2\n" + "%s", order_type, benchmark, result, processor_frequency, results); + g_free(processor_frequency); + return return_value; } + + static gchar *benchmark_include_results_reverse(gdouble result, const gchar * benchmark) { diff --git a/hardinfo2/shell.c b/hardinfo2/shell.c index 2a61246b..6d0508c7 100644 --- a/hardinfo2/shell.c +++ b/hardinfo2/shell.c @@ -1107,9 +1107,10 @@ module_selected_show_info(ShellModuleEntry * entry, gboolean reload) store = GTK_TREE_STORE(shell->info->model); + gdk_window_freeze_updates(shell->window->window); + g_object_ref(shell->info->model); gtk_tree_view_set_model(GTK_TREE_VIEW(shell->info->view), NULL); - gdk_window_freeze_updates(shell->window->window); gtk_tree_store_clear(store); -- cgit v1.2.3 From 61a8193da4f41a95852ab0bebc1afb0fab382f28 Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Thu, 30 Oct 2008 12:25:29 -0200 Subject: Fix screen blinking bug introduced with the multiple column feature --- hardinfo2/shell.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'hardinfo2/shell.c') diff --git a/hardinfo2/shell.c b/hardinfo2/shell.c index 6d0508c7..2f4cc2aa 100644 --- a/hardinfo2/shell.c +++ b/hardinfo2/shell.c @@ -724,9 +724,6 @@ 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); @@ -779,6 +776,7 @@ group_handle_special(GKeyFile * key_file, ShellModuleEntry * entry, gchar * group, gchar ** keys) { if (g_str_equal(group, "$ShellParam$")) { + gboolean headers_visible = FALSE; gint i; for (i = 0; keys[i]; i++) { @@ -817,11 +815,7 @@ group_handle_special(GKeyFile * key_file, ShellModuleEntry * entry, 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); + headers_visible = g_key_file_get_boolean(key_file, group, key, NULL); } else if (g_str_has_prefix(key, "ColumnTitle")) { GtkTreeViewColumn *column; gchar *value, *title = strchr(key, '$') + 1; @@ -874,6 +868,8 @@ group_handle_special(GKeyFile * key_file, ShellModuleEntry * entry, (key_file, group, key, NULL)); } } + + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(shell->info->view), headers_visible); } else { g_warning("Unknown parameter group: ``%s''", group); } @@ -1080,6 +1076,12 @@ module_selected_show_info(ShellModuleEntry * entry, gboolean reload) module_entry_scan(entry); key_data = module_entry_function(entry); + /* */ + gdk_window_freeze_updates(shell->info->view->window); + + g_object_ref(shell->info->model); + gtk_tree_view_set_model(GTK_TREE_VIEW(shell->info->view), NULL); + /* reset the view type to normal */ set_view_type(SHELL_VIEW_NORMAL); @@ -1107,11 +1109,6 @@ module_selected_show_info(ShellModuleEntry * entry, gboolean reload) store = GTK_TREE_STORE(shell->info->model); - gdk_window_freeze_updates(shell->window->window); - - g_object_ref(shell->info->model); - gtk_tree_view_set_model(GTK_TREE_VIEW(shell->info->view), NULL); - gtk_tree_store_clear(store); g_key_file_load_from_data(key_file, key_data, strlen(key_data), 0, @@ -1143,7 +1140,7 @@ module_selected_show_info(ShellModuleEntry * entry, gboolean reload) update_progress(); } - gdk_window_thaw_updates(shell->window->window); + gdk_window_thaw_updates(shell->info->view->window); shell_set_note_from_entry(entry); g_strfreev(groups); -- cgit v1.2.3 From 74e401413476dd683d978f1e2d11dfc16200a667 Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Thu, 30 Oct 2008 12:39:31 -0200 Subject: :/ --- hardinfo2/shell.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'hardinfo2/shell.c') diff --git a/hardinfo2/shell.c b/hardinfo2/shell.c index 2f4cc2aa..99c575e9 100644 --- a/hardinfo2/shell.c +++ b/hardinfo2/shell.c @@ -1070,6 +1070,7 @@ module_selected_show_info(ShellModuleEntry * entry, gboolean reload) GKeyFile *key_file = g_key_file_new(); GtkTreeStore *store; gchar *key_data, **groups; + gboolean has_shell_param = FALSE; gint i; gsize ngroups; @@ -1125,13 +1126,18 @@ module_selected_show_info(ShellModuleEntry * entry, gboolean reload) if (*group == '$') { group_handle_special(key_file, entry, group, keys); + has_shell_param = TRUE; } else { group_handle_normal(key_file, entry, group, keys, ngroups); } g_strfreev(keys); } - + + if (!has_shell_param) { + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(shell->info->view), FALSE); + } + g_object_unref(shell->info->model); gtk_tree_view_set_model(GTK_TREE_VIEW(shell->info->view), shell->info->model); gtk_tree_view_expand_all(GTK_TREE_VIEW(shell->info->view)); -- cgit v1.2.3 From 1d2c77e7e1b4c3fcbc6a36dd89fe3287c324e032 Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Thu, 30 Oct 2008 14:50:39 -0200 Subject: Fix typo --- hardinfo2/computer.c | 2 +- hardinfo2/shell.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'hardinfo2/shell.c') diff --git a/hardinfo2/computer.c b/hardinfo2/computer.c index 74244762..f51fdb36 100644 --- a/hardinfo2/computer.c +++ b/hardinfo2/computer.c @@ -315,7 +315,7 @@ gchar *callback_fs() return g_strdup_printf("[$ShellParam$]\n" "ViewType=1\n" "ReloadInterval=5000\n" - "ColumnTitle$TextValue=Mount Point\n" + "ColumnTitle$TextValue=Device\n" "ColumnTitle$Value=Free\n" "ColumnTitle$Extra1=Total\n" "ShowColumnHeaders=true\n" diff --git a/hardinfo2/shell.c b/hardinfo2/shell.c index 99c575e9..23ba2ad7 100644 --- a/hardinfo2/shell.c +++ b/hardinfo2/shell.c @@ -1134,21 +1134,23 @@ module_selected_show_info(ShellModuleEntry * entry, gboolean reload) g_strfreev(keys); } + /* */ if (!has_shell_param) { gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(shell->info->view), FALSE); } + /* */ g_object_unref(shell->info->model); gtk_tree_view_set_model(GTK_TREE_VIEW(shell->info->view), shell->info->model); gtk_tree_view_expand_all(GTK_TREE_VIEW(shell->info->view)); + gdk_window_thaw_updates(shell->info->view->window); + shell_set_note_from_entry(entry); + if (shell->view_type == SHELL_VIEW_PROGRESS) { update_progress(); } - gdk_window_thaw_updates(shell->info->view->window); - shell_set_note_from_entry(entry); - g_strfreev(groups); g_key_file_free(key_file); g_free(key_data); -- cgit v1.2.3