X-Git-Url: http://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Fui_unity.c;h=570567d71317e5ad919973515776d90ca4f5feec;hb=30280f0093e8aea4bc8af8a46c2e529e8ec61ac9;hp=2b949c8a65a0f074e4010b2ddb97a8d67464b7ec;hpb=e02abf054eace73a51d1f5713b86f6be85d8d61b;p=psensor.git diff --git a/src/ui_unity.c b/src/ui_unity.c index 2b949c8..570567d 100644 --- a/src/ui_unity.c +++ b/src/ui_unity.c @@ -22,9 +22,21 @@ #include #include -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) { @@ -48,38 +60,39 @@ 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 (v != UNKNOWN_DBL_VALUE) { + if (config_get_temperature_unit() == FAHRENHEIT) + v = celsius_to_fahrenheit(v); - 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; + unity_launcher_entry_set_count(psensor_entry, v); } +} - if (show && sensors && *sensors) { - v = get_max_current_value(sensors, SENSOR_TYPE_TEMP); +void ui_unity_init(void) +{ + psensor_entry = unity_launcher_entry_get_for_desktop_file + (PSENSOR_DESKTOP_FILE); - if (v != UNKNOWN_DBL_VALUE) { - if (!use_celsius) - v = celsius_to_fahrenheit(v); + count_visible = config_is_count_visible(); - unity_launcher_entry_set_count(psensor_entry, v); - } + 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); }