[gnome-system-monitor] Add cached memory information
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-system-monitor] Add cached memory information
- Date: Mon, 20 Jan 2020 07:37:57 +0000 (UTC)
commit 28737766286cc206e421ec792ea0cb231074ab6c
Author: João Paulo Just Peixoto <just1982 gmail com>
Date: Mon Jan 20 07:37:42 2020 +0000
Add cached memory information
src/interface.cpp | 8 ++++----
src/load-graph.cpp | 14 ++++++++++----
2 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/src/interface.cpp b/src/interface.cpp
index cb2f3f8a..b705c9e9 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -277,8 +277,8 @@ create_sys_view (GsmApplication *app, GtkBuilder * builder)
label = GTK_LABEL (gtk_builder_get_object(builder, "memory_label"));
- gtk_grid_attach_next_to (table, GTK_WIDGET (color_picker), GTK_WIDGET (label), GTK_POS_LEFT, 1, 2);
- gtk_grid_attach_next_to (table, GTK_WIDGET (load_graph_get_labels(mem_graph)->memory), GTK_WIDGET
(label), GTK_POS_BOTTOM, 1, 1);
+ gtk_grid_attach_next_to (table, GTK_WIDGET (color_picker), GTK_WIDGET (label), GTK_POS_LEFT, 1, 3);
+ gtk_grid_attach_next_to (table, GTK_WIDGET (load_graph_get_labels(mem_graph)->memory), GTK_WIDGET
(label), GTK_POS_BOTTOM, 1, 2);
color_picker = load_graph_get_swap_color_picker(mem_graph);
g_signal_connect (G_OBJECT (color_picker), "color-set",
@@ -289,8 +289,8 @@ create_sys_view (GsmApplication *app, GtkBuilder * builder)
label = GTK_LABEL (gtk_builder_get_object(builder, "swap_label"));
- gtk_grid_attach_next_to (table, GTK_WIDGET (color_picker), GTK_WIDGET (label), GTK_POS_LEFT, 1, 2);
- gtk_grid_attach_next_to (table, GTK_WIDGET (load_graph_get_labels(mem_graph)->swap), GTK_WIDGET (label),
GTK_POS_BOTTOM, 1, 1);
+ gtk_grid_attach_next_to (table, GTK_WIDGET (color_picker), GTK_WIDGET (label), GTK_POS_LEFT, 1, 3);
+ gtk_grid_attach_next_to (table, GTK_WIDGET (load_graph_get_labels(mem_graph)->swap), GTK_WIDGET (label),
GTK_POS_BOTTOM, 1, 2);
app->mem_graph = mem_graph;
diff --git a/src/load-graph.cpp b/src/load-graph.cpp
index fcc95c57..d147f773 100644
--- a/src/load-graph.cpp
+++ b/src/load-graph.cpp
@@ -400,19 +400,25 @@ namespace
{
void set_memory_label_and_picker(GtkLabel* label, GsmColorButton* picker,
- guint64 used, guint64 total, double percent)
+ guint64 used, guint64 cached, guint64 total, double percent)
{
char* used_text;
+ char* cached_text;
char* total_text;
char* text;
used_text = g_format_size_full(used, G_FORMAT_SIZE_IEC_UNITS);
+ cached_text = g_format_size_full(cached, G_FORMAT_SIZE_IEC_UNITS);
total_text = g_format_size_full(total, G_FORMAT_SIZE_IEC_UNITS);
if (total == 0) {
text = g_strdup(_("not available"));
} else {
// xgettext: 540MiB (53 %) of 1.0 GiB
- text = g_strdup_printf(_("%s (%.1f%%) of %s"), used_text, 100.0 * percent, total_text);
+ if (cached == 0) {
+ text = g_strdup_printf(_("%s (%.1f%%) of %s"), used_text, 100.0 * percent, total_text);
+ } else {
+ text = g_strdup_printf(_("%s (%.1f%%) of %s\nCache: %s"), used_text, 100.0 * percent,
total_text, cached_text);
+ }
}
gtk_label_set_text(label, text);
g_free(used_text);
@@ -440,11 +446,11 @@ get_memory (LoadGraph *graph)
mempercent = (float)mem.user / (float)mem.total;
set_memory_label_and_picker(GTK_LABEL(graph->labels.memory),
GSM_COLOR_BUTTON(graph->mem_color_picker),
- mem.user, mem.total, mempercent);
+ mem.user, mem.cached, mem.total, mempercent);
set_memory_label_and_picker(GTK_LABEL(graph->labels.swap),
GSM_COLOR_BUTTON(graph->swap_color_picker),
- swap.used, swap.total, swappercent);
+ swap.used, 0, swap.total, swappercent);
gtk_widget_set_sensitive (GTK_WIDGET (graph->swap_color_picker), swap.total > 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]