removed debug traces
[psensor.git] / src / ui_appindicator.c
index c6b3f52..7aa099d 100644 (file)
@@ -172,23 +172,68 @@ static GtkWidget *get_menu(struct ui_psensor *ui)
        return GTK_WIDGET(menu);
 }
 
+static void update_label(struct ui_psensor *ui)
+{
+       char *label, *str, *tmp, *guide;
+       struct psensor **p;
+
+       p =  ui_get_sensors_ordered_by_position(ui);
+       label = NULL;
+       guide = NULL;
+       while (*p) {
+               if (config_is_appindicator_label_enabled((*p)->id)) {
+                       str = psensor_current_value_to_str
+                               (*p, ui->config->temperature_unit == CELCIUS);
+
+                       if (label == NULL) {
+                               label = str;
+                       } else {
+                               tmp = malloc(strlen(label)
+                                            + 1
+                                            + strlen(str)
+                                            + 1);
+                               sprintf(tmp, "%s %s", label, str);
+                               free(label);
+                               free(str);
+                               label = tmp;
+                       }
+
+                       if (is_temp_type((*p)->type))
+                               str = "999UUU";
+                       else if (is_fan_type((*p)->type))
+                               str = "999UUU";
+                       else /* cpu load */
+                               str = "999%";
+
+                       if (guide == NULL) {
+                               guide = strdup(str);
+                       } else {
+                               tmp = malloc(strlen(guide)
+                                            + 1
+                                            + strlen(str)
+                                            + 1);
+                               sprintf(tmp, "%sW%s", guide, str);
+                               free(guide);
+                               guide = tmp;
+                       }
+
+               }
+               p++;
+       }
+
+       app_indicator_set_label(indicator, label, guide);
+}
+
 void ui_appindicator_update(struct ui_psensor *ui, unsigned int attention)
 {
        AppIndicatorStatus status;
-       char *label;
-       double v;
 
        if (!indicator)
                return;
 
-       status = app_indicator_get_status(indicator);
+       update_label(ui);
 
-       v = psensor_get_max_current_value(ui->sensors, SENSOR_TYPE_TEMP);
-       if (v != UNKNOWN_DBL_VALUE) {
-               label = psensor_value_to_str(SENSOR_TYPE_TEMP, v, 1);
-               app_indicator_set_label(indicator, label, NULL);
-               free(label);
-       }
+       status = app_indicator_get_status(indicator);
 
        if (!attention && status == APP_INDICATOR_STATUS_ATTENTION)
                app_indicator_set_status(indicator,