X-Git-Url: http://git.wpitchoune.net/gitweb/?p=psensor-pkg-ubuntu.git;a=blobdiff_plain;f=src%2Fcfg.c;fp=src%2Fcfg.c;h=0f22ccb6ed254b8d8d9cbb8c38ca7af87ec46c7b;hp=8f229754048e931a92d1d7e4251181f2980aeda5;hb=5c1e07fec97e34a94331b6b47e25c98f2b2e4cce;hpb=4c50d430bea4b8462b0ae7ab70baf3f538f87718 diff --git a/src/cfg.c b/src/cfg.c index 8f22975..0f22ccb 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -29,9 +29,8 @@ #include #define _(str) gettext(str) -#include - #include +#include #include #include @@ -55,17 +54,14 @@ static const char *KEY_SENSOR_UPDATE_INTERVAL /* Graph settings */ static const char *KEY_GRAPH_UPDATE_INTERVAL = "graph-update-interval"; - static const char *KEY_GRAPH_MONITORING_DURATION = "graph-monitoring-duration"; - static const char *KEY_GRAPH_BACKGROUND_COLOR = "graph-background-color"; - static const char *DEFAULT_GRAPH_BACKGROUND_COLOR = "#e8f4e8f4a8f5"; - static const char *KEY_GRAPH_BACKGROUND_ALPHA = "graph-background-alpha"; - static const char *KEY_GRAPH_FOREGROUND_COLOR = "graph-foreground-color"; +static const char *KEY_GRAPH_SMOOTH_CURVES_ENABLED += "graph-smooth-curves-enabled"; static const char *DEFAULT_GRAPH_FOREGROUND_COLOR = "#000000000000"; @@ -111,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; @@ -335,6 +344,17 @@ static void set_window_keep_below_enabled(bool enabled) set_bool(KEY_INTERFACE_WINDOW_KEEP_BELOW_ENABLED, enabled); } +bool config_is_smooth_curves_enabled() +{ + return get_bool(KEY_GRAPH_SMOOTH_CURVES_ENABLED); +} + +void config_set_smooth_curves_enabled(bool b) +{ + set_bool(KEY_GRAPH_SMOOTH_CURVES_ENABLED, b); +} + + static void init() { log_fct_enter(); @@ -405,12 +425,6 @@ struct config *config_load() if (c->graph_monitoring_duration < 1) c->graph_monitoring_duration = 10; - c->sensor_values_max_length - = (c->graph_monitoring_duration * 60) / c->sensor_update_interval; - - if (c->sensor_values_max_length < 3) - c->sensor_values_max_length = 3; - c->menu_bar_disabled = get_bool(KEY_INTERFACE_MENU_BAR_DISABLED); c->unity_launcher_count_disabled @@ -435,6 +449,8 @@ struct config *config_load() c->temperature_unit = get_int(KEY_INTERFACE_TEMPERATURE_UNIT); + c->sensor_values_max_length = compute_values_max_length(c); + return c; } @@ -537,15 +553,10 @@ static GKeyFile *get_sensor_key_file() | G_KEY_FILE_KEEP_TRANSLATIONS, &err); - if (!ret) { - if (err->code == G_KEY_FILE_ERROR_NOT_FOUND) - log_fct(_("The configuration file " - "does not exist.")); - else - log_err(_("Failed to parse configuration " - "file: %s"), - path); - } + if (!ret) + log_warn(_("Failed to load configuration file %s: %s"), + path, + err->message); } return key_file; @@ -757,3 +768,78 @@ void config_set_appindicator_label_enabled(const char *sid, bool enabled) { sensor_set_bool(sid, ATT_SENSOR_APPINDICATOR_LABEL_ENABLED, enabled); } + +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); +}