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