112
|
1 #!/usr/bin/python |
|
2 # -*- coding: utf-8 -*- |
|
3 |
|
4 """ |
|
5 Primitivus: a SAT frontend |
|
6 Copyright (C) 2009, 2010 Jérôme Poisson (goffi@goffi.org) |
|
7 |
|
8 This program is free software: you can redistribute it and/or modify |
|
9 it under the terms of the GNU General Public License as published by |
|
10 the Free Software Foundation, either version 3 of the License, or |
|
11 (at your option) any later version. |
|
12 |
|
13 This program is distributed in the hope that it will be useful, |
|
14 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 GNU General Public License for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
20 """ |
|
21 |
|
22 |
|
23 from quick_frontend.quick_app import QuickApp |
|
24 from quick_frontend.quick_chat_list import QuickChatList |
|
25 from quick_frontend.quick_contact_list import QuickContactList |
|
26 from quick_frontend.quick_contact_management import QuickContactManagement |
|
27 import urwid |
|
28 from profile_manager import ProfileManager |
|
29 import pdb |
|
30 """from window import Window |
|
31 from editbox import EditBox |
|
32 from statusbar import StatusBar |
|
33 from chat import Chat |
|
34 from tools.jid import JID""" |
|
35 import logging |
|
36 from logging import debug, info, error |
|
37 #import locale |
|
38 import sys, os |
|
39 #from curses import ascii |
|
40 #import locale |
|
41 #from signal import signal, SIGWINCH |
|
42 #import fcntl |
|
43 #import struct |
|
44 #import termios |
|
45 #from boxsizer import BoxSizer |
|
46 |
|
47 |
|
48 ### logging configuration FIXME: put this elsewhere ### |
|
49 logging.basicConfig(level=logging.CRITICAL, #TODO: configure it to put messages in a log file |
|
50 format='%(message)s') |
|
51 ### |
|
52 |
|
53 const_APP_NAME = "Primitivus" |
113
|
54 const_PALETTE = [('title', 'black', 'light gray', 'standout,underline'), |
|
55 ('selected', 'default', 'dark red'), |
|
56 ('selected_focus', 'default,bold', 'dark red'), |
|
57 ('default', 'default', 'default'), |
|
58 ('default_focus', 'default,bold', 'default'), |
|
59 ] |
112
|
60 |
|
61 class PrimitivusApp(QuickApp): |
|
62 |
|
63 def __init__(self): |
|
64 QuickApp.__init__(self) #XXX: yes it's an unusual place for the constructor of a parent class, but the init order is important |
|
65 |
|
66 ## main loop setup ## |
|
67 self.main_widget = self.__buildMainWidget() |
|
68 self.loop = urwid.MainLoop(self.main_widget, const_PALETTE, event_loop=urwid.GLibEventLoop(), unhandled_input=self.key_handler) |
|
69 |
|
70 def start(self): |
|
71 self.loop.run() |
|
72 |
|
73 def key_handler(self, input): |
|
74 if input in ('q', 'Q') or input == 'ctrl x': |
|
75 raise urwid.ExitMainLoop() |
|
76 |
|
77 def __buildMainWidget(self): |
113
|
78 #main_widget = urwid.Filler(ProfileManager(self)) |
112
|
79 main_widget = ProfileManager(self) |
|
80 return main_widget |
|
81 |
|
82 |
|
83 sat = PrimitivusApp() |
|
84 sat.start() |