From 48346c83250bbe986625843ca68b44bf8db3afcc Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Fri, 5 Mar 2010 14:20:04 +0100 Subject: [PATCH] make times_in_seconds a lua setting --- src/common.cc | 4 ++-- src/conky.cc | 5 ----- src/mpd.cc | 2 +- src/timeinfo.cc | 18 ++++++------------ src/timeinfo.h | 6 +++--- 5 files changed, 12 insertions(+), 23 deletions(-) diff --git a/src/common.cc b/src/common.cc index 6528d6a2..b6efb17d 100644 --- a/src/common.cc +++ b/src/common.cc @@ -211,7 +211,7 @@ void format_seconds(char *buf, unsigned int n, long seconds) long days; int hours, minutes; - if (times_in_seconds()) { + if (times_in_seconds.get(*state)) { snprintf(buf, n, "%ld", seconds); return; } @@ -235,7 +235,7 @@ void format_seconds_short(char *buf, unsigned int n, long seconds) long days; int hours, minutes; - if (times_in_seconds()) { + if (times_in_seconds.get(*state)) { snprintf(buf, n, "%ld", seconds); return; } diff --git a/src/conky.cc b/src/conky.cc index 3ca45d5f..3d58dbde 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -2585,8 +2585,6 @@ static void set_default_configurations(void) stuff_in_uppercase = 0; info.users.number = 1; - set_times_in_seconds(0); - #ifdef BUILD_PORT_MONITORS /* set default connection limit */ tcp_portmon_set_max_connections(0); @@ -2981,9 +2979,6 @@ char load_config_file(const char *f) utf8_mode = string_to_bool(value); } #endif /* BUILD_X11 */ - CONF("times_in_seconds") { - set_times_in_seconds(string_to_bool(value)); - } CONF("max_text_width") { max_text_width = atoi(value); } diff --git a/src/mpd.cc b/src/mpd.cc index cddc8911..338b9e41 100644 --- a/src/mpd.cc +++ b/src/mpd.cc @@ -313,7 +313,7 @@ static inline void format_media_player_time(char *buf, const int size, { int days, hours, minutes; - if (times_in_seconds()) { + if (times_in_seconds.get(*state)) { snprintf(buf, size, "%d", seconds); return; } diff --git a/src/timeinfo.cc b/src/timeinfo.cc index 5e463d6f..bd769a36 100644 --- a/src/timeinfo.cc +++ b/src/timeinfo.cc @@ -28,6 +28,10 @@ * */ +#include "config.h" + +#include "timeinfo.h" + #include "conky.h" #include "text_object.h" #include @@ -38,22 +42,12 @@ #include -char print_times_in_seconds = 0; - struct tztime_s { char *tz; /* timezone variable */ char *fmt; /* time display formatting */ }; -void set_times_in_seconds(char val) -{ - print_times_in_seconds = val; -} - -char times_in_seconds(void) -{ - return print_times_in_seconds; -} +conky::simple_config_setting times_in_seconds("times_in_seconds", false, false); void scan_time(struct text_object *obj, const char *arg) { @@ -171,7 +165,7 @@ static void do_format_time(struct text_object *obj, char *p, unsigned int p_max_ int minutes, hours, days, weeks; char show_minutes = 0, show_hours = 0, show_days = 0, show_weeks = 0, hidestring; - if (!times_in_seconds()) { + if (not times_in_seconds.get(*state)) { NORM_ERR("Enable \"times_in_seconds\" to use $format_time"); return; } diff --git a/src/timeinfo.h b/src/timeinfo.h index 281b3c34..ae98bae0 100644 --- a/src/timeinfo.h +++ b/src/timeinfo.h @@ -30,9 +30,9 @@ #ifndef _TIMEINFO_H #define _TIMEINFO_H -/* for the times_in_seconds configuration variable and it's users */ -void set_times_in_seconds(char); -char times_in_seconds(void); +#include "setting.hh" + +extern conky::simple_config_setting times_in_seconds; /* since time and utime are quite equal, certain functions * are shared in between both text object types. */