Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/application.py
blob: af221baa4841c86c263f36e0a92d19463d6b3826 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.

import os
import logging
logging.basicConfig(level=logging.DEBUG)
import glib
import info
logger = logging.getLogger(info.lower_name)
appname = info.name

import sweetener

if sweetener.GTK == 2:
    from applicationgtk2 import Application
else:
    from applicationgtk3 import Application

if __name__ == '__main__':
    logger.debug('Initializing %s' % info.name)
    import sys
    if info.io_mode == info.DOCUMENT:
        if len(sys.argv) > 1:
            logger.debug('Open from args %s' % sys.argv[1])
            if os.path.exists(sys.argv[1]):
                file_path = sys.argv[1]
                logger.debug('Found file')
            else:
                file_path = None
                logger.error('Could not find file')
        else:
            file_path = None
            logger.debug('Create new file')
    else:
        if os.path.exists(os.path.join(os.environ['HOME'],
                                       '.' + info.lower_name)):
            file_path = os.path.join(os.environ['HOME'], '.' + info.lower_name)
        else:
            file_path = None
    window = Application()
    window.file_path = file_path
    window.start()
    logger.debug('Closing %s' % info.name)
    exit()