avoid cpp in code
authorJean-Philippe Orsini <jeanfi@gmail.com>
Wed, 24 Sep 2014 22:06:56 +0000 (00:06 +0200)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Wed, 24 Sep 2014 22:06:56 +0000 (00:06 +0200)
src/lib/pgtop2.h
src/ui_pref.c

index c7c3968..ddf19fc 100644 (file)
 #ifndef _PSENSOR_PGTOP2_H_
 #define _PSENSOR_PGTOP2_H_
 
+#include <bool.h>
 #include <psensor.h>
 
-struct psensor *create_cpu_usage_sensor(int measures_len);
+#if defined(HAVE_GTOP) && HAVE_GTOP
+
+static inline bool gtop2_is_supported(void) { return true; }
+
+struct psensor *create_cpu_usage_sensor(int);
 void cpu_usage_sensor_update(struct psensor *);
 
 void gtop2_psensor_list_update(struct psensor **);
+void gtop2_psensor_list_append(struct psensor ***, int);
+
+#else
+
+static inline bool gtop2_is_supported(void) { return false; }
 
-void gtop2_psensor_list_append(struct psensor ***sensors, int values_max_len);
+static inline struct psensor *create_cpu_usage_sensor(int n) { return NULL; }
+static inline void cpu_usage_sensor_update(struct psensor *s) {}
+
+static inline void gtop2_psensor_list_update(struct psensor **s) {}
+static inline void gtop2_psensor_list_append(struct psensor ***s, int n) {}
+
+#endif
 
 #endif
index 5ac12fb..6f7f3b6 100644 (file)
@@ -24,6 +24,7 @@
 #include <cfg.h>
 #include <graph.h>
 #include <nvidia.h>
+#include <pgtop2.h>
 #include <pxdg.h>
 #include <ui_pref.h>
 #include <ui_color.h>
@@ -219,12 +220,14 @@ void ui_pref_dialog_run(struct ui_psensor *ui)
        w_gtop2
                = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder,
                                                           "gtop2"));
-#if !HAVE_GTOP
-       gtk_widget_set_sensitive(GTK_WIDGET(w_gtop2), 0);
-       gtk_widget_set_has_tooltip(GTK_WIDGET(w_gtop2), TRUE);
-#else
-       gtk_widget_set_has_tooltip(GTK_WIDGET(w_gtop2), FALSE);
-#endif
+
+       if (gtop2_is_supported()) {
+               gtk_widget_set_has_tooltip(GTK_WIDGET(w_gtop2), FALSE);
+       } else {
+               gtk_widget_set_sensitive(GTK_WIDGET(w_gtop2), 0);
+               gtk_widget_set_has_tooltip(GTK_WIDGET(w_gtop2), TRUE);
+       }
+
        gtk_toggle_button_set_active(w_gtop2, config_is_gtop2_enabled());
 
        w_hddtemp