~kai-huuhko/apathy/master

« back to all changes in this revision

Viewing changes to apathy/Apathy.py

  • Committer: Kai Huuhko
  • Date: 2013-03-28 00:30:25 UTC
  • Revision ID: git-v1:184297bdf04b278f6e1dcba1ebd9d917d9607a75
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
#########################################################################
 
4
#                                                                       #
 
5
# Apathy - A telepathy based communications client for mobile platforms #
 
6
# Copyright (C) 2009  Michael Sheldon <mike@mikeasoft.com>              #
 
7
# Copyright 2012 Kai Huuhko <kai@kaihuuhko.com>                         #
 
8
#                                                                       #
 
9
# This program is free software: you can redistribute it and/or modify  #
 
10
# it under the terms of the GNU General Public License as published by  #
 
11
# the Free Software Foundation, either version 3 of the License, or     #
 
12
# (at your option) any later version.                                   #
 
13
#                                                                       #
 
14
# This program is distributed in the hope that it will be useful,       #
 
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of        #
 
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         #
 
17
# GNU General Public License for more details.                          #
 
18
#                                                                       #
 
19
# You should have received a copy of the GNU General Public License     #
 
20
# along with this program.  If not, see <http://www.gnu.org/licenses/>. #
 
21
#                                                                       #
 
22
#########################################################################
 
23
 
 
24
import os.path, gettext
 
25
 
 
26
from Accounts import Accounts
 
27
from Contacts import Contacts
 
28
from Globals import *
 
29
 
 
30
import ecore, dbus, e_dbus
 
31
import elementary as e
 
32
 
 
33
from gi.repository import GObject
 
34
GObject.threads_init()
 
35
from gi.repository import TelepathyGLib as Tp
 
36
#Tp.debug_set_flags("all")
 
37
 
 
38
class Apathy(e.Window):
 
39
    def __init__(self, log):
 
40
        e.Window.__init__(self, "apathy", e.ELM_WIN_BASIC)
 
41
        
 
42
        self.title_set("Apathy")
 
43
        self.callback_delete_request_add(self.quit)
 
44
 
 
45
        bg = e.Background(self)
 
46
        bg.size_hint_weight_set(1.0, 1.0)
 
47
        self.resize_object_add(bg)
 
48
        bg.show()
 
49
                
 
50
        self.flip = flip = e.Flip(self)
 
51
        self.contacts = contacts = Contacts(self)
 
52
        self.accounts = accounts = Accounts(self)
 
53
        flip.content_front_set(contacts)
 
54
        flip.content_back_set(accounts)
 
55
        flip.size_hint_weight_set(1.0, 1.0)
 
56
        flip.size_hint_align_set(-1.0, -1.0)
 
57
        self.resize_object_add(flip)
 
58
        flip.show()
 
59
        
 
60
        self.resize(480, 640)
 
61
        self.show()
 
62
        
 
63
    def quit(self, *args):
 
64
        log.info("Apathy is exiting")
 
65
        e.exit()
 
66
 
 
67
if __name__ == "__main__":
 
68
    if not os.path.exists(USER_PATH):
 
69
        os.mkdir(USER_PATH, 0700)
 
70
    if not os.path.exists(IMAGE_PATH):
 
71
        os.mkdir(IMAGE_PATH, 0777)
 
72
 
 
73
    gettext.install("apathy", "/usr/share/locale", unicode=1)
 
74
 
 
75
    e.init()
 
76
    dbus_mainloop = e_dbus.DBusEcoreMainLoop()
 
77
    dbus.set_default_main_loop(dbus_mainloop)
 
78
 
 
79
    apathy = Apathy(log)
 
80
    
 
81
    ecore.main_loop_glib_integrate()
 
82
 
 
83
    e.run()
 
84
    e.shutdown()