Mercurial > libervia-backend
annotate frontends/primitivus/primitivus @ 116:7c482ecac0ff
primitivus: basic contact list, connexion now work \o/
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 01 Jul 2010 18:52:51 +0800 |
parents | e5ca22113280 |
children | 1f0fd6f03e2b |
rev | line source |
---|---|
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 | |
116
7c482ecac0ff
primitivus: basic contact list, connexion now work \o/
Goffi <goffi@goffi.org>
parents:
113
diff
changeset
|
29 from contact_list import ContactList |
112 | 30 import pdb |
31 """from window import Window | |
32 from editbox import EditBox | |
33 from statusbar import StatusBar | |
34 from chat import Chat | |
35 from tools.jid import JID""" | |
36 import logging | |
37 from logging import debug, info, error | |
38 #import locale | |
39 import sys, os | |
40 #from curses import ascii | |
41 #import locale | |
42 #from signal import signal, SIGWINCH | |
43 #import fcntl | |
44 #import struct | |
45 #import termios | |
46 #from boxsizer import BoxSizer | |
47 | |
48 | |
49 ### logging configuration FIXME: put this elsewhere ### | |
50 logging.basicConfig(level=logging.CRITICAL, #TODO: configure it to put messages in a log file | |
51 format='%(message)s') | |
52 ### | |
53 | |
54 const_APP_NAME = "Primitivus" | |
113 | 55 const_PALETTE = [('title', 'black', 'light gray', 'standout,underline'), |
56 ('selected', 'default', 'dark red'), | |
57 ('selected_focus', 'default,bold', 'dark red'), | |
58 ('default', 'default', 'default'), | |
59 ('default_focus', 'default,bold', 'default'), | |
60 ] | |
112 | 61 |
62 class PrimitivusApp(QuickApp): | |
63 | |
64 def __init__(self): | |
116
7c482ecac0ff
primitivus: basic contact list, connexion now work \o/
Goffi <goffi@goffi.org>
parents:
113
diff
changeset
|
65 self.CM = QuickContactManagement() #FIXME: not the best place |
112 | 66 QuickApp.__init__(self) #XXX: yes it's an unusual place for the constructor of a parent class, but the init order is important |
67 | |
68 ## main loop setup ## | |
69 self.main_widget = self.__buildMainWidget() | |
70 self.loop = urwid.MainLoop(self.main_widget, const_PALETTE, event_loop=urwid.GLibEventLoop(), unhandled_input=self.key_handler) | |
71 | |
72 def start(self): | |
73 self.loop.run() | |
74 | |
75 def key_handler(self, input): | |
76 if input in ('q', 'Q') or input == 'ctrl x': | |
77 raise urwid.ExitMainLoop() | |
78 | |
79 def __buildMainWidget(self): | |
113 | 80 #main_widget = urwid.Filler(ProfileManager(self)) |
112 | 81 main_widget = ProfileManager(self) |
82 return main_widget | |
83 | |
116
7c482ecac0ff
primitivus: basic contact list, connexion now work \o/
Goffi <goffi@goffi.org>
parents:
113
diff
changeset
|
84 def plug_profile(self, profile_key='@DEFAULT@'): |
7c482ecac0ff
primitivus: basic contact list, connexion now work \o/
Goffi <goffi@goffi.org>
parents:
113
diff
changeset
|
85 self.loop.widget = self.contactList = ContactList(self, self.CM) |
7c482ecac0ff
primitivus: basic contact list, connexion now work \o/
Goffi <goffi@goffi.org>
parents:
113
diff
changeset
|
86 QuickApp.plug_profile(self, profile_key) |
7c482ecac0ff
primitivus: basic contact list, connexion now work \o/
Goffi <goffi@goffi.org>
parents:
113
diff
changeset
|
87 |
112 | 88 |
89 sat = PrimitivusApp() | |
90 sat.start() |