disable atasmart setting if not supported
authorJean-Philippe Orsini <jeanfi@gmail.com>
Thu, 25 Sep 2014 07:31:55 +0000 (09:31 +0200)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Thu, 25 Sep 2014 07:31:55 +0000 (09:31 +0200)
src/lib/hdd.h
src/ui_pref.c

index 08aa851..b4e2a0d 100644 (file)
 #ifndef _PSENSOR_HDD_H_
 #define _PSENSOR_HDD_H_
 
+#include <bool.h>
 #include <config.h>
 #include <psensor.h>
 
-#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);
index f6cb5a5..c4e8575 100644 (file)
@@ -20,6 +20,7 @@
 #include <string.h>
 
 #include <amd.h>
+#include <hdd.h>
 #include <ui.h>
 #include <cfg.h>
 #include <graph.h>
@@ -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());