Use gamma_method_spec_t struct to control and iterate through different

gamma adjustment methods.
This commit is contained in:
Jon Lund Steffensen
2010-05-24 18:12:36 +02:00
parent 0eac0fa022
commit 6f044ccad3
8 changed files with 277 additions and 297 deletions
+61 -41
View File
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: redshift\n"
"Report-Msgid-Bugs-To: https://bugs.launchpad.net/redshift\n"
"POT-Creation-Date: 2010-05-05 23:28+0200\n"
"POT-Creation-Date: 2010-05-24 18:10+0200\n"
"PO-Revision-Date: 2010-05-05 22:20+0000\n"
"Last-Translator: Jon Lund Steffensen <Unknown>\n"
"Language-Team: Danish <da@li.org>\n"
@@ -17,17 +17,17 @@ msgstr ""
"X-Launchpad-Export-Date: 2010-05-06 04:09+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#: src/redshift.c:172
#: src/redshift.c:197
#, c-format
msgid "Period: Night\n"
msgstr "Periode: Nat\n"
#: src/redshift.c:179
#: src/redshift.c:204
#, c-format
msgid "Period: Transition (%.2f%% day)\n"
msgstr "Periode: Overgang (%.2f%% dag)\n"
#: src/redshift.c:183
#: src/redshift.c:208
#, c-format
msgid "Period: Daytime\n"
msgstr "Periode: Dag\n"
@@ -37,20 +37,20 @@ msgstr "Periode: Dag\n"
#. DAY is temperature at daytime,
#. NIGHT is temperature at night
#. no-wrap
#: src/redshift.c:198
#: src/redshift.c:223
#, c-format
msgid "Usage: %s -l LAT:LON -t DAY:NIGHT [OPTIONS...]\n"
msgstr "Brug: %s -l BRED:LÆNG -t DAG:NAT [TILVALG...]\n"
#. TRANSLATORS: help output 2
#. no-wrap
#: src/redshift.c:204
#: src/redshift.c:229
msgid "Set color temperature of display according to time of day.\n"
msgstr "Indstil skærmens farvetemperatur ud fra klokkeslæt.\n"
#. TRANSLATORS: help output 3
#. no-wrap
#: src/redshift.c:210
#: src/redshift.c:235
msgid ""
" -h\t\tDisplay this help message\n"
" -v\t\tVerbose output\n"
@@ -60,12 +60,13 @@ msgstr ""
#. TRANSLATORS: help output 4
#. no-wrap
#: src/redshift.c:216
#: src/redshift.c:241
#, fuzzy
msgid ""
" -g R:G:B\tAdditional gamma correction to apply\n"
" -l LAT:LON\tYour current location\n"
" -m METHOD\tMethod to use to set color temperature (RANDR or VidMode)\n"
" -m METHOD\tMethod to use to set color temperature\n"
" \t\t(Type `list' to see available methods)\n"
" -o\t\tOne shot mode (do not continously adjust color temperature)\n"
" -r\t\tDisable temperature transitions\n"
" -s SCREEN\tX screen to apply adjustments to\n"
@@ -83,7 +84,7 @@ msgstr ""
" -t DAG:NAT\tFarvetemperatur som sættes hhv. dag og nat\n"
#. TRANSLATORS: help output 5
#: src/redshift.c:230
#: src/redshift.c:255
#, c-format
msgid ""
"Default values:\n"
@@ -96,102 +97,104 @@ msgstr ""
" Dagtemperatur: %uK\n"
" Nattemperatur: %uK\n"
#: src/redshift.c:291
#: src/redshift.c:269
msgid "Available adjustment methods:\n"
msgstr ""
#: src/redshift.c:327
msgid "Malformed gamma argument.\n"
msgstr "Fejl i gamma-argument.\n"
#: src/redshift.c:293 src/redshift.c:312 src/redshift.c:363 src/redshift.c:375
#: src/redshift.c:384
#: src/redshift.c:329 src/redshift.c:348 src/redshift.c:394 src/redshift.c:406
#: src/redshift.c:415
msgid "Try `-h' for more information.\n"
msgstr "Prøv `-h' for mere information.\n"
#: src/redshift.c:310
#: src/redshift.c:346
msgid "Malformed location argument.\n"
msgstr "Fejl i placeringsargument.\n"
#: src/redshift.c:326
msgid "RANDR method was not enabled at compile time.\n"
msgstr "RANDR metode blev ikke slået til under kompilering.\n"
#: src/redshift.c:336
msgid "VidMode method was not enabled at compile time.\n"
msgstr "VidMode metode blev ikke slået til under kompilering.\n"
#. TRANSLATORS: This refers to the method
#. used to adjust colors e.g VidMode
#: src/redshift.c:344
#: src/redshift.c:375
#, c-format
msgid "Unknown method `%s'.\n"
msgstr "Ukendt metode `%s'.\n"
#: src/redshift.c:361
#: src/redshift.c:392
msgid "Malformed temperature argument.\n"
msgstr "Fejl i temperaturargument.\n"
#: src/redshift.c:383
#: src/redshift.c:414
msgid "Latitude and longitude must be set.\n"
msgstr "Breddegrad og længdegrad skal angives.\n"
#. TRANSLATORS: Append degree symbols if possible.
#: src/redshift.c:390
#: src/redshift.c:421
#, c-format
msgid "Location: %f, %f\n"
msgstr "Placering: %f°, %f°\n"
#: src/redshift.c:397
#: src/redshift.c:428
#, c-format
msgid "Latitude must be between %.1f and %.1f.\n"
msgstr "Breddegrad skal være mellem %.1f° og %.1f°.\n"
#: src/redshift.c:406
#: src/redshift.c:437
#, c-format
msgid "Longitude must be between %.1f and %.1f.\n"
msgstr "Længdegrad skal være mellem %.1f° og %.1f°.\n"
#: src/redshift.c:414 src/redshift.c:422
#: src/redshift.c:445 src/redshift.c:453
#, c-format
msgid "Temperature must be between %uK and %uK.\n"
msgstr "Temperatur skal være mellem %uK og %uK.\n"
#: src/redshift.c:432
#: src/redshift.c:463
#, c-format
msgid "Gamma value must be between %.1f and %.1f.\n"
msgstr "Gamma-værdi skal være mellem %.1f og %.1f.\n"
#: src/redshift.c:438
#: src/redshift.c:469
#, c-format
msgid "Gamma: %.3f, %.3f, %.3f\n"
msgstr "Gamma: %.3f, %.3f, %.3f\n"
#: src/redshift.c:444
#: src/redshift.c:475
#, c-format
msgid "CRTC can only be selected with the RANDR method.\n"
msgstr "CRTC kan kun vælges med RANDR metoden.\n"
#: src/redshift.c:457
msgid "Initialization of RANDR failed.\n"
#: src/redshift.c:488 src/redshift.c:498
#, fuzzy, c-format
msgid "Initialization of %s failed.\n"
msgstr "Fejl under klargøring af RANDR.\n"
#: src/redshift.c:459
#: src/redshift.c:500
msgid "Trying other method...\n"
msgstr "Prøver anden metode...\n"
#: src/redshift.c:474
msgid "Initialization of VidMode failed.\n"
msgstr "Fejl under klargøring af VidMode.\n"
#: src/redshift.c:509
msgid "No more methods to try.\n"
msgstr ""
#: src/redshift.c:519 src/redshift.c:626
#, fuzzy
msgid "Unable to read system time.\n"
msgstr "Kan ikke genskabe CRTC %i\n"
#. TRANSLATORS: Append degree symbol if possible.
#: src/redshift.c:497
#: src/redshift.c:528
#, c-format
msgid "Solar elevation: %f\n"
msgstr "Solhøjde: %f°\n"
#: src/redshift.c:504 src/redshift.c:666
#: src/redshift.c:535 src/redshift.c:693
#, c-format
msgid "Color temperature: %uK\n"
msgstr "Farvetemperatur: %uK\n"
#: src/redshift.c:510 src/redshift.c:675
#: src/redshift.c:540 src/redshift.c:701
msgid "Temperature adjustment failed.\n"
msgstr "Fejl ved justering af temperatur.\n"
@@ -245,3 +248,20 @@ msgstr "Fejl ved X forespørgsel: %s\n"
#: src/gtk-redshift/statusicon.py:61
msgid "Toggle"
msgstr "Slå til/fra"
#~ msgid "RANDR method was not enabled at compile time.\n"
#~ msgstr "RANDR metode blev ikke slået til under kompilering.\n"
#~ msgid "VidMode method was not enabled at compile time.\n"
#~ msgstr "VidMode metode blev ikke slået til under kompilering.\n"
#, fuzzy
#~ msgid "WinGDI method was not enabled at compile time.\n"
#~ msgstr "RANDR metode blev ikke slået til under kompilering.\n"
#~ msgid "Initialization of VidMode failed.\n"
#~ msgstr "Fejl under klargøring af VidMode.\n"
#, fuzzy
#~ msgid "Initialization of WinGDI failed.\n"
#~ msgstr "Fejl under klargøring af RANDR.\n"
+42 -40
View File
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: redshift 1.3\n"
"Report-Msgid-Bugs-To: https://bugs.launchpad.net/redshift\n"
"POT-Creation-Date: 2010-05-05 23:28+0200\n"
"POT-Creation-Date: 2010-05-24 18:10+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -16,17 +16,17 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: src/redshift.c:172
#: src/redshift.c:197
#, c-format
msgid "Period: Night\n"
msgstr ""
#: src/redshift.c:179
#: src/redshift.c:204
#, c-format
msgid "Period: Transition (%.2f%% day)\n"
msgstr ""
#: src/redshift.c:183
#: src/redshift.c:208
#, c-format
msgid "Period: Daytime\n"
msgstr ""
@@ -36,20 +36,20 @@ msgstr ""
#. DAY is temperature at daytime,
#. NIGHT is temperature at night
#. no-wrap
#: src/redshift.c:198
#: src/redshift.c:223
#, c-format
msgid "Usage: %s -l LAT:LON -t DAY:NIGHT [OPTIONS...]\n"
msgstr ""
#. TRANSLATORS: help output 2
#. no-wrap
#: src/redshift.c:204
#: src/redshift.c:229
msgid "Set color temperature of display according to time of day.\n"
msgstr ""
#. TRANSLATORS: help output 3
#. no-wrap
#: src/redshift.c:210
#: src/redshift.c:235
msgid ""
" -h\t\tDisplay this help message\n"
" -v\t\tVerbose output\n"
@@ -57,11 +57,12 @@ msgstr ""
#. TRANSLATORS: help output 4
#. no-wrap
#: src/redshift.c:216
#: src/redshift.c:241
msgid ""
" -g R:G:B\tAdditional gamma correction to apply\n"
" -l LAT:LON\tYour current location\n"
" -m METHOD\tMethod to use to set color temperature (RANDR or VidMode)\n"
" -m METHOD\tMethod to use to set color temperature\n"
" \t\t(Type `list' to see available methods)\n"
" -o\t\tOne shot mode (do not continously adjust color temperature)\n"
" -r\t\tDisable temperature transitions\n"
" -s SCREEN\tX screen to apply adjustments to\n"
@@ -70,7 +71,7 @@ msgid ""
msgstr ""
#. TRANSLATORS: help output 5
#: src/redshift.c:230
#: src/redshift.c:255
#, c-format
msgid ""
"Default values:\n"
@@ -79,102 +80,103 @@ msgid ""
" Night temperature: %uK\n"
msgstr ""
#: src/redshift.c:291
#: src/redshift.c:269
msgid "Available adjustment methods:\n"
msgstr ""
#: src/redshift.c:327
msgid "Malformed gamma argument.\n"
msgstr ""
#: src/redshift.c:293 src/redshift.c:312 src/redshift.c:363 src/redshift.c:375
#: src/redshift.c:384
#: src/redshift.c:329 src/redshift.c:348 src/redshift.c:394 src/redshift.c:406
#: src/redshift.c:415
msgid "Try `-h' for more information.\n"
msgstr ""
#: src/redshift.c:310
#: src/redshift.c:346
msgid "Malformed location argument.\n"
msgstr ""
#: src/redshift.c:326
msgid "RANDR method was not enabled at compile time.\n"
msgstr ""
#: src/redshift.c:336
msgid "VidMode method was not enabled at compile time.\n"
msgstr ""
#. TRANSLATORS: This refers to the method
#. used to adjust colors e.g VidMode
#: src/redshift.c:344
#: src/redshift.c:375
#, c-format
msgid "Unknown method `%s'.\n"
msgstr ""
#: src/redshift.c:361
#: src/redshift.c:392
msgid "Malformed temperature argument.\n"
msgstr ""
#: src/redshift.c:383
#: src/redshift.c:414
msgid "Latitude and longitude must be set.\n"
msgstr ""
#. TRANSLATORS: Append degree symbols if possible.
#: src/redshift.c:390
#: src/redshift.c:421
#, c-format
msgid "Location: %f, %f\n"
msgstr ""
#: src/redshift.c:397
#: src/redshift.c:428
#, c-format
msgid "Latitude must be between %.1f and %.1f.\n"
msgstr ""
#: src/redshift.c:406
#: src/redshift.c:437
#, c-format
msgid "Longitude must be between %.1f and %.1f.\n"
msgstr ""
#: src/redshift.c:414 src/redshift.c:422
#: src/redshift.c:445 src/redshift.c:453
#, c-format
msgid "Temperature must be between %uK and %uK.\n"
msgstr ""
#: src/redshift.c:432
#: src/redshift.c:463
#, c-format
msgid "Gamma value must be between %.1f and %.1f.\n"
msgstr ""
#: src/redshift.c:438
#: src/redshift.c:469
#, c-format
msgid "Gamma: %.3f, %.3f, %.3f\n"
msgstr ""
#: src/redshift.c:444
#: src/redshift.c:475
#, c-format
msgid "CRTC can only be selected with the RANDR method.\n"
msgstr ""
#: src/redshift.c:457
msgid "Initialization of RANDR failed.\n"
#: src/redshift.c:488 src/redshift.c:498
#, c-format
msgid "Initialization of %s failed.\n"
msgstr ""
#: src/redshift.c:459
#: src/redshift.c:500
msgid "Trying other method...\n"
msgstr ""
#: src/redshift.c:474
msgid "Initialization of VidMode failed.\n"
#: src/redshift.c:509
msgid "No more methods to try.\n"
msgstr ""
#: src/redshift.c:519 src/redshift.c:626
msgid "Unable to read system time.\n"
msgstr ""
#. TRANSLATORS: Append degree symbol if possible.
#: src/redshift.c:497
#: src/redshift.c:528
#, c-format
msgid "Solar elevation: %f\n"
msgstr ""
#: src/redshift.c:504 src/redshift.c:666
#: src/redshift.c:535 src/redshift.c:693
#, c-format
msgid "Color temperature: %uK\n"
msgstr ""
#: src/redshift.c:510 src/redshift.c:675
#: src/redshift.c:540 src/redshift.c:701
msgid "Temperature adjustment failed.\n"
msgstr ""
+61 -41
View File
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: redshift\n"
"Report-Msgid-Bugs-To: https://bugs.launchpad.net/redshift\n"
"POT-Creation-Date: 2010-05-05 23:28+0200\n"
"POT-Creation-Date: 2010-05-24 18:10+0200\n"
"PO-Revision-Date: 2010-02-02 09:20+0000\n"
"Last-Translator: Gregory Petrosyan <gregory.petrosyan@gmail.com>\n"
"Language-Team: Russian <ru@li.org>\n"
@@ -17,17 +17,17 @@ msgstr ""
"X-Launchpad-Export-Date: 2010-02-13 05:02+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#: src/redshift.c:172
#: src/redshift.c:197
#, c-format
msgid "Period: Night\n"
msgstr "Период: Ночь\n"
#: src/redshift.c:179
#: src/redshift.c:204
#, c-format
msgid "Period: Transition (%.2f%% day)\n"
msgstr "Период: Переходный (%.2f%% дневной)\n"
#: src/redshift.c:183
#: src/redshift.c:208
#, c-format
msgid "Period: Daytime\n"
msgstr "Период: День\n"
@@ -37,20 +37,20 @@ msgstr "Период: День\n"
#. DAY is temperature at daytime,
#. NIGHT is temperature at night
#. no-wrap
#: src/redshift.c:198
#: src/redshift.c:223
#, c-format
msgid "Usage: %s -l LAT:LON -t DAY:NIGHT [OPTIONS...]\n"
msgstr "Использование: %s -l ШИР:ДОЛ -t ДЕНЬ:НОЧЬ [ОПЦИИ...]\n"
#. TRANSLATORS: help output 2
#. no-wrap
#: src/redshift.c:204
#: src/redshift.c:229
msgid "Set color temperature of display according to time of day.\n"
msgstr "Установить цветовую температуру в соответствии со временем суток.\n"
#. TRANSLATORS: help output 3
#. no-wrap
#: src/redshift.c:210
#: src/redshift.c:235
msgid ""
" -h\t\tDisplay this help message\n"
" -v\t\tVerbose output\n"
@@ -60,12 +60,13 @@ msgstr ""
#. TRANSLATORS: help output 4
#. no-wrap
#: src/redshift.c:216
#: src/redshift.c:241
#, fuzzy
msgid ""
" -g R:G:B\tAdditional gamma correction to apply\n"
" -l LAT:LON\tYour current location\n"
" -m METHOD\tMethod to use to set color temperature (RANDR or VidMode)\n"
" -m METHOD\tMethod to use to set color temperature\n"
" \t\t(Type `list' to see available methods)\n"
" -o\t\tOne shot mode (do not continously adjust color temperature)\n"
" -r\t\tDisable temperature transitions\n"
" -s SCREEN\tX screen to apply adjustments to\n"
@@ -81,7 +82,7 @@ msgstr ""
" -t ДЕНЬ:НОЧЬ\tЦветовая температура для ночного/дневного времени\n"
#. TRANSLATORS: help output 5
#: src/redshift.c:230
#: src/redshift.c:255
#, c-format
msgid ""
"Default values:\n"
@@ -90,102 +91,104 @@ msgid ""
" Night temperature: %uK\n"
msgstr ""
#: src/redshift.c:291
#: src/redshift.c:269
msgid "Available adjustment methods:\n"
msgstr ""
#: src/redshift.c:327
msgid "Malformed gamma argument.\n"
msgstr "Некорректная величина гаммы.\n"
#: src/redshift.c:293 src/redshift.c:312 src/redshift.c:363 src/redshift.c:375
#: src/redshift.c:384
#: src/redshift.c:329 src/redshift.c:348 src/redshift.c:394 src/redshift.c:406
#: src/redshift.c:415
msgid "Try `-h' for more information.\n"
msgstr "Воспользуйтесь «-h» для получения дополнительной информации.\n"
#: src/redshift.c:310
#: src/redshift.c:346
msgid "Malformed location argument.\n"
msgstr "Некорректное значение местоположения.\n"
#: src/redshift.c:326
msgid "RANDR method was not enabled at compile time.\n"
msgstr "Метод RANDR был выключен во время компиляции.\n"
#: src/redshift.c:336
msgid "VidMode method was not enabled at compile time.\n"
msgstr "Метод VidMode был выключен во время компиляции.\n"
#. TRANSLATORS: This refers to the method
#. used to adjust colors e.g VidMode
#: src/redshift.c:344
#: src/redshift.c:375
#, c-format
msgid "Unknown method `%s'.\n"
msgstr "Неизвестный метод «%s».\n"
#: src/redshift.c:361
#: src/redshift.c:392
msgid "Malformed temperature argument.\n"
msgstr "Некорректное значение температуры.\n"
#: src/redshift.c:383
#: src/redshift.c:414
msgid "Latitude and longitude must be set.\n"
msgstr "Широта и долгота должны быть указаны.\n"
#. TRANSLATORS: Append degree symbols if possible.
#: src/redshift.c:390
#: src/redshift.c:421
#, c-format
msgid "Location: %f, %f\n"
msgstr "Местоположение: %f°, %f°\n"
#: src/redshift.c:397
#: src/redshift.c:428
#, c-format
msgid "Latitude must be between %.1f and %.1f.\n"
msgstr "Широта должна быть между %.1f и %.1f.\n"
#: src/redshift.c:406
#: src/redshift.c:437
#, c-format
msgid "Longitude must be between %.1f and %.1f.\n"
msgstr "Долгота должна быть между %.1f и %.1f.\n"
#: src/redshift.c:414 src/redshift.c:422
#: src/redshift.c:445 src/redshift.c:453
#, c-format
msgid "Temperature must be between %uK and %uK.\n"
msgstr "Температура должна быть между %uK и %uK.\n"
#: src/redshift.c:432
#: src/redshift.c:463
#, c-format
msgid "Gamma value must be between %.1f and %.1f.\n"
msgstr "Гамма должна быть между %.1f и %.1f.\n"
#: src/redshift.c:438
#: src/redshift.c:469
#, c-format
msgid "Gamma: %.3f, %.3f, %.3f\n"
msgstr "Гамма: %.3f, %.3f, %.3f\n"
#: src/redshift.c:444
#: src/redshift.c:475
#, c-format
msgid "CRTC can only be selected with the RANDR method.\n"
msgstr ""
#: src/redshift.c:457
msgid "Initialization of RANDR failed.\n"
#: src/redshift.c:488 src/redshift.c:498
#, fuzzy, c-format
msgid "Initialization of %s failed.\n"
msgstr "Инициализация RANDR не удалась.\n"
#: src/redshift.c:459
#: src/redshift.c:500
msgid "Trying other method...\n"
msgstr "Пробую другой метод...\n"
#: src/redshift.c:474
msgid "Initialization of VidMode failed.\n"
msgstr "Инициализация VidMode не удалась.\n"
#: src/redshift.c:509
msgid "No more methods to try.\n"
msgstr ""
#: src/redshift.c:519 src/redshift.c:626
#, fuzzy
msgid "Unable to read system time.\n"
msgstr "Не удается восстановить CRTC %i\n"
#. TRANSLATORS: Append degree symbol if possible.
#: src/redshift.c:497
#: src/redshift.c:528
#, c-format
msgid "Solar elevation: %f\n"
msgstr "Высота Солнца над горизонтом: %f°\n"
#: src/redshift.c:504 src/redshift.c:666
#: src/redshift.c:535 src/redshift.c:693
#, c-format
msgid "Color temperature: %uK\n"
msgstr "Цветовая температура: %uK\n"
#: src/redshift.c:510 src/redshift.c:675
#: src/redshift.c:540 src/redshift.c:701
msgid "Temperature adjustment failed.\n"
msgstr "Корректировка цветовой температуры не удалась.\n"
@@ -239,3 +242,20 @@ msgstr "Запрос X не удался: %s\n"
#: src/gtk-redshift/statusicon.py:61
msgid "Toggle"
msgstr "Включить / Выключить"
#~ msgid "RANDR method was not enabled at compile time.\n"
#~ msgstr "Метод RANDR был выключен во время компиляции.\n"
#~ msgid "VidMode method was not enabled at compile time.\n"
#~ msgstr "Метод VidMode был выключен во время компиляции.\n"
#, fuzzy
#~ msgid "WinGDI method was not enabled at compile time.\n"
#~ msgstr "Метод RANDR был выключен во время компиляции.\n"
#~ msgid "Initialization of VidMode failed.\n"
#~ msgstr "Инициализация VidMode не удалась.\n"
#, fuzzy
#~ msgid "Initialization of WinGDI failed.\n"
#~ msgstr "Инициализация RANDR не удалась.\n"
+109 -171
View File
@@ -88,6 +88,53 @@ typedef enum {
GAMMA_METHOD_MAX
} gamma_method_t;
typedef int gamma_method_init_func(void *state, int screen_num, int crtc_num);
typedef void gamma_method_free_func(void *state);
typedef void gamma_method_restore_func(void *state);
typedef int gamma_method_set_temperature_func(void *state, int temp,
float gamma[3]);
typedef struct {
char *name;
gamma_method_init_func *init;
gamma_method_free_func *free;
gamma_method_restore_func *restore;
gamma_method_set_temperature_func *set_temperature;
} gamma_method_spec_t;
/* Gamma adjustment method structs */
static const gamma_method_spec_t gamma_methods[] = {
#ifdef ENABLE_RANDR
{
"RANDR",
(gamma_method_init_func *)randr_init,
(gamma_method_free_func *)randr_free,
(gamma_method_restore_func *)randr_restore,
(gamma_method_set_temperature_func *)randr_set_temperature
},
#endif
#ifdef ENABLE_VIDMODE
{
"VidMode",
(gamma_method_init_func *)vidmode_init,
(gamma_method_free_func *)vidmode_free,
(gamma_method_restore_func *)vidmode_restore,
(gamma_method_set_temperature_func *)vidmode_set_temperature
},
#endif
#ifdef ENABLE_WINGDI
{
"WinGDI",
(gamma_method_init_func *)w32gdi_init,
(gamma_method_free_func *)w32gdi_free,
(gamma_method_restore_func *)w32gdi_restore,
(gamma_method_set_temperature_func *)w32gdi_set_temperature
},
#endif
{ NULL, NULL, NULL, NULL, NULL }
};
/* Bounds for parameters. */
#define MIN_LAT -90.0
@@ -139,82 +186,6 @@ static int disable = 0;
#endif /* ! HAVE_SYS_SIGNAL_H */
/* Restore saved gamma ramps with the appropriate adjustment method. */
static void
gamma_state_restore(gamma_state_t *state, gamma_method_t method)
{
switch (method) {
#ifdef ENABLE_RANDR
case GAMMA_METHOD_RANDR:
randr_restore(&state->randr);
break;
#endif
#ifdef ENABLE_VIDMODE
case GAMMA_METHOD_VIDMODE:
vidmode_restore(&state->vidmode);
break;
#endif
#ifdef ENABLE_WINGDI
case GAMMA_METHOD_WINGDI:
w32gdi_restore(&state->w32gdi);
break;
#endif
default:
break;
}
}
/* Free the state associated with the appropriate adjustment method. */
static void
gamma_state_free(gamma_state_t *state, gamma_method_t method)
{
switch (method) {
#ifdef ENABLE_RANDR
case GAMMA_METHOD_RANDR:
randr_free(&state->randr);
break;
#endif
#ifdef ENABLE_VIDMODE
case GAMMA_METHOD_VIDMODE:
vidmode_free(&state->vidmode);
break;
#endif
#ifdef ENABLE_WINGDI
case GAMMA_METHOD_WINGDI:
w32gdi_free(&state->w32gdi);
break;
#endif
default:
break;
}
}
/* Set temperature with the appropriate adjustment method. */
static int
gamma_state_set_temperature(gamma_state_t *state, gamma_method_t method,
int temp, float gamma[3])
{
switch (method) {
#ifdef ENABLE_RANDR
case GAMMA_METHOD_RANDR:
return randr_set_temperature(&state->randr, temp, gamma);
#endif
#ifdef ENABLE_VIDMODE
case GAMMA_METHOD_VIDMODE:
return vidmode_set_temperature(&state->vidmode, temp, gamma);
#endif
#ifdef ENABLE_WINGDI
case GAMMA_METHOD_WINGDI:
return w32gdi_set_temperature(&state->w32gdi, temp, gamma);
#endif
default:
break;
}
return -1;
}
/* Calculate color temperature for the specified solar elevation. */
static int
calculate_temp(double elevation, int temp_day, int temp_night,
@@ -269,8 +240,8 @@ print_help(const char *program_name)
no-wrap */
fputs(_(" -g R:G:B\tAdditional gamma correction to apply\n"
" -l LAT:LON\tYour current location\n"
" -m METHOD\tMethod to use to set color temperature"
" (RANDR, VidMode or WinGDI)\n"
" -m METHOD\tMethod to use to set color temperature\n"
" \t\t(Type `list' to see available methods)\n"
" -o\t\tOne shot mode (do not continously adjust"
" color temperature)\n"
" -r\t\tDisable temperature transitions\n"
@@ -292,6 +263,15 @@ print_help(const char *program_name)
printf("Please report bugs to <%s>\n", PACKAGE_BUGREPORT);
}
static void
print_method_list()
{
fputs(_("Available adjustment methods:\n"), stdout);
for (int i = 0; gamma_methods[i].name != NULL; i++) {
printf(" %s\n", gamma_methods[i].name);
}
}
int
main(int argc, char *argv[])
@@ -314,7 +294,9 @@ main(int argc, char *argv[])
int temp_day = DEFAULT_DAY_TEMP;
int temp_night = DEFAULT_NIGHT_TEMP;
float gamma[3] = { DEFAULT_GAMMA, DEFAULT_GAMMA, DEFAULT_GAMMA };
int method = -1;
const gamma_method_spec_t *method = NULL;
int screen_num = -1;
int crtc_num = -1;
int transition = 1;
@@ -372,37 +354,22 @@ main(int argc, char *argv[])
lon = atof(s);
break;
case 'm':
if (strcmp(optarg, "randr") == 0 ||
strcmp(optarg, "RANDR") == 0) {
#ifdef ENABLE_RANDR
method = GAMMA_METHOD_RANDR;
#else
fputs(_("RANDR method was not"
" enabled at compile time.\n"),
stderr);
exit(EXIT_FAILURE);
#endif
} else if (strcmp(optarg, "vidmode") == 0 ||
strcmp(optarg, "VidMode") == 0) {
#ifdef ENABLE_VIDMODE
method = GAMMA_METHOD_VIDMODE;
#else
fputs(_("VidMode method was not"
" enabled at compile time.\n"),
stderr);
exit(EXIT_FAILURE);
#endif
} else if (strcmp(optarg, "wingdi") == 0 ||
strcmp(optarg, "WinGDI") == 0) {
#ifdef ENABLE_WINGDI
method = GAMMA_METHOD_WINGDI;
#else
fputs(_("WinGDI method was not"
" enabled at compile time.\n"),
stderr);
exit(EXIT_FAILURE);
#endif
} else {
/* Print list of methods if argument is `list' */
if (strcasecmp(optarg, "list") == 0) {
print_method_list();
exit(EXIT_SUCCESS);
}
/* Lookup argument in gamma methods table */
for (int i = 0; gamma_methods[i].name != NULL; i++) {
const gamma_method_spec_t *m =
&gamma_methods[i];
if (strcasecmp(optarg, m->name) == 0) {
method = m;
}
}
if (method == NULL) {
/* TRANSLATORS: This refers to the method
used to adjust colors e.g VidMode */
fprintf(stderr, _("Unknown method `%s'.\n"),
@@ -513,64 +480,36 @@ main(int argc, char *argv[])
/* Initialize gamma adjustment method. If method is negative
try all methods until one that works is found. */
gamma_state_t state;
#ifdef ENABLE_RANDR
if (method < 0 || method == GAMMA_METHOD_RANDR) {
/* Initialize RANDR state */
r = randr_init(&state.randr, screen_num, crtc_num);
if (method != NULL) {
/* Use method specified on command line */
r = method->init(&state, screen_num, crtc_num);
if (r < 0) {
fputs(_("Initialization of RANDR failed.\n"), stderr);
if (method < 0) {
fprintf(stderr, _("Initialization of %s failed.\n"),
method->name);
exit(EXIT_FAILURE);
}
} else {
/* Try all methods, use the first that works */
for (int i = 0; gamma_methods[i].name != NULL; i++) {
const gamma_method_spec_t *m = &gamma_methods[i];
r = m->init(&state, screen_num, crtc_num);
if (r < 0) {
fprintf(stderr, _("Initialization of %s"
" failed.\n"), m->name);
fputs(_("Trying other method...\n"), stderr);
} else {
exit(EXIT_FAILURE);
method = m;
break;
}
} else {
method = GAMMA_METHOD_RANDR;
}
}
#endif
#ifdef ENABLE_VIDMODE
if (method < 0 || method == GAMMA_METHOD_VIDMODE) {
/* Initialize VidMode state */
r = vidmode_init(&state.vidmode, screen_num);
if (r < 0) {
fputs(_("Initialization of VidMode failed.\n"),
stderr);
if (method < 0) {
fputs(_("Trying other method...\n"), stderr);
} else {
exit(EXIT_FAILURE);
}
} else {
method = GAMMA_METHOD_VIDMODE;
/* Failure if no methods were successful at this point. */
if (method == NULL) {
fputs(_("No more methods to try.\n"), stderr);
exit(EXIT_FAILURE);
}
}
#endif
#ifdef ENABLE_WINGDI
if (method < 0 || method == GAMMA_METHOD_WINGDI) {
/* Initialize WinGDI state */
r = w32gdi_init(&state.w32gdi);
if (r < 0) {
fputs(_("Initialization of WinGDI failed.\n"),
stderr);
if (method < 0) {
fputs(_("Trying other method...\n"), stderr);
} else {
exit(EXIT_FAILURE);
}
} else {
method = GAMMA_METHOD_WINGDI;
}
}
#endif
/* Failure if no methods were successful at this point. */
if (method < 0) {
fputs(_("No more methods to try.\n"), stderr);
exit(EXIT_FAILURE);
}
if (one_shot) {
/* Current angular elevation of the sun */
@@ -578,7 +517,7 @@ main(int argc, char *argv[])
r = systemtime_get_time(&now);
if (r < 0) {
fputs(_("Unable to read system time.\n"), stderr);
gamma_state_free(&state, method);
method->free(&state);
exit(EXIT_FAILURE);
}
@@ -596,10 +535,10 @@ main(int argc, char *argv[])
if (verbose) printf(_("Color temperature: %uK\n"), temp);
/* Adjust temperature */
r = gamma_state_set_temperature(&state, method, temp, gamma);
r = method->set_temperature(&state, temp, gamma);
if (r < 0) {
fputs(_("Temperature adjustment failed.\n"), stderr);
gamma_state_free(&state, method);
method->free(&state);
exit(EXIT_FAILURE);
}
} else {
@@ -686,7 +625,7 @@ main(int argc, char *argv[])
if (r < 0) {
fputs(_("Unable to read system time.\n"),
stderr);
gamma_state_free(&state, method);
method->free(&state);
exit(EXIT_FAILURE);
}
@@ -737,7 +676,7 @@ main(int argc, char *argv[])
if (short_trans_done) {
if (disabled) {
/* Restore saved gamma ramps */
gamma_state_restore(&state, method);
method->restore(&state);
}
short_trans_done = 0;
}
@@ -756,13 +695,12 @@ main(int argc, char *argv[])
/* Adjust temperature */
if (!disabled || short_trans) {
r = gamma_state_set_temperature(&state,
method,
temp, gamma);
r = method->set_temperature(&state,
temp, gamma);
if (r < 0) {
fputs(_("Temperature adjustment"
" failed.\n"), stderr);
gamma_state_free(&state, method);
method->free(&state);
exit(EXIT_FAILURE);
}
}
@@ -778,11 +716,11 @@ main(int argc, char *argv[])
}
/* Restore saved gamma ramps */
gamma_state_restore(&state, method);
method->restore(&state);
}
/* Clean up gamma adjustment state */
gamma_state_free(&state, method);
method->free(&state);
return EXIT_SUCCESS;
}
+1 -1
View File
@@ -32,7 +32,7 @@
int
vidmode_init(vidmode_state_t *state, int screen_num)
vidmode_init(vidmode_state_t *state, int screen_num, int crtc_num)
{
int r;
+1 -1
View File
@@ -31,7 +31,7 @@ typedef struct {
uint16_t *saved_ramps;
} vidmode_state_t;
int vidmode_init(vidmode_state_t *state, int screen_num);
int vidmode_init(vidmode_state_t *state, int screen_num, int crtc_num);
void vidmode_free(vidmode_state_t *state);
void vidmode_restore(vidmode_state_t *state);
int vidmode_set_temperature(vidmode_state_t *state, int temp, float gamma[3]);
+1 -1
View File
@@ -38,7 +38,7 @@
int
w32gdi_init(w32gdi_state_t *state)
w32gdi_init(w32gdi_state_t *state, int screen_num, int crtc_num)
{
BOOL r;
+1 -1
View File
@@ -29,7 +29,7 @@ typedef struct {
WORD *saved_ramps;
} w32gdi_state_t;
int w32gdi_init(w32gdi_state_t *state);
int w32gdi_init(w32gdi_state_t *state, int screen_num, int crtc_num);
void w32gdi_free(w32gdi_state_t *state);
void w32gdi_restore(w32gdi_state_t *state);
int w32gdi_set_temperature(w32gdi_state_t *state, int temp, float gamma[3]);