~ubuntu-branches/ubuntu/saucy/pida/saucy

« back to all changes in this revision

Viewing changes to src/configuration/options.py

  • Committer: Bazaar Package Importer
  • Author(s): Ante Karamatic
  • Date: 2005-09-27 10:19:38 UTC
  • Revision ID: james.westby@ubuntu.com-20050927101938-o7ak8uqyuvewfuw8
Tags: upstream-0.2.2
ImportĀ upstreamĀ versionĀ 0.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*- 
 
2
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
 
3
# $Id: options.py 447 2005-07-22 17:45:33Z aafshar $
 
4
#Copyright (c) 2005 Ali Afshar aafshar@gmail.com
 
5
 
 
6
#Permission is hereby granted, free of charge, to any person obtaining a copy
 
7
#of this software and associated documentation files (the "Software"), to deal
 
8
#in the Software without restriction, including without limitation the rights
 
9
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
10
#copies of the Software, and to permit persons to whom the Software is
 
11
#furnished to do so, subject to the following conditions:
 
12
 
 
13
#The above copyright notice and this permission notice shall be included in
 
14
#all copies or substantial portions of the Software.
 
15
 
 
16
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
17
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
18
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
19
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
20
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
21
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 
22
#SOFTWARE.
 
23
 
 
24
''' Default configuration options '''
 
25
 
 
26
# System imports
 
27
import os
 
28
import sys
 
29
import ConfigParser as configparser
 
30
 
 
31
# The pida registry
 
32
import registry
 
33
 
 
34
def which(name):
 
35
    ''' Returns the path of the application named name using 'which'. '''
 
36
    p = os.popen('which %s' % name)
 
37
    w = p.read().strip()
 
38
    p.close()
 
39
    if len(w):
 
40
        if 'command not found' in w:
 
41
            return None
 
42
        else:
 
43
            return w
 
44
    else:
 
45
        return None
 
46
 
 
47
def configure(reg):
 
48
    """
 
49
    Default global configuration.
 
50
    """
 
51
    dirs_group = reg.add_group('directories',
 
52
                                  'Locations of directories pida will use.')
 
53
    # user directory
 
54
    dirs_user = dirs_group.add('user',
 
55
                 registry.CreatingDirectory,
 
56
                 os.path.expanduser('~/.pida'),
 
57
                 'The base per-user directory')
 
58
    # libraries
 
59
    # This takes a bit of work
 
60
    prefix = __file__.split('lib', 1)[0]
 
61
    dirs_libs = dirs_group.add('shared',
 
62
                 registry.Directory,
 
63
                 os.path.join(prefix, 'share', 'pida'),
 
64
                 'The shared library directory.')
 
65
 
 
66
    dirs_sock = dirs_group.add('socket',
 
67
                 registry.CreatingDirectory,
 
68
                 os.path.join(dirs_user._default, '.sockets'),
 
69
                 'Where Pida will start Unix Domain Sockets')
 
70
                 
 
71
 #       ### Files
 
72
    file_group = reg.add_group('files',
 
73
        'Location of files Pida will use.')
 
74
 
 
75
    file_icon = file_group.add('icon_data',
 
76
                registry.MustExistFile,
 
77
                os.path.join(dirs_libs._default, 'icons.dat'),
 
78
                'Location of the icons file')
 
79
    
 
80
    file_proj = file_group.add('project_data',
 
81
                registry.File,
 
82
                os.path.join(dirs_user._default, 'pida.projects'),
 
83
                'Location of the project data file.')
 
84
 
 
85
    file_log = file_group.add('log',
 
86
                registry.File,
 
87
                os.path.join(dirs_user._default, 'pida.log'),
 
88
                'Location of the log file.')
 
89
 
 
90
    file_shrt = file_group.add('shortcut_data',
 
91
                registry.File,
 
92
                os.path.join(dirs_user._default, 'pida.shortcuts'),
 
93
                'Location of the shortcuts data file.')
 
94
 
 
95
 
 
96
 #       ### External command options
 
97
    coms_group = reg.add_group('commands',
 
98
        'Paths to external commands used by Pida')
 
99
                  
 
100
 
 
101
    coms_gvim = coms_group.add('vim',
 
102
                registry.WhichFile,
 
103
                'gvim',
 
104
                'Path to Gvim (may be set as /path/to/vim -g).')
 
105
 
 
106
    coms_cvim = coms_group.add('console_vim',
 
107
                registry.WhichFile,
 
108
                'vim',
 
109
                'Path to console Vim')
 
110
 
 
111
    coms_evim = coms_group.add('evim',
 
112
                registry.WhichFile,
 
113
                'evim',
 
114
                'Path to the modeless (easy) Vim version.')
 
115
 
 
116
    coms_emacs = coms_group.add('xemacs',
 
117
                registry.WhichFile,
 
118
                'xemacs',
 
119
                'Path to XEmacs.')
 
120
 
 
121
    coms_pyth = coms_group.add('python',
 
122
                registry.WhichFile,
 
123
                'python',
 
124
                'Path to the Python interpreter.')
 
125
 
 
126
    coms_shel = coms_group.add('shell',
 
127
                registry.WhichFile,
 
128
                os.getenv('SHELL'),
 
129
                'The path to your preferred shell.')
 
130
 
 
131
    coms_brow = coms_group.add('browser',
 
132
                registry.WhichFile,
 
133
                'firefox',
 
134
                'The path to your preferred browser.')
 
135
 
 
136
    coms_pdoc = coms_group.add('pydoc',
 
137
                registry.WhichFile,
 
138
                'pydoc',
 
139
                'The path to the pydoc program.')
 
140
 
 
141
    logs_group = reg.add_group('log',
 
142
                               'Logging options.')
 
143
 
 
144
    log_level = logs_group.add('level',
 
145
                   registry.Integer,
 
146
                   20,
 
147
                   'The default logging level (10=debug, 50=critical)')
 
148
 
 
149
    log_level.adjustment = (10, 50, 10)
 
150
 
 
151
    lay_group = reg.add_group('layout', 'Thigs to do with layout')
 
152
 
 
153
    lay_max = lay_group.add('start_maximised',
 
154
        registry.Boolean,
 
155
        False,
 
156
        'Whether Pida will start Maximized')
 
157
 
 
158
    lay_vert = lay_group.add('vertical_split',
 
159
               registry.Boolean,
 
160
               0,
 
161
               'Whether to split the view vertically (requires restart).')
 
162
    
 
163
    lay_embd = lay_group.add('embedded_mode',
 
164
                  registry.Boolean,
 
165
                  1,
 
166
                  'Determines whether Pida will start Vim embedded.')
 
167
   
 
168
    lay_term = lay_group.add('terminal_under_editor',
 
169
        registry.Boolean,
 
170
        False,
 
171
        'Determines whther the terminal will appear underneath the editor')
 
172
 
 
173
    lay_status = lay_group.add('status_bar',
 
174
        registry.Boolean,
 
175
        False,
 
176
        'Whether a status bar will be shown')
 
177
 
 
178
    core_group = reg.add_group('components',
 
179
        'Choose which components to use.')
 
180
 
 
181
    core_editor = core_group.add('editor',
 
182
        registry.List,
 
183
        'vim',
 
184
        'The editor Pida will use')
 
185
    
 
186
    core_editor.choices = ['vim', 'culebra']
 
187
 
 
188
if __name__ == '__main__':
 
189
    pass