comparison frontends/primitivus/primitivus @ 180:fdb961f27ae9

Primitivus: file sending and progress management - added "send file" in one2one chat's menu - new progress widget which is linked to the notification bar - the notification bar show the average progress of all the current progress bars, and is used to show progress details - if present, pudb is used for debugging (can continue without breaking terminal's setting)
author Goffi <goffi@goffi.org>
date Mon, 16 Aug 2010 21:16:43 +0800
parents a50953ac6191
children a566f654929e
comparison
equal deleted inserted replaced
179:d6c0c5dca9b9 180:fdb961f27ae9
28 from profile_manager import ProfileManager 28 from profile_manager import ProfileManager
29 from contact_list import ContactList 29 from contact_list import ContactList
30 from chat import Chat 30 from chat import Chat
31 from gateways import GatewaysManager 31 from gateways import GatewaysManager
32 import custom_widgets 32 import custom_widgets
33 import pdb
34 import logging 33 import logging
35 from logging import debug, info, error 34 from logging import debug, info, error
36 import sys, os 35 import sys, os
37 from tools.jid import JID 36 from tools.jid import JID
38 from xmlui import XMLUI 37 from xmlui import XMLUI
38 from progress import Progress
39 39
40 40
41 ### logging configuration FIXME: put this elsewhere ### 41 ### logging configuration FIXME: put this elsewhere ###
42 logging.basicConfig(level=logging.CRITICAL, #TODO: configure it to put messages in a log file 42 logging.basicConfig(level=logging.CRITICAL, #TODO: configure it to put messages in a log file
43 format='%(message)s') 43 format='%(message)s')
57 ('menubar', 'light gray,bold', 'dark red'), 57 ('menubar', 'light gray,bold', 'dark red'),
58 ('selected_menu', 'light gray,bold', 'dark green'), 58 ('selected_menu', 'light gray,bold', 'dark green'),
59 ('menuitem', 'light gray,bold', 'dark red'), 59 ('menuitem', 'light gray,bold', 'dark red'),
60 ('menuitem_focus', 'light gray,bold', 'dark green'), 60 ('menuitem_focus', 'light gray,bold', 'dark green'),
61 ('notifs', 'black,bold', 'yellow'), 61 ('notifs', 'black,bold', 'yellow'),
62 ('notifs_focus', 'dark red', 'yellow'),
62 ('card_neutral', 'dark gray', 'white', 'standout,underline'), 63 ('card_neutral', 'dark gray', 'white', 'standout,underline'),
63 ('card_neutral_selected', 'dark gray', 'dark green', 'standout,underline'), 64 ('card_neutral_selected', 'dark gray', 'dark green', 'standout,underline'),
64 ('card_special', 'brown', 'white', 'standout,underline'), 65 ('card_special', 'brown', 'white', 'standout,underline'),
65 ('card_special_selected', 'brown', 'dark green', 'standout,underline'), 66 ('card_special_selected', 'brown', 'dark green', 'standout,underline'),
66 ('card_red', 'dark red', 'white', 'standout,underline'), 67 ('card_red', 'dark red', 'white', 'standout,underline'),
67 ('card_red_selected', 'dark red', 'dark green', 'standout,underline'), 68 ('card_red_selected', 'dark red', 'dark green', 'standout,underline'),
68 ('card_black', 'black', 'white', 'standout,underline'), 69 ('card_black', 'black', 'white', 'standout,underline'),
69 ('card_black_selected', 'black', 'dark green', 'standout,underline'), 70 ('card_black_selected', 'black', 'dark green', 'standout,underline'),
71 ('directory', 'dark cyan, bold', 'default'),
72 ('directory_focus', 'dark cyan, bold', 'dark green'),
73 ('separator', 'brown', 'default'),
74 ('warning', 'light red', 'default'),
75 ('progress_normal', 'default', 'black'),
76 ('progress_complete', 'default', 'light red'),
70 ] 77 ]
71 78
72 class ChatList(QuickChatList): 79 class ChatList(QuickChatList):
73 """This class manage the list of chat windows""" 80 """This class manage the list of chat windows"""
74 81
90 97
91 ##misc setup## 98 ##misc setup##
92 self.chat_wins=ChatList(self) 99 self.chat_wins=ChatList(self)
93 self.notBar = custom_widgets.NotificationBar() 100 self.notBar = custom_widgets.NotificationBar()
94 urwid.connect_signal(self.notBar,'change',self.onNotification) 101 urwid.connect_signal(self.notBar,'change',self.onNotification)
102 self.progress_wid = Progress(self)
103 urwid.connect_signal(self.notBar.progress,'click',lambda x:self.addWindow(self.progress_wid))
95 self.__saved_overlay = None 104 self.__saved_overlay = None
96 105
97 def debug(self): 106 def debug(self):
98 """convenient method to reset screen and launch pdb""" 107 """convenient method to reset screen and launch p(u)db"""
99 import os 108 try:
100 os.system('reset') 109 import pudb
101 print 'Entered debug mode' 110 pudb.set_trace()
102 pdb.set_trace() 111 except:
103 112 import os,pdb
104 def write_log(self, log, file_name='/tmp/primitivus_log'): 113 os.system('reset')
114 print 'Entered debug mode'
115 pdb.set_trace()
116
117 def writeLog(self, log, file_name='/tmp/primitivus_log'):
105 """method to write log in a temporary file, useful for debugging""" 118 """method to write log in a temporary file, useful for debugging"""
106 with open(file_name, 'a') as f: 119 with open(file_name, 'a') as f:
107 f.write(log+"\n") 120 f.write(log+"\n")
108 121
109 def redraw(self): 122 def redraw(self):
259 assert(len(self.center_part.widget_list)<=2) 272 assert(len(self.center_part.widget_list)<=2)
260 wid_idx = len(self.center_part.widget_list)-1 273 wid_idx = len(self.center_part.widget_list)-1
261 self.center_part.widget_list[wid_idx] = urwid.Filler(urwid.Text('')) 274 self.center_part.widget_list[wid_idx] = urwid.Filler(urwid.Text(''))
262 self.center_part.set_focus(0) 275 self.center_part.set_focus(0)
263 self.redraw() 276 self.redraw()
264 277
278 def addProgress (self, id, message):
279 """Follow a SàT progress bar
280 @param id: SàT id of the progression
281 @param message: message to show to identify the progression"""
282 self.progress_wid.addProgress(id, message)
283
284 def setProgress(self, percentage):
285 """Set the progression shown in notification bar"""
286 self.notBar.setProgress(percentage)
287
265 def contactSelected(self, contact_list): 288 def contactSelected(self, contact_list):
266 contact = contact_list.get_contact() 289 contact = contact_list.get_contact()
267 if contact: 290 if contact:
268 assert(len(self.center_part.widget_list)==2) 291 assert(len(self.center_part.widget_list)==2)
269 self.center_part.widget_list[1] = self.chat_wins[contact] 292 self.center_part.widget_list[1] = self.chat_wins[contact]