added enable/disable provider preferences
authorJean-Philippe Orsini <jeanfi@gmail.com>
Wed, 17 Sep 2014 17:44:18 +0000 (19:44 +0200)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Wed, 17 Sep 2014 17:44:18 +0000 (19:44 +0200)
src/cfg.c
src/cfg.h
src/glade/psensor-pref.glade
src/ui_pref.c

index ce82834..0f22ccb 100644 (file)
--- a/src/cfg.c
+++ b/src/cfg.c
@@ -107,6 +107,19 @@ static const char *KEY_SLOG_INTERVAL = "slog-interval";
 /* Path to the script called when a notification is raised */
 static const char *KEY_NOTIFICATION_SCRIPT = "notif-script";
 
+/* Provider settings */
+static const char *KEY_PROVIDER_LMSENSORS_ENABLED
+= "provider-lmsensors-enabled";
+static const char *KEY_PROVIDER_ATIADLSDK_ENABLED
+= "provider-atiadlsdk-enabled";
+static const char *KEY_PROVIDER_GTOP2_ENABLED = "provider-gtop2-enabled";
+static const char *KEY_PROVIDER_HDDTEMP_ENABLED = "provider-hddtemp-enabled";
+static const char *KEY_PROVIDER_LIBATASMART_ENABLED
+= "provider-libatasmart-enabled";
+static const char *KEY_PROVIDER_NVCTRL_ENABLED = "provider-nvctrl-enabled";
+static const char *KEY_PROVIDER_UDISKS2_ENABLED = "provider-udisks2-enabled";
+
+
 static GSettings *settings;
 
 static char *user_dir;
@@ -760,3 +773,73 @@ GSettings *config_get_GSettings()
 {
        return settings;
 }
+
+bool config_is_lmsensor_enabled()
+{
+       return get_bool(KEY_PROVIDER_LMSENSORS_ENABLED);
+}
+
+bool config_is_gtop2_enabled()
+{
+       return get_bool(KEY_PROVIDER_GTOP2_ENABLED);
+}
+
+bool config_is_udisks2_enabled()
+{
+       return get_bool(KEY_PROVIDER_UDISKS2_ENABLED);
+}
+
+bool config_is_hddtemp_enabled()
+{
+       return get_bool(KEY_PROVIDER_HDDTEMP_ENABLED);
+}
+
+bool config_is_libatasmart_enabled()
+{
+       return get_bool(KEY_PROVIDER_LIBATASMART_ENABLED);
+}
+
+bool config_is_nvctrl_enabled()
+{
+       return get_bool(KEY_PROVIDER_NVCTRL_ENABLED);
+}
+
+bool config_is_atiadlsdk_enabled()
+{
+       return get_bool(KEY_PROVIDER_ATIADLSDK_ENABLED);
+}
+
+void config_set_lmsensor_enable(bool b)
+{
+       set_bool(KEY_PROVIDER_LMSENSORS_ENABLED, b);
+}
+
+void config_set_nvctrl_enable(bool b)
+{
+       set_bool(KEY_PROVIDER_NVCTRL_ENABLED, b);
+}
+
+void config_set_atiadlsdk_enable(bool b)
+{
+       set_bool(KEY_PROVIDER_ATIADLSDK_ENABLED, b);
+}
+
+void config_set_gtop2_enable(bool b)
+{
+       set_bool(KEY_PROVIDER_GTOP2_ENABLED, b);
+}
+
+void config_set_hddtemp_enable(bool b)
+{
+       set_bool(KEY_PROVIDER_HDDTEMP_ENABLED, b);
+}
+
+void config_set_libatasmart_enable(bool b)
+{
+       set_bool(KEY_PROVIDER_LIBATASMART_ENABLED, b);
+}
+
+void config_set_udisks2_enable(bool b)
+{
+       set_bool(KEY_PROVIDER_UDISKS2_ENABLED, b);
+}
index 9f84e06..ed2e20e 100644 (file)
--- a/src/cfg.h
+++ b/src/cfg.h
@@ -125,6 +125,27 @@ void config_set_notif_script(const char *);
 bool config_is_sensor_enabled(const char *sid);
 void config_set_sensor_enabled(const char *sid, bool enabled);
 
+bool config_is_lmsensor_enabled();
+void config_set_lmsensor_enable(bool);
+
+bool config_is_gtop2_enabled();
+void config_set_gtop2_enable(bool);
+
+bool config_is_udisks2_enabled();
+void config_set_udisks2_enable(bool);
+
+bool config_is_hddtemp_enabled();
+void config_set_hddtemp_enable(bool);
+
+bool config_is_libatasmart_enabled();
+void config_set_libatasmart_enable(bool);
+
+bool config_is_nvctrl_enabled();
+void config_set_nvctrl_enable(bool);
+
+bool config_is_atiadlsdk_enabled();
+void config_set_atiadlsdk_enable(bool);
+
 /*
  * Returns the user directory containing psensor data (configuration
  * and log).
index 9647ab7..54b1ee1 100644 (file)
               </packing>
             </child>
             <child>
+              <object class="GtkGrid" id="grid3">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="valign">start</property>
+                <property name="margin_left">4</property>
+                <property name="margin_right">4</property>
+                <property name="margin_top">4</property>
+                <property name="margin_bottom">4</property>
+                <child>
+                  <object class="GtkCheckButton" id="lmsensors">
+                    <property name="label" translatable="yes">Enable support of lm-sensors</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="margin_left">14</property>
+                    <property name="margin_right">4</property>
+                    <property name="margin_top">4</property>
+                    <property name="margin_bottom">4</property>
+                    <property name="xalign">0</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">1</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkCheckButton" id="nvctrl">
+                    <property name="label" translatable="yes">Enable support of NVCtrl (NVidia)</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="margin_left">14</property>
+                    <property name="margin_right">4</property>
+                    <property name="margin_top">4</property>
+                    <property name="margin_bottom">4</property>
+                    <property name="xalign">0</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">3</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkCheckButton" id="atiadlsdk">
+                    <property name="label" translatable="yes">Enable support of ATI ADL</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="margin_left">14</property>
+                    <property name="margin_right">4</property>
+                    <property name="margin_top">4</property>
+                    <property name="margin_bottom">4</property>
+                    <property name="xalign">0</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">4</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkCheckButton" id="gtop2">
+                    <property name="label" translatable="yes">Enable support of gtop2</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="margin_left">14</property>
+                    <property name="margin_right">4</property>
+                    <property name="margin_top">4</property>
+                    <property name="margin_bottom">4</property>
+                    <property name="xalign">0</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">6</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkCheckButton" id="hddtemp">
+                    <property name="label" translatable="yes">Enable support of hddtemp daemon</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="margin_left">14</property>
+                    <property name="margin_right">4</property>
+                    <property name="margin_top">4</property>
+                    <property name="margin_bottom">4</property>
+                    <property name="xalign">0</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">8</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkCheckButton" id="libatasmart">
+                    <property name="label" translatable="yes">Enable support of libatasmart</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="margin_left">14</property>
+                    <property name="margin_right">4</property>
+                    <property name="margin_top">4</property>
+                    <property name="margin_bottom">4</property>
+                    <property name="xalign">0</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">9</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkCheckButton" id="udisks2">
+                    <property name="label" translatable="yes">Enable support of udisks2</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="margin_left">14</property>
+                    <property name="margin_right">4</property>
+                    <property name="margin_top">4</property>
+                    <property name="margin_bottom">4</property>
+                    <property name="xalign">0</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">10</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label17">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="halign">center</property>
+                    <property name="margin_left">4</property>
+                    <property name="margin_right">4</property>
+                    <property name="margin_top">4</property>
+                    <property name="margin_bottom">4</property>
+                    <property name="label" translatable="yes">The changes are applied after the restart of psensor.</property>
+                    <attributes>
+                      <attribute name="style" value="italic"/>
+                    </attributes>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">11</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label22">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="margin_left">4</property>
+                    <property name="margin_right">4</property>
+                    <property name="margin_top">8</property>
+                    <property name="margin_bottom">4</property>
+                    <property name="xalign">0</property>
+                    <property name="xpad">4</property>
+                    <property name="label" translatable="yes">Hard disk drive</property>
+                    <property name="angle">0.01</property>
+                    <attributes>
+                      <attribute name="weight" value="bold"/>
+                    </attributes>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">7</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label18">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="margin_left">4</property>
+                    <property name="margin_right">4</property>
+                    <property name="margin_top">8</property>
+                    <property name="margin_bottom">4</property>
+                    <property name="xalign">0</property>
+                    <property name="xpad">4</property>
+                    <property name="label" translatable="yes">CPU and memory usage</property>
+                    <property name="angle">0.01</property>
+                    <attributes>
+                      <attribute name="weight" value="bold"/>
+                    </attributes>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">5</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label19">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="margin_left">4</property>
+                    <property name="margin_right">4</property>
+                    <property name="margin_top">8</property>
+                    <property name="margin_bottom">4</property>
+                    <property name="xalign">0</property>
+                    <property name="xpad">4</property>
+                    <property name="label" translatable="yes">GPU with proprietary driver</property>
+                    <property name="angle">0.01</property>
+                    <attributes>
+                      <attribute name="weight" value="bold"/>
+                    </attributes>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">2</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label20">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="margin_left">4</property>
+                    <property name="margin_right">4</property>
+                    <property name="margin_top">8</property>
+                    <property name="margin_bottom">4</property>
+                    <property name="xalign">0</property>
+                    <property name="xpad">4</property>
+                    <property name="label" translatable="yes">Motherboard, CPU and GPU</property>
+                    <property name="angle">0.01</property>
+                    <attributes>
+                      <attribute name="weight" value="bold"/>
+                    </attributes>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="position">4</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+            <child type="tab">
+              <object class="GtkLabel" id="label13">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Providers</property>
+              </object>
+              <packing>
+                <property name="position">4</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+            <child>
               <placeholder/>
             </child>
             <child type="tab">
index 72322f4..5494777 100644 (file)
@@ -54,7 +54,9 @@ void ui_pref_dialog_run(struct ui_psensor *ui)
        GtkComboBox *w_sensorlist_pos;
        GtkToggleButton *w_hide_window_decoration, *w_keep_window_below,
                *w_enable_menu, *w_enable_launcher_counter, *w_hide_on_startup,
-               *w_win_restore, *w_slog_enabled, *w_autostart, *w_smooth_curves;
+               *w_win_restore, *w_slog_enabled, *w_autostart, *w_smooth_curves,
+               *w_atiadlsdk, *w_lmsensors, *w_nvctrl, *w_gtop2, *w_hddtemp,
+               *w_libatasmart, *w_udisks2;
        GtkComboBoxText *w_temp_unit;
        GtkEntry *w_notif_script;
        char *notif_script;
@@ -172,6 +174,60 @@ void ui_pref_dialog_run(struct ui_psensor *ui)
        gtk_combo_box_set_active(GTK_COMBO_BOX(w_temp_unit),
                                 cfg->temperature_unit);
 
+       /* providers */
+       w_lmsensors
+               = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder,
+                                                          "lmsensors"));
+       gtk_toggle_button_set_active(w_lmsensors, config_is_lmsensor_enabled());
+
+       w_nvctrl
+               = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder,
+                                                          "nvctrl"));
+#if !HAVE_NVIDIA
+       gtk_widget_set_sensitive(GTK_WIDGET(w_nvctrl), 0);
+#endif
+       gtk_toggle_button_set_active(w_nvctrl, config_is_nvctrl_enabled());
+
+       w_atiadlsdk
+               = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder,
+                                                          "atiadlsdk"));
+#if !HAVE_LIBATIADL
+       gtk_widget_set_sensitive(GTK_WIDGET(w_atiadlsdk), 0);
+#endif
+       gtk_toggle_button_set_active(w_atiadlsdk,
+                                    config_is_atiadlsdk_enabled());
+
+       w_gtop2
+               = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder,
+                                                          "gtop2"));
+#if !HAVE_GTOP
+       gtk_widget_set_sensitive(GTK_WIDGET(w_gtop2), 0);
+#endif
+       gtk_toggle_button_set_active(w_gtop2, config_is_gtop2_enabled());
+
+       w_hddtemp
+               = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder,
+                                                          "hddtemp"));
+       gtk_toggle_button_set_active(w_hddtemp, config_is_hddtemp_enabled());
+
+
+       w_libatasmart
+               = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder,
+                                                          "libatasmart"));
+#if !HAVE_ATASMART
+       gtk_widget_set_sensitive(GTK_WIDGET(w_libatasmart), 0);
+#endif
+       gtk_toggle_button_set_active(w_libatasmart,
+                                    config_is_libatasmart_enabled());
+
+       w_udisks2
+               = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder,
+                                                          "udisks2"));
+#if !HAVE_LIBUDISKS2
+       gtk_widget_set_sensitive(GTK_WIDGET(w_udisks2), 0);
+#endif
+       gtk_toggle_button_set_active(w_udisks2, config_is_udisks2_enabled());
+
        result = gtk_dialog_run(diag);
 
        if (result == GTK_RESPONSE_ACCEPT) {
@@ -257,6 +313,27 @@ void ui_pref_dialog_run(struct ui_psensor *ui)
                config_set_smooth_curves_enabled
                        (gtk_toggle_button_get_active(w_smooth_curves));
 
+               config_set_lmsensor_enable
+                       (gtk_toggle_button_get_active(w_lmsensors));
+
+               config_set_nvctrl_enable
+                       (gtk_toggle_button_get_active(w_nvctrl));
+
+               config_set_atiadlsdk_enable
+                       (gtk_toggle_button_get_active(w_atiadlsdk));
+
+               config_set_gtop2_enable
+                       (gtk_toggle_button_get_active(w_gtop2));
+
+               config_set_hddtemp_enable
+                       (gtk_toggle_button_get_active(w_hddtemp));
+
+               config_set_libatasmart_enable
+                       (gtk_toggle_button_get_active(w_libatasmart));
+
+               config_set_udisks2_enable
+                       (gtk_toggle_button_get_active(w_udisks2));
+
                pxdg_set_autostart(gtk_toggle_button_get_active(w_autostart));
 
                pthread_mutex_unlock(&ui->sensors_mutex);