use_celsius = 1;
else
use_celsius = 0;
- ui_unity_launcher_entry_update(ui->sensors,
- !cfg->unity_launcher_count_disabled,
- use_celsius);
+ ui_unity_launcher_entry_update(ui->sensors);
if (ui->graph_update_interval != cfg->graph_update_interval) {
ui->graph_update_interval = cfg->graph_update_interval;
g_timeout_add(1000 * ui.graph_update_interval, ui_refresh_thread, &ui);
ui_appindicator_init(&ui);
+ ui_unity_init();
gdk_notify_startup_complete();
#include <temperature.h>
#include <ui_unity.h>
-static int initialized;
static UnityLauncherEntry *psensor_entry;
-static unsigned int last_visible = -1;
+static bool count_visible;
+
+static void
+count_visible_changed_cbk(GSettings *settings, gchar *key, gpointer data)
+{
+ count_visible = config_is_count_visible();
+
+ if (count_visible) {
+ unity_launcher_entry_set_count(psensor_entry, 0);
+ unity_launcher_entry_set_count_visible(psensor_entry, TRUE);
+ } else {
+ unity_launcher_entry_set_count_visible(psensor_entry, FALSE);
+ }
+}
static double get_max_current_value(struct psensor **sensors, unsigned int type)
{
return m;
}
-void ui_unity_launcher_entry_update(struct psensor **sensors,
- unsigned int show,
- int use_celsius)
+void ui_unity_launcher_entry_update(struct psensor **sensors)
{
double v;
- if (!initialized) {
- psensor_entry = unity_launcher_entry_get_for_desktop_file
- (PSENSOR_DESKTOP_FILE);
+ if (!count_visible || !sensors || !*sensors)
+ return;
- unity_launcher_entry_set_count(psensor_entry, 0);
- initialized = 1;
- }
+ v = get_max_current_value(sensors, SENSOR_TYPE_TEMP);
- if (last_visible != show) {
- if (show)
- unity_launcher_entry_set_count_visible(psensor_entry,
- TRUE);
- else
- unity_launcher_entry_set_count_visible(psensor_entry,
- FALSE);
- last_visible = show;
- }
+ if (v != UNKNOWN_DBL_VALUE) {
+ if (config_get_temperature_unit() == FAHRENHEIT)
+ v = celsius_to_fahrenheit(v);
- if (show && sensors && *sensors) {
- v = get_max_current_value(sensors, SENSOR_TYPE_TEMP);
-
- if (v != UNKNOWN_DBL_VALUE) {
- if (!use_celsius)
- v = celsius_to_fahrenheit(v);
-
- unity_launcher_entry_set_count(psensor_entry, v);
- }
+ unity_launcher_entry_set_count(psensor_entry, v);
}
}
void ui_unity_init(void)
{
+ psensor_entry = unity_launcher_entry_get_for_desktop_file
+ (PSENSOR_DESKTOP_FILE);
+
+ count_visible = config_is_count_visible();
+
+ if (count_visible) {
+ unity_launcher_entry_set_count(psensor_entry, 0);
+ unity_launcher_entry_set_count_visible(psensor_entry, TRUE);
+ } else {
+ unity_launcher_entry_set_count_visible(psensor_entry, FALSE);
+ }
+
+ g_signal_connect_after(config_get_GSettings(),
+ "changed::interface-unity-launcher-count-disabled",
+ G_CALLBACK(count_visible_changed_cbk),
+ NULL);
}
static inline bool ui_unity_is_supported(void) { return true; }
-void ui_unity_launcher_entry_update(struct psensor **, unsigned int, int);
+void ui_unity_launcher_entry_update(struct psensor **);
void ui_unity_init(void);
static inline bool ui_unity_is_supported(void) { return false; }
static inline void
-ui_unity_launcher_entry_update(struct psensor **s,
- unsigned int show,
- int use_celsius) {}
+ui_unity_launcher_entry_update(struct psensor **s) {}
static inline void ui_unity_init(void) {}