[gnome-system-monitor] Added option to disable smooth cpu chart (bgo#778470)
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-system-monitor] Added option to disable smooth cpu chart (bgo#778470)
- Date: Mon, 13 Feb 2017 22:00:11 +0000 (UTC)
commit e60c3860b7c45043e6eab52a51ebefeeeaf53a77
Author: Robert Roth <robert roth off gmail com>
Date: Mon Feb 13 23:58:40 2017 +0200
Added option to disable smooth cpu chart (bgo#778470)
data/preferences.ui | 20 ++++++++++++++++++-
src/application.cpp | 13 ++++++++++++
src/application.h | 2 +
src/load-graph.cpp | 21 +++++++++++++------
...rg.gnome.gnome-system-monitor.gschema.xml.in.in | 8 +++++++
src/prefsdialog.cpp | 5 ++++
src/settings-keys.h | 1 +
7 files changed, 62 insertions(+), 8 deletions(-)
---
diff --git a/data/preferences.ui b/data/preferences.ui
index 55436ab..a2676b3 100644
--- a/data/preferences.ui
+++ b/data/preferences.ui
@@ -398,6 +398,24 @@
</packing>
</child>
<child>
+ <object class="GtkCheckButton" id="draw_smooth_button">
+ <property name="label" translatable="yes">Draw CPU chart as s_mooth
graph</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="hexpand">True</property>
+ <property name="use_underline">True</property>
+ <property name="halign">start</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkCheckButton" id="bits_button">
<property name="label" translatable="yes">_Show network speed in
bits</property>
<property name="visible">True</property>
@@ -410,7 +428,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
diff --git a/src/application.cpp b/src/application.cpp
index facdf3a..d5a5e57 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -39,6 +39,14 @@ cb_draw_stacked_changed (Gio::Settings& settings, Glib::ustring key, GsmApplicat
}
static void
+cb_draw_smooth_changed (Gio::Settings& settings, Glib::ustring key, GsmApplication* app)
+{
+ app->config.draw_smooth = settings.get_boolean(key);
+ app->cpu_graph->clear_background();
+ load_graph_reset(app->cpu_graph);
+}
+
+static void
cb_network_in_bits_changed (Gio::Settings& settings, Glib::ustring key, GsmApplication* app)
{
app->config.network_in_bits = settings.get_boolean(key);
@@ -156,6 +164,11 @@ GsmApplication::load_settings()
cb_draw_stacked_changed (*this->settings.operator->(), key, this);
});
+ config.draw_smooth = this->settings->get_boolean (GSM_SETTING_DRAW_SMOOTH);
+ this->settings->signal_changed(GSM_SETTING_DRAW_SMOOTH).connect ([this](const Glib::ustring& key) {
+ cb_draw_smooth_changed (*this->settings.operator->(), key, this);
+ });
+
config.network_in_bits = this->settings->get_boolean (GSM_SETTING_NETWORK_IN_BITS);
this->settings->signal_changed (GSM_SETTING_NETWORK_IN_BITS).connect ([this](const Glib::ustring& key) {
cb_network_in_bits_changed (*this->settings.operator->(), key, this);
diff --git a/src/application.h b/src/application.h
index 68eff87..730b9c5 100644
--- a/src/application.h
+++ b/src/application.h
@@ -43,6 +43,7 @@ struct ProcConfig
num_cpus(0),
solaris_mode(false),
draw_stacked(false),
+ draw_smooth(true),
network_in_bits(false)
{
std::fill(&this->cpu_color[0], &this->cpu_color[GLIBTOP_NCPU], GdkRGBA());
@@ -61,6 +62,7 @@ struct ProcConfig
gint num_cpus;
bool solaris_mode;
bool draw_stacked;
+ bool draw_smooth;
bool network_in_bits;
};
diff --git a/src/load-graph.cpp b/src/load-graph.cpp
index 85264fe..4ad0f7e 100644
--- a/src/load-graph.cpp
+++ b/src/load-graph.cpp
@@ -252,6 +252,7 @@ load_graph_draw (GtkWidget *widget,
cairo_clip(cr);
bool drawStacked = graph->type == LOAD_GRAPH_CPU && GsmApplication::get()->config.draw_stacked;
+ bool drawSmooth = graph->type == LOAD_GRAPH_CPU && GsmApplication::get()->config.draw_smooth;
for (j = graph->n-1; j >= 0; j--) {
gdk_cairo_set_source_rgba (cr, &(graph->colors [j]));
if (drawStacked) {
@@ -262,13 +263,19 @@ load_graph_draw (GtkWidget *widget,
for (i = 1; i < LoadGraph::NUM_POINTS; ++i) {
if (graph->data[i][j] == -1.0f)
continue;
- cairo_curve_to (cr,
- x_offset - ((i - 0.5f) * graph->graph_delx),
- (1.0f - graph->data[i-1][j]) * graph->real_draw_height + 3.5f,
- x_offset - ((i - 0.5f) * graph->graph_delx),
- (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f,
- x_offset - (i * graph->graph_delx),
- (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f);
+ if (drawSmooth) {
+ cairo_curve_to (cr,
+ x_offset - ((i - 0.5f) * graph->graph_delx),
+ (1.0f - graph->data[i-1][j]) * graph->real_draw_height + 3.5f,
+ x_offset - ((i - 0.5f) * graph->graph_delx),
+ (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f,
+ x_offset - (i * graph->graph_delx),
+ (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f);
+ } else {
+ cairo_line_to (cr, x_offset - (i * graph->graph_delx),
+ (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f);
+ }
+
}
if (drawStacked) {
cairo_rel_line_to (cr, 0, graph->real_draw_height + 3.5f);
diff --git a/src/org.gnome.gnome-system-monitor.gschema.xml.in.in
b/src/org.gnome.gnome-system-monitor.gschema.xml.in.in
index 383377d..6095749 100644
--- a/src/org.gnome.gnome-system-monitor.gschema.xml.in.in
+++ b/src/org.gnome.gnome-system-monitor.gschema.xml.in.in
@@ -36,6 +36,14 @@
</_description>
</key>
+ <key type="b" name="cpu-smooth-graph">
+ <default>true
+ </default>
+ <_summary>Show CPU chart as smooth graph using Bezier curves</_summary>
+ <_description>If TRUE, system-monitor shows the CPU chart as a smoothed graph, otherwise as a line
chart.
+ </_description>
+ </key>
+
<key name="smooth-refresh" type="b">
<default>true
</default>
diff --git a/src/prefsdialog.cpp b/src/prefsdialog.cpp
index 1e24b34..9f18fd7 100644
--- a/src/prefsdialog.cpp
+++ b/src/prefsdialog.cpp
@@ -250,6 +250,11 @@ create_preferences_dialog (GsmApplication *app)
draw_stacked_button, "active",
G_SETTINGS_BIND_DEFAULT);
+ GtkCheckButton *draw_smooth_button = GTK_CHECK_BUTTON (gtk_builder_get_object (builder,
"draw_smooth_button"));
+ g_settings_bind (app->settings->gobj (), GSM_SETTING_DRAW_SMOOTH,
+ draw_smooth_button, "active",
+ G_SETTINGS_BIND_DEFAULT);
+
create_field_page (builder, GTK_TREE_VIEW (app->tree), "proctree");
update = (gfloat) app->config.graph_update_interval;
diff --git a/src/settings-keys.h b/src/settings-keys.h
index 2ef20cc..87fbb9f 100644
--- a/src/settings-keys.h
+++ b/src/settings-keys.h
@@ -24,6 +24,7 @@
#define GSM_SETTING_NET_IN_COLOR "net-in-color"
#define GSM_SETTING_NET_OUT_COLOR "net-out-color"
#define GSM_SETTING_DRAW_STACKED "cpu-stacked-area-chart"
+#define GSM_SETTING_DRAW_SMOOTH "cpu-smooth-graph"
#define GSM_SETTING_NETWORK_IN_BITS "network-in-bits"
#define GSM_SETTING_SHOW_CPU "show-cpu"
#define GSM_SETTING_SHOW_MEM "show-mem"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]