avoid cpp usage
[psensor.git] / src / ui_sensorpref.c
index 76a90ea..ff93a02 100644 (file)
 
 #include <cfg.h>
 #include <temperature.h>
+#include <ui_appindicator.h>
 #include <ui_pref.h>
 #include <ui_sensorlist.h>
 #include <ui_sensorpref.h>
 #include <ui_color.h>
 
 
-#if defined(HAVE_APPINDICATOR) || defined(HAVE_APPINDICATOR_029)
-#include "ui_appindicator.h"
-#endif
-
 enum {
        COL_NAME = 0,
        COL_SENSOR_PREF
@@ -291,18 +288,21 @@ update_pref(struct sensor_pref *p, struct config *cfg, GtkBuilder *builder)
                (gtk_builder_get_object(builder, "indicator_label_checkbox"));
 
 
-#if !HAVE_APPINDICATOR && !HAVE_APPINDICATOR_029
-       gtk_widget_set_sensitive(GTK_WIDGET(w_appindicator_label_enabled),
-                                FALSE);
-       gtk_widget_set_sensitive(GTK_WIDGET(w_appindicator_enabled), FALSE);
-       gtk_widget_set_has_tooltip(GTK_WIDGET(w_appindicator_label_enabled),
-                                  TRUE);
-       gtk_widget_set_has_tooltip(GTK_WIDGET(w_appindicator_enabled), TRUE);
-#else
-       gtk_widget_set_has_tooltip(GTK_WIDGET(w_appindicator_label_enabled),
-                                  FALSE);
-       gtk_widget_set_has_tooltip(GTK_WIDGET(w_appindicator_enabled), FALSE);
-#endif
+       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_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);
@@ -337,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++)
@@ -346,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);
        }
 }
@@ -496,7 +497,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
        }