diff options
Diffstat (limited to 'src/util.cpp')
-rw-r--r-- | src/util.cpp | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/src/util.cpp b/src/util.cpp index a6f46af..14c559d 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -422,6 +422,47 @@ namespace procman } } + void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer, + GtkTreeModel *model, GtkTreeIter *iter, + gpointer user_data) + { + const guint index = GPOINTER_TO_UINT(user_data); + + guint64 size; + GValue value = { 0 }; + + gtk_tree_model_get_value(model, iter, index, &value); + + switch (G_VALUE_TYPE(&value)) { + case G_TYPE_ULONG: + size = g_value_get_ulong(&value); + break; + + case G_TYPE_UINT64: + size = g_value_get_uint64(&value); + break; + + default: + g_assert_not_reached(); + } + + g_value_unset(&value); + + if (size == 0) { + char *str = g_strdup_printf ("<i>%s</i>", _("N/A")); + g_object_set(renderer, "markup", str, NULL); + g_free(str); + } + else { + char *str = g_format_size(size); + char *formatted_str = g_strdup_printf(_("%s/s"), str); + g_object_set(renderer, "text", formatted_str, NULL); + g_free(formatted_str); + g_free(str); + } + + } + void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer, GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data) @@ -568,4 +609,4 @@ namespace procman g_free(current_value); } -}
\ No newline at end of file +} |