aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeandro A. F. Pereira <leandro@hardinfo.org>2008-10-31 22:35:43 -0300
committerLeandro A. F. Pereira <leandro@hardinfo.org>2008-10-31 22:35:43 -0300
commit26bfbc6e7310f76b8fca6fee2957a74e7fd1feae (patch)
tree07a52e1c0d34e615b5e89245daf24476f48658a7
parent69268767f3055cb6e1548459185c2617ef7977f6 (diff)
parentcafe9d5b63c93d7d0c20154bb8ffa510dd50cbef (diff)
Merge branch 'master' of git@github.com:lpereira/hardinfo
-rw-r--r--hardinfo2/arch/linux/common/boots.h7
-rw-r--r--hardinfo2/arch/linux/common/filesystem.h16
-rw-r--r--hardinfo2/computer.c10
-rw-r--r--hardinfo2/shell.c41
-rw-r--r--hardinfo2/shell.h2
5 files changed, 56 insertions, 20 deletions
diff --git a/hardinfo2/arch/linux/common/boots.h b/hardinfo2/arch/linux/common/boots.h
index b5285a9f..8a3c11fa 100644
--- a/hardinfo2/arch/linux/common/boots.h
+++ b/hardinfo2/arch/linux/common/boots.h
@@ -47,11 +47,10 @@ scan_boots_real(void)
}
}
- tmp = g_strsplit(buffer, " ", 5);
- computer->os->boots = h_strdup_cprintf("\n%s=Kernel %s",
+ tmp = g_strsplit(buffer, " ", 0);
+ computer->os->boots = h_strdup_cprintf("\n%s %s %s %s=%s|%s",
computer->os->boots,
- tmp[4],
- tmp[3]);
+ tmp[4], tmp[5], tmp[6], tmp[7], tmp[3], tmp[8]);
g_strfreev(tmp);
}
}
diff --git a/hardinfo2/arch/linux/common/filesystem.h b/hardinfo2/arch/linux/common/filesystem.h
index b3008387..0224e962 100644
--- a/hardinfo2/arch/linux/common/filesystem.h
+++ b/hardinfo2/arch/linux/common/filesystem.h
@@ -51,10 +51,22 @@ scan_filesystems(void)
tmp = g_strsplit(buf, " ", 0);
if (!statfs(tmp[1], &sfs)) {
+ gfloat use_ratio;
+
size = (float) sfs.f_bsize * (float) sfs.f_blocks;
avail = (float) sfs.f_bsize * (float) sfs.f_bavail;
used = size - avail;
+ if (size == 0.0f) {
+ continue;
+ }
+
+ if (avail == 0.0f) {
+ use_ratio = 100.0f;
+ } else {
+ use_ratio = 100.0f * (used / size);
+ }
+
gchar *strsize = size_human_readable(size),
*stravail = size_human_readable(avail),
*strused = size_human_readable(used);
@@ -81,9 +93,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|%s\n",
+ fs_list = h_strdup_cprintf("$FS%d$%s=%.2f|%s|%s\n",
fs_list,
- count, tmp[0], stravail, strsize);
+ count, tmp[0], use_ratio, strsize, stravail);
g_free(strsize);
g_free(stravail);
diff --git a/hardinfo2/computer.c b/hardinfo2/computer.c
index f51fdb36..809fc0c0 100644
--- a/hardinfo2/computer.c
+++ b/hardinfo2/computer.c
@@ -293,6 +293,7 @@ gchar *callback_boots()
{
return g_strdup_printf("[$ShellParam$]\n"
"ColumnTitle$TextValue=Date\n"
+ "ColumnTitle$Extra1=Time\n"
"ColumnTitle$Value=Kernel Version\n"
"ShowColumnHeaders=true\n"
"\n"
@@ -313,11 +314,14 @@ gchar *callback_locales()
gchar *callback_fs()
{
return g_strdup_printf("[$ShellParam$]\n"
- "ViewType=1\n"
+ "ViewType=4\n"
"ReloadInterval=5000\n"
- "ColumnTitle$TextValue=Device\n"
- "ColumnTitle$Value=Free\n"
+ "Zebra=1\n"
+ "NormalizePercentage=false\n"
"ColumnTitle$Extra1=Total\n"
+ "ColumnTitle$Extra2=Available\n"
+ "ColumnTitle$Progress=Usage %%\n"
+ "ColumnTitle$TextValue=Device\n"
"ShowColumnHeaders=true\n"
"[Mounted File Systems]\n%s\n", fs_list);
}
diff --git a/hardinfo2/shell.c b/hardinfo2/shell.c
index 23ba2ad7..1883c7bc 100644
--- a/hardinfo2/shell.c
+++ b/hardinfo2/shell.c
@@ -742,6 +742,7 @@ static void set_view_type(ShellViewType viewtype)
if (viewtype < SHELL_VIEW_NORMAL || viewtype >= SHELL_VIEW_N_VIEWS)
viewtype = SHELL_VIEW_NORMAL;
+ shell->normalize_percentage = TRUE;
shell->view_type = viewtype;
switch (viewtype) {
@@ -762,11 +763,17 @@ static void set_view_type(ShellViewType viewtype)
shell->hpaned->allocation.height -
shell->loadgraph->height - 16);
break;
+ case SHELL_VIEW_PROGRESS_DUAL:
+ gtk_notebook_set_page(GTK_NOTEBOOK(shell->notebook), 0);
+ gtk_widget_show(shell->notebook);
+ /* fallthrough */
case SHELL_VIEW_PROGRESS:
shell_action_set_enabled("SaveGraphAction", TRUE);
gtk_tree_view_column_set_visible(shell->info->col_progress, TRUE);
gtk_tree_view_column_set_visible(shell->info->col_value, FALSE);
- gtk_widget_hide(shell->notebook);
+
+ if (viewtype == SHELL_VIEW_PROGRESS)
+ gtk_widget_hide(shell->notebook);
break;
}
}
@@ -797,6 +804,8 @@ group_handle_special(GKeyFile * key_file, ShellModuleEntry * entry,
sfutbl->sfu = fu;
update_sfusrc = g_slist_prepend(update_sfusrc, sfutbl);
+ } else if (g_str_equal(key, "NormalizePercentage")) {
+ shell->normalize_percentage = g_key_file_get_boolean(key_file, group, key, NULL);
} else if (g_str_equal(key, "LoadGraphSuffix")) {
gchar *suffix =
g_key_file_get_value(key_file, group, key, NULL);
@@ -992,15 +1001,19 @@ static void update_progress()
gtk_tree_model_get_iter_first(model, &fiter);
/* finds the maximum value */
- iter = fiter;
- do {
- gtk_tree_model_get(model, &iter, INFO_TREE_COL_VALUE, &tmp, -1);
-
- cur = atof(tmp);
- maxv = MAX(maxv, cur);
-
- g_free(tmp);
- } while (gtk_tree_model_iter_next(model, &iter));
+ if (shell->normalize_percentage) {
+ iter = fiter;
+ do {
+ gtk_tree_model_get(model, &iter, INFO_TREE_COL_VALUE, &tmp, -1);
+
+ cur = atof(tmp);
+ maxv = MAX(maxv, cur);
+
+ g_free(tmp);
+ } while (gtk_tree_model_iter_next(model, &iter));
+ } else {
+ maxv = 100.0f;
+ }
/* calculates the relative percentage and finds the maximum percentage */
if (shell->_order_type == SHELL_ORDER_ASCENDING) {
@@ -1147,7 +1160,7 @@ module_selected_show_info(ShellModuleEntry * entry, gboolean reload)
gdk_window_thaw_updates(shell->info->view->window);
shell_set_note_from_entry(entry);
- if (shell->view_type == SHELL_VIEW_PROGRESS) {
+ if (shell->view_type == SHELL_VIEW_PROGRESS || shell->view_type == SHELL_VIEW_PROGRESS_DUAL) {
update_progress();
}
@@ -1313,10 +1326,12 @@ static ShellInfoTree *info_tree_new(gboolean extra)
model = GTK_TREE_MODEL(store);
treeview = gtk_tree_view_new_with_model(model);
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE);
+ gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(treeview), TRUE);
info->col_progress = column = gtk_tree_view_column_new();
gtk_tree_view_column_set_visible(column, FALSE);
gtk_tree_view_column_set_min_width(column, 240);
+ gtk_tree_view_column_set_clickable(column, TRUE);
gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
cr_progress = gtk_cell_renderer_progress_new();
@@ -1329,6 +1344,7 @@ static ShellInfoTree *info_tree_new(gboolean extra)
info->col_textvalue = column = gtk_tree_view_column_new();
gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+ gtk_tree_view_column_set_clickable(column, TRUE);
cr_pbuf = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_pack_start(column, cr_pbuf, FALSE);
@@ -1343,6 +1359,7 @@ static ShellInfoTree *info_tree_new(gboolean extra)
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);
+ gtk_tree_view_column_set_clickable(column, TRUE);
cr_text = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(column, cr_text, FALSE);
@@ -1352,6 +1369,7 @@ static ShellInfoTree *info_tree_new(gboolean extra)
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);
+ gtk_tree_view_column_set_clickable(column, TRUE);
cr_text = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(column, cr_text, FALSE);
@@ -1360,6 +1378,7 @@ static ShellInfoTree *info_tree_new(gboolean extra)
info->col_value = column = gtk_tree_view_column_new();
gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+ gtk_tree_view_column_set_clickable(column, TRUE);
cr_text = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(column, cr_text, FALSE);
diff --git a/hardinfo2/shell.h b/hardinfo2/shell.h
index 2fa2f968..56b7765f 100644
--- a/hardinfo2/shell.h
+++ b/hardinfo2/shell.h
@@ -48,6 +48,7 @@ typedef enum {
SHELL_VIEW_DUAL,
SHELL_VIEW_LOAD_GRAPH,
SHELL_VIEW_PROGRESS,
+ SHELL_VIEW_PROGRESS_DUAL,
SHELL_VIEW_N_VIEWS
} ShellViewType;
@@ -86,6 +87,7 @@ struct _Shell {
GtkUIManager *ui_manager;
ShellViewType view_type;
+ gboolean normalize_percentage;
gint _pulses;
ShellOrderType _order_type;