annotate frontends/primitivus/primitivus @ 113:e5ca22113280

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