X-Git-Url: https://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Fui_sensorpref.c;h=9dce476fcaa3818a045b9859f4319207538acd50;hb=138f4d6a450e4ead5da85fdef006e48e906223d8;hp=715eed59a43f85290ad93e04a578330753851bee;hpb=7bb2223ce108e56525eddc6e01627c0fd2ecc3df;p=psensor.git diff --git a/src/ui_sensorpref.c b/src/ui_sensorpref.c index 715eed5..9dce476 100644 --- a/src/ui_sensorpref.c +++ b/src/ui_sensorpref.c @@ -22,16 +22,13 @@ #include #include +#include #include #include #include #include -#if defined(HAVE_APPINDICATOR) || defined(HAVE_APPINDICATOR_029) -#include "ui_appindicator.h" -#endif - enum { COL_NAME = 0, COL_SENSOR_PREF @@ -45,7 +42,7 @@ struct sensor_pref { int alarm_enabled; int alarm_high_threshold; int alarm_low_threshold; - unsigned int appindicator_enabled; + bool appindicator_enabled; unsigned int appindicator_label_enabled; unsigned int display_enabled; }; @@ -79,7 +76,7 @@ sensor_pref_new(struct psensor *s, struct config *cfg) = celsius_to_fahrenheit(s->alarm_low_threshold); } - p->appindicator_enabled = s->appindicator_enabled; + p->appindicator_enabled = config_is_appindicator_enabled(s->id); p->appindicator_label_enabled = config_is_appindicator_label_enabled(s->id); @@ -89,7 +86,7 @@ sensor_pref_new(struct psensor *s, struct config *cfg) static void sensor_pref_free(struct sensor_pref *p) { if (!p) - return ; + return; free(p->name); free(p->color); @@ -190,7 +187,7 @@ void ui_sensorpref_color_set_cb(GtkColorButton *widget, gpointer data) if (p) { gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(widget), &color); - color_set_f(p->color, color.red, color.green, color.blue); + color_set(p->color, color.red, color.green, color.blue); } } @@ -290,24 +287,30 @@ update_pref(struct sensor_pref *p, struct config *cfg, GtkBuilder *builder) w_appindicator_label_enabled = GTK_TOGGLE_BUTTON (gtk_builder_get_object(builder, "indicator_label_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, - p->alarm_high_threshold); - gtk_spin_button_set_value(w_low_threshold, - p->alarm_low_threshold); - gtk_widget_set_sensitive(GTK_WIDGET(w_alarm), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET(w_high_threshold), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET(w_low_threshold), TRUE); + + if (is_appindicator_supported()) { + gtk_widget_set_has_tooltip + (GTK_WIDGET(w_appindicator_label_enabled), FALSE); + gtk_widget_set_has_tooltip + (GTK_WIDGET(w_appindicator_enabled), FALSE); } else { - gtk_toggle_button_set_active(w_alarm, 0); - gtk_spin_button_set_value(w_high_threshold, 0); - gtk_spin_button_set_value(w_low_threshold, 0); - gtk_widget_set_sensitive(GTK_WIDGET(w_alarm), FALSE); - gtk_widget_set_sensitive(GTK_WIDGET(w_high_threshold), FALSE); - gtk_widget_set_sensitive(GTK_WIDGET(w_low_threshold), FALSE); + gtk_widget_set_sensitive + (GTK_WIDGET(w_appindicator_label_enabled), FALSE); + gtk_widget_set_has_tooltip + (GTK_WIDGET(w_appindicator_label_enabled), TRUE); + gtk_widget_set_sensitive + (GTK_WIDGET(w_appindicator_enabled), FALSE); + gtk_widget_set_has_tooltip + (GTK_WIDGET(w_appindicator_enabled), TRUE); } + gtk_toggle_button_set_active(w_alarm, p->alarm_enabled); + gtk_spin_button_set_value(w_high_threshold, p->alarm_high_threshold); + gtk_spin_button_set_value(w_low_threshold, p->alarm_low_threshold); + gtk_widget_set_sensitive(GTK_WIDGET(w_alarm), TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(w_high_threshold), TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(w_low_threshold), TRUE); + gtk_toggle_button_set_active(w_appindicator_enabled, p->appindicator_enabled); @@ -334,6 +337,7 @@ select_sensor(struct psensor *s, struct psensor **sensors, GtkTreeView *tree) struct psensor **s_cur; int i; GtkTreePath *p; + GtkTreeSelection *sel; p = NULL; for (s_cur = sensors, i = 0; *s_cur; s_cur++, i++) @@ -343,9 +347,9 @@ select_sensor(struct psensor *s, struct psensor **sensors, GtkTreeView *tree) } if (p) { - GtkTreeSelection *s = gtk_tree_view_get_selection(tree); + sel = gtk_tree_view_get_selection(tree); - gtk_tree_selection_select_path(s, p); + gtk_tree_selection_select_path(sel, p); gtk_tree_path_free(p); } } @@ -385,13 +389,13 @@ static void apply_pref(struct sensor_pref *p, int pos, struct config *cfg) config_set_sensor_alarm_enabled(s->id, s->alarm_enabled); } - color_set(s->color, p->color->red, p->color->green, p->color->blue); + 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); - } + config_set_appindicator_enabled(s->id, p->appindicator_enabled); config_set_appindicator_label_enabled(s->id, p->appindicator_label_enabled); @@ -450,7 +454,7 @@ void ui_sensorpref_dialog_run(struct psensor *sensor, struct ui_psensor *ui) if (!ok) { log_printf(LOG_ERR, error->message); g_error_free(error); - return ; + return; } w_sensors_list @@ -490,7 +494,7 @@ void ui_sensorpref_dialog_run(struct psensor *sensor, struct ui_psensor *ui) if (result == GTK_RESPONSE_ACCEPT) { apply_prefs(model, ui->config); ui_sensorlist_update(ui, 1); -#if defined(HAVE_APPINDICATOR) || defined(HAVE_APPINDICATOR_029) +#if defined(HAVE_APPINDICATOR) ui_appindicator_update_menu(ui); #endif }