Displaying units in temp monitor
Erik-Jan <[email protected]>
| Newsgroups | gmane.comp.gnome.apps.gkrellm |
|---|---|
| Message-ID | <[email protected]> |
Hi, Attached is a patch to toggle the display of the temperature units (F or C) in the sensors temperature monitor. In gkrellm-configuration -> builtins -> sensors, on the Options-tab, there is a new option 'Show units'. Checking it, it shows the F or C in the temperature monitor; unchecking it, it doesn't show the F or C. Why? Not showing the units makes the monitor a bit less cramped and therefore more pleasing to the eyes. Bye Erik-Jan
gkrellm-2.3.2-show_units.patch
(text/plain, 2.7 KB)
diff -Naur gkrellm-2.3.2-orig/src/sensors.c gkrellm-2.3.2/src/sensors.c
--- gkrellm-2.3.2-orig/src/sensors.c 2008-10-04 02:33:37.000000000 +0200
+++ gkrellm-2.3.2/src/sensors.c 2008-10-05 17:38:25.000000000 +0200
@@ -191,7 +191,8 @@
/* ======================================================================== */
static gboolean use_threads,
thread_data_valid,
- units_fahrenheit;
+ units_fahrenheit,
+ show_units;
static gboolean thread_busy;
@@ -522,7 +523,12 @@
if (temp)
*temp = t;
if (units)
- *units = units_fahrenheit ? 'F':'C';
+ {
+ if (show_units)
+ *units = units_fahrenheit ? 'F':'C';
+ else
+ *units = '\0';
+ }
if ((_GK.debug_level & DEBUG_SENSORS) && sensor)
printf("sensor_temp: %s %s t=%.2f\n",
sensor->name_locale, sensor->path, sensor->value);
@@ -1362,7 +1368,10 @@
return;
style = gkrellm_meter_style(style_id);
m = gkrellm_get_style_margins(style);
- format = units_fahrenheit ? "188.8F" : "88.8C";
+ if (show_units)
+ format = units_fahrenheit ? "188.8F" : "88.8C";
+ else
+ format = units_fahrenheit ? "188.8" : "88.8";
assign_textstyles(temperature_list, &ts_name, &ts_sensor, format);
gkrellm_get_top_bottom_margins(style, &y, NULL);
y += bezel_style->border.top;
@@ -1773,6 +1782,8 @@
fprintf(f, "%s units_fahrenheit %d\n", SENSOR_CONFIG_KEYWORD,
units_fahrenheit);
+ fprintf(f, "%s show_units %d\n", SENSOR_CONFIG_KEYWORD,
+ show_units);
fprintf(f, "%s volt_display_mode %d\n", SENSOR_CONFIG_KEYWORD,
display_mode);
/* _GK.mbmon_port is handled in config.c so that the port can be
@@ -1807,6 +1818,8 @@
sscanf(item, "%d", &sensor_config_sysdep_private);
else if (!strcmp(config, "units_fahrenheit"))
sscanf(item, "%d", &units_fahrenheit);
+ else if (!strcmp(config, "show_units"))
+ sscanf(item, "%d", &show_units);
else if (!strcmp(config, "volt_display_mode"))
sscanf(item, "%d", &display_mode);
else if (!strcmp(config, "sensor_float_factor"))
@@ -2589,6 +2602,21 @@
}
static void
+cb_show_units(GtkWidget *button, gpointer data)
+ {
+ gint show;
+
+ show = GTK_TOGGLE_BUTTON(button)->active;
+ if (show == show_units)
+ return;
+ show_units = show;
+
+ gkrellm_sensors_rebuild(DO_TEMP, FALSE, FALSE);
+ gkrellm_cpu_draw_sensors(NULL);
+ gkrellm_proc_draw_sensors(NULL);
+ }
+
+static void
cb_voltages_display(GtkWidget *entry, gpointer data)
{
gint i;
@@ -2812,6 +2840,10 @@
units_fahrenheit, FALSE, FALSE, 0,
cb_temperature_units, NULL,
_("Display fahrenheit"));
+ gkrellm_gtk_check_button_connected(box, &button,
+ show_units, FALSE, FALSE, 0,
+ cb_show_units, NULL,
+ _("Show units"));
if (!sensor_list)
gtk_widget_set_sensitive(button, FALSE);