aboutsummaryrefslogtreecommitdiffstats
path: root/src/gamma-vidmode.c
diff options
context:
space:
mode:
authorJon Lund Steffensen <jonlst@gmail.com>2010-05-27 02:20:29 +0200
committerJon Lund Steffensen <jonlst@gmail.com>2010-05-27 02:20:29 +0200
commit441dae4a44f60665c9f669a80304b688285c9c22 (patch)
tree572d08dfeeac1e2a4d737513d9e6c8daa4b0f343 /src/gamma-vidmode.c
parentLet gamma methods and location providers print help on option parameters. (diff)
downloadredshift-ng-441dae4a44f60665c9f669a80304b688285c9c22.tar.gz
redshift-ng-441dae4a44f60665c9f669a80304b688285c9c22.tar.bz2
redshift-ng-441dae4a44f60665c9f669a80304b688285c9c22.tar.xz
Split init function of methods and providers into init and start.
The set_option function can be called to set options between init and start.
Diffstat (limited to 'src/gamma-vidmode.c')
-rw-r--r--src/gamma-vidmode.c60
1 files changed, 31 insertions, 29 deletions
diff --git a/src/gamma-vidmode.c b/src/gamma-vidmode.c
index e8f6d63..970c45d 100644
--- a/src/gamma-vidmode.c
+++ b/src/gamma-vidmode.c
@@ -37,36 +37,10 @@
int
-vidmode_init(vidmode_state_t *state, char *args)
+vidmode_init(vidmode_state_t *state)
{
- int screen_num = -1;
-
- /* Parse arguments. */
- while (args != NULL) {
- char *next_arg = strchr(args, ':');
- if (next_arg != NULL) *(next_arg++) = '\0';
-
- char *value = strchr(args, '=');
- if (value != NULL) *(value++) = '\0';
-
- if (strcasecmp(args, "screen") == 0) {
- if (value == NULL) {
- fprintf(stderr, _("Missing value for"
- " parameter: `%s'.\n"),
- args);
- return -1;
- }
- screen_num = atoi(value);
- } else {
- fprintf(stderr, _("Unknown method parameter: `%s'.\n"),
- args);
- return -1;
- }
-
- args = next_arg;
- }
-
- int r;
+ state->screen_num = -1;
+ state->saved_ramps = NULL;
/* Open display */
state->display = XOpenDisplay(NULL);
@@ -76,6 +50,15 @@ vidmode_init(vidmode_state_t *state, char *args)
return -1;
}
+ return 0;
+}
+
+int
+vidmode_start(vidmode_state_t *state)
+{
+ int r;
+ int screen_num = state->screen_num;
+
if (screen_num < 0) screen_num = DefaultScreen(state->display);
state->screen_num = screen_num;
@@ -152,6 +135,25 @@ vidmode_print_help(FILE *f)
fputs("\n", f);
}
+int
+vidmode_set_option(vidmode_state_t *state, const char *key, const char *value)
+{
+ if (key == NULL) {
+ fprintf(stderr, _("Missing value for parameter: `%s'.\n"),
+ key);
+ return -1;
+ }
+
+ if (strcasecmp(key, "screen") == 0) {
+ state->screen_num = atoi(value);
+ } else {
+ fprintf(stderr, _("Unknown method parameter: `%s'.\n"), key);
+ return -1;
+ }
+
+ return 0;
+}
+
void
vidmode_restore(vidmode_state_t *state)
{