diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/location-corelocation.m | 8 | ||||
-rw-r--r-- | src/location-geoclue.c | 6 | ||||
-rw-r--r-- | src/location-geoclue2.c | 6 | ||||
-rw-r--r-- | src/redshift.c | 39 | ||||
-rw-r--r-- | src/systemtime.c | 20 | ||||
-rw-r--r-- | src/systemtime.h | 9 |
6 files changed, 56 insertions, 32 deletions
diff --git a/src/location-corelocation.m b/src/location-corelocation.m index 626949c..edf3e45 100644 --- a/src/location-corelocation.m +++ b/src/location-corelocation.m @@ -56,7 +56,7 @@ if (authStatus != kCLAuthorizationStatusNotDetermined && authStatus != kCLAuthorizationStatusAuthorized) { fputs(_("Not authorized to obtain location" - "from CoreLocation.\n"), stderr); + " from CoreLocation.\n"), stderr); CFRunLoopStop(CFRunLoopGetCurrent()); } @@ -127,9 +127,9 @@ location_corelocation_print_help(FILE *f) fputs(_("Use the location as discovered by the Corelocation provider.\n"), f); fputs("\n", f); - fputs(_("NOTE: currently redshift doesn't recheck CoreLocation once started,\n" - "which means it has to be restarted to take notice after travel.\n"), - f); + fprintf(f, _("NOTE: currently Redshift doesn't recheck %s once started,\n" + "which means it has to be restarted to take notice after travel.\n"), + "CoreLocation"); fputs("\n", f); } diff --git a/src/location-geoclue.c b/src/location-geoclue.c index 07865c5..378b933 100644 --- a/src/location-geoclue.c +++ b/src/location-geoclue.c @@ -137,9 +137,9 @@ location_geoclue_print_help(FILE *f) fputs(_(" name=N\tName of Geoclue provider (or `default')\n" " path=N\tPath of Geoclue provider (or `default')\n"), f); fputs("\n", f); - fputs(_("NOTE: currently redshift doesn't recheck geoclue once started,\n" - "which means it has to be restarted to take notice after travel.\n"), - f); + fprintf(f, _("NOTE: currently Redshift doesn't recheck %s once started,\n" + "which means it has to be restarted to take notice after travel.\n"), + "GeoClue"); fputs("\n", f); } diff --git a/src/location-geoclue2.c b/src/location-geoclue2.c index 4c4150e..9b9b725 100644 --- a/src/location-geoclue2.c +++ b/src/location-geoclue2.c @@ -69,9 +69,9 @@ location_geoclue2_print_help(FILE *f) fputs(_("Use the location as discovered by a GeoClue2 provider.\n"), f); fputs("\n", f); - fputs(_("NOTE: currently redshift doesn't recheck GeoClue2 once started,\n" - "which means it has to be restarted to take notice after travel.\n"), - f); + fprintf(f, _("NOTE: currently Redshift doesn't recheck %s once started,\n" + "which means it has to be restarted to take notice after travel.\n"), + "GeoClue2"); fputs("\n", f); } diff --git a/src/redshift.c b/src/redshift.c index c1fc259..429ae38 100644 --- a/src/redshift.c +++ b/src/redshift.c @@ -25,7 +25,6 @@ #include <stdlib.h> #include <unistd.h> #include <string.h> -#include <time.h> #include <math.h> #include <locale.h> #include <errno.h> @@ -300,6 +299,7 @@ typedef enum { /* Names of periods of day */ static const char *period_names[] = { + /* TRANSLATORS: Name printed when period of day is unknown */ N_("None"), N_("Daytime"), N_("Night"), @@ -1172,12 +1172,25 @@ main(int argc, char *argv[]) provider->free(&location_state); if (verbose) { - /* TRANSLATORS: Append degree symbols after %f if possible. */ + /* TRANSLATORS: Abbreviation for `north' */ + const char *north = _("N"); + /* TRANSLATORS: Abbreviation for `south' */ + const char *south = _("S"); + /* TRANSLATORS: Abbreviation for `east' */ + const char *east = _("E"); + /* TRANSLATORS: Abbreviation for `west' */ + const char *west = _("W"); + + /* TRANSLATORS: Append degree symbols after %f if possible. + The string following each number is an abreviation for + north, source, east or west (N, S, E, W). */ printf(_("Location: %.2f %s, %.2f %s\n"), - fabs(lat), lat >= 0.f ? _("N") : _("S"), - fabs(lon), lon >= 0.f ? _("E") : _("W")); + fabs(lat), lat >= 0.f ? north : south, + fabs(lon), lon >= 0.f ? east : west); + printf(_("Temperatures: %dK at day, %dK at night\n"), day.temperature, night.temperature); + /* TRANSLATORS: Append degree symbols if possible. */ printf(_("Solar elevations: day above %.1f, night below %.1f\n"), transition_high, transition_low); @@ -1261,10 +1274,12 @@ main(int argc, char *argv[]) } if (verbose) { + /* TRANSLATORS: The string in parenthesis is either + Daytime or Night (translated). */ printf(_("Gamma (%s): %.3f, %.3f, %.3f\n"), - "Day", day.gamma[0], day.gamma[1], day.gamma[2]); + _("Daytime"), day.gamma[0], day.gamma[1], day.gamma[2]); printf(_("Gamma (%s): %.3f, %.3f, %.3f\n"), - "Night", night.gamma[0], night.gamma[1], night.gamma[2]); + _("Night"), night.gamma[0], night.gamma[1], night.gamma[2]); } /* Initialize gamma adjustment method. If method is NULL @@ -1594,13 +1609,11 @@ main(int argc, char *argv[]) sizeof(color_setting_t)); /* Sleep for 5 seconds or 0.1 second. */ -#ifndef _WIN32 - if (short_trans_delta) usleep(SLEEP_DURATION_SHORT*1000); - else usleep(SLEEP_DURATION*1000); -#else /* ! _WIN32 */ - if (short_trans_delta) Sleep(SLEEP_DURATION_SHORT); - else Sleep(SLEEP_DURATION); -#endif /* ! _WIN32 */ + if (short_trans_delta) { + systemtime_msleep(SLEEP_DURATION_SHORT); + } else { + systemtime_msleep(SLEEP_DURATION); + } } /* Restore saved gamma ramps */ diff --git a/src/systemtime.c b/src/systemtime.c index 12b74cc..0d0cb85 100644 --- a/src/systemtime.c +++ b/src/systemtime.c @@ -18,17 +18,22 @@ */ #include <stdio.h> +#include <unistd.h> #ifndef _WIN32 -# ifdef _POSIX_TIMERS +# if _POSIX_TIMERS > 0 # include <time.h> # else # include <sys/time.h> # endif +#else +# include <windows.h> #endif #include "systemtime.h" + +/* Return current time in T as the number of seconds since the epoch. */ int systemtime_get_time(double *t) { @@ -41,7 +46,7 @@ systemtime_get_time(double *t) /* FILETIME is tenths of microseconds since 1601-01-01 UTC */ *t = (i.QuadPart / 10000000.0) - 11644473600.0; -#elif defined(_POSIX_TIMERS) /* POSIX timers */ +#elif _POSIX_TIMERS > 0 /* POSIX timers */ struct timespec now; int r = clock_gettime(CLOCK_REALTIME, &now); if (r < 0) { @@ -63,3 +68,14 @@ systemtime_get_time(double *t) return 0; } + +/* Sleep for a number of milliseconds. */ +void +systemtime_msleep(unsigned int msecs) +{ +#ifndef _WIN32 + usleep(msecs*1000); +#else + Sleep(msecs); +#endif +} diff --git a/src/systemtime.h b/src/systemtime.h index 90da169..184e41d 100644 --- a/src/systemtime.h +++ b/src/systemtime.h @@ -14,19 +14,14 @@ You should have received a copy of the GNU General Public License along with Redshift. If not, see <http://www.gnu.org/licenses/>. - Copyright (c) 2010 Jon Lund Steffensen <jonlst@gmail.com> + Copyright (c) 2010-2014 Jon Lund Steffensen <jonlst@gmail.com> */ #ifndef REDSHIFT_SYSTEMTIME_H #define REDSHIFT_SYSTEMTIME_H -#ifndef _WIN32 -# include <time.h> -#else -# include <windows.h> -#endif - int systemtime_get_time(double *now); +void systemtime_msleep(unsigned int msecs); #endif /* ! REDSHIFT_SYSTEMTIME_H */ |