1 /* gamma-dummy.c -- No-op gamma adjustment
2    This file is part of Redshift.
3 
4    Redshift is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation, either version 3 of the License, or
7    (at your option) any later version.
8 
9    Redshift is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13 
14    You should have received a copy of the GNU General Public License
15    along with Redshift.  If not, see <http://www.gnu.org/licenses/>.
16 
17    Copyright (c) 2013-2017  Jon Lund Steffensen <jonlst@gmail.com>
18 */
19 
20 #include <stdio.h>
21 #include <stdlib.h>
22 
23 #ifdef ENABLE_NLS
24 # include <libintl.h>
25 # define _(s) gettext(s)
26 #else
27 # define _(s) s
28 #endif
29 
30 #include "redshift.h"
31 
32 
33 static int
gamma_dummy_init(void ** state)34 gamma_dummy_init(void **state)
35 {
36 	*state = NULL;
37 	return 0;
38 }
39 
40 static int
gamma_dummy_start(void * state)41 gamma_dummy_start(void *state)
42 {
43 	fputs(_("WARNING: Using dummy gamma method! Display will not be affected by this gamma method.\n"), stderr);
44 	return 0;
45 }
46 
47 static void
gamma_dummy_restore(void * state)48 gamma_dummy_restore(void *state)
49 {
50 }
51 
52 static void
gamma_dummy_free(void * state)53 gamma_dummy_free(void *state)
54 {
55 }
56 
57 static void
gamma_dummy_print_help(FILE * f)58 gamma_dummy_print_help(FILE *f)
59 {
60 	fputs(_("Does not affect the display but prints the color temperature to the terminal.\n"), f);
61 	fputs("\n", f);
62 }
63 
64 static int
gamma_dummy_set_option(void * state,const char * key,const char * value)65 gamma_dummy_set_option(void *state, const char *key, const char *value)
66 {
67 	fprintf(stderr, _("Unknown method parameter: `%s'.\n"), key);
68 	return -1;
69 }
70 
71 static int
gamma_dummy_set_temperature(void * state,const color_setting_t * setting,int preserve)72 gamma_dummy_set_temperature(
73 	void *state, const color_setting_t *setting, int preserve)
74 {
75 	printf(_("Temperature: %i\n"), setting->temperature);
76 	return 0;
77 }
78 
79 
80 const gamma_method_t dummy_gamma_method = {
81 	"dummy", 0,
82 	(gamma_method_init_func *)gamma_dummy_init,
83 	(gamma_method_start_func *)gamma_dummy_start,
84 	(gamma_method_free_func *)gamma_dummy_free,
85 	(gamma_method_print_help_func *)gamma_dummy_print_help,
86 	(gamma_method_set_option_func *)gamma_dummy_set_option,
87 	(gamma_method_restore_func *)gamma_dummy_restore,
88 	(gamma_method_set_temperature_func *)gamma_dummy_set_temperature
89 };
90