Mercurial > libervia-backend
annotate frontends/src/primitivus/primitivus @ 931:3b30e9f83d88
misc: sat stop would not kill all sat instances anymore
author | souliane <souliane@mailoo.org> |
---|---|
date | Sun, 23 Mar 2014 22:44:49 +0100 |
parents | a9401694d2dc |
children | 3a96920c07b7 |
rev | line source |
---|---|
112 | 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:
608
diff
changeset
|
4 # Primitivus: a SAT frontend |
811 | 5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Jérôme Poisson (goffi@goffi.org) |
112 | 6 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
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:
608
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:
608
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:
608
diff
changeset
|
10 # (at your option) any later version. |
112 | 11 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
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:
608
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:
608
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:
608
diff
changeset
|
15 # GNU Affero General Public License for more details. |
112 | 16 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
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:
608
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
112 | 19 |
20 | |
771 | 21 from sat.core.i18n import _ |
112 | 22 import urwid |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
23 from urwid_satext import sat_widgets |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
24 from urwid_satext.files_management import FileDialog |
225
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
25 from sat_frontends.quick_frontend.quick_app import QuickApp |
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
26 from sat_frontends.quick_frontend.quick_chat_list import QuickChatList |
661
d81f55a58c08
primitivus: fixed crash on private messages
Goffi <goffi@goffi.org>
parents:
641
diff
changeset
|
27 from sat_frontends.quick_frontend.quick_utils import getNewPath, unescapePrivate |
225
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
28 from sat_frontends.primitivus.profile_manager import ProfileManager |
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
29 from sat_frontends.primitivus.contact_list import ContactList |
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
30 from sat_frontends.primitivus.chat import Chat |
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
31 from sat_frontends.primitivus.xmlui import XMLUI |
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
32 from sat_frontends.primitivus.progress import Progress |
475
6bb9305e0b9c
frontend: Fix notify import in Primitivus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
459
diff
changeset
|
33 from sat_frontends.primitivus.notify import Notify |
719
56aa0e98c92e
frontends tools: moved src/tools/frontends to frontends/src/tools
souliane <souliane@mailoo.org>
parents:
688
diff
changeset
|
34 from sat_frontends.tools.misc import InputHistory |
736
6246eb6d64a0
frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents:
719
diff
changeset
|
35 from sat_frontends.primitivus.constants import Const |
737
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
36 from sat_frontends.constants import Const as commonConst |
112 | 37 import logging |
38 from logging import debug, info, error | |
225
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
39 from sat.tools.jid import JID |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
40 from os.path import join |
112 | 41 |
42 | |
43 ### logging configuration FIXME: put this elsewhere ### | |
44 logging.basicConfig(level=logging.CRITICAL, #TODO: configure it to put messages in a log file | |
45 format='%(message)s') | |
46 ### | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
47 |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
48 class ChatList(QuickChatList): |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
49 """This class manage the list of chat windows""" |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
50 |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
51 def createChat(self, target): |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
52 return Chat(target, self.host) |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
53 |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
54 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
55 class EditBar(sat_widgets.ModalEdit): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
56 """ |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
57 The modal edit bar where you would enter messages and commands. |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
58 """ |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
59 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
60 def __init__(self, app): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
61 modes = {None: ('NORMAL', u''), |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
62 'i': ('INSERTION', u'> '), |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
63 ':': ('COMMAND', u':')} #XXX: captions *MUST* be unicode |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
64 super(EditBar, self).__init__(modes) |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
65 self.app = app |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
66 self.setCompletionMethod(self._text_completion) |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
67 urwid.connect_signal(self, 'click', self.onTextEntered) |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
68 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
69 def _text_completion(self, text, completion_data, mode): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
70 if mode == 'INSERTION': |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
71 return self._nick_completion(text, completion_data) |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
72 else: |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
73 return text |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
74 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
75 def _nick_completion(self, text, completion_data): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
76 """Completion method which complete pseudo in group chat |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
77 for params, see AdvancedEdit""" |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
78 contact = self.app.contact_list.getContact() ###Based on the fact that there is currently only one contact selectable at once |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
79 if contact: |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
80 chat = self.app.chat_wins[contact] |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
81 if chat.type != "group": |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
82 return text |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
83 space = text.rfind(" ") |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
84 start = text[space+1:] |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
85 nicks = list(chat.occupants) |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
86 nicks.sort() |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
87 try: |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
88 start_idx=nicks.index(completion_data['last_nick'])+1 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
89 if start_idx == len(nicks): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
90 start_idx = 0 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
91 except (KeyError,ValueError): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
92 start_idx = 0 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
93 for idx in range(start_idx,len(nicks)) + range(0,start_idx): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
94 if nicks[idx].lower().startswith(start.lower()): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
95 completion_data['last_nick'] = nicks[idx] |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
96 return text[:space+1] + nicks[idx] + (': ' if space < 0 else '') |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
97 return text |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
98 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
99 def onTextEntered(self, editBar): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
100 """Called when text is entered in the main edit bar""" |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
101 if self.mode == 'INSERTION': |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
102 contact = self.app.contact_list.getContact() ###Based on the fact that there is currently only one contact selectableat once |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
103 if contact: |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
104 chat = self.app.chat_wins[contact] |
776
f89173f44850
frontends: fixed sendMessage calls, sendMessage is now async so callback and errback need to be specified + redraw in PrimivitusApp.notify
Goffi <goffi@goffi.org>
parents:
773
diff
changeset
|
105 self.app.sendMessage(contact, |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
106 editBar.get_edit_text(), |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
107 mess_type = "groupchat" if chat.type == 'group' else "chat", |
776
f89173f44850
frontends: fixed sendMessage calls, sendMessage is now async so callback and errback need to be specified + redraw in PrimivitusApp.notify
Goffi <goffi@goffi.org>
parents:
773
diff
changeset
|
108 errback=lambda failure: self.app.notify(_("Error while sending message (%s)") % unicode(failure)), |
f89173f44850
frontends: fixed sendMessage calls, sendMessage is now async so callback and errback need to be specified + redraw in PrimivitusApp.notify
Goffi <goffi@goffi.org>
parents:
773
diff
changeset
|
109 profile_key=self.app.profile |
f89173f44850
frontends: fixed sendMessage calls, sendMessage is now async so callback and errback need to be specified + redraw in PrimivitusApp.notify
Goffi <goffi@goffi.org>
parents:
773
diff
changeset
|
110 ) |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
111 editBar.set_edit_text('') |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
112 elif self.mode == 'COMMAND': |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
113 self.commandHandler() |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
114 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
115 def commandHandler(self): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
116 #TODO: separate class with auto documentation (with introspection) |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
117 # and completion method |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
118 command = self.get_edit_text() |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
119 if command == 'quit': |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
120 self.app.onExit() |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
121 raise urwid.ExitMainLoop() |
737
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
122 elif command == 'presence': |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
123 self.app.status_bar.onPresenceClick() |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
124 elif command in ['presence %s' % show for show in commonConst.PRESENCE.keys()]: |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
125 self.app.status_bar.onChange(user_data=sat_widgets.ClickableText(commonConst.PRESENCE[command[9:]])) |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
126 elif command == 'status': |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
127 self.app.status_bar.onStatusClick() |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
128 elif command.startswith('status '): |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
129 self.app.status_bar.onChange(user_data=sat_widgets.AdvancedEdit(command[7:])) |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
130 else: |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
131 return |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
132 self.set_edit_text('') |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
133 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
134 def keypress(self, size, key): |
671
4e691a231763
frontend, primitivus: added input history (mode-wise)
souliane <souliane@mailoo.org>
parents:
661
diff
changeset
|
135 """Callback when a key is pressed. Send "composing" states |
4e691a231763
frontend, primitivus: added input history (mode-wise)
souliane <souliane@mailoo.org>
parents:
661
diff
changeset
|
136 and move the index of the temporary history stack.""" |
4e691a231763
frontend, primitivus: added input history (mode-wise)
souliane <souliane@mailoo.org>
parents:
661
diff
changeset
|
137 def history_cb(text): |
4e691a231763
frontend, primitivus: added input history (mode-wise)
souliane <souliane@mailoo.org>
parents:
661
diff
changeset
|
138 self.set_edit_text(text) |
4e691a231763
frontend, primitivus: added input history (mode-wise)
souliane <souliane@mailoo.org>
parents:
661
diff
changeset
|
139 self.set_edit_pos(len(text)) |
4e691a231763
frontend, primitivus: added input history (mode-wise)
souliane <souliane@mailoo.org>
parents:
661
diff
changeset
|
140 |
4e691a231763
frontend, primitivus: added input history (mode-wise)
souliane <souliane@mailoo.org>
parents:
661
diff
changeset
|
141 if key == "esc": |
738
e867f146d49f
primitivus: save the input history when "esc" is pressed
souliane <souliane@mailoo.org>
parents:
737
diff
changeset
|
142 # first save the text to the current mode, then change to NORMAL |
e867f146d49f
primitivus: save the input history when "esc" is pressed
souliane <souliane@mailoo.org>
parents:
737
diff
changeset
|
143 self.app._updateInputHistory(self.get_edit_text(), mode=self.mode) |
671
4e691a231763
frontend, primitivus: added input history (mode-wise)
souliane <souliane@mailoo.org>
parents:
661
diff
changeset
|
144 self.app._updateInputHistory(mode='NORMAL') |
4e691a231763
frontend, primitivus: added input history (mode-wise)
souliane <souliane@mailoo.org>
parents:
661
diff
changeset
|
145 if self._mode == 'NORMAL' and key in self._modes: |
4e691a231763
frontend, primitivus: added input history (mode-wise)
souliane <souliane@mailoo.org>
parents:
661
diff
changeset
|
146 self.app._updateInputHistory(mode=self._modes[key][0]) |
4e691a231763
frontend, primitivus: added input history (mode-wise)
souliane <souliane@mailoo.org>
parents:
661
diff
changeset
|
147 if key == "up": |
4e691a231763
frontend, primitivus: added input history (mode-wise)
souliane <souliane@mailoo.org>
parents:
661
diff
changeset
|
148 self.app._updateInputHistory(self.get_edit_text(), -1, history_cb, self.mode) |
913
d08cbdd566e2
primitivus: EditBar doesn't propagate key pressed anymore if it manage a 'up' or 'down' event (history event)
Goffi <goffi@goffi.org>
parents:
911
diff
changeset
|
149 return |
671
4e691a231763
frontend, primitivus: added input history (mode-wise)
souliane <souliane@mailoo.org>
parents:
661
diff
changeset
|
150 elif key == "down": |
4e691a231763
frontend, primitivus: added input history (mode-wise)
souliane <souliane@mailoo.org>
parents:
661
diff
changeset
|
151 self.app._updateInputHistory(self.get_edit_text(), +1, history_cb, self.mode) |
913
d08cbdd566e2
primitivus: EditBar doesn't propagate key pressed anymore if it manage a 'up' or 'down' event (history event)
Goffi <goffi@goffi.org>
parents:
911
diff
changeset
|
152 return |
671
4e691a231763
frontend, primitivus: added input history (mode-wise)
souliane <souliane@mailoo.org>
parents:
661
diff
changeset
|
153 elif key == "enter": |
4e691a231763
frontend, primitivus: added input history (mode-wise)
souliane <souliane@mailoo.org>
parents:
661
diff
changeset
|
154 self.app._updateInputHistory(self.get_edit_text(), mode=self.mode) |
4e691a231763
frontend, primitivus: added input history (mode-wise)
souliane <souliane@mailoo.org>
parents:
661
diff
changeset
|
155 else: |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
156 contact = self.app.contact_list.getContact() |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
157 if contact: |
661
d81f55a58c08
primitivus: fixed crash on private messages
Goffi <goffi@goffi.org>
parents:
641
diff
changeset
|
158 self.app.bridge.chatStateComposing(unescapePrivate(contact), self.app.profile) |
671
4e691a231763
frontend, primitivus: added input history (mode-wise)
souliane <souliane@mailoo.org>
parents:
661
diff
changeset
|
159 return super(EditBar, self).keypress(size, key) |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
160 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
161 |
671
4e691a231763
frontend, primitivus: added input history (mode-wise)
souliane <souliane@mailoo.org>
parents:
661
diff
changeset
|
162 class PrimitivusApp(QuickApp, InputHistory): |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
163 |
112 | 164 def __init__(self): |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
165 QuickApp.__init__(self) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
166 |
112 | 167 ## main loop setup ## |
117 | 168 self.main_widget = ProfileManager(self) |
737
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
169 self.loop = urwid.MainLoop(self.main_widget, Const.PALETTE, event_loop=urwid.GLibEventLoop(), input_filter=self.inputFilter, unhandled_input=self.keyHandler) |
112 | 170 |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
171 ##misc setup## |
679
59c9a7ff903d
wix, misc: use picture of dimension 32x32 for tray icon + better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
673
diff
changeset
|
172 self.chat_wins = ChatList(self) |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
173 self.notBar = sat_widgets.NotificationBar() |
679
59c9a7ff903d
wix, misc: use picture of dimension 32x32 for tray icon + better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
673
diff
changeset
|
174 urwid.connect_signal(self.notBar, 'change', self.onNotification) |
180
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
175 self.progress_wid = Progress(self) |
679
59c9a7ff903d
wix, misc: use picture of dimension 32x32 for tray icon + better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
673
diff
changeset
|
176 urwid.connect_signal(self.notBar.progress, 'click', lambda x: self.addWindow(self.progress_wid)) |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
177 self.__saved_overlay = None |
380
ede26abf6ca1
primitivus: freedesktop notifications (if available) when somebody is talking to us and we have not focus, or our nick is pinged and we have not focus.
Goffi <goffi@goffi.org>
parents:
276
diff
changeset
|
178 |
507
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
503
diff
changeset
|
179 self.x_notify = Notify() |
524
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
180 |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
181 @property |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
182 def mode(self): |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
183 return self.editBar.mode |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
184 |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
185 @mode.setter |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
186 def mode(self, value): |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
187 self.editBar.mode = value |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
188 |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
189 def modeHint(self, value): |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
190 """Change mode if make sens (i.e.: if there is nothing in the editBar""" |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
191 if not self.editBar.get_edit_text(): |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
192 self.mode = value |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
193 |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
194 def debug(self): |
180
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
195 """convenient method to reset screen and launch p(u)db""" |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
196 try: |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
197 import pudb |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
198 pudb.set_trace() |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
199 except: |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
200 import os,pdb |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
201 os.system('reset') |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
202 print 'Entered debug mode' |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
203 pdb.set_trace() |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
204 |
180
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
205 def writeLog(self, log, file_name='/tmp/primitivus_log'): |
131 | 206 """method to write log in a temporary file, useful for debugging""" |
157
13888bdb72b6
primitivus: button are now working with XMLUI
Goffi <goffi@goffi.org>
parents:
153
diff
changeset
|
207 with open(file_name, 'a') as f: |
13888bdb72b6
primitivus: button are now working with XMLUI
Goffi <goffi@goffi.org>
parents:
153
diff
changeset
|
208 f.write(log+"\n") |
129
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
209 |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
210 def redraw(self): |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
211 """redraw the screen""" |
422
5a18c5f08d9b
Primitivus: Profile Manager: fixed redraw on profile change + use of AdvandedEdit for login field
Goffi <goffi@goffi.org>
parents:
415
diff
changeset
|
212 try: |
5a18c5f08d9b
Primitivus: Profile Manager: fixed redraw on profile change + use of AdvandedEdit for login field
Goffi <goffi@goffi.org>
parents:
415
diff
changeset
|
213 self.loop.draw_screen() |
5a18c5f08d9b
Primitivus: Profile Manager: fixed redraw on profile change + use of AdvandedEdit for login field
Goffi <goffi@goffi.org>
parents:
415
diff
changeset
|
214 except AttributeError: |
5a18c5f08d9b
Primitivus: Profile Manager: fixed redraw on profile change + use of AdvandedEdit for login field
Goffi <goffi@goffi.org>
parents:
415
diff
changeset
|
215 pass |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
216 |
112 | 217 def start(self): |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
218 self.i = 0 |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
219 self.loop.set_alarm_in(0,lambda a,b: self.postInit()) |
112 | 220 self.loop.run() |
221 | |
127
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
222 def inputFilter(self, input, raw): |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
223 if self.__saved_overlay and input != ['ctrl s']: |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
224 return |
127
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
225 for i in input: |
153
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
226 if isinstance(i,tuple): |
127
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
227 if i[0] == 'mouse press': |
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
228 if i[1] == 4: #Mouse wheel up |
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
229 input[input.index(i)] = 'up' |
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
230 if i[1] == 5: #Mouse wheel down |
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
231 input[input.index(i)] = 'down' |
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
232 return input |
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
233 |
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
234 def keyHandler(self, input): |
131 | 235 if input == 'meta m': |
181 | 236 """User want to (un)hide the menu roller""" |
128
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
237 try: |
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
238 if self.main_widget.header == None: |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
239 self.main_widget.header = self.menu_roller |
128
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
240 else: |
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
241 self.main_widget.header = None |
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
242 except AttributeError: |
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
243 pass |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
244 elif input == 'ctrl n': |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
245 """User wants to see next notification""" |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
246 self.notBar.showNext() |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
247 elif input == 'ctrl s': |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
248 """User wants to (un)hide overlay window""" |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
249 if isinstance(self.loop.widget,urwid.Overlay): |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
250 self.__saved_overlay = self.loop.widget |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
251 self.loop.widget = self.main_widget |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
252 else: |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
253 if self.__saved_overlay: |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
254 self.loop.widget = self.__saved_overlay |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
255 self.__saved_overlay = None |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
256 |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
257 elif input == 'ctrl d' and 'D' in self.bridge.getVersion(): #Debug only for dev versions |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
258 self.debug() |
124 | 259 elif input == 'f2': #user wants to (un)hide the contact_list |
260 try: | |
608
ea9aa51234eb
Primitivus: fixed contacts list (un)hidding
Goffi <goffi@goffi.org>
parents:
607
diff
changeset
|
261 for wid, options in self.center_part.contents: |
ea9aa51234eb
Primitivus: fixed contacts list (un)hidding
Goffi <goffi@goffi.org>
parents:
607
diff
changeset
|
262 if self.contact_list is wid: |
ea9aa51234eb
Primitivus: fixed contacts list (un)hidding
Goffi <goffi@goffi.org>
parents:
607
diff
changeset
|
263 self.center_part.contents.remove((wid, options)) |
ea9aa51234eb
Primitivus: fixed contacts list (un)hidding
Goffi <goffi@goffi.org>
parents:
607
diff
changeset
|
264 break |
124 | 265 else: |
607
c123dddaea6b
primitivus: fixed urwid issues with recent urwid versions
Goffi <goffi@goffi.org>
parents:
605
diff
changeset
|
266 self.center_part.contents.insert(0, (self.contact_list, ('weight', 2, False))) |
124 | 267 except AttributeError: |
268 #The main widget is not built (probably in Profile Manager) | |
269 pass | |
129
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
270 elif input == 'window resize': |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
271 width,height = self.loop.screen_size |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
272 if height<=5 and width<=35: |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
273 if not 'save_main_widget' in dir(self): |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
274 self.save_main_widget = self.loop.widget |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
275 self.loop.widget = urwid.Filler(urwid.Text(_("Pleeeeasse, I can't even breathe !"))) |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
276 else: |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
277 if 'save_main_widget' in dir(self): |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
278 self.loop.widget = self.save_main_widget |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
279 del self.save_main_widget |
128
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
280 try: |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
281 return self.menu_roller.checkShortcuts(input) |
128
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
282 except AttributeError: |
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
283 return input |
124 | 284 |
755
e3ad48a2aab2
core, frontends: callMenu is now async and don't use callback_id anymore
Goffi <goffi@goffi.org>
parents:
752
diff
changeset
|
285 def _buildMenuRoller(self): |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
286 menu = sat_widgets.Menu(self.loop) |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
287 general = _("General") |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
288 menu.addMenu(general, _("Connect"), self.onConnectRequest) |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
289 menu.addMenu(general, _("Disconnect"), self.onDisconnectRequest) |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
290 menu.addMenu(general, _("Parameters"), self.onParam) |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
291 menu.addMenu(general, _("About"), self.onAboutRequest) |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
292 menu.addMenu(general, _("Exit"), self.onExitRequest, 'ctrl x') |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
293 contact = _("Contact") |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
294 menu.addMenu(contact, _("Add contact"), self.onAddContactRequest) |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
295 menu.addMenu(contact, _("Remove contact"), self.onRemoveContactRequest) |
131 | 296 communication = _("Communication") |
297 menu.addMenu(communication, _("Join room"), self.onJoinRoomRequest, 'meta j') | |
145
c8b231abfe96
Primitivus: additionnal menus management
Goffi <goffi@goffi.org>
parents:
144
diff
changeset
|
298 #additionals menus |
c8b231abfe96
Primitivus: additionnal menus management
Goffi <goffi@goffi.org>
parents:
144
diff
changeset
|
299 #FIXME: do this in a more generic way (in quickapp) |
773 | 300 add_menus = self.bridge.getMenus('', Const.NO_SECURITY_LIMIT) |
301 def add_menu_cb(callback_id): | |
302 self.launchAction(callback_id, None, profile_key = self.profile) | |
303 for id_, type_, path, path_i18n in add_menus: | |
755
e3ad48a2aab2
core, frontends: callMenu is now async and don't use callback_id anymore
Goffi <goffi@goffi.org>
parents:
752
diff
changeset
|
304 assert(type_=="NORMAL") #TODO: manage other types |
773 | 305 if len(path) != 2: |
306 raise NotImplementedError("Menu with a path != 2 are not implemented yet") | |
797
84214df2d837
primitivus: fixed bad closure, resulting in menus bug.
Goffi <goffi@goffi.org>
parents:
777
diff
changeset
|
307 menu.addMenu(path_i18n[0], path_i18n[1], lambda menu,id_=id_: add_menu_cb(id_)) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
308 |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
309 menu_roller = sat_widgets.MenuRoller([(_('Main menu'),menu)]) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
310 return menu_roller |
131 | 311 |
755
e3ad48a2aab2
core, frontends: callMenu is now async and don't use callback_id anymore
Goffi <goffi@goffi.org>
parents:
752
diff
changeset
|
312 def _buildMainWidget(self): |
679
59c9a7ff903d
wix, misc: use picture of dimension 32x32 for tray icon + better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
673
diff
changeset
|
313 self.contact_list = ContactList(self, on_click=self.contactSelected, on_change=lambda w: self.redraw()) |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
495
diff
changeset
|
314 #self.center_part = urwid.Columns([('weight',2,self.contact_list),('weight',8,Chat('',self))]) |
679
59c9a7ff903d
wix, misc: use picture of dimension 32x32 for tray icon + better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
673
diff
changeset
|
315 self.center_part = urwid.Columns([('weight', 2, self.contact_list), ('weight', 8, urwid.Filler(urwid.Text('')))]) |
524
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
316 |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
317 self.editBar = EditBar(self) |
755
e3ad48a2aab2
core, frontends: callMenu is now async and don't use callback_id anymore
Goffi <goffi@goffi.org>
parents:
752
diff
changeset
|
318 self.menu_roller = self._buildMenuRoller() |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
319 self.main_widget = sat_widgets.FocusFrame(self.center_part, header=self.menu_roller, footer=self.editBar, focus_part='footer') |
118
76055a209ed9
primitivus: added edition zone at the bottom
Goffi <goffi@goffi.org>
parents:
117
diff
changeset
|
320 return self.main_widget |
112 | 321 |
116
7c482ecac0ff
primitivus: basic contact list, connexion now work \o/
Goffi <goffi@goffi.org>
parents:
113
diff
changeset
|
322 def plug_profile(self, profile_key='@DEFAULT@'): |
755
e3ad48a2aab2
core, frontends: callMenu is now async and don't use callback_id anymore
Goffi <goffi@goffi.org>
parents:
752
diff
changeset
|
323 self.loop.widget = self._buildMainWidget() |
415
3348331e0f09
primitivus: fixed screen redraw after plugin profile
Goffi <goffi@goffi.org>
parents:
411
diff
changeset
|
324 self.redraw() |
116
7c482ecac0ff
primitivus: basic contact list, connexion now work \o/
Goffi <goffi@goffi.org>
parents:
113
diff
changeset
|
325 QuickApp.plug_profile(self, profile_key) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
326 |
120 | 327 def removePopUp(self, widget=None): |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
328 "Remove current pop-up, and if there is other in queue, show it" |
117 | 329 self.loop.widget = self.main_widget |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
330 next_popup = self.notBar.getNextPopup() |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
331 if next_popup: |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
332 #we still have popup to show, we display it |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
333 self.showPopUp(next_popup) |
117 | 334 |
737
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
335 def showPopUp(self, pop_up_widget, perc_width=40, perc_height=40, align='center', valign='middle'): |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
336 "Show a pop-up window if possible, else put it in queue" |
687
af0d08a84cc6
primitivus card_game: bug fix and improvement
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
337 if not isinstance(self.loop.widget, urwid.Overlay): |
737
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
338 display_widget = urwid.Overlay(pop_up_widget, self.main_widget, align, ('relative', perc_width), valign, ('relative', perc_height)) |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
339 self.loop.widget = display_widget |
219
782319a64ac6
primitivus, wix: added forgotten profile
Goffi <goffi@goffi.org>
parents:
216
diff
changeset
|
340 self.redraw() |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
341 else: |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
342 self.notBar.addPopUp(pop_up_widget) |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
343 |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
344 def notify(self, message): |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
345 """"Notify message to user via notification bar""" |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
346 self.notBar.addMessage(message) |
776
f89173f44850
frontends: fixed sendMessage calls, sendMessage is now async so callback and errback need to be specified + redraw in PrimivitusApp.notify
Goffi <goffi@goffi.org>
parents:
773
diff
changeset
|
347 self.redraw() |
112 | 348 |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
349 def addWindow(self, widget): |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
350 """Display a window if possible, |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
351 else add it in the notification bar queue |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
352 @param widget: BoxWidget""" |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
353 assert(len(self.center_part.widget_list)<=2) |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
354 wid_idx = len(self.center_part.widget_list)-1 |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
355 self.center_part.widget_list[wid_idx] = widget |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
356 self.menu_roller.removeMenu(_('Chat menu')) |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
495
diff
changeset
|
357 self.contact_list.unselectAll() |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
358 self.redraw() |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
359 |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
360 def removeWindow(self): |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
361 """Remove window showed on the right column""" |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
362 #TODO: to a better Window management than this crappy hack |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
363 assert(len(self.center_part.widget_list)<=2) |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
364 wid_idx = len(self.center_part.widget_list)-1 |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
365 self.center_part.widget_list[wid_idx] = urwid.Filler(urwid.Text('')) |
911
b12706d164d7
primitivus: removed deprecated use of set_focus
Goffi <goffi@goffi.org>
parents:
907
diff
changeset
|
366 self.center_part.focus_position = 0 |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
367 self.redraw() |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
368 |
180
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
369 def addProgress (self, id, message): |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
370 """Follow a SàT progress bar |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
371 @param id: SàT id of the progression |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
372 @param message: message to show to identify the progression""" |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
373 self.progress_wid.addProgress(id, message) |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
374 |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
375 def setProgress(self, percentage): |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
376 """Set the progression shown in notification bar""" |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
377 self.notBar.setProgress(percentage) |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
378 |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
379 def contactSelected(self, contact_list): |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
495
diff
changeset
|
380 contact = contact_list.getContact() |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
381 if contact: |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
382 assert(len(self.center_part.widget_list)==2) |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
383 self.center_part.widget_list[1] = self.chat_wins[contact] |
144
80661755ea8d
Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
137
diff
changeset
|
384 self.menu_roller.addMenu(_('Chat menu'), self.chat_wins[contact].getMenu()) |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
385 |
513
8ee9113d307b
core, quick_frontend, primitivus, wixi, bridge: fixed delayed message timestamp:
Goffi <goffi@goffi.org>
parents:
510
diff
changeset
|
386 def newMessage(self, from_jid, to_jid, msg, _type, extra, profile): |
8ee9113d307b
core, quick_frontend, primitivus, wixi, bridge: fixed delayed message timestamp:
Goffi <goffi@goffi.org>
parents:
510
diff
changeset
|
387 QuickApp.newMessage(self, from_jid, to_jid, msg, _type, extra, profile) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
388 |
688
f7878ad3c846
tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents:
687
diff
changeset
|
389 if not from_jid in self.contact_list and from_jid.bare != self.profiles[profile]['whoami'].bare: |
503
10119c2a9d33
Primitivus: new entities are added to contact list if they send messages + QuickFrontend: names fixes
Goffi <goffi@goffi.org>
parents:
501
diff
changeset
|
390 #XXX: needed to show entities which haven't sent any |
10119c2a9d33
Primitivus: new entities are added to contact list if they send messages + QuickFrontend: names fixes
Goffi <goffi@goffi.org>
parents:
501
diff
changeset
|
391 # presence information and which are not in roster |
10119c2a9d33
Primitivus: new entities are added to contact list if they send messages + QuickFrontend: names fixes
Goffi <goffi@goffi.org>
parents:
501
diff
changeset
|
392 #TODO: put these entities in a "not in roster" list |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
393 self.contact_list.replace(from_jid) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
394 |
688
f7878ad3c846
tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents:
687
diff
changeset
|
395 if JID(self.contact_list.selected).bare != from_jid.bare: |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
396 self.contact_list.putAlert(from_jid) |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
397 |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
398 def _dialogOkCb(self, widget, data): |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
399 self.removePopUp() |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
400 answer_cb = data[0] |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
401 answer_data = [data[1]] if data[1] else [] |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
402 answer_cb(True, *answer_data) |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
403 |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
404 def _dialogCancelCb(self, widget, data): |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
405 self.removePopUp() |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
406 answer_cb = data[0] |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
407 answer_data = [data[1]] if data[1] else [] |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
408 answer_cb(False, *answer_data) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
409 |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
410 |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
411 def showDialog(self, message, title="", type_="info", answer_cb = None, answer_data = None): |
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
412 if type_ == 'info': |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
413 popup = sat_widgets.Alert(unicode(title), unicode(message), ok_cb=answer_cb or self.removePopUp) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
414 elif type_ == 'error': |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
415 popup = sat_widgets.Alert(unicode(title), unicode(message), ok_cb=answer_cb or self.removePopUp) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
416 elif type_ == 'yes/no': |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
417 popup = sat_widgets.ConfirmDialog(unicode(message), |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
418 yes_cb=self._dialogOkCb, yes_value = (answer_cb, answer_data), |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
419 no_cb=self._dialogCancelCb, no_value = (answer_cb, answer_data)) |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
420 else: |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
421 popup = sat_widgets.Alert(unicode(title), unicode(message), ok_cb=answer_cb or self.removePopUp) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
422 error(_('unmanaged dialog type: %s'), type_) |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
423 self.showPopUp(popup) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
424 |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
425 def onNotification(self, notBar): |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
426 """Called when a new notification has been received""" |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
427 if not isinstance(self.main_widget, sat_widgets.FocusFrame): |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
428 #if we are not in the main configuration, we ignore the notifications bar |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
429 return |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
430 if isinstance(self.main_widget.footer,sat_widgets.AdvancedEdit): |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
431 if not self.notBar.canHide(): |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
432 #the notification bar is not visible and has usefull informations, we show it |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
433 pile = urwid.Pile([self.notBar, self.editBar]) |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
434 self.main_widget.footer = pile |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
435 else: |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
436 if not isinstance(self.main_widget.footer, urwid.Pile): |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
437 error(_("INTERNAL ERROR: Unexpected class for main widget's footer")) |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
438 assert(False) |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
439 if self.notBar.canHide(): |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
440 #No notification left, we can hide the bar |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
441 self.main_widget.footer = self.editBar |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
442 |
759
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
443 def launchAction(self, callback_id, data=None, profile_key="@NONE@"): |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
444 """ Launch a dynamic action |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
445 @param callback_id: id of the action to launch |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
446 @param data: data needed only for certain actions |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
447 @param profile_key: %(doc_profile_key)s |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
448 |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
449 """ |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
450 if data is None: |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
451 data = dict() |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
452 def action_cb(data): |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
453 if not data: |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
454 # action was a one shot, nothing to do |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
455 pass |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
456 elif "xmlui" in data: |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
457 ui = XMLUI(self, xml_data = data['xmlui']) |
804
5174657b3378
XMLUI (core, frontends): added JidWidget and DividerWidget + popup type + some bugfixes:
Goffi <goffi@goffi.org>
parents:
799
diff
changeset
|
458 ui.show() |
759
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
459 else: |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
460 self.showPopUp(sat_widgets.Alert(_("Error"), _(u"Unmanaged action result"), ok_cb=self.removePopUp)) |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
461 def action_eb(failure): |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
462 self.showPopUp(sat_widgets.Alert(_("Error"), unicode(failure), ok_cb=self.removePopUp)) |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
463 |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
464 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
|
465 |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
466 def askConfirmation(self, confirmation_id, confirmation_type, data, profile): |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
467 if not self.check_profile(profile): |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
468 return |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
469 answer_data={} |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
470 |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
471 def dir_selected_cb(path): |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
472 dest_path = join(path, data['filename']) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
473 answer_data["dest_path"] = getNewPath(dest_path) |
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
474 self.addProgress(confirmation_id, dest_path) |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
475 accept_cb(None) |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
476 |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
477 def accept_file_transfer_cb(widget): |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
478 self.removePopUp() |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
479 pop_up_widget = FileDialog(dir_selected_cb, refuse_cb, title=_(u"Where do you want to save the file ?"), style=['dir']) |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
480 self.showPopUp(pop_up_widget) |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
481 |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
482 def accept_cb(widget): |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
483 self.removePopUp() |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
484 self.bridge.confirmationAnswer(confirmation_id, True, answer_data, profile) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
485 |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
486 def refuse_cb(widget): |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
487 self.removePopUp() |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
488 self.bridge.confirmationAnswer(confirmation_id, False, answer_data, profile) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
489 |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
490 if confirmation_type == "FILE_TRANSFER": |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
491 pop_up_widget = sat_widgets.ConfirmDialog(_("The contact %(jid)s wants to send you the file %(filename)s\nDo you accept ?") % {'jid':data["from"], 'filename':data["filename"]}, no_cb=refuse_cb, yes_cb=accept_file_transfer_cb) |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
492 self.showPopUp(pop_up_widget) |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
493 |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
494 elif confirmation_type == "YES/NO": |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
495 pop_up_widget = sat_widgets.ConfirmDialog(data["message"], no_cb=refuse_cb, yes_cb=accept_cb) |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
496 self.showPopUp(pop_up_widget) |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
497 |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
498 def actionResult(self, type_, id, data, profile): |
807
be4c5e24dab9
plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents:
804
diff
changeset
|
499 # FIXME: to be removed |
546
9dd297c513b4
primitivus: fixed actionResult call (fix gateways management)
Goffi <goffi@goffi.org>
parents:
542
diff
changeset
|
500 if not self.check_profile(profile): |
9dd297c513b4
primitivus: fixed actionResult call (fix gateways management)
Goffi <goffi@goffi.org>
parents:
542
diff
changeset
|
501 return |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
502 |
153
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
503 if not id in self.current_action_ids: |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
504 debug (_('unknown id, ignoring')) |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
505 return |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
506 if type_ == "SUPPRESS": |
153
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
507 self.current_action_ids.remove(id) |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
508 elif type_ == "XMLUI": |
153
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
509 self.current_action_ids.remove(id) |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
510 debug (_("XML user interface received")) |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
511 misc = {} |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
512 #FIXME FIXME FIXME: must clean all this crap ! |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
513 title = _('Form') |
173 | 514 if data['type'] == 'registration': |
153
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
515 title = _('Registration') |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
516 misc['target'] = data['target'] |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
517 misc['action_back'] = self.bridge.gatewayRegister |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
518 ui = XMLUI(self, title=title, xml_data = data['xml'], misc = misc) |
173 | 519 if data['type'] == 'registration': |
520 ui.show('popup') | |
521 else: | |
522 ui.show('window') | |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
523 elif type_ == "ERROR": |
173 | 524 self.current_action_ids.remove(id) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
525 self.showPopUp(sat_widgets.Alert(_("Error"), unicode(data["message"]), ok_cb=self.removePopUp)) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
526 elif type_ == "RESULT": |
173 | 527 self.current_action_ids.remove(id) |
528 if self.current_action_ids_cb.has_key(id): | |
529 callback = self.current_action_ids_cb[id] | |
530 del self.current_action_ids_cb[id] | |
531 callback(data) | |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
532 elif type_ == "DICT_DICT": |
173 | 533 self.current_action_ids.remove(id) |
534 if self.current_action_ids_cb.has_key(id): | |
535 callback = self.current_action_ids_cb[id] | |
536 del self.current_action_ids_cb[id] | |
537 callback(data) | |
153
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
538 else: |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
539 error (_("FIXME FIXME FIXME: type [%s] not implemented") % type_) |
153
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
540 raise NotImplementedError |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
541 |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
542 ##DIALOGS CALLBACKS## |
120 | 543 def onJoinRoom(self, button, edit): |
544 self.removePopUp() | |
545 room_jid = JID(edit.get_edit_text()) | |
546 if room_jid.is_valid(): | |
405
10b4f577d0c0
MUC update to follow wokkel's MUC branch update
Goffi <goffi@goffi.org>
parents:
382
diff
changeset
|
547 self.bridge.joinMUC(room_jid, self.profiles[self.profile]['whoami'].node, {}, self.profile) |
120 | 548 else: |
549 message = _("'%s' is an invalid JID !") % room_jid | |
550 error (message) | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
551 self.showPopUp(sat_widgets.Alert(_("Error"), message, ok_cb=self.removePopUp)) |
120 | 552 |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
553 def onAddContact(self, button, edit): |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
554 self.removePopUp() |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
555 jid=JID(edit.get_edit_text()) |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
556 if jid.is_valid(): |
688
f7878ad3c846
tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents:
687
diff
changeset
|
557 self.bridge.addContact(jid.bare, profile_key=self.profile) |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
558 else: |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
559 message = _("'%s' is an invalid JID !") % jid |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
560 error (message) |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
561 self.showPopUp(sat_widgets.Alert(_("Error"), message, ok_cb=self.removePopUp)) |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
562 |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
563 def onRemoveContact(self, button): |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
564 self.removePopUp() |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
495
diff
changeset
|
565 info(_("Unsubscribing %s presence"),self.contact_list.getContact()) |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
495
diff
changeset
|
566 self.bridge.delContact(self.contact_list.getContact(), profile_key=self.profile) |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
567 |
173 | 568 #MENU EVENTS# |
131 | 569 def onConnectRequest(self, menu): |
570 self.bridge.connect(self.profile) | |
571 | |
572 def onDisconnectRequest(self, menu): | |
573 self.bridge.disconnect(self.profile) | |
574 | |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
575 def onParam(self, menu): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
422
diff
changeset
|
576 def success(params): |
777
5642939d254e
core, bridge: new method paramsRegisterApp to register frontend's specific parameters
souliane <souliane@mailoo.org>
parents:
776
diff
changeset
|
577 self.addWindow(XMLUI(self, xml_data=params)) |
5642939d254e
core, bridge: new method paramsRegisterApp to register frontend's specific parameters
souliane <souliane@mailoo.org>
parents:
776
diff
changeset
|
578 |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
422
diff
changeset
|
579 def failure(error): |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
422
diff
changeset
|
580 self.showPopUp(sat_widgets.Alert(_("Error"), _("Can't get parameters"), ok_cb=self.removePopUp)) |
777
5642939d254e
core, bridge: new method paramsRegisterApp to register frontend's specific parameters
souliane <souliane@mailoo.org>
parents:
776
diff
changeset
|
581 self.bridge.getParamsUI(app=Const.APP_NAME, profile_key=self.profile, callback=success, errback=failure) |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
582 |
131 | 583 def onExitRequest(self, menu): |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
584 QuickApp.onExit(self) |
131 | 585 raise urwid.ExitMainLoop() |
586 | |
587 def onJoinRoomRequest(self, menu): | |
588 """User wants to join a MUC room""" | |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
589 pop_up_widget = sat_widgets.InputDialog(_("Entering a MUC room"), _("Please enter MUC's JID"), default_txt = 'room@muc_service.server.tld', cancel_cb=self.removePopUp, ok_cb=self.onJoinRoom) |
131 | 590 self.showPopUp(pop_up_widget) |
591 | |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
592 def onAddContactRequest(self, menu): |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
593 pop_up_widget = sat_widgets.InputDialog(_("Adding a contact"), _("Please enter new contact JID"), default_txt = 'name@server.tld', cancel_cb=self.removePopUp, ok_cb=self.onAddContact) |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
594 self.showPopUp(pop_up_widget) |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
595 |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
596 def onRemoveContactRequest(self, menu): |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
495
diff
changeset
|
597 contact = self.contact_list.getContact() |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
598 if not contact: |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
599 self.showPopUp(sat_widgets.Alert(_("Error"), _("You have not selected any contact to delete !"), ok_cb=self.removePopUp)) |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
600 else: |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
601 pop_up_widget = sat_widgets.ConfirmDialog(_("Are you sure you want to delete the contact [%s] ?" % contact), yes_cb=self.onRemoveContact, no_cb=self.removePopUp) |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
602 self.showPopUp(pop_up_widget) |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
603 |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
604 def onAboutRequest(self, menu): |
737
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
605 self.showPopUp(sat_widgets.Alert(_("About"), Const.APP_NAME + " v" + self.bridge.getVersion(), ok_cb=self.removePopUp)) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
606 |
173 | 607 #MISC CALLBACKS# |
608 | |
737
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
609 def setStatusOnline(self, online=True, show="", statuses={}): |
850
30fd34309949
primitivus: displayed presence/status was not updated when the presence is "Online".
souliane <souliane@mailoo.org>
parents:
812
diff
changeset
|
610 if not online or not statuses: |
917
a9401694d2dc
bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
souliane <souliane@mailoo.org>
parents:
913
diff
changeset
|
611 self.status_bar.setPresenceStatus(show if online else 'unavailable', '') |
737
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
612 return |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
613 try: |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
614 self.status_bar.setPresenceStatus(show, statuses['default']) |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
615 except (KeyError, TypeError): |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
616 pass |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
617 |
112 | 618 sat = PrimitivusApp() |
619 sat.start() |