Mercurial > libervia-backend
annotate frontends/src/wix/main_window.py @ 1162:b32800b9793e
primitivus: SIGINT is now ignored, APP_QUIT key/menu or :quit command must be used to quit Primitivus
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 04 Sep 2014 19:05:57 +0200 |
parents | 75025461141f |
children | 69ffe61240eb |
rev | line source |
---|---|
0 | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | |
3 | |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
4 # wix: a SAT frontend |
811 | 5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Jérôme Poisson (goffi@goffi.org) |
0 | 6 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
10 # (at your option) any later version. |
0 | 11 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
15 # GNU Affero General Public License for more details. |
0 | 16 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
0 | 19 |
20 | |
771 | 21 from sat.core.i18n import _ |
1093
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
22 from sat_frontends.wix.constants import Const as C |
227 | 23 from sat_frontends.quick_frontend.quick_chat_list import QuickChatList |
24 from sat_frontends.quick_frontend.quick_app import QuickApp | |
0 | 25 import wx |
227 | 26 from sat_frontends.wix.contact_list import ContactList |
27 from sat_frontends.wix.chat import Chat | |
1106
e2e1e27a3680
frontends: XMLUI refactoring + dialogs:
Goffi <goffi@goffi.org>
parents:
1103
diff
changeset
|
28 from sat_frontends.wix import xmlui |
227 | 29 from sat_frontends.wix.profile import Profile |
30 from sat_frontends.wix.profile_manager import ProfileManager | |
0 | 31 import os.path |
1139
75025461141f
move sat.tools.jid to sat_frontends.tools.jid
souliane <souliane@mailoo.org>
parents:
1106
diff
changeset
|
32 from sat_frontends.tools.jid import JID |
1011 | 33 from sat.core.log import getLogger |
34 log = getLogger(__name__) | |
736
6246eb6d64a0
frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents:
688
diff
changeset
|
35 from sat_frontends.wix.constants import Const |
0 | 36 |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
42
diff
changeset
|
37 idCONNECT,\ |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
42
diff
changeset
|
38 idDISCONNECT,\ |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
42
diff
changeset
|
39 idEXIT,\ |
191 | 40 idABOUT,\ |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
42
diff
changeset
|
41 idPARAM,\ |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
42
diff
changeset
|
42 idSHOW_PROFILE,\ |
72 | 43 idJOIN_ROOM,\ |
987
3a96920c07b7
core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
939
diff
changeset
|
44 = range(7) |
0 | 45 |
46 class ChatList(QuickChatList): | |
47 """This class manage the list of chat windows""" | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
48 |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
42
diff
changeset
|
49 def createChat(self, target): |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
42
diff
changeset
|
50 return Chat(target, self.host) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
51 |
0 | 52 class MainWindow(wx.Frame, QuickApp): |
53 """main app window""" | |
54 | |
55 def __init__(self): | |
366
0806a65a5fa9
wix: updated paths to use media_dir
Goffi <goffi@goffi.org>
parents:
228
diff
changeset
|
56 QuickApp.__init__(self) |
796
46aa5ada61bf
core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
777
diff
changeset
|
57 wx.Frame.__init__(self,None, title="SàT Wix", size=(350,500)) |
0 | 58 |
68 | 59 #sizer |
60 self.sizer = wx.BoxSizer(wx.VERTICAL) | |
61 self.SetSizer(self.sizer) | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
62 |
0 | 63 #Frame elements |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
491
diff
changeset
|
64 self.contact_list = ContactList(self, self) |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
491
diff
changeset
|
65 self.contact_list.registerActivatedCB(self.onContactActivated) |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
491
diff
changeset
|
66 self.contact_list.Hide() |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
491
diff
changeset
|
67 self.sizer.Add(self.contact_list, 1, flag=wx.EXPAND) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
68 |
0 | 69 self.chat_wins=ChatList(self) |
70 self.CreateStatusBar() | |
71 | |
72 #ToolBar | |
73 self.tools=self.CreateToolBar() | |
736
6246eb6d64a0
frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents:
688
diff
changeset
|
74 self.statusBox = wx.ComboBox(self.tools, -1, "Online", choices=[status[1] for status in Const.PRESENCE], |
0 | 75 style=wx.CB_DROPDOWN | wx.CB_READONLY) |
76 self.tools.AddControl(self.statusBox) | |
77 self.tools.AddSeparator() | |
737
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
78 self.statusTxt = wx.TextCtrl(self.tools, -1, style=wx.TE_PROCESS_ENTER) |
0 | 79 self.tools.AddControl(self.statusTxt) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
80 self.Bind(wx.EVT_COMBOBOX, self.onStatusChange, self.statusBox) |
0 | 81 self.Bind(wx.EVT_TEXT_ENTER, self.onStatusChange, self.statusTxt) |
82 self.tools.Disable() | |
366
0806a65a5fa9
wix: updated paths to use media_dir
Goffi <goffi@goffi.org>
parents:
228
diff
changeset
|
83 |
11 | 84 #tray icon |
679
59c9a7ff903d
wix, misc: use picture of dimension 32x32 for tray icon + better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
653
diff
changeset
|
85 ticon = wx.Icon(os.path.join(self.media_dir, 'icons/crystal/32/tray_icon.xpm'), wx.BITMAP_TYPE_XPM) |
11 | 86 self.tray_icon = wx.TaskBarIcon() |
70 | 87 self.tray_icon.SetIcon(ticon, _("Wix jabber client")) |
11 | 88 wx.EVT_TASKBAR_LEFT_UP(self.tray_icon, self.onTrayClick) |
89 | |
0 | 90 |
91 #events | |
92 self.Bind(wx.EVT_CLOSE, self.onClose, self) | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
93 |
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
94 |
68 | 95 #profile panel |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
96 self.profile_pan = ProfileManager(self) |
68 | 97 self.sizer.Add(self.profile_pan, 1, flag=wx.EXPAND) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
98 |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
105
diff
changeset
|
99 self.postInit() |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
105
diff
changeset
|
100 |
0 | 101 self.Show() |
102 | |
1035
c4c14480715a
wix: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents:
1011
diff
changeset
|
103 def plug_profile_1(self, profile_key='@DEFAULT@'): |
68 | 104 """Hide profile panel then plug profile""" |
1011 | 105 log.debug (_('plugin profile %s' % profile_key)) |
68 | 106 self.profile_pan.Hide() |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
491
diff
changeset
|
107 self.contact_list.Show() |
68 | 108 self.sizer.Layout() |
1035
c4c14480715a
wix: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents:
1011
diff
changeset
|
109 super(MainWindow, self).plug_profile_1(profile_key) |
1093
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
110 #menus |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
111 self.createMenus() |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
112 |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
113 def addMenus(self, menubar, type_, menu_data=None): |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
114 """Add cached menus to instance |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
115 @param menu: wx.MenuBar instance |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
116 @param type_: menu type like is sat.core.sat_main.importMenu |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
117 @param menu_data: data to send with these menus |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
118 |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
119 """ |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
120 menus = self.profiles[self.profile]['menus'].get(type_,[]) |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
121 for id_, path, path_i18n in menus: |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
122 if len(path) != 2: |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
123 raise NotImplementedError("Menu with a path != 2 are not implemented yet") |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
124 category = path_i18n[0] # TODO: manage path with more than 2 levels |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
125 name = path_i18n[1] |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
126 menu_idx = menubar.FindMenu(category) |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
127 current_menu = None |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
128 if menu_idx == wx.NOT_FOUND: |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
129 #the menu is new, we create it |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
130 current_menu = wx.Menu() |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
131 menubar.Append(current_menu, category) |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
132 else: |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
133 current_menu = menubar.GetMenu(menu_idx) |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
134 assert(current_menu != None) |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
135 item_id = wx.NewId() |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
136 help_string = self.bridge.getMenuHelp(id_, '') |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
137 current_menu.Append(item_id, name, help=help_string) |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
138 #now we register the event |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
139 def event_answer(e, id_=id_): |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
140 self.launchAction(id_, menu_data, profile_key = self.profile) |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
141 |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
142 wx.EVT_MENU(menubar.Parent, item_id, event_answer) |
68 | 143 |
0 | 144 def createMenus(self): |
1011 | 145 log.info(_("Creating menus")) |
0 | 146 connectMenu = wx.Menu() |
70 | 147 connectMenu.Append(idCONNECT, _("&Connect CTRL-c"),_(" Connect to the server")) |
148 connectMenu.Append(idDISCONNECT, _("&Disconnect CTRL-d"),_(" Disconnect from the server")) | |
149 connectMenu.Append(idPARAM,_("&Parameters"),_(" Configure the program")) | |
0 | 150 connectMenu.AppendSeparator() |
736
6246eb6d64a0
frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents:
688
diff
changeset
|
151 connectMenu.Append(idABOUT, _("A&bout"), _(" About %s") % Const.APP_NAME) |
70 | 152 connectMenu.Append(idEXIT,_("E&xit"),_(" Terminate the program")) |
0 | 153 contactMenu = wx.Menu() |
25
53e921c8a357
new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
154 communicationMenu = wx.Menu() |
72 | 155 communicationMenu.Append(idJOIN_ROOM, _("&Join Room"),_(" Join a Multi-User Chat room")) |
68 | 156 self.menuBar = wx.MenuBar() |
70 | 157 self.menuBar.Append(connectMenu,_("&General")) |
158 self.menuBar.Append(contactMenu,_("&Contacts")) | |
159 self.menuBar.Append(communicationMenu,_("&Communication")) | |
68 | 160 self.SetMenuBar(self.menuBar) |
0 | 161 |
101 | 162 #additionals menus |
163 #FIXME: do this in a more generic way (in quickapp) | |
1093
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
164 self.addMenus(self.menuBar, C.MENU_GLOBAL) |
101 | 165 |
987
3a96920c07b7
core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
939
diff
changeset
|
166 # menu items that should be displayed after the automatically added ones |
3a96920c07b7
core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
939
diff
changeset
|
167 contactMenu.AppendSeparator() |
3a96920c07b7
core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
souliane <souliane@mailoo.org>
parents:
939
diff
changeset
|
168 contactMenu.Append(idSHOW_PROFILE, _("&Show profile"), _(" Show contact's profile")) |
101 | 169 |
0 | 170 #events |
171 wx.EVT_MENU(self, idCONNECT, self.onConnectRequest) | |
1 | 172 wx.EVT_MENU(self, idDISCONNECT, self.onDisconnectRequest) |
0 | 173 wx.EVT_MENU(self, idPARAM, self.onParam) |
191 | 174 wx.EVT_MENU(self, idABOUT, self.onAbout) |
0 | 175 wx.EVT_MENU(self, idEXIT, self.onExit) |
42
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
176 wx.EVT_MENU(self, idSHOW_PROFILE, self.onShowProfile) |
72 | 177 wx.EVT_MENU(self, idJOIN_ROOM, self.onJoinRoom) |
0 | 178 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
179 def newMessageHandler(self, from_jid, to_jid, msg, _type, extra, profile): |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
180 QuickApp.newMessageHandler(self, from_jid, to_jid, msg, _type, extra, profile) |
0 | 181 |
182 def showAlert(self, message): | |
183 # TODO: place this in a separate class | |
184 popup=wx.PopupWindow(self) | |
185 ### following code come from wxpython demo | |
186 popup.SetBackgroundColour("CADET BLUE") | |
187 st = wx.StaticText(popup, -1, message, pos=(10,10)) | |
188 sz = st.GetBestSize() | |
189 popup.SetSize( (sz.width+20, sz.height+20) ) | |
190 x=(wx.DisplaySize()[0]-popup.GetSize()[0])/2 | |
191 popup.SetPosition((x,0)) | |
192 popup.Show() | |
193 wx.CallLater(5000,popup.Destroy) | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
194 |
1106
e2e1e27a3680
frontends: XMLUI refactoring + dialogs:
Goffi <goffi@goffi.org>
parents:
1103
diff
changeset
|
195 def showDialog(self, message, title="", type_="info", answer_cb = None, answer_data = None): |
e2e1e27a3680
frontends: XMLUI refactoring + dialogs:
Goffi <goffi@goffi.org>
parents:
1103
diff
changeset
|
196 if type_ == 'info': |
0 | 197 flags = wx.OK | wx.ICON_INFORMATION |
1106
e2e1e27a3680
frontends: XMLUI refactoring + dialogs:
Goffi <goffi@goffi.org>
parents:
1103
diff
changeset
|
198 elif type_ == 'error': |
0 | 199 flags = wx.OK | wx.ICON_ERROR |
1106
e2e1e27a3680
frontends: XMLUI refactoring + dialogs:
Goffi <goffi@goffi.org>
parents:
1103
diff
changeset
|
200 elif type_ == 'yes/no': |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
42
diff
changeset
|
201 flags = wx.YES_NO | wx.ICON_QUESTION |
0 | 202 else: |
203 flags = wx.OK | wx.ICON_INFORMATION | |
1106
e2e1e27a3680
frontends: XMLUI refactoring + dialogs:
Goffi <goffi@goffi.org>
parents:
1103
diff
changeset
|
204 log.error(_('unmanaged dialog type: %s'), type_) |
0 | 205 dlg = wx.MessageDialog(self, message, title, flags) |
206 answer = dlg.ShowModal() | |
207 dlg.Destroy() | |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
180
diff
changeset
|
208 if answer_cb: |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
180
diff
changeset
|
209 data = [answer_data] if answer_data else [] |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
180
diff
changeset
|
210 answer_cb(True if (answer == wx.ID_YES or answer == wx.ID_OK) else False, *data) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
211 |
737
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
212 def setStatusOnline(self, online=True, show="", statuses={}): |
0 | 213 """enable/disable controls, must be called when local user online status change""" |
214 if online: | |
736
6246eb6d64a0
frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents:
688
diff
changeset
|
215 self.SetStatusText(Const.msgONLINE) |
0 | 216 self.tools.Enable() |
737
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
217 try: |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
218 presence = [x for x in Const.PRESENCE if x[0] == show][0][1] |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
219 self.statusBox.SetValue(presence) |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
220 except (TypeError, IndexError): |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
221 pass |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
222 try: |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
223 self.statusTxt.SetValue(statuses['default']) |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
224 except (TypeError, KeyError): |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
225 pass |
0 | 226 else: |
736
6246eb6d64a0
frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents:
688
diff
changeset
|
227 self.SetStatusText(Const.msgOFFLINE) |
0 | 228 self.tools.Disable() |
229 return | |
230 | |
759
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
231 def launchAction(self, callback_id, data=None, profile_key="@NONE@"): |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
232 """ Launch a dynamic action |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
233 @param callback_id: id of the action to launch |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
234 @param data: data needed only for certain actions |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
235 @param profile_key: %(doc_profile_key)s |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
236 |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
237 """ |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
238 if data is None: |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
239 data = dict() |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
240 def action_cb(data): |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
241 if not data: |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
242 # action was a one shot, nothing to do |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
243 pass |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
244 elif "xmlui" in data: |
1011 | 245 log.debug (_("XML user interface received")) |
1106
e2e1e27a3680
frontends: XMLUI refactoring + dialogs:
Goffi <goffi@goffi.org>
parents:
1103
diff
changeset
|
246 ui = xmlui.create(self, xml_data = data['xmlui']) |
e2e1e27a3680
frontends: XMLUI refactoring + dialogs:
Goffi <goffi@goffi.org>
parents:
1103
diff
changeset
|
247 ui.show() |
1035
c4c14480715a
wix: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents:
1011
diff
changeset
|
248 elif "authenticated_profile" in data: |
c4c14480715a
wix: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents:
1011
diff
changeset
|
249 assert("caller" in data) |
c4c14480715a
wix: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents:
1011
diff
changeset
|
250 if data["caller"] == "profile_manager": |
c4c14480715a
wix: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents:
1011
diff
changeset
|
251 assert(self.profile_pan.IsShown()) |
c4c14480715a
wix: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents:
1011
diff
changeset
|
252 self.profile_pan.getXMPPParams(data['authenticated_profile']) |
c4c14480715a
wix: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents:
1011
diff
changeset
|
253 elif data["caller"] == "plug_profile": |
c4c14480715a
wix: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents:
1011
diff
changeset
|
254 self.plug_profile_1(data['authenticated_profile']) |
c4c14480715a
wix: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents:
1011
diff
changeset
|
255 else: |
c4c14480715a
wix: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents:
1011
diff
changeset
|
256 raise NotImplementedError |
759
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
257 else: |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
258 dlg = wx.MessageDialog(self, _(u"Unmanaged action result"), |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
259 _('Error'), |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
260 wx.OK | wx.ICON_ERROR |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
261 ) |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
262 dlg.ShowModal() |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
263 dlg.Destroy() |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
264 def action_eb(failure): |
1063
6ec513ad92c2
frontends: async failures are more detailed (full class name + error message)
souliane <souliane@mailoo.org>
parents:
1060
diff
changeset
|
265 dlg = wx.MessageDialog(self, failure.message, |
6ec513ad92c2
frontends: async failures are more detailed (full class name + error message)
souliane <souliane@mailoo.org>
parents:
1060
diff
changeset
|
266 failure.fullname, |
759
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
267 wx.OK | wx.ICON_ERROR |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
268 ) |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
269 dlg.ShowModal() |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
270 dlg.Destroy() |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
271 |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
272 self.bridge.launchAction(callback_id, data, profile_key, callback=action_cb, errback=action_eb) |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
273 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
274 def askConfirmationHandler(self, confirmation_id, confirmation_type, data, profile): |
0 | 275 #TODO: refactor this in QuickApp |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
276 if not self.check_profile(profile): |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
277 return |
1011 | 278 log.debug (_("Confirmation asked")) |
0 | 279 answer_data={} |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
280 if confirmation_type == "FILE_TRANSFER": |
1011 | 281 log.debug (_("File transfer confirmation asked")) |
70 | 282 dlg = wx.MessageDialog(self, _("The contact %(jid)s wants to send you the file %(filename)s\nDo you accept ?") % {'jid':data["from"], 'filename':data["filename"]}, |
283 _('File Request'), | |
0 | 284 wx.YES_NO | wx.ICON_QUESTION |
285 ) | |
286 answer=dlg.ShowModal() | |
287 if answer==wx.ID_YES: | |
70 | 288 filename = wx.FileSelector(_("Where do you want to save the file ?"), flags = wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) |
0 | 289 if filename: |
290 answer_data["dest_path"] = filename | |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
291 self.bridge.confirmationAnswer(confirmation_id, True, answer_data, profile) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
292 self.waitProgress(confirmation_id, _("File Transfer"), _("Copying %s") % os.path.basename(filename), profile) |
0 | 293 else: |
294 answer = wx.ID_NO | |
295 if answer==wx.ID_NO: | |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
296 self.bridge.confirmationAnswer(confirmation_id, False, answer_data, profile) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
297 |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
298 dlg.Destroy() |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
299 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
300 elif confirmation_type == "YES/NO": |
1011 | 301 log.debug (_("Yes/No confirmation asked")) |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
302 dlg = wx.MessageDialog(self, data["message"], |
70 | 303 _('Confirmation'), |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
304 wx.YES_NO | wx.ICON_QUESTION |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
305 ) |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
306 answer=dlg.ShowModal() |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
307 if answer==wx.ID_YES: |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
308 self.bridge.confirmationAnswer(confirmation_id, True, {}, profile) |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
309 if answer==wx.ID_NO: |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
310 self.bridge.confirmationAnswer(confirmation_id, False, {}, profile) |
0 | 311 |
312 dlg.Destroy() | |
313 | |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
314 def actionResultHandler(self, type_, id_, data, profile): |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
315 if not self.check_profile(profile): |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
316 return |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
317 log.debug (_("actionResult: type_ = [%(type_)s] id_ = [%(id_)s] data = [%(data)s]") % {'type_':type_, 'id_':id_, 'data':data}) |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
318 if not id_ in self.current_action_ids: |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
319 log.debug (_('unknown id_, ignoring')) |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
42
diff
changeset
|
320 return |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
321 if type_ == "SUPPRESS": |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
322 self.current_action_ids.remove(id_) |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
323 elif type_ == "SUCCESS": |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
324 self.current_action_ids.remove(id_) |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
325 dlg = wx.MessageDialog(self, data["message"], |
70 | 326 _('Success'), |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
327 wx.OK | wx.ICON_INFORMATION |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
328 ) |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
329 dlg.ShowModal() |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
330 dlg.Destroy() |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
331 elif type_ == "ERROR": |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
332 self.current_action_ids.remove(id_) |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
333 dlg = wx.MessageDialog(self, data["message"], |
70 | 334 _('Error'), |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
335 wx.OK | wx.ICON_ERROR |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
336 ) |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
337 dlg.ShowModal() |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
338 dlg.Destroy() |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
339 elif type_ == "XMLUI": |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
340 self.current_action_ids.remove(id_) |
1011 | 341 log.debug (_("XML user interface received")) |
91 | 342 misc = {} |
343 #FIXME FIXME FIXME: must clean all this crap ! | |
344 title = _('Form') | |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
345 if data['type_'] == _('registration'): |
103 | 346 title = _('Registration') |
91 | 347 misc['target'] = data['target'] |
348 misc['action_back'] = self.bridge.gatewayRegister | |
1106
e2e1e27a3680
frontends: XMLUI refactoring + dialogs:
Goffi <goffi@goffi.org>
parents:
1103
diff
changeset
|
349 xmlui.create(self, title=title, xml_data = data['xml'], misc = misc) |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
350 elif type_ == "RESULT": |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
351 self.current_action_ids.remove(id_) |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
352 if self.current_action_ids_cb.has_key(id_): |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
353 callback = self.current_action_ids_cb[id_] |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
354 del self.current_action_ids_cb[id_] |
42
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
355 callback(data) |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
356 elif type_ == "DICT_DICT": |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
357 self.current_action_ids.remove(id_) |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
358 if self.current_action_ids_cb.has_key(id_): |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
359 callback = self.current_action_ids_cb[id_] |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
360 del self.current_action_ids_cb[id_] |
42
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
361 callback(data) |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
362 else: |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
363 log.error (_("FIXME FIXME FIXME: type_ [%s] not implemented") % type_) |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
364 raise NotImplementedError |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
365 |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
366 |
0 | 367 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
368 def progressCB(self, progress_id, title, message, profile): |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
369 data = self.bridge.getProgress(progress_id, profile) |
0 | 370 if data: |
371 if not self.pbar: | |
372 #first answer, we must construct the bar | |
180
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
373 self.pbar = wx.ProgressDialog(title, message, float(data['size']), None, |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
374 wx.PD_SMOOTH | wx.PD_ELAPSED_TIME | wx.PD_ESTIMATED_TIME | wx.PD_REMAINING_TIME) |
180
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
375 self.pbar.finish_value = float(data['size']) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
376 |
0 | 377 self.pbar.Update(int(data['position'])) |
378 elif self.pbar: | |
379 self.pbar.Update(self.pbar.finish_value) | |
380 return | |
381 | |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
382 wx.CallLater(10, self.progressCB, progress_id, title, message, profile) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
383 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
384 def waitProgress (self, progress_id, title, message, profile): |
0 | 385 self.pbar = None |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
386 wx.CallLater(10, self.progressCB, progress_id, title, message, profile) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
387 |
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
388 |
0 | 389 |
390 ### events ### | |
391 | |
392 def onContactActivated(self, jid): | |
1011 | 393 log.debug (_("onContactActivated: %s"), jid) |
688
f7878ad3c846
tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
394 if self.chat_wins[jid.bare].IsShown(): |
f7878ad3c846
tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
395 self.chat_wins[jid.bare].Hide() |
0 | 396 else: |
688
f7878ad3c846
tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
397 self.chat_wins[jid.bare].Show() |
0 | 398 |
399 def onConnectRequest(self, e): | |
1060
aa15453ec54d
core (xmpp), stdui (profile_manager), bridge, frontends: raise an exception if the XMPP connection failed instead of sending a signal
souliane <souliane@mailoo.org>
parents:
1059
diff
changeset
|
400 QuickApp.asyncConnect(self, self.profile) |
0 | 401 |
1 | 402 def onDisconnectRequest(self, e): |
68 | 403 self.bridge.disconnect(self.profile) |
1 | 404 |
0 | 405 def __updateStatus(self): |
737
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
406 show = [x for x in Const.PRESENCE if x[1] == self.statusBox.GetValue()][0][0] |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
407 status = self.statusTxt.GetValue() |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
408 self.bridge.setPresence(show=show, statuses={'default': status}, profile_key=self.profile) #FIXME: manage multilingual statuses |
0 | 409 |
410 def onStatusChange(self, e): | |
1011 | 411 log.debug(_("Status change request")) |
0 | 412 self.__updateStatus() |
413 | |
414 def onParam(self, e): | |
1011 | 415 log.debug(_("Param request")) |
796
46aa5ada61bf
core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
777
diff
changeset
|
416 def success(params): |
1106
e2e1e27a3680
frontends: XMLUI refactoring + dialogs:
Goffi <goffi@goffi.org>
parents:
1103
diff
changeset
|
417 xmlui.create(self, xml_data=params, title=_("Configuration")) |
796
46aa5ada61bf
core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
777
diff
changeset
|
418 |
46aa5ada61bf
core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
777
diff
changeset
|
419 def failure(error): |
1063
6ec513ad92c2
frontends: async failures are more detailed (full class name + error message)
souliane <souliane@mailoo.org>
parents:
1060
diff
changeset
|
420 dlg = wx.MessageDialog(self, error.message, |
6ec513ad92c2
frontends: async failures are more detailed (full class name + error message)
souliane <souliane@mailoo.org>
parents:
1060
diff
changeset
|
421 error.fullname, |
796
46aa5ada61bf
core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
777
diff
changeset
|
422 wx.OK | wx.ICON_ERROR |
46aa5ada61bf
core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
777
diff
changeset
|
423 ) |
46aa5ada61bf
core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
777
diff
changeset
|
424 dlg.ShowModal() |
46aa5ada61bf
core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
777
diff
changeset
|
425 dlg.Destroy() |
46aa5ada61bf
core, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
777
diff
changeset
|
426 self.bridge.getParamsUI(app=Const.APP_NAME, profile_key=self.profile, callback=success, errback=failure) |
0 | 427 |
191 | 428 def onAbout(self, e): |
429 about = wx.AboutDialogInfo() | |
736
6246eb6d64a0
frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents:
688
diff
changeset
|
430 about.SetName(Const.APP_NAME) |
191 | 431 about.SetVersion (unicode(self.bridge.getVersion())) |
811 | 432 about.SetCopyright(u"(C) 2009, 2010, 2011, 2012, 2013, 2014 Jérôme Poisson aka Goffi") |
191 | 433 about.SetDescription( _(u"%(name)s is a SàT (Salut à Toi) frontend\n"+ |
736
6246eb6d64a0
frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents:
688
diff
changeset
|
434 u"%(name)s is based on WxPython, and is the standard graphic interface of SàT") % {'name': Const.APP_NAME}) |
191 | 435 about.SetWebSite(("http://www.goffi.org", "Goffi's non-hebdo (french)")) |
436 about.SetDevelopers([ "Goffi (Jérôme Poisson)"]) | |
437 try: | |
736
6246eb6d64a0
frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents:
688
diff
changeset
|
438 with open(Const.LICENCE_PATH, "r") as licence: |
191 | 439 about.SetLicence(''.join(licence.readlines())) |
440 except: | |
441 pass | |
442 | |
443 wx.AboutBox(about) | |
444 | |
0 | 445 def onExit(self, e): |
446 self.Close() | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
447 |
42
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
448 def onShowProfile(self, e): |
1011 | 449 log.debug(_("Show contact's profile request")) |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
491
diff
changeset
|
450 target = self.contact_list.getSelection() |
42
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
451 if not target: |
70 | 452 dlg = wx.MessageDialog(self, _("You haven't selected any contact !"), |
453 _('Error'), | |
42
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
454 wx.OK | wx.ICON_ERROR |
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
455 ) |
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
456 dlg.ShowModal() |
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
457 dlg.Destroy() |
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
458 return |
939 | 459 _id = self.bridge.getCard(target.bare, self.profile) |
491
1e4731f1e1d7
wix: renamed id variable to avoid reserved name
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
460 self.current_action_ids.add(_id) |
1e4731f1e1d7
wix: renamed id variable to avoid reserved name
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
461 self.current_action_ids_cb[_id] = self.onProfileReceived |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
462 |
42
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
463 def onProfileReceived(self, data): |
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
464 """Called when a profile is received""" |
1011 | 465 log.debug (_('Profile received: [%s]') % data) |
939 | 466 Profile(self, data) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
467 |
72 | 468 def onJoinRoom(self, e): |
1011 | 469 log.warning('FIXME: temporary menu, must be improved') |
80
9681f18d06bd
wix: basic dialog to join MUC room, jid node is now displayed in conversations instead of full jid
Goffi <goffi@goffi.org>
parents:
75
diff
changeset
|
470 #TODO: a proper MUC room joining dialog with nickname etc |
9681f18d06bd
wix: basic dialog to join MUC room, jid node is now displayed in conversations instead of full jid
Goffi <goffi@goffi.org>
parents:
75
diff
changeset
|
471 dlg = wx.TextEntryDialog( |
9681f18d06bd
wix: basic dialog to join MUC room, jid node is now displayed in conversations instead of full jid
Goffi <goffi@goffi.org>
parents:
75
diff
changeset
|
472 self, _("Please enter MUC's JID"), |
204 | 473 #_('Entering a MUC room'), 'test@conference.necton2.int') |
474 _('Entering a MUC room'), 'room@muc_service.server.tld') | |
80
9681f18d06bd
wix: basic dialog to join MUC room, jid node is now displayed in conversations instead of full jid
Goffi <goffi@goffi.org>
parents:
75
diff
changeset
|
475 if dlg.ShowModal() == wx.ID_OK: |
9681f18d06bd
wix: basic dialog to join MUC room, jid node is now displayed in conversations instead of full jid
Goffi <goffi@goffi.org>
parents:
75
diff
changeset
|
476 room_jid=JID(dlg.GetValue()) |
9681f18d06bd
wix: basic dialog to join MUC room, jid node is now displayed in conversations instead of full jid
Goffi <goffi@goffi.org>
parents:
75
diff
changeset
|
477 if room_jid.is_valid(): |
405
10b4f577d0c0
MUC update to follow wokkel's MUC branch update
Goffi <goffi@goffi.org>
parents:
391
diff
changeset
|
478 self.bridge.joinMUC(room_jid, self.profiles[self.profile]['whoami'].node, {}, self.profile) |
80
9681f18d06bd
wix: basic dialog to join MUC room, jid node is now displayed in conversations instead of full jid
Goffi <goffi@goffi.org>
parents:
75
diff
changeset
|
479 else: |
1011 | 480 log.error (_("'%s' is an invalid JID !"), room_jid) |
42
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
481 |
0 | 482 def onClose(self, e): |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
483 QuickApp.onExit(self) |
1011 | 484 log.info(_("Exiting...")) |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
485 for win in self.chat_wins: |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
486 self.chat_wins[win].Destroy() |
628
42ee0b0b0a15
wix: fixed application quitting (fix bug 25)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
487 self.tray_icon.Destroy() |
0 | 488 e.Skip() |
11 | 489 |
490 def onTrayClick(self, e): | |
1011 | 491 log.debug(_("Tray Click")) |
11 | 492 if self.IsShown(): |
493 self.Hide() | |
494 else: | |
495 self.Show() | |
496 self.Raise() | |
497 e.Skip() |