From: Jean-Philippe Orsini Date: Thu, 25 Sep 2014 07:31:55 +0000 (+0200) Subject: disable atasmart setting if not supported X-Git-Tag: v1.2.0~117 X-Git-Url: http://git.wpitchoune.net/gitweb/?p=psensor.git;a=commitdiff_plain;h=ab393ba7bba2961e61856f42778bd05e563d78b1 disable atasmart setting if not supported --- diff --git a/src/lib/hdd.h b/src/lib/hdd.h index 08aa851..b4e2a0d 100644 --- a/src/lib/hdd.h +++ b/src/lib/hdd.h @@ -19,12 +19,24 @@ #ifndef _PSENSOR_HDD_H_ #define _PSENSOR_HDD_H_ +#include #include #include -#ifdef HAVE_ATASMART -void atasmart_psensor_list_append(struct psensor ***sensors, int values_length); -void atasmart_psensor_list_update(struct psensor **sensors); +#if defined(HAVE_ATASMART) && HAVE_ATASMART + +static inline bool atasmart_is_supported(void) { return true; } + +void atasmart_psensor_list_append(struct psensor ***, int); +void atasmart_psensor_list_update(struct psensor **); + +#else + +static inline bool atasmart_is_supported(void) { return false; } + +static inline void atasmart_psensor_list_append(struct psensor ***s, int n) {} +static inline void atasmart_psensor_list_update(struct psensor **s) {} + #endif void hddtemp_psensor_list_append(struct psensor ***sensors, int values_length); diff --git a/src/ui_pref.c b/src/ui_pref.c index f6cb5a5..c4e8575 100644 --- a/src/ui_pref.c +++ b/src/ui_pref.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -248,12 +249,14 @@ void ui_pref_dialog_run(struct ui_psensor *ui) w_libatasmart = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "libatasmart")); -#if !HAVE_ATASMART - gtk_widget_set_sensitive(GTK_WIDGET(w_libatasmart), 0); - gtk_widget_set_has_tooltip(GTK_WIDGET(w_libatasmart), TRUE); -#else - gtk_widget_set_has_tooltip(GTK_WIDGET(w_libatasmart), FALSE); -#endif + + if (atasmart_is_supported()) { + gtk_widget_set_has_tooltip(GTK_WIDGET(w_libatasmart), FALSE); + } else { + gtk_widget_set_sensitive(GTK_WIDGET(w_libatasmart), 0); + gtk_widget_set_has_tooltip(GTK_WIDGET(w_libatasmart), TRUE); + } + gtk_toggle_button_set_active(w_libatasmart, config_is_libatasmart_enabled());