static void sensor_notify_units(IsSensor *sensor, GParamSpec *pspec, IsSensorDialog *self) { gtk_label_set_text(GTK_LABEL(self->priv->units_label), is_sensor_get_units(sensor)); }
static void update_sensor_from_max(IsMaxPlugin *self) { IsMaxPluginPrivate *priv; gchar *label; priv = self->priv; label = g_strdup_printf("↑%s", is_sensor_get_label(priv->max)); is_sensor_set_label(priv->sensor, label); is_sensor_set_icon(priv->sensor, is_sensor_get_icon(priv->max)); is_sensor_set_value(priv->sensor, is_sensor_get_value(priv->max)); is_sensor_set_units(priv->sensor, is_sensor_get_units(priv->max)); is_sensor_set_digits(priv->sensor, is_sensor_get_digits(priv->max)); g_free(label); }
static void is_sensor_dialog_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { IsSensorDialog *self = IS_SENSOR_DIALOG(object); IsSensorDialogPrivate *priv = self->priv; gchar *markup; switch (property_id) { case PROP_SENSOR: priv->sensor = g_object_ref(g_value_get_object(value)); markup = g_strdup_printf("<span weight='bold'>%s: %s</span>", _("Sensor"), is_sensor_get_path(priv->sensor)); gtk_label_set_markup(GTK_LABEL(priv->path_label), markup); g_free(markup); gtk_widget_set_sensitive(priv->label_entry, TRUE); gtk_entry_set_text(GTK_ENTRY(priv->label_entry), is_sensor_get_label(priv->sensor)); g_signal_connect(priv->label_entry, "changed", G_CALLBACK(label_changed), self); g_signal_connect(priv->sensor, "notify::label", G_CALLBACK(sensor_notify_label), self); gtk_widget_set_sensitive(priv->alarm_mode_combo_box, TRUE); gtk_combo_box_set_active(GTK_COMBO_BOX(priv->alarm_mode_combo_box), is_sensor_get_alarm_mode(priv->sensor)); g_signal_connect(priv->alarm_mode_combo_box, "changed", G_CALLBACK(alarm_mode_changed), self); g_signal_connect(priv->sensor, "notify::alarm-mode", G_CALLBACK(sensor_notify_alarm_mode), self); /* set sensitive so we can update */ gtk_widget_set_sensitive(priv->alarm_value_spin_button, TRUE); gtk_spin_button_set_digits(GTK_SPIN_BUTTON(priv->alarm_value_spin_button), is_sensor_get_digits(priv->sensor)); gtk_spin_button_set_value(GTK_SPIN_BUTTON(priv->alarm_value_spin_button), is_sensor_get_alarm_value(priv->sensor)); g_signal_connect(priv->alarm_value_spin_button, "value-changed", G_CALLBACK(alarm_value_changed), self); g_signal_connect(priv->sensor, "notify::alarm-value", G_CALLBACK(sensor_notify_alarm_value), self); gtk_widget_set_sensitive(priv->alarm_value_spin_button, (is_sensor_get_alarm_mode(priv->sensor) != IS_SENSOR_ALARM_MODE_DISABLED)); gtk_widget_set_sensitive(priv->units_label, TRUE); gtk_label_set_text(GTK_LABEL(priv->units_label), is_sensor_get_units(priv->sensor)); g_signal_connect(priv->sensor, "notify::units", G_CALLBACK(sensor_notify_units), self); gtk_widget_set_sensitive(priv->low_value, TRUE); gtk_spin_button_set_value(GTK_SPIN_BUTTON(priv->low_value), is_sensor_get_low_value(priv->sensor)); g_signal_connect(priv->low_value, "value-changed", G_CALLBACK(low_value_changed), self); g_signal_connect(priv->sensor, "notify::low-value", G_CALLBACK(sensor_notify_low_value), self); gtk_label_set_text(GTK_LABEL(priv->low_units_label), is_sensor_get_units(priv->sensor)); gtk_widget_set_sensitive(priv->high_value, TRUE); gtk_spin_button_set_value(GTK_SPIN_BUTTON(priv->high_value), is_sensor_get_high_value(priv->sensor)); g_signal_connect(priv->high_value, "value-changed", G_CALLBACK(high_value_changed), self); g_signal_connect(priv->sensor, "notify::high-value", G_CALLBACK(sensor_notify_high_value), self); gtk_label_set_text(GTK_LABEL(priv->high_units_label), is_sensor_get_units(priv->sensor)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; } }
static void update_sensor_menu_item_label(IsIndicator *self, IsSensor *sensor, GtkMenuItem *menu_item) { gchar *text; text = g_strdup_printf("%s %2.*f%s", is_sensor_get_label(sensor), is_sensor_get_digits(sensor), is_sensor_get_value(sensor), is_sensor_get_units(sensor)); gtk_menu_item_set_label(menu_item, text); g_free(text); text = NULL; #if HAVE_APPINDICATOR if (sensor == self->priv->primary) { IsIndicatorPrivate *priv = self->priv; gboolean connected; g_object_get(self, "connected", &connected, NULL); /* using fallback so just set icon */ if (!connected) { app_indicator_set_icon_full(APP_INDICATOR(self), PACKAGE, is_sensor_get_label(sensor)); return; } if (priv->display_flags & IS_INDICATOR_DISPLAY_VALUE) { text = g_strdup_printf("%2.*f%s", is_sensor_get_digits(sensor), is_sensor_get_value(sensor), is_sensor_get_units(sensor)); } if (priv->display_flags & IS_INDICATOR_DISPLAY_LABEL) { /* join label to existing text - if text is NULL this will just show label */ text = g_strjoin(" ", is_sensor_get_label(sensor), text, NULL); } if (priv->display_flags & IS_INDICATOR_DISPLAY_ICON) { app_indicator_set_icon_full(APP_INDICATOR(self), is_sensor_get_icon_path(sensor), is_sensor_get_label(sensor)); } else { /* set to a 1x1 transparent icon for no icon */ app_indicator_set_icon_full(APP_INDICATOR(self), "indicator-sensors-no-icon", is_sensor_get_label(sensor)); } app_indicator_set_label(APP_INDICATOR(self), text, text); g_free(text); app_indicator_set_status(APP_INDICATOR(self), is_sensor_get_alarmed(sensor) ? APP_INDICATOR_STATUS_ATTENTION : APP_INDICATOR_STATUS_ACTIVE); } #else gtk_status_icon_set_from_icon_name(GTK_STATUS_ICON(self), PACKAGE); #endif }