/*
- * Copyright (C) 2010-2012 jeanfi@gmail.com
+ * Copyright (C) 2010-2013 jeanfi@gmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
#include "ui_sensorpref.h"
#include "ui_color.h"
+#if defined(HAVE_APPINDICATOR) || defined(HAVE_APPINDICATOR_029)
+#include "ui_appindicator.h"
+#endif
+
struct sensor_pref {
struct psensor *sensor;
char *name;
int alarm_enabled;
int alarm_high_threshold;
int alarm_low_threshold;
+ unsigned int appindicator_enabled;
};
struct cb_data {
= celcius_to_fahrenheit(s->alarm_low_threshold);
}
+ p->appindicator_enabled = s->appindicator_enabled;
+
return p;
}
p->alarm_enabled = gtk_toggle_button_get_active(btn);
}
+static void
+on_appindicator_toggled(GtkToggleButton *btn, gpointer data)
+{
+ struct cb_data *cbdata = data;
+ struct sensor_pref *p;
+
+ p = get_selected_sensor_pref(cbdata->builder, cbdata->prefs);
+
+ if (p)
+ p->appindicator_enabled = gtk_toggle_button_get_active(btn);
+}
+
static void on_color_set(GtkColorButton *widget, gpointer data)
{
struct cb_data *cbdata = data;
"value-changed",
G_CALLBACK(on_alarm_low_threshold_changed),
cbdata);
+
+ g_signal_connect(gtk_builder_get_object(builder,
+ "indicator_checkbox"),
+ "toggled",
+ G_CALLBACK(on_appindicator_toggled),
+ cbdata);
}
static void
struct config *cfg,
GtkBuilder *builder)
{
- GtkLabel *w_id, *w_type, *w_high_threshold_unit, *w_low_threshold_unit;
+ GtkLabel *w_id, *w_type, *w_high_threshold_unit, *w_low_threshold_unit,
+ *w_chipname;
GtkEntry *w_name;
- GtkToggleButton *w_draw, *w_alarm;
+ GtkToggleButton *w_draw, *w_alarm, *w_appindicator_enabled;
GtkColorButton *w_color;
GtkSpinButton *w_high_threshold, *w_low_threshold;
GdkColor *color;
w_name = GTK_ENTRY(gtk_builder_get_object(builder, "sensor_name"));
gtk_entry_set_text(w_name, p->name);
+ w_chipname = GTK_LABEL(gtk_builder_get_object(builder, "chip_name"));
+ if (s->chip)
+ gtk_label_set_text(w_chipname, s->chip);
+ else
+ gtk_label_set_text(w_chipname, _("Unknown"));
+
w_draw = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder,
"sensor_draw"));
gtk_toggle_button_set_active(w_draw, p->enabled);
psensor_type_to_unit_str(s->type,
use_celcius));
+ w_appindicator_enabled = GTK_TOGGLE_BUTTON
+ (gtk_builder_get_object(builder, "indicator_checkbox"));
+
if (is_temp_type(s->type) || is_fan_type(s->type)) {
gtk_toggle_button_set_active(w_alarm, p->alarm_enabled);
gtk_spin_button_set_value(w_high_threshold,
gtk_widget_set_sensitive(GTK_WIDGET(w_high_threshold), FALSE);
gtk_widget_set_sensitive(GTK_WIDGET(w_low_threshold), FALSE);
}
+
+ gtk_toggle_button_set_active(w_appindicator_enabled,
+ p->appindicator_enabled);
+
}
static void on_changed(GtkTreeSelection *selection, gpointer data)
color_set(s->color,
p->color->red, p->color->green, p->color->blue);
config_set_sensor_color(s->id, s->color);
+
+ if (s->appindicator_enabled != p->appindicator_enabled) {
+ s->appindicator_enabled = p->appindicator_enabled;
+ config_set_appindicator_enabled
+ (s->id, s->appindicator_enabled);
+ }
}
}
if (result == GTK_RESPONSE_ACCEPT) {
apply_prefs(cbdata.prefs, ui->sensors, ui->config);
- ui_sensorlist_update_sensors_preferences(ui);
+ ui_sensorlist_update(ui, 1);
+#if defined(HAVE_APPINDICATOR) || defined(HAVE_APPINDICATOR_029)
+ ui_appindicator_update_menu(ui);
+#endif
}
g_object_unref(G_OBJECT(builder));