~nmu-sscheel/gtg/rework-task-editor

« back to all changes in this revision

Viewing changes to GTG/core/__init__.py

  • Committer: Bertrand Rousseau
  • Date: 2012-05-09 22:33:25 UTC
  • mfrom: (1178 trunk)
  • mto: This revision was merged to the branch mainline in revision 1179.
  • Revision ID: bertrand.rousseau@gmail.com-20120509223325-a53d8nwo0x9g93bc
Merge nimit branch and trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- coding: utf-8 -*-
2
2
# -----------------------------------------------------------------------------
3
3
# Gettings Things Gnome! - a personal organizer for the GNOME desktop
4
 
# Copyright (c) 2008-2009 - Lionel Dricot & Bertrand Rousseau
 
4
# Copyright (c) 2008-2012 - Lionel Dricot & Bertrand Rousseau
5
5
#
6
6
# This program is free software: you can redistribute it and/or modify it under
7
7
# the terms of the GNU General Public License as published by the Free Software
17
17
# this program.  If not, see <http://www.gnu.org/licenses/>.
18
18
# -----------------------------------------------------------------------------
19
19
 
20
 
 
21
20
"""
22
21
GTG's core functionality.
23
22
 
37
36
 
38
37
"""
39
38
 
40
 
 
41
39
#=== IMPORT ====================================================================
42
40
import os
43
41
from xdg.BaseDirectory import xdg_data_home, xdg_config_home
45
43
from GTG.tools.testingmode import TestingMode
46
44
 
47
45
import GTG
48
 
from GTG.tools.logger import Log
49
46
from GTG.tools.borg   import Borg
50
47
 
51
 
 
52
48
DEFAULTS = {
53
49
'browser': {
54
 
            'bg_color_enable': False,
 
50
            "bg_color_enable": True,
55
51
            "contents_preview_enable": False,
56
52
            'tag_pane': False,
57
53
            "sidebar_width": 120,
59
55
            'bottom_pane_position': 300,
60
56
            'toolbar': True,
61
57
            'quick_add': True,
62
 
            "bg_color_enable": True,
63
58
            'collapsed_tasks': [],
64
59
            'collapsed_tags': [],
65
60
            'view': 'default',
66
61
            "opened_tasks": [],
67
62
            'width': 400,
68
63
            'height': 400,
 
64
            'max': False,
69
65
            'x_pos': 10,
70
66
            'y_pos': 10,
71
67
            'tasklist_sort_column': 5,
111
107
            toreturn = self.__defaults[name]
112
108
            self.__conf[name] = toreturn
113
109
        else:
114
 
            print "Warning : no default conf value for %s in %s" % (name, self.__name)
 
110
            print "Warning : no default conf value for %s in %s" % (
 
111
                name, self.__name)
115
112
            toreturn = None
116
113
        return toreturn
117
114
 
129
126
    CONF_FILE = "gtg.conf"
130
127
    TASK_CONF_FILE = "tasks.conf"
131
128
    conf_dict = None
132
 
    #DBUS
 
129
    #DBus
133
130
    BUSNAME = "org.gnome.GTG"
134
131
    BUSINTERFACE = "/org/gnome/GTG"
135
132
    #TAGS
154
151
        if not os.path.exists(self.data_dir):
155
152
            os.makedirs(self.data_dir)
156
153
        if not os.path.exists(self.conf_dir + self.CONF_FILE):
157
 
            f = open(self.conf_dir + self.CONF_FILE, "w")
158
 
            f.close()
 
154
            open(self.conf_dir + self.CONF_FILE, "w").close()
159
155
        if not os.path.exists(self.conf_dir + self.TASK_CONF_FILE):
160
 
            f = open(self.conf_dir + self.TASK_CONF_FILE, "w")
161
 
            f.close()
162
 
        for file in [self.conf_dir + self.CONF_FILE,
 
156
            open(self.conf_dir + self.TASK_CONF_FILE, "w").close()
 
157
        for conf_file in [self.conf_dir + self.CONF_FILE,
163
158
                     self.conf_dir + self.TASK_CONF_FILE]:
164
 
            if not ((file, os.R_OK) and os.access(file, os.W_OK)):
 
159
            if not os.access(conf_file, os.R_OK | os.W_OK):
165
160
                raise Exception("File " + file + \
166
161
                            " is a configuration file for gtg, but it "
167
162
                            "cannot be read or written. Please check it")
179
174
        return SubConfig(name, self.conf_dict[name])
180
175
 
181
176
    def get_icons_directories(self):
182
 
        '''
183
 
        Returns the directories containing the icons
184
 
        '''
 
177
        """ Returns the directories containing the icons """
185
178
        return [GTG.DATA_DIR, os.path.join(GTG.DATA_DIR, "icons")]
186
179
 
187
180
    def get_data_dir(self):