~ubuntu-branches/ubuntu/precise/nvidia-settings/precise-proposed

« back to all changes in this revision

Viewing changes to nvidia-settings-1.0/src/nvidia-settings.c

  • Committer: Bazaar Package Importer
  • Author(s): Randall Donald
  • Date: 2004-07-03 19:09:17 UTC
  • Revision ID: james.westby@ubuntu.com-20040703190917-rqkze2s58ux5pamy
Tags: upstream-1.0
ImportĀ upstreamĀ versionĀ 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * nvidia-settings: A tool for configuring the NVIDIA X driver on Unix
 
3
 * and Linux systems.
 
4
 *
 
5
 * Copyright (C) 2004 NVIDIA Corporation.
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or
 
8
 * modify it under the terms of Version 2 of the GNU General Public
 
9
 * License as published by the Free Software Foundation.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful, but
 
12
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See Version 2
 
14
 * of the GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the:
 
18
 *
 
19
 *           Free Software Foundation, Inc.
 
20
 *           59 Temple Place - Suite 330
 
21
 *           Boston, MA 02111-1307, USA
 
22
 *
 
23
 */
 
24
 
 
25
#include "NvCtrlAttributes.h"
 
26
 
 
27
#include "command-line.h"
 
28
#include "config-file.h"
 
29
#include "query-assign.h"
 
30
#include "msg.h"
 
31
 
 
32
#include "ctkui.h"
 
33
 
 
34
#include <stdlib.h>
 
35
 
 
36
 
 
37
int main(int argc, char **argv)
 
38
{
 
39
    ConfigProperties conf;
 
40
    ParsedAttribute *p;
 
41
    CtrlHandles *h;
 
42
    Options *op;
 
43
    int ret;
 
44
    
 
45
    /*
 
46
     * initialize the ui
 
47
     *
 
48
     * XXX it would be nice if we didn't do this up front, since we
 
49
     * may not even use the gui, but we want the toolkit to have a
 
50
     * chance to parse the commandline before we do... we should
 
51
     * investigate gtk_init_check().
 
52
     */
 
53
    
 
54
    ctk_init(&argc, &argv);
 
55
    
 
56
    /* parse the commandline */
 
57
    
 
58
    op = parse_command_line(argc, argv, ctk_get_display());
 
59
 
 
60
    /* process any query or assignment commandline options */
 
61
 
 
62
    if (op->num_assignments || op->num_queries) {
 
63
        ret = nv_process_assignments_and_queries(op);
 
64
        return ret ? 0 : 1;
 
65
    }
 
66
    
 
67
    /* initialize the parsed attribute list */
 
68
 
 
69
    p = nv_parsed_attribute_init();
 
70
 
 
71
    /* upload the data from the config file */
 
72
    
 
73
    ret = nv_read_config_file(op->config, op->ctrl_display, p, &conf);
 
74
 
 
75
    /*
 
76
     * if the user requested that we only load the config file, then
 
77
     * exit now
 
78
     */
 
79
    
 
80
    if (op->load) {
 
81
        return ret ? 0 : 1;
 
82
    }
 
83
 
 
84
    /* allocate the CtrlHandles for this X screen */
 
85
 
 
86
    h = nv_alloc_ctrl_handles(op->ctrl_display);
 
87
    
 
88
    if (!h || !h->dpy) {
 
89
        return 1;
 
90
    }
 
91
 
 
92
    /* pass control to the gui */
 
93
 
 
94
    ctk_main(h->h, h->num_screens, p, &conf);
 
95
 
 
96
    /* write the configuration file */
 
97
 
 
98
    nv_write_config_file(op->config, h, p, &conf);
 
99
 
 
100
    /* cleanup */
 
101
 
 
102
    nv_free_ctrl_handles(h);
 
103
    nv_parsed_attribute_free(p);
 
104
 
 
105
    return 0;
 
106
    
 
107
} /* main() */