summaryrefslogtreecommitdiff
path: root/multiload/src
diff options
context:
space:
mode:
authorrbuj <[email protected]>2020-12-17 19:52:59 +0100
committerLuke from DC <[email protected]>2020-12-25 00:22:04 +0000
commiteddd0898e16124081e226b07fd0901ff0eae2871 (patch)
tree55d6e197c089ffd32a30d054ea4a0efd9ec83a9d /multiload/src
parentdddc1ac496a3f94e2c2b780d8d89465459c8bd67 (diff)
downloadmate-applets-eddd0898e16124081e226b07fd0901ff0eae2871.tar.bz2
mate-applets-eddd0898e16124081e226b07fd0901ff0eae2871.tar.xz
multiload: Add properties.ui
Diffstat (limited to 'multiload/src')
-rw-r--r--multiload/src/global.h70
-rw-r--r--multiload/src/properties.c1033
2 files changed, 491 insertions, 612 deletions
diff --git a/multiload/src/global.h b/multiload/src/global.h
index 7b5db895..f40f194a 100644
--- a/multiload/src/global.h
+++ b/multiload/src/global.h
@@ -10,6 +10,31 @@
G_BEGIN_DECLS
+#define KEY_CPULOAD_USR_COLOR "cpuload-color0"
+#define KEY_CPULOAD_SYS_COLOR "cpuload-color1"
+#define KEY_CPULOAD_NICE_COLOR "cpuload-color2"
+#define KEY_CPULOAD_IOWAIT_COLOR "cpuload-color3"
+#define KEY_CPULOAD_IDLE_COLOR "cpuload-color4"
+#define KEY_MEMLOAD_USER_COLOR "memload-color0"
+#define KEY_MEMLOAD_SHARED_COLOR "memload-color1"
+#define KEY_MEMLOAD_BUFFER_COLOR "memload-color2"
+#define KEY_MEMLOAD_CACHED_COLOR "memload-color3"
+#define KEY_MEMLOAD_FREE_COLOR "memload-color4"
+#define KEY_NETLOAD2_IN_COLOR "netload2-color0"
+#define KEY_NETLOAD2_OUT_COLOR "netload2-color1"
+#define KEY_NETLOAD2_LOOPBACK_COLOR "netload2-color2"
+#define KEY_NETLOAD2_BACKGROUND_COLOR "netload2-color3"
+#define KEY_NETLOAD2_GRIDLINE_COLOR "netload2-color4"
+#define KEY_NETLOAD2_INDICATOR_COLOR "netload2-color5"
+#define KEY_SWAPLOAD_USED_COLOR "swapload-color0"
+#define KEY_SWAPLOAD_FREE_COLOR "swapload-color1"
+#define KEY_LOADAVG_AVERAGE_COLOR "loadavg-color0"
+#define KEY_LOADAVG_BACKGROUND_COLOR "loadavg-color1"
+#define KEY_LOADAVG_GRIDLINE_COLOR "loadavg-color2"
+#define KEY_DISKLOAD_READ_COLOR "diskload-color0"
+#define KEY_DISKLOAD_WRITE_COLOR "diskload-color1"
+#define KEY_DISKLOAD_FREE_COLOR "diskload-color2"
+
#define KEY_NET_THRESHOLD1 "netthreshold1"
#define KEY_NET_THRESHOLD2 "netthreshold2"
#define KEY_NET_THRESHOLD3 "netthreshold3"
@@ -27,6 +52,8 @@ G_BEGIN_DECLS
#define VIEW_LOADAVG_KEY "view-loadavg"
#define VIEW_DISKLOAD_KEY "view-diskload"
+#define DISKLOAD_NVME_KEY "diskload-nvme-diskstats"
+
#define REFRESH_RATE_KEY "speed"
#define REFRESH_RATE_MIN 50
#define REFRESH_RATE_MAX 60000
@@ -52,6 +79,15 @@ typedef enum {
} E_graph;
typedef enum {
+ cpuload_usr = 0,
+ cpuload_sys,
+ cpuload_nice,
+ cpuload_iowait,
+ cpuload_free,
+ cpuload_n
+} E_cpuload;
+
+typedef enum {
memload_user = 0,
memload_shared,
memload_buffer,
@@ -61,13 +97,27 @@ typedef enum {
} E_memload;
typedef enum {
- cpuload_usr = 0,
- cpuload_sys,
- cpuload_nice,
- cpuload_iowait,
- cpuload_free,
- cpuload_n
-} E_cpuload;
+ netload2_in = 0,
+ netload2_out,
+ netload2_loopback,
+ netload2_background,
+ netload2_gridline,
+ netload2_indicator,
+ netload2_n
+} E_netload2;
+
+typedef enum {
+ swapload_used = 0,
+ swapload_free,
+ swapload_n
+} E_swapload;
+
+typedef enum {
+ loadavg_average = 0,
+ loadavg_background,
+ loadavg_gridline,
+ loadavg_n
+} E_loadavg;
typedef enum {
diskload_read = 0,
@@ -76,12 +126,6 @@ typedef enum {
diskload_n
} E_diskload;
-typedef enum {
- swapload_used = 0,
- swapload_free,
- swapload_n
-} E_swapload;
-
struct _LoadGraph {
MultiloadApplet *multiload;
diff --git a/multiload/src/properties.c b/multiload/src/properties.c
index ffe1b88c..37cc8bf2 100644
--- a/multiload/src/properties.c
+++ b/multiload/src/properties.c
@@ -21,14 +21,6 @@
#include "global.h"
-#define PROP_CPU 0
-#define PROP_MEM 1
-#define PROP_NET 2
-#define PROP_SWAP 3
-#define PROP_AVG 4
-#define PROP_DISK 5
-
-#define HIG_IDENTATION " "
#define NEVER_SENSITIVE "never_sensitive"
/* set sensitive and setup NEVER_SENSITIVE appropriately */
@@ -66,18 +58,17 @@ properties_set_insensitive(MultiloadApplet *ma)
}
if (total_graphs < 2)
- soft_set_sensitive(ma->check_boxes[last_graph], FALSE);
-
- return;
+ soft_set_sensitive (ma->check_boxes[last_graph], FALSE);
}
static void
-properties_close_cb (GtkWidget *widget, gint arg, MultiloadApplet *ma)
+on_properties_dialog_response (GtkWidget *widget,
+ gint arg,
+ MultiloadApplet *ma)
{
GError *error = NULL;
- switch (arg)
- {
+ switch (arg) {
case GTK_RESPONSE_HELP:
gtk_show_uri_on_window (NULL,
@@ -88,7 +79,6 @@ properties_close_cb (GtkWidget *widget, gint arg, MultiloadApplet *ma)
if (error) { /* FIXME: the user needs to see this */
g_warning ("help error: %s\n", error->message);
g_error_free (error);
- error = NULL;
}
break;
@@ -100,43 +90,6 @@ properties_close_cb (GtkWidget *widget, gint arg, MultiloadApplet *ma)
}
static void
-property_toggled_cb(GtkWidget *widget, gpointer name)
-{
- MultiloadApplet *ma;
- gint prop_type;
- gboolean active;
-
- active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget));
- ma = g_object_get_data(G_OBJECT(widget), "MultiloadApplet");
- prop_type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "prop_type"));
-
- /* FIXME: the first toggle button to be checked/dechecked does not work, but after that everything is cool. what gives? */
- /* FIXME: check if this is still valid for gsettings */
- g_settings_set_boolean (ma->settings, (gchar *)name, active);
- g_settings_set_boolean (ma->settings, (gchar *)name, active);
-
- if (active)
- {
- guint i;
-
- for (i = 0; i < graph_n; i++)
- soft_set_sensitive(ma->check_boxes[i], TRUE);
- gtk_widget_show_all (ma->graphs[prop_type]->main_widget);
- ma->graphs[prop_type]->visible = TRUE;
- load_graph_start(ma->graphs[prop_type]);
- }
- else
- {
- load_graph_stop(ma->graphs[prop_type]);
- gtk_widget_hide (ma->graphs[prop_type]->main_widget);
- ma->graphs[prop_type]->visible = FALSE;
- properties_set_insensitive(ma);
- }
-
- return;
-}
-
-static void
on_speed_spin_button_value_changed (GtkSpinButton *spin_button,
gpointer user_data)
{
@@ -231,579 +184,358 @@ on_net_threshold3_spin_button_value_changed (GtkSpinButton *spin_button,
g_settings_set_uint64 (ma->settings, KEY_NET_THRESHOLD3, ma->net_threshold3);
}
-/* create a new page in the notebook widget, add it, and return a pointer to it */
-static GtkWidget *
-add_page(GtkWidget *notebook, gchar *label)
+static void
+color_button_set (GtkColorChooser *button,
+ GSettings *settings,
+ const char *key,
+ GdkRGBA *color)
{
- GtkWidget *page;
- GtkWidget *page_label;
+ gchar *color_string;
- page = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_set_homogeneous (GTK_BOX (page), TRUE);
- page_label = gtk_label_new(label);
- gtk_container_set_border_width(GTK_CONTAINER(page), 6);
+ gtk_color_chooser_get_rgba (button, color);
+ color_string = gdk_rgba_to_string (color);
+ g_settings_set_string (settings, key, color_string);
+ g_free (color_string);
+}
- gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, page_label);
+static void
+on_cpuload_usr_color_button_color_set (GtkColorButton *button,
+ MultiloadApplet *ma)
+{
+ color_button_set (GTK_COLOR_CHOOSER (button),
+ ma->settings, KEY_CPULOAD_USR_COLOR,
+ &(ma->graphs[graph_cpuload]->colors[cpuload_usr]));
+}
- return page;
+static void
+on_cpuload_sys_color_button_color_set (GtkColorButton *button,
+ MultiloadApplet *ma)
+{
+ color_button_set (GTK_COLOR_CHOOSER (button),
+ ma->settings, KEY_CPULOAD_SYS_COLOR,
+ &(ma->graphs[graph_cpuload]->colors[cpuload_sys]));
}
-/* save the selected color to gsettings and apply it on the applet */
static void
-color_picker_set_cb(GtkColorChooser *color_picker, gchar *key)
+on_cpuload_nice_color_button_color_set (GtkColorButton *button,
+ MultiloadApplet *ma)
{
- gchar *color_string;
- guint8 prop_type;
- GdkRGBA color;
- MultiloadApplet *ma;
-
- ma = g_object_get_data (G_OBJECT (color_picker), "MultiloadApplet");
-
- if (strstr(key, "cpuload"))
- prop_type = PROP_CPU;
- else if (strstr(key, "memload"))
- prop_type = PROP_MEM;
- else if (strstr(key, "netload2"))
- prop_type = PROP_NET;
- else if (strstr(key, "swapload"))
- prop_type = PROP_SWAP;
- else if (strstr(key, "loadavg"))
- prop_type = PROP_AVG;
- else if (strstr(key, "diskload"))
- prop_type = PROP_DISK;
- else
- g_assert_not_reached();
+ color_button_set (GTK_COLOR_CHOOSER (button),
+ ma->settings, KEY_CPULOAD_NICE_COLOR,
+ &(ma->graphs[graph_cpuload]->colors[cpuload_nice]));
+}
- gtk_color_chooser_get_rgba(color_picker, &color);
+static void
+on_cpuload_iowait_color_button_color_set (GtkColorButton *button,
+ MultiloadApplet *ma)
+{
+ color_button_set (GTK_COLOR_CHOOSER (button),
+ ma->settings, KEY_CPULOAD_IOWAIT_COLOR,
+ &(ma->graphs[graph_cpuload]->colors[cpuload_iowait]));
+}
- color_string = gdk_rgba_to_string (&color);
- g_settings_set_string(ma->settings, key, color_string);
+static void
+on_cpuload_free_color_button_color_set (GtkColorButton *button,
+ MultiloadApplet *ma)
+{
+ color_button_set (GTK_COLOR_CHOOSER (button),
+ ma->settings, KEY_CPULOAD_IDLE_COLOR,
+ &(ma->graphs[graph_cpuload]->colors[cpuload_free]));
+}
- gdk_rgba_parse(&(ma->graphs[prop_type]->colors[g_ascii_digit_value(key[strlen(key) - 1]) ]),
- color_string);
+static void
+on_memload_user_color_button_color_set (GtkColorButton *button,
+ MultiloadApplet *ma)
+{
+ color_button_set (GTK_COLOR_CHOOSER (button),
+ ma->settings, KEY_MEMLOAD_USER_COLOR,
+ &(ma->graphs[graph_memload]->colors[memload_user]));
+}
- return;
+static void
+on_memload_shared_color_button_color_set (GtkColorButton *button,
+ MultiloadApplet *ma)
+{
+ color_button_set (GTK_COLOR_CHOOSER (button),
+ ma->settings, KEY_MEMLOAD_SHARED_COLOR,
+ &(ma->graphs[graph_memload]->colors[memload_shared]));
}
-/* create a color selector */
static void
-add_color_selector(GtkWidget *page, gchar *name, gchar *key, MultiloadApplet *ma)
+on_memload_buffer_color_button_color_set (GtkColorButton *button,
+ MultiloadApplet *ma)
{
- GtkWidget *vbox;
- GtkWidget *label;
- GtkWidget *color_picker;
- GdkRGBA color;
- gchar *color_string;
+ color_button_set (GTK_COLOR_CHOOSER (button),
+ ma->settings, KEY_MEMLOAD_BUFFER_COLOR,
+ &(ma->graphs[graph_memload]->colors[memload_buffer]));
+}
- color_string = g_settings_get_string (ma->settings, key);
- if (!color_string)
- color_string = g_strdup ("#000000");
- gdk_rgba_parse (&color, color_string);
- g_free (color_string);
+static void
+on_memload_cached_color_button_color_set (GtkColorButton *button,
+ MultiloadApplet *ma)
+{
+ color_button_set (GTK_COLOR_CHOOSER (button),
+ ma->settings, KEY_MEMLOAD_CACHED_COLOR,
+ &(ma->graphs[graph_memload]->colors[memload_cached]));
+}
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- label = gtk_label_new_with_mnemonic(name);
- color_picker = gtk_color_button_new();
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), color_picker);
+static void
+on_memload_free_color_button_color_set (GtkColorButton *button,
+ MultiloadApplet *ma)
+{
+ color_button_set (GTK_COLOR_CHOOSER (button),
+ ma->settings, KEY_MEMLOAD_FREE_COLOR,
+ &(ma->graphs[graph_memload]->colors[memload_free]));
+}
- gtk_box_pack_start(GTK_BOX(vbox), color_picker, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+static void
+on_netload2_in_color_button_color_set (GtkColorButton *button,
+ MultiloadApplet *ma)
+{
+ color_button_set (GTK_COLOR_CHOOSER (button),
+ ma->settings, KEY_NETLOAD2_IN_COLOR,
+ &(ma->graphs[graph_netload2]->colors[netload2_in]));
+}
- gtk_box_pack_start(GTK_BOX(page), vbox, FALSE, FALSE, 0);
+static void
+on_netload2_out_color_button_color_set (GtkColorButton *button,
+ MultiloadApplet *ma)
+{
+ color_button_set (GTK_COLOR_CHOOSER (button),
+ ma->settings, KEY_NETLOAD2_OUT_COLOR,
+ &(ma->graphs[graph_netload2]->colors[netload2_out]));
+}
- g_object_set_data (G_OBJECT (color_picker), "MultiloadApplet", ma);
+static void
+on_netload2_loopback_color_button_color_set (GtkColorButton *button,
+ MultiloadApplet *ma)
+{
+ color_button_set (GTK_COLOR_CHOOSER (button),
+ ma->settings, KEY_NETLOAD2_LOOPBACK_COLOR,
+ &(ma->graphs[graph_netload2]->colors[netload2_loopback]));
+}
- gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(color_picker), &color);
+static void
+on_netload2_background_color_button_color_set (GtkColorButton *button,
+ MultiloadApplet *ma)
+{
+ color_button_set (GTK_COLOR_CHOOSER (button),
+ ma->settings, KEY_NETLOAD2_BACKGROUND_COLOR,
+ &(ma->graphs[graph_netload2]->colors[netload2_background]));
+}
- g_signal_connect(G_OBJECT(color_picker), "color_set", G_CALLBACK(color_picker_set_cb), key);
+static void
+on_netload2_gridline_color_button_color_set (GtkColorButton *button,
+ MultiloadApplet *ma)
+{
+ color_button_set (GTK_COLOR_CHOOSER (button),
+ ma->settings, KEY_NETLOAD2_GRIDLINE_COLOR,
+ &(ma->graphs[graph_netload2]->colors[netload2_gridline]));
+}
- if ( ! g_settings_is_writable (ma->settings, key))
- hard_set_sensitive (vbox, FALSE);
+static void
+on_netload2_indicator_color_button_color_set (GtkColorButton *button,
+ MultiloadApplet *ma)
+{
+ color_button_set (GTK_COLOR_CHOOSER (button),
+ ma->settings, KEY_NETLOAD2_INDICATOR_COLOR,
+ &(ma->graphs[graph_netload2]->colors[netload2_indicator]));
+}
- return;
+static void
+on_swapload_used_color_button_color_set (GtkColorButton *button,
+ MultiloadApplet *ma)
+{
+ color_button_set (GTK_COLOR_CHOOSER (button),
+ ma->settings, KEY_SWAPLOAD_USED_COLOR,
+ &(ma->graphs[graph_swapload]->colors[swapload_used]));
}
-/* save the checkbox option to gsettings and apply it on the applet */
static void
-nvme_checkbox_toggled_cb (GtkCheckButton *checkbox,
- MultiloadApplet *ma)
+on_swapload_free_color_button_color_set (GtkColorButton *button,
+ MultiloadApplet *ma)
{
- gboolean option;
+ color_button_set (GTK_COLOR_CHOOSER (button),
+ ma->settings, KEY_SWAPLOAD_FREE_COLOR,
+ &(ma->graphs[graph_swapload]->colors[swapload_free]));
+}
- option = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox));
- ma->nvme_diskstats = option;
- g_settings_set_boolean (ma->settings, "diskload-nvme-diskstats", option);
+static void
+on_loadavg_average_color_button_color_set (GtkColorButton *button,
+ MultiloadApplet *ma)
+{
+ color_button_set (GTK_COLOR_CHOOSER (button),
+ ma->settings, KEY_LOADAVG_AVERAGE_COLOR,
+ &(ma->graphs[graph_loadavg]->colors[loadavg_average]));
+}
- return;
+static void
+on_loadavg_background_color_button_color_set (GtkColorButton *button,
+ MultiloadApplet *ma)
+{
+ color_button_set (GTK_COLOR_CHOOSER (button),
+ ma->settings, KEY_LOADAVG_BACKGROUND_COLOR,
+ &(ma->graphs[graph_loadavg]->colors[loadavg_background]));
}
-/* creates the properties dialog using up-to-the-minute info from gsettings */
static void
-fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
+on_loadavg_gridline_color_button_color_set (GtkColorButton *button,
+ MultiloadApplet *ma)
{
- GtkWidget *page;
- GtkWidget *hbox, *vbox;
- GtkWidget *categories_vbox;
- GtkWidget *category_vbox;
- GtkWidget *control_vbox;
- GtkWidget *control_hbox;
- GtkWidget *check_box;
- GtkWidget *indent;
- GtkWidget *spin_button;
- GtkWidget *label;
- MatePanelAppletOrient orient;
- GtkSizeGroup *label_size;
- GtkSizeGroup *spin_size;
- gchar *label_text;
- gchar *title;
- guint spin_value_uint;
- guint64 spin_value_uint64;
-
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
- gtk_widget_show (vbox);
-
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
- vbox, TRUE, TRUE, 0);
-
- categories_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
- gtk_box_pack_start (GTK_BOX (vbox), categories_vbox, TRUE, TRUE, 0);
- gtk_widget_show (categories_vbox);
-
- category_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_box_pack_start (GTK_BOX (categories_vbox), category_vbox, TRUE, TRUE, 0);
- gtk_widget_show (category_vbox);
-
- title = g_strconcat ("<span weight=\"bold\">", _("Monitored Resources"), "</span>", NULL);
- label = gtk_label_new_with_mnemonic (_(title));
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
- gtk_label_set_xalign (GTK_LABEL (label), 0.0);
- gtk_box_pack_start (GTK_BOX (category_vbox), label, FALSE, FALSE, 0);
- g_free (title);
-
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_pack_start (GTK_BOX (category_vbox), hbox, TRUE, TRUE, 0);
- gtk_widget_show (hbox);
-
- indent = gtk_label_new (HIG_IDENTATION);
- gtk_label_set_justify (GTK_LABEL (indent), GTK_JUSTIFY_LEFT);
- gtk_box_pack_start (GTK_BOX (hbox), indent, FALSE, FALSE, 0);
- gtk_widget_show (indent);
-
- control_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_box_pack_start (GTK_BOX (hbox), control_vbox, TRUE, TRUE, 0);
- gtk_widget_show (control_vbox);
-
- control_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
- gtk_box_pack_start (GTK_BOX (control_vbox), control_hbox, TRUE, TRUE, 0);
- gtk_widget_show (control_hbox);
-
- check_box = gtk_check_button_new_with_mnemonic(_("_Processor"));
- ma->check_boxes[0] = check_box;
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_box),
- g_settings_get_boolean (ma->settings,
- VIEW_CPULOAD_KEY));
- g_object_set_data(G_OBJECT(check_box), "MultiloadApplet", ma);
- g_object_set_data(G_OBJECT(check_box), "prop_type", GINT_TO_POINTER(PROP_CPU));
- g_signal_connect(G_OBJECT(check_box), "toggled",
- G_CALLBACK(property_toggled_cb), VIEW_CPULOAD_KEY);
- gtk_box_pack_start (GTK_BOX (control_hbox), check_box, FALSE, FALSE, 0);
-
- if ( ! g_settings_is_writable (ma->settings, VIEW_CPULOAD_KEY))
- hard_set_sensitive (check_box, FALSE);
-
- check_box = gtk_check_button_new_with_mnemonic(_("_Memory"));
- ma->check_boxes[1] = check_box;
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_box),
- g_settings_get_boolean (ma->settings, VIEW_MEMLOAD_KEY));
- g_object_set_data(G_OBJECT(check_box), "MultiloadApplet", ma);
- g_object_set_data(G_OBJECT(check_box), "prop_type", GINT_TO_POINTER(PROP_MEM));
- g_signal_connect(G_OBJECT(check_box), "toggled",
- G_CALLBACK(property_toggled_cb), VIEW_MEMLOAD_KEY);
- gtk_box_pack_start (GTK_BOX (control_hbox), check_box, FALSE, FALSE, 0);
-
- if ( ! g_settings_is_writable (ma->settings, VIEW_MEMLOAD_KEY))
- hard_set_sensitive (check_box, FALSE);
-
- check_box = gtk_check_button_new_with_mnemonic(_("_Network"));
- ma->check_boxes[2] = check_box;
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_box),
- g_settings_get_boolean (ma->settings, VIEW_NETLOAD_KEY));
- g_object_set_data(G_OBJECT(check_box), "MultiloadApplet", ma);
- g_object_set_data(G_OBJECT(check_box), "prop_type", GINT_TO_POINTER(PROP_NET));
- g_signal_connect(G_OBJECT(check_box), "toggled",
- G_CALLBACK(property_toggled_cb), VIEW_NETLOAD_KEY);
- gtk_box_pack_start (GTK_BOX (control_hbox), check_box, FALSE, FALSE, 0);
-
- if ( ! g_settings_is_writable (ma->settings, VIEW_NETLOAD_KEY))
- hard_set_sensitive (check_box, FALSE);
-
- check_box = gtk_check_button_new_with_mnemonic (_("S_wap Space"));
- ma->check_boxes[3] = check_box;
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_box),
- g_settings_get_boolean (ma->settings, VIEW_SWAPLOAD_KEY));
- g_object_set_data(G_OBJECT(check_box), "MultiloadApplet", ma);
- g_object_set_data(G_OBJECT(check_box), "prop_type", GINT_TO_POINTER(PROP_SWAP));
- g_signal_connect(G_OBJECT(check_box), "toggled",
- G_CALLBACK(property_toggled_cb), VIEW_SWAPLOAD_KEY);
- gtk_box_pack_start (GTK_BOX (control_hbox), check_box, FALSE, FALSE, 0);
-
- if ( ! g_settings_is_writable (ma->settings, VIEW_SWAPLOAD_KEY))
- hard_set_sensitive (check_box, FALSE);
-
- check_box = gtk_check_button_new_with_mnemonic(_("_Load"));
- ma->check_boxes[4] = check_box;
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_box),
- g_settings_get_boolean (ma->settings, VIEW_LOADAVG_KEY));
- g_object_set_data(G_OBJECT(check_box), "MultiloadApplet", ma);
- g_object_set_data(G_OBJECT(check_box), "prop_type", GINT_TO_POINTER(PROP_AVG));
- g_signal_connect(G_OBJECT(check_box), "toggled",
- G_CALLBACK(property_toggled_cb), VIEW_LOADAVG_KEY);
- gtk_box_pack_start(GTK_BOX(control_hbox), check_box, FALSE, FALSE, 0);
-
- if ( ! g_settings_is_writable (ma->settings, VIEW_LOADAVG_KEY))
- hard_set_sensitive (check_box, FALSE);
-
- check_box = gtk_check_button_new_with_mnemonic(_("_Harddisk"));
- ma->check_boxes[5] = check_box;
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_box),
- g_settings_get_boolean (ma->settings, VIEW_DISKLOAD_KEY));
- g_object_set_data (G_OBJECT (check_box), "MultiloadApplet", ma);
- g_object_set_data (G_OBJECT (check_box), "prop_type",
- GINT_TO_POINTER (PROP_DISK));
- g_signal_connect (G_OBJECT (check_box), "toggled",
- G_CALLBACK (property_toggled_cb), VIEW_DISKLOAD_KEY);
- gtk_box_pack_start (GTK_BOX (control_hbox), check_box, FALSE, FALSE, 0);
-
- if ( ! g_settings_is_writable (ma->settings, VIEW_DISKLOAD_KEY))
- hard_set_sensitive (check_box, FALSE);
-
- category_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_box_pack_start (GTK_BOX (categories_vbox), category_vbox, TRUE, TRUE, 0);
- gtk_widget_show (category_vbox);
-
- title = g_strconcat ("<span weight=\"bold\">", _("Options"), "</span>", NULL);
- label = gtk_label_new (title);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
- gtk_label_set_xalign (GTK_LABEL (label), 0.0);
- gtk_box_pack_start (GTK_BOX (category_vbox), label, FALSE, FALSE, 0);
- gtk_widget_show (label);
- g_free (title);
-
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_pack_start (GTK_BOX (category_vbox), hbox, TRUE, TRUE, 0);
- gtk_widget_show (hbox);
-
- indent = gtk_label_new (HIG_IDENTATION);
- gtk_label_set_justify (GTK_LABEL (indent), GTK_JUSTIFY_LEFT);
- gtk_box_pack_start (GTK_BOX (hbox), indent, FALSE, FALSE, 0);
- gtk_widget_show (indent);
-
- control_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_box_pack_start (GTK_BOX (hbox), control_vbox, TRUE, TRUE, 0);
- gtk_widget_show (control_vbox);
-
- control_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
- gtk_box_pack_start (GTK_BOX (control_vbox), control_hbox, TRUE, TRUE, 0);
- gtk_widget_show (control_hbox);
-
- label_size = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+ color_button_set (GTK_COLOR_CHOOSER (button),
+ ma->settings, KEY_LOADAVG_GRIDLINE_COLOR,
+ &(ma->graphs[graph_loadavg]->colors[loadavg_gridline]));
+}
- orient = mate_panel_applet_get_orient(ma->applet);
- if ( (orient == MATE_PANEL_APPLET_ORIENT_UP) || (orient == MATE_PANEL_APPLET_ORIENT_DOWN) )
- label_text = g_strdup(_("System m_onitor width: "));
- else
- label_text = g_strdup(_("System m_onitor height: "));
-
- label = gtk_label_new_with_mnemonic(label_text);
- gtk_label_set_xalign (GTK_LABEL (label), 0.0f);
- gtk_size_group_add_widget (label_size, label);
- gtk_box_pack_start (GTK_BOX (control_hbox), label, FALSE, FALSE, 0);
-
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_box_pack_start (GTK_BOX (control_hbox), hbox, TRUE, TRUE, 0);
- gtk_widget_show (hbox);
-
- spin_size = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-
- spin_button = gtk_spin_button_new_with_range (GRAPH_SIZE_MIN, GRAPH_SIZE_MAX, 5);
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), spin_button);
- spin_value_uint = CLAMP (g_settings_get_uint (ma->settings, GRAPH_SIZE_KEY),
- GRAPH_SIZE_MIN,
- GRAPH_SIZE_MAX);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin_button), (gdouble) spin_value_uint);
- g_signal_connect (GTK_SPIN_BUTTON (spin_button), "value-changed",
- G_CALLBACK (on_graph_size_spin_button_value_changed), ma);
-
- if ( ! g_settings_is_writable (ma->settings, GRAPH_SIZE_KEY)) {
- hard_set_sensitive (label, FALSE);
- hard_set_sensitive (hbox, FALSE);
- }
+static void
+on_diskload_read_color_button_color_set (GtkColorButton *button,
+ MultiloadApplet *ma)
+{
+ color_button_set (GTK_COLOR_CHOOSER (button),
+ ma->settings, KEY_DISKLOAD_READ_COLOR,
+ &(ma->graphs[graph_diskload]->colors[diskload_read]));
+}
- gtk_size_group_add_widget (spin_size, spin_button);
- gtk_box_pack_start (GTK_BOX (hbox), spin_button, FALSE, FALSE, 0);
-
- label = gtk_label_new (_("pixels"));
- gtk_label_set_xalign (GTK_LABEL (label), 0.0f);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
-
- control_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
- gtk_box_pack_start (GTK_BOX (control_vbox), control_hbox, TRUE, TRUE, 0);
- gtk_widget_show (control_hbox);
-
- label = gtk_label_new_with_mnemonic(_("Sys_tem monitor update interval: "));
- gtk_label_set_xalign (GTK_LABEL (label), 0.0f);
- gtk_size_group_add_widget (label_size, label);
- gtk_box_pack_start (GTK_BOX (control_hbox), label, FALSE, FALSE, 0);
-
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_box_pack_start (GTK_BOX (control_hbox), hbox, TRUE, TRUE, 0);
- gtk_widget_show (hbox);
-
- spin_button = gtk_spin_button_new_with_range (REFRESH_RATE_MIN,
- REFRESH_RATE_MAX,
- 50);
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), spin_button);
- spin_value_uint = CLAMP (g_settings_get_uint (ma->settings, REFRESH_RATE_KEY),
- REFRESH_RATE_MIN,
- REFRESH_RATE_MAX);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin_button),
- (gdouble) spin_value_uint);
- g_signal_connect (GTK_SPIN_BUTTON (spin_button), "value-changed",
- G_CALLBACK (on_speed_spin_button_value_changed), ma);
- gtk_size_group_add_widget (spin_size, spin_button);
- gtk_box_pack_start (GTK_BOX (hbox), spin_button, FALSE, FALSE, 0);
-
- if ( ! g_settings_is_writable (ma->settings, REFRESH_RATE_KEY)) {
- hard_set_sensitive (label, FALSE);
- hard_set_sensitive (hbox, FALSE);
- }
+static void
+on_diskload_write_color_button_color_set (GtkColorButton *button,
+ MultiloadApplet *ma)
+{
+ color_button_set (GTK_COLOR_CHOOSER (button),
+ ma->settings, KEY_DISKLOAD_WRITE_COLOR,
+ &(ma->graphs[graph_diskload]->colors[diskload_write]));
+}
- label = gtk_label_new(_("milliseconds"));
- gtk_label_set_xalign (GTK_LABEL (label), 0.0f);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
-
- g_free(label_text);
-
- category_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_box_pack_start (GTK_BOX (categories_vbox), category_vbox, TRUE, TRUE, 0);
- gtk_widget_show (category_vbox);
-
- title = g_strconcat ("<span weight=\"bold\">", _("Colors"), "</span>", NULL);
- label = gtk_label_new (title);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
- gtk_label_set_xalign (GTK_LABEL (label), 0.0);
- gtk_box_pack_start (GTK_BOX (category_vbox), label, FALSE, FALSE, 0);
- gtk_widget_show (label);
- g_free (title);
-
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_pack_start (GTK_BOX (category_vbox), hbox, TRUE, TRUE, 0);
- gtk_widget_show (hbox);
-
- indent = gtk_label_new (HIG_IDENTATION);
- gtk_label_set_justify (GTK_LABEL (indent), GTK_JUSTIFY_LEFT);
- gtk_box_pack_start (GTK_BOX (hbox), indent, FALSE, FALSE, 0);
- gtk_widget_show (indent);
-
- control_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_box_pack_start (GTK_BOX (hbox), control_vbox, TRUE, TRUE, 0);
- gtk_widget_show (control_vbox);
-
- ma->notebook = gtk_notebook_new();
- gtk_container_add (GTK_CONTAINER (control_vbox), ma->notebook);
-
- page = add_page(ma->notebook, _("Processor"));
- gtk_container_set_border_width (GTK_CONTAINER (page), 12);
- add_color_selector(page, _("_User"), "cpuload-color0", ma);
- add_color_selector(page, _("S_ystem"), "cpuload-color1", ma);
- add_color_selector(page, _("N_ice"), "cpuload-color2", ma);
- add_color_selector(page, _("I_OWait"), "cpuload-color3", ma);
- add_color_selector(page, _("I_dle"), "cpuload-color4", ma);
-
- page = add_page(ma->notebook, _("Memory"));
- gtk_container_set_border_width (GTK_CONTAINER (page), 12);
- add_color_selector(page, _("_User"), "memload-color0", ma);
- add_color_selector(page, _("Sh_ared"), "memload-color1", ma);
- add_color_selector(page, _("_Buffers"), "memload-color2", ma);
- add_color_selector (page, _("Cach_ed"), "memload-color3", ma);
- add_color_selector(page, _("F_ree"), "memload-color4", ma);
-
- page = add_page(ma->notebook, _("Network"));
- gtk_container_set_border_width (GTK_CONTAINER (page), 12);
- add_color_selector (page, _("_In"), "netload2-color0", ma);
- add_color_selector(page, _("_Out"), "netload2-color1", ma);
- add_color_selector (page, _("_Local"), "netload2-color2", ma);
- add_color_selector(page, _("_Background"), "netload2-color3", ma);
- add_color_selector(page, _("_Gridline"), "netload2-color4", ma);
- add_color_selector(page, _("_Indicator"), "netload2-color5", ma);
-
- page = add_page(ma->notebook, _("Swap Space"));
- gtk_container_set_border_width (GTK_CONTAINER (page), 12);
- add_color_selector(page, _("_Used"), "swapload-color0", ma);
- add_color_selector(page, _("_Free"), "swapload-color1", ma);
-
- page = add_page(ma->notebook, _("Load"));
- gtk_container_set_border_width (GTK_CONTAINER (page), 12);
- add_color_selector(page, _("_Average"), "loadavg-color0", ma);
- add_color_selector(page, _("_Background"), "loadavg-color1", ma);
- add_color_selector(page, _("_Gridline"), "loadavg-color2", ma);
-
- page = add_page (ma->notebook, _("Harddisk"));
- gtk_container_set_border_width (GTK_CONTAINER (page), 12);
- add_color_selector (page, _("_Read"), "diskload-color0", ma);
- add_color_selector (page, _("_Write"), "diskload-color1", ma);
- add_color_selector (page, _("_Background"), "diskload-color2", 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);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
- gtk_label_set_xalign (GTK_LABEL (label), 0.0);
- gtk_box_pack_start (GTK_BOX (category_vbox), label, FALSE, FALSE, 0);
- gtk_widget_show (label);
- g_free (title);
-
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_pack_start (GTK_BOX (category_vbox), hbox, TRUE, TRUE, 0);
- gtk_widget_show (hbox);
-
- indent = gtk_label_new (HIG_IDENTATION);
- gtk_label_set_justify (GTK_LABEL (indent), GTK_JUSTIFY_LEFT);
- gtk_box_pack_start (GTK_BOX (hbox), indent, FALSE, FALSE, 0);
- gtk_widget_show (indent);
-
- control_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_box_pack_start (GTK_BOX (hbox), control_vbox, TRUE, TRUE, 0);
- gtk_widget_show (control_vbox);
-
- control_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
- gtk_box_pack_start (GTK_BOX (control_vbox), control_hbox, TRUE, TRUE, 0);
- gtk_widget_show (control_hbox);
-
- label_size = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-
- label_text = g_strdup(_("Threshold 1: "));
- label = gtk_label_new_with_mnemonic(label_text);
- gtk_label_set_xalign (GTK_LABEL (label), 0.0f);
- gtk_size_group_add_widget (label_size, label);
- gtk_box_pack_start (GTK_BOX (control_hbox), label, FALSE, FALSE, 0);
-
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_box_pack_start (GTK_BOX (control_hbox), hbox, TRUE, TRUE, 0);
- gtk_widget_show (hbox);
-
- spin_size = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-
- spin_button = gtk_spin_button_new_with_range (MIN_NET_THRESHOLD1, MAX_NET_THRESHOLD1, 5);
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), spin_button);
- spin_value_uint64 = g_settings_get_uint64 (ma->settings, KEY_NET_THRESHOLD1);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin_button), (gdouble) spin_value_uint64);
- g_signal_connect (GTK_SPIN_BUTTON (spin_button), "value-changed",
- G_CALLBACK (on_net_threshold1_spin_button_value_changed), ma);
-
- if ( ! g_settings_is_writable (ma->settings, KEY_NET_THRESHOLD1))
- {
- hard_set_sensitive (label, FALSE);
- hard_set_sensitive (hbox, FALSE);
- }
+static void
+on_diskload_free_color_button_color_set (GtkColorButton *button,
+ MultiloadApplet *ma)
+{
+ color_button_set (GTK_COLOR_CHOOSER (button),
+ ma->settings, KEY_DISKLOAD_FREE_COLOR,
+ &(ma->graphs[graph_diskload]->colors[diskload_free]));
+}
- gtk_size_group_add_widget (spin_size, spin_button);
- gtk_box_pack_start (GTK_BOX (hbox), spin_button, FALSE, FALSE, 0);
-
- label = gtk_label_new (_("bytes"));
- gtk_label_set_xalign (GTK_LABEL (label), 0.0f);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
-
- control_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
- gtk_box_pack_start (GTK_BOX (control_vbox), control_hbox, TRUE, TRUE, 0);
- gtk_widget_show (control_hbox);
-
- label = gtk_label_new_with_mnemonic(_("Threshold 2: "));
- gtk_label_set_xalign (GTK_LABEL (label), 0.0f);
- gtk_size_group_add_widget (label_size, label);
- gtk_box_pack_start (GTK_BOX (control_hbox), label, FALSE, FALSE, 0);
-
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_box_pack_start (GTK_BOX (control_hbox), hbox, TRUE, TRUE, 0);
- gtk_widget_show (hbox);
-
- spin_button = gtk_spin_button_new_with_range (MIN_NET_THRESHOLD2, MAX_NET_THRESHOLD2, 5);
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), spin_button);
- spin_value_uint64 = g_settings_get_uint64 (ma->settings, KEY_NET_THRESHOLD2);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin_button), (gdouble) spin_value_uint64);
- g_signal_connect (GTK_SPIN_BUTTON (spin_button), "value-changed",
- G_CALLBACK (on_net_threshold2_spin_button_value_changed), ma);
- gtk_size_group_add_widget (spin_size, spin_button);
- gtk_box_pack_start (GTK_BOX (hbox), spin_button, FALSE, FALSE, 0);
-
- if ( ! g_settings_is_writable (ma->settings, KEY_NET_THRESHOLD2))
- {
- hard_set_sensitive (label, FALSE);
- hard_set_sensitive (hbox, FALSE);
- }
+static void
+graph_set_active (MultiloadApplet *ma,
+ LoadGraph *graph,
+ gboolean active)
+{
+ graph->visible = active;
+ if (active) {
+ guint i;
- label = gtk_label_new(_("bytes"));
- gtk_label_set_xalign (GTK_LABEL (label), 0.0f);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
-
- control_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
- gtk_box_pack_start (GTK_BOX (control_vbox), control_hbox, TRUE, TRUE, 0);
- gtk_widget_show (control_hbox);
-
- label = gtk_label_new_with_mnemonic(_("Threshold 3: "));
- gtk_label_set_xalign (GTK_LABEL (label), 0.0f);
- gtk_size_group_add_widget (label_size, label);
- gtk_box_pack_start (GTK_BOX (control_hbox), label, FALSE, FALSE, 0);
-
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_box_pack_start (GTK_BOX (control_hbox), hbox, TRUE, TRUE, 0);
- gtk_widget_show (hbox);
-
- spin_button = gtk_spin_button_new_with_range (MIN_NET_THRESHOLD3, MAX_NET_THRESHOLD3, 5);
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), spin_button);
- spin_value_uint64 = g_settings_get_uint64 (ma->settings, KEY_NET_THRESHOLD3);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin_button), (gdouble) spin_value_uint64);
- g_signal_connect (GTK_SPIN_BUTTON (spin_button), "value-changed",
- G_CALLBACK (on_net_threshold3_spin_button_value_changed), ma);
- gtk_size_group_add_widget (spin_size, spin_button);
- gtk_box_pack_start (GTK_BOX (hbox), spin_button, FALSE, FALSE, 0);
-
- if ( ! g_settings_is_writable (ma->settings, KEY_NET_THRESHOLD3))
- {
- hard_set_sensitive (label, FALSE);
- hard_set_sensitive (hbox, FALSE);
+ for (i = 0; i < graph_n; i++)
+ soft_set_sensitive(ma->check_boxes[i], TRUE);
+ gtk_widget_show_all (graph->main_widget);
+ load_graph_start (graph);
+ } else {
+ load_graph_stop (graph);
+ gtk_widget_hide (graph->main_widget);
+ properties_set_insensitive (ma);
}
+}
+
+#define GRAPH_ACTIVE_SET(x) graph_set_active (ma, ma->graphs[(x)], \
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox)))
+
+static void
+on_graph_cpuload_checkbox_toggled (GtkCheckButton *checkbox,
+ MultiloadApplet *ma)
+{
+ GRAPH_ACTIVE_SET (graph_cpuload);
+}
+
+static void
+on_graph_memload_checkbox_toggled (GtkCheckButton *checkbox,
+ MultiloadApplet *ma)
+{
+ GRAPH_ACTIVE_SET (graph_memload);
+}
+
+static void
+on_graph_netload2_checkbox_toggled (GtkCheckButton *checkbox,
+ MultiloadApplet *ma)
+{
+ GRAPH_ACTIVE_SET (graph_netload2);
+}
+
+static void
+on_graph_swapload_checkbox_toggled (GtkCheckButton *checkbox,
+ MultiloadApplet *ma)
+{
+ GRAPH_ACTIVE_SET (graph_swapload);
+}
+
+static void
+on_graph_loadavg_checkbox_toggled (GtkCheckButton *checkbox,
+ MultiloadApplet *ma)
+{
+ GRAPH_ACTIVE_SET (graph_loadavg);
+}
+
+static void
+on_graph_diskload_checkbox_toggled (GtkCheckButton *checkbox,
+ MultiloadApplet *ma)
+{
+ GRAPH_ACTIVE_SET (graph_diskload);
+}
+
+/* save the checkbox option to gsettings and apply it on the applet */
+static void
+on_nvme_checkbox_toggled (GtkCheckButton *checkbox,
+ MultiloadApplet *ma)
+{
+ ma->nvme_diskstats = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox));
+}
+
+static void
+read_spin_uint_button (GtkWidget *widget,
+ GSettings *settings,
+ const char *key,
+ guint min,
+ guint max)
+{
+ guint value;
- label = gtk_label_new(_("bytes"));
- gtk_label_set_xalign (GTK_LABEL (label), 0.0f);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ value = CLAMP (g_settings_get_uint (settings, key), min, max);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), (gdouble) value);
+ if (!g_settings_is_writable (settings, key))
+ hard_set_sensitive (widget, FALSE);
+}
- g_free(label_text);
+static void
+read_spin_uint64_button (GtkWidget *widget,
+ GSettings *settings,
+ const char *key,
+ guint min,
+ guint max)
+{
+ guint64 value;
- category_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_box_pack_start (GTK_BOX (categories_vbox), category_vbox, TRUE, TRUE, 0);
+ value = CLAMP (g_settings_get_uint64 (settings, key), min, max);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), (gdouble) value);
+
+ if (!g_settings_is_writable (settings, key))
+ hard_set_sensitive (widget, FALSE);
+}
- control_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
- gtk_box_pack_start (GTK_BOX (control_vbox), control_hbox, TRUE, TRUE, 0);
- gtk_widget_show (control_hbox);
+static void
+read_color_button (GtkWidget *widget,
+ GSettings *settings,
+ const char *key)
+{
+ GdkRGBA color;
+ gchar *color_string;
- gtk_widget_show (category_vbox);
+ if ((color_string = g_settings_get_string (settings, key)) != NULL) {
+ gdk_rgba_parse (&color, color_string);
+ g_free (color_string);
+ } else {
+ gdk_rgba_parse (&color, "#000000");
+ }
+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (widget), &color);
- return;
+ if (!g_settings_is_writable (settings, key))
+ hard_set_sensitive (widget, FALSE);
}
/* show properties dialog */
@@ -811,7 +543,11 @@ void
multiload_properties_cb (GtkAction *action,
MultiloadApplet *ma)
{
- GtkWidget *dialog = NULL;
+ GtkBuilder *builder;
+ GtkWidget *dialog = NULL;
+ GtkWidget *graph_size_spin_button_label;
+ const char *graph_size_spin_button_label_txt;
+ MatePanelAppletOrient orient;
if (ma->prop_dialog) {
dialog = ma->prop_dialog;
@@ -825,28 +561,127 @@ multiload_properties_cb (GtkAction *action,
return;
}
- dialog = gtk_dialog_new_with_buttons (_("System Monitor Preferences"),
- NULL, 0,
- "gtk-help", GTK_RESPONSE_HELP,
- "gtk-close", GTK_RESPONSE_CLOSE,
- NULL);
- gtk_window_set_screen (GTK_WINDOW (dialog),
+ builder = gtk_builder_new_from_resource (MULTILOAD_RESOURCE_PATH "properties.ui");
+ gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
+
+ #define GET_WIDGET(x) (GTK_WIDGET (gtk_builder_get_object (builder, (x))))
+
+ ma->prop_dialog = GET_WIDGET ("properties_dialog");
+
+ read_color_button (GET_WIDGET ("cpuload_free_color_button"), ma->settings, KEY_CPULOAD_IDLE_COLOR);
+ read_color_button (GET_WIDGET ("cpuload_iowait_color_button"), ma->settings, KEY_CPULOAD_IOWAIT_COLOR);
+ read_color_button (GET_WIDGET ("cpuload_nice_color_button"), ma->settings, KEY_CPULOAD_NICE_COLOR);
+ read_color_button (GET_WIDGET ("cpuload_sys_color_button"), ma->settings, KEY_CPULOAD_SYS_COLOR);
+ read_color_button (GET_WIDGET ("cpuload_usr_color_button"), ma->settings, KEY_CPULOAD_USR_COLOR);
+ read_color_button (GET_WIDGET ("diskload_free_color_button"), ma->settings, KEY_DISKLOAD_FREE_COLOR);
+ read_color_button (GET_WIDGET ("diskload_read_color_button"), ma->settings, KEY_DISKLOAD_READ_COLOR);
+ read_color_button (GET_WIDGET ("diskload_write_color_button"), ma->settings, KEY_DISKLOAD_WRITE_COLOR);
+ read_color_button (GET_WIDGET ("loadavg_average_color_button"), ma->settings, KEY_LOADAVG_AVERAGE_COLOR);
+ read_color_button (GET_WIDGET ("loadavg_background_color_button"), ma->settings, KEY_LOADAVG_BACKGROUND_COLOR);
+ read_color_button (GET_WIDGET ("loadavg_gridline_color_button"), ma->settings, KEY_LOADAVG_GRIDLINE_COLOR);
+ read_color_button (GET_WIDGET ("memload_buffer_color_button"), ma->settings, KEY_MEMLOAD_BUFFER_COLOR);
+ read_color_button (GET_WIDGET ("memload_cached_color_button"), ma->settings, KEY_MEMLOAD_CACHED_COLOR);
+ read_color_button (GET_WIDGET ("memload_free_color_button"), ma->settings, KEY_MEMLOAD_FREE_COLOR);
+ read_color_button (GET_WIDGET ("memload_shared_color_button"), ma->settings, KEY_MEMLOAD_SHARED_COLOR);
+ read_color_button (GET_WIDGET ("memload_user_color_button"), ma->settings, KEY_MEMLOAD_USER_COLOR);
+ read_color_button (GET_WIDGET ("netload2_background_color_button"), ma->settings, KEY_NETLOAD2_BACKGROUND_COLOR);
+ read_color_button (GET_WIDGET ("netload2_gridline_color_button"), ma->settings, KEY_NETLOAD2_GRIDLINE_COLOR);
+ read_color_button (GET_WIDGET ("netload2_in_color_button"), ma->settings, KEY_NETLOAD2_IN_COLOR);
+ read_color_button (GET_WIDGET ("netload2_indicator_color_button"), ma->settings, KEY_NETLOAD2_INDICATOR_COLOR);
+ read_color_button (GET_WIDGET ("netload2_loopback_color_button"), ma->settings, KEY_NETLOAD2_LOOPBACK_COLOR);
+ read_color_button (GET_WIDGET ("netload2_out_color_button"), ma->settings, KEY_NETLOAD2_OUT_COLOR);
+ read_color_button (GET_WIDGET ("swapload_free_color_button"), ma->settings, KEY_SWAPLOAD_FREE_COLOR);
+ read_color_button (GET_WIDGET ("swapload_used_color_button"), ma->settings, KEY_SWAPLOAD_USED_COLOR);
+
+ graph_size_spin_button_label = GET_WIDGET ("graph_size_spin_button_label");
+ orient = mate_panel_applet_get_orient(ma->applet);
+ switch (orient) {
+ case MATE_PANEL_APPLET_ORIENT_UP:
+ case MATE_PANEL_APPLET_ORIENT_DOWN:
+ graph_size_spin_button_label_txt = _("System m_onitor width:");
+ break;
+ default:
+ graph_size_spin_button_label_txt = _("System m_onitor height:");
+ }
+ gtk_label_set_text_with_mnemonic (GTK_LABEL (graph_size_spin_button_label), graph_size_spin_button_label_txt);
+
+ read_spin_uint_button (GET_WIDGET ("graph_size_spin_button"), ma->settings, GRAPH_SIZE_KEY, GRAPH_SIZE_MIN, GRAPH_SIZE_MAX);
+ read_spin_uint_button (GET_WIDGET ("speed_spin_button"), ma->settings, REFRESH_RATE_KEY, REFRESH_RATE_MIN, REFRESH_RATE_MAX);
+
+ read_spin_uint64_button (GET_WIDGET ("net_threshold1_spin_button"), ma->settings, KEY_NET_THRESHOLD1, MIN_NET_THRESHOLD1, MAX_NET_THRESHOLD1);
+ read_spin_uint64_button (GET_WIDGET ("net_threshold2_spin_button"), ma->settings, KEY_NET_THRESHOLD2, MIN_NET_THRESHOLD2, MAX_NET_THRESHOLD2);
+ read_spin_uint64_button (GET_WIDGET ("net_threshold3_spin_button"), ma->settings, KEY_NET_THRESHOLD3, MIN_NET_THRESHOLD3, MAX_NET_THRESHOLD3);
+
+ ma->notebook = GET_WIDGET ("notebook");
+
+ ma->check_boxes[graph_cpuload] = GET_WIDGET ("graph_cpuload_checkbox");
+ ma->check_boxes[graph_memload] = GET_WIDGET ("graph_memload_checkbox");
+ ma->check_boxes[graph_netload2] = GET_WIDGET ("graph_netload2_checkbox");
+ ma->check_boxes[graph_swapload] = GET_WIDGET ("graph_swapload_checkbox");
+ ma->check_boxes[graph_loadavg] = GET_WIDGET ("graph_loadavg_checkbox");
+ ma->check_boxes[graph_diskload] = GET_WIDGET ("graph_diskload_checkbox");
+
+ g_settings_bind (ma->settings, VIEW_CPULOAD_KEY, ma->check_boxes[graph_cpuload], "active", G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (ma->settings, VIEW_MEMLOAD_KEY, ma->check_boxes[graph_memload], "active", G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (ma->settings, VIEW_NETLOAD_KEY, ma->check_boxes[graph_netload2], "active", G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (ma->settings, VIEW_SWAPLOAD_KEY, ma->check_boxes[graph_swapload], "active", G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (ma->settings, VIEW_LOADAVG_KEY, ma->check_boxes[graph_loadavg], "active", G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (ma->settings, VIEW_DISKLOAD_KEY, ma->check_boxes[graph_diskload], "active", G_SETTINGS_BIND_DEFAULT);
+
+ g_settings_bind (ma->settings, DISKLOAD_NVME_KEY, GET_WIDGET ("nvme_checkbox"), "active", G_SETTINGS_BIND_DEFAULT);
+
+ #undef GET_WIDGET
+
+ properties_set_insensitive (ma);
+
+ gtk_builder_add_callback_symbols (builder,
+ "on_cpuload_usr_color_button_color_set", G_CALLBACK (on_cpuload_usr_color_button_color_set),
+ "on_cpuload_sys_color_button_color_set", G_CALLBACK (on_cpuload_sys_color_button_color_set),
+ "on_cpuload_nice_color_button_color_set", G_CALLBACK (on_cpuload_nice_color_button_color_set),
+ "on_cpuload_iowait_color_button_color_set", G_CALLBACK (on_cpuload_iowait_color_button_color_set),
+ "on_cpuload_free_color_button_color_set", G_CALLBACK (on_cpuload_free_color_button_color_set),
+ "on_memload_user_color_button_color_set", G_CALLBACK (on_memload_user_color_button_color_set),
+ "on_memload_shared_color_button_color_set", G_CALLBACK (on_memload_shared_color_button_color_set),
+ "on_memload_buffer_color_button_color_set", G_CALLBACK (on_memload_buffer_color_button_color_set),
+ "on_memload_cached_color_button_color_set", G_CALLBACK (on_memload_cached_color_button_color_set),
+ "on_memload_free_color_button_color_set", G_CALLBACK (on_memload_free_color_button_color_set),
+ "on_netload2_in_color_button_color_set", G_CALLBACK (on_netload2_in_color_button_color_set),
+ "on_netload2_out_color_button_color_set", G_CALLBACK (on_netload2_out_color_button_color_set),
+ "on_netload2_loopback_color_button_color_set", G_CALLBACK (on_netload2_loopback_color_button_color_set),
+ "on_netload2_background_color_button_color_set", G_CALLBACK (on_netload2_background_color_button_color_set),
+ "on_netload2_gridline_color_button_color_set", G_CALLBACK (on_netload2_gridline_color_button_color_set),
+ "on_netload2_indicator_color_button_color_set", G_CALLBACK (on_netload2_indicator_color_button_color_set),
+ "on_swapload_used_color_button_color_set", G_CALLBACK (on_swapload_used_color_button_color_set),
+ "on_swapload_free_color_button_color_set", G_CALLBACK (on_swapload_free_color_button_color_set),
+ "on_loadavg_average_color_button_color_set", G_CALLBACK (on_loadavg_average_color_button_color_set),
+ "on_loadavg_background_color_button_color_set", G_CALLBACK (on_loadavg_background_color_button_color_set),
+ "on_loadavg_gridline_color_button_color_set", G_CALLBACK (on_loadavg_gridline_color_button_color_set),
+ "on_diskload_read_color_button_color_set", G_CALLBACK (on_diskload_read_color_button_color_set),
+ "on_diskload_write_color_button_color_set", G_CALLBACK (on_diskload_write_color_button_color_set),
+ "on_diskload_free_color_button_color_set", G_CALLBACK (on_diskload_free_color_button_color_set),
+ "on_properties_dialog_response", G_CALLBACK (on_properties_dialog_response),
+ "on_graph_cpuload_checkbox_toggled", G_CALLBACK (on_graph_cpuload_checkbox_toggled),
+ "on_graph_memload_checkbox_toggled", G_CALLBACK (on_graph_memload_checkbox_toggled),
+ "on_graph_netload2_checkbox_toggled", G_CALLBACK (on_graph_netload2_checkbox_toggled),
+ "on_graph_swapload_checkbox_toggled", G_CALLBACK (on_graph_swapload_checkbox_toggled),
+ "on_graph_loadavg_checkbox_toggled", G_CALLBACK (on_graph_loadavg_checkbox_toggled),
+ "on_graph_diskload_checkbox_toggled", G_CALLBACK (on_graph_diskload_checkbox_toggled),
+ "on_nvme_checkbox_toggled", G_CALLBACK (on_nvme_checkbox_toggled),
+ "on_graph_size_spin_button_value_changed", G_CALLBACK (on_graph_size_spin_button_value_changed),
+ "on_speed_spin_button_value_changed", G_CALLBACK (on_speed_spin_button_value_changed),
+ "on_net_threshold1_spin_button_value_changed", G_CALLBACK (on_net_threshold1_spin_button_value_changed),
+ "on_net_threshold2_spin_button_value_changed", G_CALLBACK (on_net_threshold2_spin_button_value_changed),
+ "on_net_threshold3_spin_button_value_changed", G_CALLBACK (on_net_threshold3_spin_button_value_changed),
+ NULL);
+
+ gtk_builder_connect_signals (builder, ma);
+
+ g_object_unref (builder);
+
+ gtk_window_set_screen (GTK_WINDOW (ma->prop_dialog),
gtk_widget_get_screen (GTK_WIDGET (ma->applet)));
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
- gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 2);
-
- fill_properties(dialog, ma);
-
- properties_set_insensitive(ma);
-
- g_signal_connect(G_OBJECT(dialog), "response",
- G_CALLBACK(properties_close_cb), ma);
-
- ma->prop_dialog = dialog;
- gtk_widget_show_all(dialog);
+ gtk_widget_show_all (ma->prop_dialog);
gtk_notebook_set_current_page (GTK_NOTEBOOK (ma->notebook),
ma->last_clicked);