diff options
-rw-r--r-- | multiload/global.h | 1 | ||||
-rw-r--r-- | multiload/linux-proc.c | 5 | ||||
-rw-r--r-- | multiload/main.c | 1 | ||||
-rw-r--r-- | multiload/properties.c | 50 |
4 files changed, 19 insertions, 38 deletions
diff --git a/multiload/global.h b/multiload/global.h index 916c9946..5e93be0a 100644 --- a/multiload/global.h +++ b/multiload/global.h @@ -129,6 +129,7 @@ struct _MultiloadApplet float swapload_used_ratio; float diskload_used_ratio; + gboolean nvme_diskstats; NetSpeed *netspeed_in; NetSpeed *netspeed_out; diff --git a/multiload/linux-proc.c b/multiload/linux-proc.c index 0a011971..8923c9ac 100644 --- a/multiload/linux-proc.c +++ b/multiload/linux-proc.c @@ -103,7 +103,6 @@ GetDiskLoad (int Maximum, guint i; int max; - gboolean nvme_diskstats; guint64 read, write; guint64 readdiff, writediff; @@ -112,7 +111,6 @@ GetDiskLoad (int Maximum, multiload = g->multiload; - nvme_diskstats = g_settings_get_boolean (multiload->settings, "diskload-nvme-diskstats"); if(first_call) { @@ -121,7 +119,7 @@ GetDiskLoad (int Maximum, read = write = 0; - if (nvme_diskstats) + if (multiload->nvme_diskstats) { FILE *fdr; char line[255]; @@ -130,6 +128,7 @@ GetDiskLoad (int Maximum, fdr = fopen("/proc/diskstats", "r"); if (!fdr) { + multiload->nvme_diskstats = FALSE; g_settings_set_boolean (multiload->settings, "diskload-nvme-diskstats", FALSE); return; } diff --git a/multiload/main.c b/multiload/main.c index 17ac1806..b670e019 100644 --- a/multiload/main.c +++ b/multiload/main.c @@ -411,6 +411,7 @@ multiload_create_graphs(MultiloadApplet *ma) graph_types[i].name, graph_types[i].callback); } + ma->nvme_diskstats = g_settings_get_boolean (ma->settings, "diskload-nvme-diskstats"); /* for Network graph, colors[4] is grid line color, it should not be used in loop in load-graph.c */ /* for Network graph, colors[5] is indicator color, it should not be used in loop in load-graph.c */ ma->graphs[graph_netload2]->n = 4; diff --git a/multiload/properties.c b/multiload/properties.c index e9ad76a9..c1717e72 100644 --- a/multiload/properties.c +++ b/multiload/properties.c @@ -326,43 +326,14 @@ add_color_selector(GtkWidget *page, gchar *name, gchar *key, MultiloadApplet *ma /* save the checkbox option to gsettings and apply it on the applet */ static void -checkbox_toggled_cb(GtkCheckButton *checkbox, gchar *key) +nvme_checkbox_toggled_cb (GtkCheckButton *checkbox, + MultiloadApplet *ma) { - MultiloadApplet *ma; - gboolean option; - - ma = g_object_get_data (G_OBJECT (checkbox), "MultiloadApplet"); - - option = g_settings_get_boolean(ma->settings, key); - g_settings_set_boolean(ma->settings, key, !option); - - return; -} - -/* adds checkbox option */ -static void -add_checkbox(GtkWidget *page, gchar *name, gchar *key, MultiloadApplet *ma) -{ - GtkWidget *vbox; - GtkWidget *checkbox; gboolean option; - option = g_settings_get_boolean (ma->settings, key); - - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); - checkbox = gtk_check_button_new_with_mnemonic (name); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(checkbox), option); - - gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0); - - gtk_box_pack_start(GTK_BOX(page), vbox, FALSE, FALSE, 0); - - g_object_set_data (G_OBJECT (checkbox), "MultiloadApplet", ma); - - g_signal_connect(G_OBJECT(checkbox), "toggled", G_CALLBACK(checkbox_toggled_cb), key); - - if ( ! g_settings_is_writable (ma->settings, key)) - hard_set_sensitive (vbox, FALSE); + option = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox)); + ma->nvme_diskstats = option; + g_settings_set_boolean (ma->settings, "diskload-nvme-diskstats", option); return; } @@ -681,7 +652,16 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma) add_color_selector (page, _("_Read"), "diskload-color0", ma); add_color_selector (page, _("_Write"), "diskload-color1", ma); add_color_selector (page, _("_Background"), "diskload-color2", ma); - add_checkbox(page, _("Use diskstats for NVMe"), "diskload-nvme-diskstats", ma); + GtkWidget *nvme_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); + GtkWidget *nvme_checkbox = gtk_check_button_new_with_mnemonic (_("Use diskstats for NVMe")); + ma->nvme_diskstats = g_settings_get_boolean (ma->settings, "diskload-nvme-diskstats"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (nvme_checkbox), + ma->nvme_diskstats); + g_signal_connect (G_OBJECT (nvme_checkbox), "toggled", + G_CALLBACK (nvme_checkbox_toggled_cb), ma); + gtk_box_pack_start (GTK_BOX(nvme_box), nvme_checkbox, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX(page), nvme_box, FALSE, FALSE, 0); + gtk_widget_show (nvme_box); title = g_strconcat ("<span weight=\"bold\">", _("Network speed thresholds"), "</span>", NULL); label = gtk_label_new (title); |