comparison frontends/primitivus/profile_manager.py @ 119:ded2431cea5a

Primitivus: chat window / text sending. Primitivus has now the most basics features \o/ - core: new getVersion method - primitivus: new debug key (C-d), only work if SàT is in dev version (D in version) - quick_app: new post_init method, used for automatique task like auto-plug - primitivus: lists now use genericList (Box) or List (Flow) - primitivus: List now manage correctly its size - primitivus: new FocusFrame widget which manage focus changing with 'tab' - primitivus: advancedEdit now manage 'click' signal - primitivus: contactList now manager 'change' and 'click' signals - primitivus: Chat window now working
author Goffi <goffi@goffi.org>
date Mon, 05 Jul 2010 19:13:36 +0800
parents 1f0fd6f03e2b
children 2240f34f6452
comparison
equal deleted inserted replaced
118:76055a209ed9 119:ded2431cea5a
18 You should have received a copy of the GNU General Public License 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/>. 19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 """ 20 """
21 21
22 import urwid 22 import urwid
23 from custom_widgets import Password,List,InputDialog,ConfirmDialog,Alert 23 from custom_widgets import Password,List,InputDialog,ConfirmDialog,Alert,FocusFrame
24 24
25 25
26 class ProfileManager(urwid.WidgetWrap): 26 class ProfileManager(urwid.WidgetWrap):
27 27
28 def __init__(self, host): 28 def __init__(self, host):
33 33
34 #login & password box must be created before list because of onProfileChange 34 #login & password box must be created before list because of onProfileChange
35 self.login_wid = urwid.Edit(_('Login:'),align='center') 35 self.login_wid = urwid.Edit(_('Login:'),align='center')
36 self.pass_wid = Password(_('Password:'),align='center') 36 self.pass_wid = Password(_('Password:'),align='center')
37 37
38 self.list_profile = List(profiles, style=['single'], align='center', on_state_change=self.onProfileChange) 38 self.list_profile = List(profiles, style=['single'], align='center', on_click=self.onProfileChange)
39 39
40 #toto = urwid.Padding(urwid.Text('toto'), align='center') 40 #toto = urwid.Padding(urwid.Text('toto'), align='center')
41 41
42 #new & delete buttons 42 #new & delete buttons
43 buttons = [urwid.Button(_("New"), self.onNewProfile), 43 buttons = [urwid.Button(_("New"), self.onNewProfile),
72 self.__refillProfiles() 72 self.__refillProfiles()
73 self.list_profile.selectValue(name) 73 self.list_profile.selectValue(name)
74 self.host.removePopUp() 74 self.host.removePopUp()
75 75
76 def deleteProfile(self, button): 76 def deleteProfile(self, button):
77 profile_name = self.list_profile.getValue() 77 profile_name = self.list_profile.getSelectedValue()
78 if profile_name: 78 if profile_name:
79 self.host.bridge.deleteProfile(profile_name) 79 self.host.bridge.deleteProfile(profile_name)
80 self.__refillProfiles() 80 self.__refillProfiles()
81 self.host.removePopUp() 81 self.host.removePopUp()
82 82
84 def onNewProfile(self, e): 84 def onNewProfile(self, e):
85 pop_up_widget = InputDialog(_("New profile"), _("Please enter a new profile name"), cancel_cb=self.cancelDialog, ok_cb=self.newProfile) 85 pop_up_widget = InputDialog(_("New profile"), _("Please enter a new profile name"), cancel_cb=self.cancelDialog, ok_cb=self.newProfile)
86 self.host.showPopUp(pop_up_widget) 86 self.host.showPopUp(pop_up_widget)
87 87
88 def onDeleteProfile(self, e): 88 def onDeleteProfile(self, e):
89 pop_up_widget = ConfirmDialog(_("Are you sure you want to delete the profile %s ?") % self.list_profile.getValue(), no_cb=self.cancelDialog, yes_cb=self.deleteProfile) 89 pop_up_widget = ConfirmDialog(_("Are you sure you want to delete the profile %s ?") % self.list_profile.getSelectedValue(), no_cb=self.cancelDialog, yes_cb=self.deleteProfile)
90 self.host.showPopUp(pop_up_widget) 90 self.host.showPopUp(pop_up_widget)
91 91
92 def onProfileChange(self, list_wid): 92 def onProfileChange(self, list_wid):
93 profile_name = list_wid.getValue() 93 profile_name = list_wid.getSelectedValue()
94 if profile_name: 94 if profile_name:
95 jabberID = self.host.bridge.getParamA("JabberID", "Connection", profile_key=profile_name) 95 jabberID = self.host.bridge.getParamA("JabberID", "Connection", profile_key=profile_name)
96 password = self.host.bridge.getParamA("Password", "Connection", profile_key=profile_name) 96 password = self.host.bridge.getParamA("Password", "Connection", profile_key=profile_name)
97 self.login_wid.set_edit_text(jabberID) 97 self.login_wid.set_edit_text(jabberID)
98 self.pass_wid.set_edit_text(password) 98 self.pass_wid.set_edit_text(password)
99 99
100 def onConnectProfile(self, button): 100 def onConnectProfile(self, button):
101 profile_name = self.list_profile.getValue() 101 profile_name = self.list_profile.getSelectedValue()
102 if not profile_name: 102 if not profile_name:
103 pop_up_widget = Alert(_('No profile selected'), _('You need to create and select a profile before connecting'), ok_cb=self.cancelDialog) 103 pop_up_widget = Alert(_('No profile selected'), _('You need to create and select a profile before connecting'), ok_cb=self.cancelDialog)
104 self.host.showPopUp(pop_up_widget) 104 self.host.showPopUp(pop_up_widget)
105 elif profile_name[0] == '@': 105 elif profile_name[0] == '@':
106 pop_up_widget = Alert(_('Bad profile name'), _("A profile name can't start with a @"), ok_cb=self.cancelDialog) 106 pop_up_widget = Alert(_('Bad profile name'), _("A profile name can't start with a @"), ok_cb=self.cancelDialog)