Mercurial > libervia-backend
annotate sat_frontends/primitivus/base.py @ 3743:54c249ec35ce
core (memory/migration): ignore FTS table when autogenerating script for migration:
SQLite Full-Text Search stable are not associated to Python object and can't be detected
by Alembic. To avoid the generation of unwanted drop commands, they are now ignored when
autogenerating migration scripts.
rel 364
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 22 Mar 2022 17:00:42 +0100 |
parents | b5bed164dce0 |
children | 524856bd7b19 |
rev | line source |
---|---|
3028 | 1 #!/usr/bin/env python3 |
112 | 2 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
3 # Primitivus: a SAT frontend |
1766 | 4 # Copyright (C) 2009-2016 Jérôme Poisson (goffi@goffi.org) |
112 | 5 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
6 # 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
|
7 # 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
|
8 # 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
|
9 # (at your option) any later version. |
112 | 10 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
11 # 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
|
12 # 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
|
13 # 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
|
14 # GNU Affero General Public License for more details. |
112 | 15 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
16 # 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
|
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
112 | 18 |
19 | |
1225
82dabb442e2e
frontends (primitivus): new command :search <pattern>
souliane <souliane@mailoo.org>
parents:
1186
diff
changeset
|
20 from sat.core.i18n import _, D_ |
1010
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
21 from sat_frontends.primitivus.constants import Const as C |
1021
a836b6da2c5c
core (log): moved configuration to core.log_config; this avoid import issues with pyjamas.
Goffi <goffi@goffi.org>
parents:
1019
diff
changeset
|
22 from sat.core import log_config |
a836b6da2c5c
core (log): moved configuration to core.log_config; this avoid import issues with pyjamas.
Goffi <goffi@goffi.org>
parents:
1019
diff
changeset
|
23 log_config.satConfigure(C.LOG_BACKEND_STANDARD, C) |
1010
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
24 from sat.core import log as logging |
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
25 log = logging.getLogger(__name__) |
1949
c5fd304d0976
primitivus: added bracketed_paste option in sat.conf (if set, the bracketed paste mode will be activated on Primitivus start)
Goffi <goffi@goffi.org>
parents:
1948
diff
changeset
|
26 from sat.tools import config as sat_config |
112 | 27 import urwid |
1947
be4b143cf123
primitivus: fixed paste detection/handling:
Goffi <goffi@goffi.org>
parents:
1946
diff
changeset
|
28 from urwid.util import is_wide_char |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
29 from urwid_satext import sat_widgets |
225
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
30 from sat_frontends.quick_frontend.quick_app import QuickApp |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
31 from sat_frontends.quick_frontend import quick_utils |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
32 from sat_frontends.quick_frontend import quick_chat |
225
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
33 from sat_frontends.primitivus.profile_manager import ProfileManager |
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
34 from sat_frontends.primitivus.contact_list import ContactList |
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
35 from sat_frontends.primitivus.chat import Chat |
1106
e2e1e27a3680
frontends: XMLUI refactoring + dialogs:
Goffi <goffi@goffi.org>
parents:
1103
diff
changeset
|
36 from sat_frontends.primitivus import xmlui |
225
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
37 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
|
38 from sat_frontends.primitivus.notify import Notify |
1158
c0f15e52695a
primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
39 from sat_frontends.primitivus.keys import action_key_map as a_key |
1159
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
40 from sat_frontends.primitivus import config |
719
56aa0e98c92e
frontends tools: moved src/tools/frontends to frontends/src/tools
souliane <souliane@mailoo.org>
parents:
688
diff
changeset
|
41 from sat_frontends.tools.misc import InputHistory |
2098
e0066920a661
primitivus, jp: dynamic bridge + fixed D-Bus bridge:
Goffi <goffi@goffi.org>
parents:
2086
diff
changeset
|
42 from sat.tools.common import dynamic_import |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
43 from sat_frontends.tools import jid |
1162
b32800b9793e
primitivus: SIGINT is now ignored, APP_QUIT key/menu or :quit command must be used to quit Primitivus
Goffi <goffi@goffi.org>
parents:
1160
diff
changeset
|
44 import signal |
1949
c5fd304d0976
primitivus: added bracketed_paste option in sat.conf (if set, the bracketed paste mode will be activated on Primitivus start)
Goffi <goffi@goffi.org>
parents:
1948
diff
changeset
|
45 import sys |
2098
e0066920a661
primitivus, jp: dynamic bridge + fixed D-Bus bridge:
Goffi <goffi@goffi.org>
parents:
2086
diff
changeset
|
46 ## bridge handling |
e0066920a661
primitivus, jp: dynamic bridge + fixed D-Bus bridge:
Goffi <goffi@goffi.org>
parents:
2086
diff
changeset
|
47 # we get bridge name from conf and initialise the right class accordingly |
e0066920a661
primitivus, jp: dynamic bridge + fixed D-Bus bridge:
Goffi <goffi@goffi.org>
parents:
2086
diff
changeset
|
48 main_config = sat_config.parseMainConf() |
e0066920a661
primitivus, jp: dynamic bridge + fixed D-Bus bridge:
Goffi <goffi@goffi.org>
parents:
2086
diff
changeset
|
49 bridge_name = sat_config.getConfig(main_config, '', 'bridge', 'dbus') |
e0066920a661
primitivus, jp: dynamic bridge + fixed D-Bus bridge:
Goffi <goffi@goffi.org>
parents:
2086
diff
changeset
|
50 if 'dbus' not in bridge_name: |
e0066920a661
primitivus, jp: dynamic bridge + fixed D-Bus bridge:
Goffi <goffi@goffi.org>
parents:
2086
diff
changeset
|
51 print(u"only D-Bus bridge is currently supported") |
e0066920a661
primitivus, jp: dynamic bridge + fixed D-Bus bridge:
Goffi <goffi@goffi.org>
parents:
2086
diff
changeset
|
52 sys.exit(3) |
112 | 53 |
54 | |
637
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 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
60 def __init__(self, host): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
61 modes = {None: (C.MODE_NORMAL, u''), |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
62 a_key['MODE_INSERTION']: (C.MODE_INSERTION, u'> '), |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
63 a_key['MODE_COMMAND']: (C.MODE_COMMAND, u':')} #XXX: captions *MUST* be unicode |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
64 super(EditBar, self).__init__(modes) |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
65 self.host = host |
637
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): |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
70 if mode == C.MODE_INSERTION: |
1971
9421e721d5e2
primitivus (chat): fixed nick completion. Completion is now managed per widget, if completion method exists
Goffi <goffi@goffi.org>
parents:
1970
diff
changeset
|
71 if self.host.selected_widget is not None: |
9421e721d5e2
primitivus (chat): fixed nick completion. Completion is now managed per widget, if completion method exists
Goffi <goffi@goffi.org>
parents:
1970
diff
changeset
|
72 try: |
9421e721d5e2
primitivus (chat): fixed nick completion. Completion is now managed per widget, if completion method exists
Goffi <goffi@goffi.org>
parents:
1970
diff
changeset
|
73 completion = self.host.selected_widget.completion |
9421e721d5e2
primitivus (chat): fixed nick completion. Completion is now managed per widget, if completion method exists
Goffi <goffi@goffi.org>
parents:
1970
diff
changeset
|
74 except AttributeError: |
9421e721d5e2
primitivus (chat): fixed nick completion. Completion is now managed per widget, if completion method exists
Goffi <goffi@goffi.org>
parents:
1970
diff
changeset
|
75 return text |
9421e721d5e2
primitivus (chat): fixed nick completion. Completion is now managed per widget, if completion method exists
Goffi <goffi@goffi.org>
parents:
1970
diff
changeset
|
76 else: |
9421e721d5e2
primitivus (chat): fixed nick completion. Completion is now managed per widget, if completion method exists
Goffi <goffi@goffi.org>
parents:
1970
diff
changeset
|
77 return completion(text, completion_data) |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
78 else: |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
79 return text |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
80 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
81 def onTextEntered(self, editBar): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
82 """Called when text is entered in the main edit bar""" |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
83 if self.mode == C.MODE_INSERTION: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
84 if isinstance(self.host.selected_widget, quick_chat.QuickChat): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
85 chat_widget = self.host.selected_widget |
1955
633b5c21aefd
backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents:
1938
diff
changeset
|
86 self.host.messageSend( |
633b5c21aefd
backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents:
1938
diff
changeset
|
87 chat_widget.target, |
633b5c21aefd
backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents:
1938
diff
changeset
|
88 {'': editBar.get_edit_text()}, # TODO: handle language |
1963
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
89 mess_type = C.MESS_TYPE_GROUPCHAT if chat_widget.type == C.CHAT_GROUP else C.MESS_TYPE_CHAT, # TODO: put this in QuickChat |
2134
f45250052846
primitivus: fixed display of error if a message can't be sent
Goffi <goffi@goffi.org>
parents:
2126
diff
changeset
|
90 errback=lambda failure: self.host.showDialog(_("Error while sending message ({})").format(failure), type="error"), |
1955
633b5c21aefd
backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents:
1938
diff
changeset
|
91 profile_key=chat_widget.profile |
633b5c21aefd
backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents:
1938
diff
changeset
|
92 ) |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
93 editBar.set_edit_text('') |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
94 elif self.mode == C.MODE_COMMAND: |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
95 self.commandHandler() |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
96 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
97 def commandHandler(self): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
98 #TODO: separate class with auto documentation (with introspection) |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
99 # and completion method |
1119
5968fd8d2248
primitivus: change behavior of commands ":presence" and ":status" :
souliane <souliane@mailoo.org>
parents:
1106
diff
changeset
|
100 tokens = self.get_edit_text().split(' ') |
5968fd8d2248
primitivus: change behavior of commands ":presence" and ":status" :
souliane <souliane@mailoo.org>
parents:
1106
diff
changeset
|
101 command, args = tokens[0], tokens[1:] |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
102 if command == 'quit': |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
103 self.host.onExit() |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
104 raise urwid.ExitMainLoop() |
1010
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
105 elif command == 'messages': |
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
106 wid = sat_widgets.GenericList(logging.memoryGet()) |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
107 self.host.selectWidget(wid) |
1434
b06047e1c1fb
primitivus: fix setting the presence and status
souliane <souliane@mailoo.org>
parents:
1417
diff
changeset
|
108 # FIXME: reactivate the command |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
109 # elif command == 'presence': |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
110 # values = [value for value in commonConst.PRESENCE.keys()] |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
111 # values = [value if value else 'online' for value in values] # the empty value actually means 'online' |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
112 # if args and args[0] in values: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
113 # presence = '' if args[0] == 'online' else args[0] |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
114 # self.host.status_bar.onChange(user_data=sat_widgets.ClickableText(commonConst.PRESENCE[presence])) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
115 # else: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
116 # self.host.status_bar.onPresenceClick() |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
117 # elif command == 'status': |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
118 # if args: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
119 # self.host.status_bar.onChange(user_data=sat_widgets.AdvancedEdit(args[0])) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
120 # else: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
121 # self.host.status_bar.onStatusClick() |
1125
d6c3fea5ecfe
quick_frontend, primitivus: add primitivus command ":history [limit]" (default value for limit is 50)
souliane <souliane@mailoo.org>
parents:
1124
diff
changeset
|
122 elif command == 'history': |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
123 widget = self.host.selected_widget |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
124 if isinstance(widget, quick_chat.QuickChat): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
125 try: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
126 limit = int(args[0]) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
127 except (IndexError, ValueError): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
128 limit = 50 |
1963
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
129 widget.updateHistory(size=limit, profile=widget.profile) |
1225
82dabb442e2e
frontends (primitivus): new command :search <pattern>
souliane <souliane@mailoo.org>
parents:
1186
diff
changeset
|
130 elif command == 'search': |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
131 widget = self.host.selected_widget |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
132 if isinstance(widget, quick_chat.QuickChat): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
133 pattern = " ".join(args) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
134 if not pattern: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
135 self.host.notif_bar.addMessage(D_("Please specify the globbing pattern to search for")) |
1963
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
136 else: |
2013
b536dd121da1
backend (memory), frontends: improved history filtering:
Goffi <goffi@goffi.org>
parents:
2012
diff
changeset
|
137 widget.updateHistory(size=C.HISTORY_LIMIT_NONE, filters={'search': pattern}, profile=widget.profile) |
1966
d727aab9a80e
primitivus: basic handling of filter, only language can filtered for now
Goffi <goffi@goffi.org>
parents:
1963
diff
changeset
|
138 elif command == 'filter': |
d727aab9a80e
primitivus: basic handling of filter, only language can filtered for now
Goffi <goffi@goffi.org>
parents:
1963
diff
changeset
|
139 # FIXME: filter is now only for current widget, |
d727aab9a80e
primitivus: basic handling of filter, only language can filtered for now
Goffi <goffi@goffi.org>
parents:
1963
diff
changeset
|
140 # need to be able to set it globally or per widget |
d727aab9a80e
primitivus: basic handling of filter, only language can filtered for now
Goffi <goffi@goffi.org>
parents:
1963
diff
changeset
|
141 widget = self.host.selected_widget |
d727aab9a80e
primitivus: basic handling of filter, only language can filtered for now
Goffi <goffi@goffi.org>
parents:
1963
diff
changeset
|
142 # FIXME: Q&D way, need to be more generic |
d727aab9a80e
primitivus: basic handling of filter, only language can filtered for now
Goffi <goffi@goffi.org>
parents:
1963
diff
changeset
|
143 if isinstance(widget, quick_chat.QuickChat): |
d727aab9a80e
primitivus: basic handling of filter, only language can filtered for now
Goffi <goffi@goffi.org>
parents:
1963
diff
changeset
|
144 widget.setFilter(args) |
2022
88c41a195728
primitivus (chat): added :topic (and :subject and :title aliases) to change subject with a dialog (/!\ urwid SàText need to be updated)
Goffi <goffi@goffi.org>
parents:
2016
diff
changeset
|
145 elif command in ('topic', 'suject', 'title'): |
88c41a195728
primitivus (chat): added :topic (and :subject and :title aliases) to change subject with a dialog (/!\ urwid SàText need to be updated)
Goffi <goffi@goffi.org>
parents:
2016
diff
changeset
|
146 try: |
88c41a195728
primitivus (chat): added :topic (and :subject and :title aliases) to change subject with a dialog (/!\ urwid SàText need to be updated)
Goffi <goffi@goffi.org>
parents:
2016
diff
changeset
|
147 new_title = args[0].strip() |
88c41a195728
primitivus (chat): added :topic (and :subject and :title aliases) to change subject with a dialog (/!\ urwid SàText need to be updated)
Goffi <goffi@goffi.org>
parents:
2016
diff
changeset
|
148 except IndexError: |
88c41a195728
primitivus (chat): added :topic (and :subject and :title aliases) to change subject with a dialog (/!\ urwid SàText need to be updated)
Goffi <goffi@goffi.org>
parents:
2016
diff
changeset
|
149 new_title = None |
88c41a195728
primitivus (chat): added :topic (and :subject and :title aliases) to change subject with a dialog (/!\ urwid SàText need to be updated)
Goffi <goffi@goffi.org>
parents:
2016
diff
changeset
|
150 widget = self.host.selected_widget |
88c41a195728
primitivus (chat): added :topic (and :subject and :title aliases) to change subject with a dialog (/!\ urwid SàText need to be updated)
Goffi <goffi@goffi.org>
parents:
2016
diff
changeset
|
151 if isinstance(widget, quick_chat.QuickChat) and widget.type == C.CHAT_GROUP: |
88c41a195728
primitivus (chat): added :topic (and :subject and :title aliases) to change subject with a dialog (/!\ urwid SàText need to be updated)
Goffi <goffi@goffi.org>
parents:
2016
diff
changeset
|
152 widget.onSubjectDialog(new_title) |
737
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
153 else: |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
154 return |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
155 self.set_edit_text('') |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
156 |
1160
2ff15a6c5791
primitivus: moved history method definition out of keypress
Goffi <goffi@goffi.org>
parents:
1159
diff
changeset
|
157 def _historyCb(self, text): |
2ff15a6c5791
primitivus: moved history method definition out of keypress
Goffi <goffi@goffi.org>
parents:
1159
diff
changeset
|
158 self.set_edit_text(text) |
2ff15a6c5791
primitivus: moved history method definition out of keypress
Goffi <goffi@goffi.org>
parents:
1159
diff
changeset
|
159 self.set_edit_pos(len(text)) |
2ff15a6c5791
primitivus: moved history method definition out of keypress
Goffi <goffi@goffi.org>
parents:
1159
diff
changeset
|
160 |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
161 def keypress(self, size, key): |
671
4e691a231763
frontend, primitivus: added input history (mode-wise)
souliane <souliane@mailoo.org>
parents:
661
diff
changeset
|
162 """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
|
163 and move the index of the temporary history stack.""" |
1158
c0f15e52695a
primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
164 if key == a_key['MODAL_ESCAPE']: |
738
e867f146d49f
primitivus: save the input history when "esc" is pressed
souliane <souliane@mailoo.org>
parents:
737
diff
changeset
|
165 # first save the text to the current mode, then change to NORMAL |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
166 self.host._updateInputHistory(self.get_edit_text(), mode=self.mode) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
167 self.host._updateInputHistory(mode=C.MODE_NORMAL) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
168 if self._mode == C.MODE_NORMAL and key in self._modes: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
169 self.host._updateInputHistory(mode=self._modes[key][0]) |
1158
c0f15e52695a
primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
170 if key == a_key['HISTORY_PREV']: |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
171 self.host._updateInputHistory(self.get_edit_text(), -1, self._historyCb, 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
|
172 return |
1158
c0f15e52695a
primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
173 elif key == a_key['HISTORY_NEXT']: |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
174 self.host._updateInputHistory(self.get_edit_text(), +1, self._historyCb, 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
|
175 return |
1158
c0f15e52695a
primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
176 elif key == a_key['EDIT_ENTER']: |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
177 self.host._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
|
178 else: |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
179 if (self._mode == C.MODE_INSERTION |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
180 and isinstance(self.host.selected_widget, quick_chat.QuickChat) |
2012
53587e738aca
primitivus: dont call chatStateComposing where history keys are pressed
Goffi <goffi@goffi.org>
parents:
2008
diff
changeset
|
181 and key not in sat_widgets.FOCUS_KEYS |
2900
93dfbeb41da8
primitivus: don't call chatStateComposing when host is out of sync:
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
182 and key not in (a_key['HISTORY_PREV'], a_key['HISTORY_NEXT']) |
93dfbeb41da8
primitivus: don't call chatStateComposing when host is out of sync:
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
183 and self.host.sync): |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
184 self.host.bridge.chatStateComposing(self.host.selected_widget.target, self.host.selected_widget.profile) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
185 |
671
4e691a231763
frontend, primitivus: added input history (mode-wise)
souliane <souliane@mailoo.org>
parents:
661
diff
changeset
|
186 return super(EditBar, self).keypress(size, key) |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
187 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
188 |
1181
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
189 class PrimitivusTopWidget(sat_widgets.FocusPile): |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
190 """Top most widget used in Primitivus""" |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
191 _focus_inversed = True |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
192 positions = ('menu', 'body', 'notif_bar', 'edit_bar') |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
193 can_hide = ('menu', 'notif_bar') |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
194 |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
195 def __init__(self, body, menu, notif_bar, edit_bar): |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
196 self._body = body |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
197 self._menu = menu |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
198 self._notif_bar = notif_bar |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
199 self._edit_bar = edit_bar |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
200 self._hidden = {'notif_bar'} |
1186
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
201 self._focus_extra = False |
1181
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
202 super(PrimitivusTopWidget, self).__init__([('pack', self._menu), self._body, ('pack', self._edit_bar)]) |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
203 for position in self.positions: |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
204 setattr(self, |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
205 position, |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
206 property(lambda: self, self.widgetGet(position=position), |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
207 lambda pos, new_wid: self.widgetSet(new_wid, position=pos)) |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
208 ) |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
209 self.focus_position = len(self.contents)-1 |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
210 |
1186
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
211 def getVisiblePositions(self, keep=None): |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
212 """Return positions that are not hidden in the right order |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
213 |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
214 @param keep: if not None, this position will be keep in the right order, even if it's hidden |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
215 (can be useful to find its index) |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
216 @return (list): list of visible positions |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
217 """ |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
218 return [pos for pos in self.positions if (keep and pos == keep) or pos not in self._hidden] |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
219 |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
220 def keypress(self, size, key): |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
221 """Manage FOCUS keys that focus directly a main part (one of self.positions) |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
222 |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
223 To avoid key conflicts, a combinaison must be made with FOCUS_EXTRA then an other key |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
224 """ |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
225 if key == a_key['FOCUS_EXTRA']: |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
226 self._focus_extra = True |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
227 return |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
228 if self._focus_extra: |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
229 self._focus_extra = False |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
230 if key in ('m', '1'): |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
231 focus = 'menu' |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
232 elif key in ('b', '2'): |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
233 focus = 'body' |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
234 elif key in ('n', '3'): |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
235 focus = 'notif_bar' |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
236 elif key in ('e', '4'): |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
237 focus = 'edit_bar' |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
238 else: |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
239 return super(PrimitivusTopWidget, self).keypress(size, key) |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
240 |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
241 if focus in self._hidden: |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
242 return |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
243 |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
244 self.focus_position = self.getVisiblePositions().index(focus) |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
245 return |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
246 |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
247 return super(PrimitivusTopWidget, self).keypress(size, key) |
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
248 |
1181
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
249 def widgetGet(self, position): |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
250 if not position in self.positions: |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
251 raise ValueError("Unknown position {}".format(position)) |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
252 return getattr(self, "_{}".format(position)) |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
253 |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
254 def widgetSet(self, widget, position): |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
255 if not position in self.positions: |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
256 raise ValueError("Unknown position {}".format(position)) |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
257 return setattr(self, "_{}".format(position), widget) |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
258 |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
259 def hideSwitch(self, position): |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
260 if not position in self.can_hide: |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
261 raise ValueError("Can't switch position {}".format(position)) |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
262 hide = not position in self._hidden |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
263 widget = self.widgetGet(position) |
1186
9cc858acae91
primitivus: added a FOCUS_EXTRA key (default: "ctrl f") which can be used to focus a main part:
Goffi <goffi@goffi.org>
parents:
1185
diff
changeset
|
264 idx = self.getVisiblePositions(position).index(position) |
1181
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
265 if hide: |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
266 del self.contents[idx] |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
267 self._hidden.add(position) |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
268 else: |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
269 self.contents.insert(idx, (widget, ('pack', None))) |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
270 self._hidden.remove(position) |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
271 |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
272 def show(self, position): |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
273 if position in self._hidden: |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
274 self.hideSwitch(position) |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
275 |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
276 def hide(self, position): |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
277 if not position in self._hidden: |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
278 self.hideSwitch(position) |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
279 |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
280 |
671
4e691a231763
frontend, primitivus: added input history (mode-wise)
souliane <souliane@mailoo.org>
parents:
661
diff
changeset
|
281 class PrimitivusApp(QuickApp, InputHistory): |
2067
7834743705f0
quich frontend, primivius (chat): better avatar handling:
Goffi <goffi@goffi.org>
parents:
2050
diff
changeset
|
282 MB_HANDLER = False |
2123
c42aab22c2c0
plugin XEP-0054, quick frontend(app): various improvments:
Goffi <goffi@goffi.org>
parents:
2098
diff
changeset
|
283 AVATARS_HANDLER = False |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
284 |
112 | 285 def __init__(self): |
2098
e0066920a661
primitivus, jp: dynamic bridge + fixed D-Bus bridge:
Goffi <goffi@goffi.org>
parents:
2086
diff
changeset
|
286 bridge_module = dynamic_import.bridge(bridge_name, 'sat_frontends.bridge') |
e0066920a661
primitivus, jp: dynamic bridge + fixed D-Bus bridge:
Goffi <goffi@goffi.org>
parents:
2086
diff
changeset
|
287 if bridge_module is None: |
e0066920a661
primitivus, jp: dynamic bridge + fixed D-Bus bridge:
Goffi <goffi@goffi.org>
parents:
2086
diff
changeset
|
288 log.error(u"Can't import {} bridge".format(bridge_name)) |
e0066920a661
primitivus, jp: dynamic bridge + fixed D-Bus bridge:
Goffi <goffi@goffi.org>
parents:
2086
diff
changeset
|
289 sys.exit(3) |
e0066920a661
primitivus, jp: dynamic bridge + fixed D-Bus bridge:
Goffi <goffi@goffi.org>
parents:
2086
diff
changeset
|
290 else: |
e0066920a661
primitivus, jp: dynamic bridge + fixed D-Bus bridge:
Goffi <goffi@goffi.org>
parents:
2086
diff
changeset
|
291 log.debug(u"Loading {} bridge".format(bridge_name)) |
e0066920a661
primitivus, jp: dynamic bridge + fixed D-Bus bridge:
Goffi <goffi@goffi.org>
parents:
2086
diff
changeset
|
292 QuickApp.__init__(self, bridge_factory=bridge_module.Bridge, xmlui=xmlui, check_options=quick_utils.check_options, connect_bridge=False) |
112 | 293 ## main loop setup ## |
2098
e0066920a661
primitivus, jp: dynamic bridge + fixed D-Bus bridge:
Goffi <goffi@goffi.org>
parents:
2086
diff
changeset
|
294 event_loop = urwid.GLibEventLoop if 'dbus' in bridge_name else urwid.TwistedEventLoop |
e0066920a661
primitivus, jp: dynamic bridge + fixed D-Bus bridge:
Goffi <goffi@goffi.org>
parents:
2086
diff
changeset
|
295 self.loop = urwid.MainLoop(urwid.SolidFill(), C.PALETTE, event_loop=event_loop(), input_filter=self.inputFilter, unhandled_input=self.keyHandler) |
e0066920a661
primitivus, jp: dynamic bridge + fixed D-Bus bridge:
Goffi <goffi@goffi.org>
parents:
2086
diff
changeset
|
296 |
3481
7892585b7e17
core (setup), jp, primitivus: update console scripts + classifiers:
Goffi <goffi@goffi.org>
parents:
3028
diff
changeset
|
297 @classmethod |
7892585b7e17
core (setup), jp, primitivus: update console scripts + classifiers:
Goffi <goffi@goffi.org>
parents:
3028
diff
changeset
|
298 def run(cls): |
7892585b7e17
core (setup), jp, primitivus: update console scripts + classifiers:
Goffi <goffi@goffi.org>
parents:
3028
diff
changeset
|
299 cls().start() |
7892585b7e17
core (setup), jp, primitivus: update console scripts + classifiers:
Goffi <goffi@goffi.org>
parents:
3028
diff
changeset
|
300 |
2098
e0066920a661
primitivus, jp: dynamic bridge + fixed D-Bus bridge:
Goffi <goffi@goffi.org>
parents:
2086
diff
changeset
|
301 def onBridgeConnected(self): |
112 | 302 |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
303 ##misc setup## |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
304 self._visible_widgets = set() |
1181
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
305 self.notif_bar = sat_widgets.NotificationBar() |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
306 urwid.connect_signal(self.notif_bar, 'change', self.onNotification) |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
307 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
308 self.progress_wid = self.widgets.getOrCreateWidget(Progress, None, on_new_widget=None) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
309 urwid.connect_signal(self.notif_bar.progress, 'click', lambda x: self.selectWidget(self.progress_wid)) |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
310 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
|
311 |
507
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
503
diff
changeset
|
312 self.x_notify = Notify() |
524
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
313 |
1162
b32800b9793e
primitivus: SIGINT is now ignored, APP_QUIT key/menu or :quit command must be used to quit Primitivus
Goffi <goffi@goffi.org>
parents:
1160
diff
changeset
|
314 # we already manage exit with a_key['APP_QUIT'], so we don't want C-c |
b32800b9793e
primitivus: SIGINT is now ignored, APP_QUIT key/menu or :quit command must be used to quit Primitivus
Goffi <goffi@goffi.org>
parents:
1160
diff
changeset
|
315 signal.signal(signal.SIGINT, signal.SIG_IGN) |
1949
c5fd304d0976
primitivus: added bracketed_paste option in sat.conf (if set, the bracketed paste mode will be activated on Primitivus start)
Goffi <goffi@goffi.org>
parents:
1948
diff
changeset
|
316 sat_conf = sat_config.parseMainConf() |
3494
b5bed164dce0
frontends (primitivus): `SECTION_NAME` is now `CONFIG_SECTION`
Goffi <goffi@goffi.org>
parents:
3481
diff
changeset
|
317 self._bracketed_paste = C.bool( |
b5bed164dce0
frontends (primitivus): `SECTION_NAME` is now `CONFIG_SECTION`
Goffi <goffi@goffi.org>
parents:
3481
diff
changeset
|
318 sat_config.getConfig(sat_conf, C.CONFIG_SECTION, 'bracketed_paste', 'false') |
b5bed164dce0
frontends (primitivus): `SECTION_NAME` is now `CONFIG_SECTION`
Goffi <goffi@goffi.org>
parents:
3481
diff
changeset
|
319 ) |
1949
c5fd304d0976
primitivus: added bracketed_paste option in sat.conf (if set, the bracketed paste mode will be activated on Primitivus start)
Goffi <goffi@goffi.org>
parents:
1948
diff
changeset
|
320 if self._bracketed_paste: |
c5fd304d0976
primitivus: added bracketed_paste option in sat.conf (if set, the bracketed paste mode will be activated on Primitivus start)
Goffi <goffi@goffi.org>
parents:
1948
diff
changeset
|
321 log.debug("setting bracketed paste mode as requested") |
c5fd304d0976
primitivus: added bracketed_paste option in sat.conf (if set, the bracketed paste mode will be activated on Primitivus start)
Goffi <goffi@goffi.org>
parents:
1948
diff
changeset
|
322 sys.stdout.write("\033[?2004h") |
c5fd304d0976
primitivus: added bracketed_paste option in sat.conf (if set, the bracketed paste mode will be activated on Primitivus start)
Goffi <goffi@goffi.org>
parents:
1948
diff
changeset
|
323 self._bracketed_mode_set = True |
1162
b32800b9793e
primitivus: SIGINT is now ignored, APP_QUIT key/menu or :quit command must be used to quit Primitivus
Goffi <goffi@goffi.org>
parents:
1160
diff
changeset
|
324 |
2098
e0066920a661
primitivus, jp: dynamic bridge + fixed D-Bus bridge:
Goffi <goffi@goffi.org>
parents:
2086
diff
changeset
|
325 self.loop.widget = self.main_widget = ProfileManager(self) |
e0066920a661
primitivus, jp: dynamic bridge + fixed D-Bus bridge:
Goffi <goffi@goffi.org>
parents:
2086
diff
changeset
|
326 self.postInit() |
e0066920a661
primitivus, jp: dynamic bridge + fixed D-Bus bridge:
Goffi <goffi@goffi.org>
parents:
2086
diff
changeset
|
327 |
524
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
328 @property |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
329 def visible_widgets(self): |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
330 return self._visible_widgets |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
331 |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
332 @property |
524
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
333 def mode(self): |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
334 return self.editBar.mode |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
335 |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
336 @mode.setter |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
337 def mode(self, value): |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
338 self.editBar.mode = value |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
339 |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
340 def modeHint(self, value): |
1010
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
341 """Change mode if make sens (i.e.: if there is nothing in the editBar)""" |
524
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
342 if not self.editBar.get_edit_text(): |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
343 self.mode = value |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
344 |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
345 def debug(self): |
1010
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
346 """convenient method to reset screen and launch (i)p(u)db""" |
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
347 log.info('Entered debug mode') |
180
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
348 try: |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
349 import pudb |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
350 pudb.set_trace() |
1010
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
351 except ImportError: |
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
352 import os |
180
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
353 os.system('reset') |
1010
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
354 try: |
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
355 import ipdb |
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
356 ipdb.set_trace() |
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
357 except ImportError: |
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
358 import pdb |
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
359 pdb.set_trace() |
129
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
360 |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
361 def redraw(self): |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
362 """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
|
363 try: |
5a18c5f08d9b
Primitivus: Profile Manager: fixed redraw on profile change + use of AdvandedEdit for login field
Goffi <goffi@goffi.org>
parents:
415
diff
changeset
|
364 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
|
365 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
|
366 pass |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
367 |
112 | 368 def start(self): |
2098
e0066920a661
primitivus, jp: dynamic bridge + fixed D-Bus bridge:
Goffi <goffi@goffi.org>
parents:
2086
diff
changeset
|
369 self.connectBridge() |
112 | 370 self.loop.run() |
371 | |
1159
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
372 def postInit(self): |
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
373 try: |
1165
ca15fb1abbc4
primitivus: added disable_mouse config option /!\ minimal Urwid version is now 1.2.0
Goffi <goffi@goffi.org>
parents:
1164
diff
changeset
|
374 config.applyConfig(self) |
1159
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
375 except Exception as e: |
1409
3265a2639182
massive (preventive) addition of 'u' (unicode) before the strings passed to logging functions
souliane <souliane@mailoo.org>
parents:
1407
diff
changeset
|
376 log.error(u"configuration error: {}".format(e)) |
1609
66f0e877625b
primitivus: fixed alert case + alert in profileManager
Goffi <goffi@goffi.org>
parents:
1582
diff
changeset
|
377 popup = self.alert(_(u"Configuration Error"), _(u"Something went wrong while reading the configuration, please check :messages")) |
1159
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
378 if self.options.profile: |
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
379 self._early_popup = popup |
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
380 else: |
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
381 self.showPopUp(popup) |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
382 super(PrimitivusApp, self).postInit(self.main_widget) |
1159
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
383 |
1947
be4b143cf123
primitivus: fixed paste detection/handling:
Goffi <goffi@goffi.org>
parents:
1946
diff
changeset
|
384 def keysToText(self, keys): |
be4b143cf123
primitivus: fixed paste detection/handling:
Goffi <goffi@goffi.org>
parents:
1946
diff
changeset
|
385 """Generator return normal text from urwid keys""" |
be4b143cf123
primitivus: fixed paste detection/handling:
Goffi <goffi@goffi.org>
parents:
1946
diff
changeset
|
386 for k in keys: |
be4b143cf123
primitivus: fixed paste detection/handling:
Goffi <goffi@goffi.org>
parents:
1946
diff
changeset
|
387 if k == 'tab': |
be4b143cf123
primitivus: fixed paste detection/handling:
Goffi <goffi@goffi.org>
parents:
1946
diff
changeset
|
388 yield u'\t' |
be4b143cf123
primitivus: fixed paste detection/handling:
Goffi <goffi@goffi.org>
parents:
1946
diff
changeset
|
389 elif k == 'enter': |
be4b143cf123
primitivus: fixed paste detection/handling:
Goffi <goffi@goffi.org>
parents:
1946
diff
changeset
|
390 yield u'\n' |
be4b143cf123
primitivus: fixed paste detection/handling:
Goffi <goffi@goffi.org>
parents:
1946
diff
changeset
|
391 elif is_wide_char(k,0) or (len(k)==1 and ord(k) >= 32): |
be4b143cf123
primitivus: fixed paste detection/handling:
Goffi <goffi@goffi.org>
parents:
1946
diff
changeset
|
392 yield k |
be4b143cf123
primitivus: fixed paste detection/handling:
Goffi <goffi@goffi.org>
parents:
1946
diff
changeset
|
393 |
1164 | 394 def inputFilter(self, input_, raw): |
395 if self.__saved_overlay and input_ != a_key['OVERLAY_HIDE']: | |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
396 return |
1946
827bb478d8af
primitivus: paste is now detected, and put in edit bar, so use can check and validate it
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
397 |
1949
c5fd304d0976
primitivus: added bracketed_paste option in sat.conf (if set, the bracketed paste mode will be activated on Primitivus start)
Goffi <goffi@goffi.org>
parents:
1948
diff
changeset
|
398 ## paste detection/handling |
1947
be4b143cf123
primitivus: fixed paste detection/handling:
Goffi <goffi@goffi.org>
parents:
1946
diff
changeset
|
399 if (len(input_) > 1 and # XXX: it may be needed to increase this value if buffer |
be4b143cf123
primitivus: fixed paste detection/handling:
Goffi <goffi@goffi.org>
parents:
1946
diff
changeset
|
400 not isinstance(input_[0], tuple) and # or other things result in several chars at once |
1952
2c1a1b56dd22
primitivus: fixed window resize (was blocked by paste detection)
Goffi <goffi@goffi.org>
parents:
1949
diff
changeset
|
401 not 'window resize' in input_): # (e.g. using Primitivus through ssh). Need some testing |
1947
be4b143cf123
primitivus: fixed paste detection/handling:
Goffi <goffi@goffi.org>
parents:
1946
diff
changeset
|
402 # and experience to adjust value. |
1948
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
403 if input_[0] == 'begin paste' and not self._bracketed_paste: |
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
404 log.info(u"Bracketed paste mode detected") |
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
405 self._bracketed_paste = True |
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
406 |
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
407 if self._bracketed_paste: |
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
408 # after this block, extra will contain non pasted keys |
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
409 # and input_ will contain pasted keys |
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
410 try: |
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
411 begin_idx = input_.index('begin paste') |
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
412 except ValueError: |
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
413 # this is not a paste, maybe we have something buffering |
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
414 # or bracketed mode is set in conf but not enabled in term |
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
415 extra = input_ |
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
416 input_ = [] |
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
417 else: |
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
418 try: |
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
419 end_idx = input_.index('end paste') |
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
420 except ValueError: |
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
421 log.warning(u"missing end paste sequence, discarding paste") |
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
422 extra = input_[:begin_idx] |
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
423 del input_[begin_idx:] |
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
424 else: |
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
425 extra = input_[:begin_idx] + input_[end_idx+1:] |
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
426 input_ = input_[begin_idx+1:end_idx] |
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
427 else: |
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
428 extra = None |
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
429 |
1947
be4b143cf123
primitivus: fixed paste detection/handling:
Goffi <goffi@goffi.org>
parents:
1946
diff
changeset
|
430 log.debug(u"Paste detected (len {})".format(len(input_))) |
1946
827bb478d8af
primitivus: paste is now detected, and put in edit bar, so use can check and validate it
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
431 try: |
827bb478d8af
primitivus: paste is now detected, and put in edit bar, so use can check and validate it
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
432 edit_bar = self.editBar |
827bb478d8af
primitivus: paste is now detected, and put in edit bar, so use can check and validate it
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
433 except AttributeError: |
1981
2f97e58b6fa1
primitivus: paste is now treated as normal text instead of discarded if edit_bar doesn't exist
Goffi <goffi@goffi.org>
parents:
1974
diff
changeset
|
434 log.warning(u"Paste treated as normal text: there is no edit bar yet") |
2f97e58b6fa1
primitivus: paste is now treated as normal text instead of discarded if edit_bar doesn't exist
Goffi <goffi@goffi.org>
parents:
1974
diff
changeset
|
435 if extra is None: |
2f97e58b6fa1
primitivus: paste is now treated as normal text instead of discarded if edit_bar doesn't exist
Goffi <goffi@goffi.org>
parents:
1974
diff
changeset
|
436 extra = [] |
2f97e58b6fa1
primitivus: paste is now treated as normal text instead of discarded if edit_bar doesn't exist
Goffi <goffi@goffi.org>
parents:
1974
diff
changeset
|
437 extra.extend(input_) |
1946
827bb478d8af
primitivus: paste is now detected, and put in edit bar, so use can check and validate it
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
438 else: |
1974
b34fdb44b7d4
primitivus: ignore paste if edit bar is not selected
Goffi <goffi@goffi.org>
parents:
1952
diff
changeset
|
439 if self.main_widget.focus == edit_bar: |
b34fdb44b7d4
primitivus: ignore paste if edit bar is not selected
Goffi <goffi@goffi.org>
parents:
1952
diff
changeset
|
440 # XXX: if a paste is detected, we append it directly to the edit bar text |
b34fdb44b7d4
primitivus: ignore paste if edit bar is not selected
Goffi <goffi@goffi.org>
parents:
1952
diff
changeset
|
441 # so the user can check it and press [enter] if it's OK |
b34fdb44b7d4
primitivus: ignore paste if edit bar is not selected
Goffi <goffi@goffi.org>
parents:
1952
diff
changeset
|
442 buf_paste = u''.join(self.keysToText(input_)) |
b34fdb44b7d4
primitivus: ignore paste if edit bar is not selected
Goffi <goffi@goffi.org>
parents:
1952
diff
changeset
|
443 pos = edit_bar.edit_pos |
b34fdb44b7d4
primitivus: ignore paste if edit bar is not selected
Goffi <goffi@goffi.org>
parents:
1952
diff
changeset
|
444 edit_bar.set_edit_text(u'{}{}{}'.format(edit_bar.edit_text[:pos], buf_paste, edit_bar.edit_text[pos:])) |
b34fdb44b7d4
primitivus: ignore paste if edit bar is not selected
Goffi <goffi@goffi.org>
parents:
1952
diff
changeset
|
445 edit_bar.edit_pos+=len(buf_paste) |
b34fdb44b7d4
primitivus: ignore paste if edit bar is not selected
Goffi <goffi@goffi.org>
parents:
1952
diff
changeset
|
446 else: |
b34fdb44b7d4
primitivus: ignore paste if edit bar is not selected
Goffi <goffi@goffi.org>
parents:
1952
diff
changeset
|
447 # we are not on the edit_bar, |
b34fdb44b7d4
primitivus: ignore paste if edit bar is not selected
Goffi <goffi@goffi.org>
parents:
1952
diff
changeset
|
448 # so we treat pasted text as normal text |
b34fdb44b7d4
primitivus: ignore paste if edit bar is not selected
Goffi <goffi@goffi.org>
parents:
1952
diff
changeset
|
449 if extra is None: |
b34fdb44b7d4
primitivus: ignore paste if edit bar is not selected
Goffi <goffi@goffi.org>
parents:
1952
diff
changeset
|
450 extra = [] |
b34fdb44b7d4
primitivus: ignore paste if edit bar is not selected
Goffi <goffi@goffi.org>
parents:
1952
diff
changeset
|
451 extra.extend(input_) |
1948
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
452 if not extra: |
1946
827bb478d8af
primitivus: paste is now detected, and put in edit bar, so use can check and validate it
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
453 return |
1948
373550000092
primitivus: bracketed paste mode is now detected
Goffi <goffi@goffi.org>
parents:
1947
diff
changeset
|
454 input_ = extra |
1949
c5fd304d0976
primitivus: added bracketed_paste option in sat.conf (if set, the bracketed paste mode will be activated on Primitivus start)
Goffi <goffi@goffi.org>
parents:
1948
diff
changeset
|
455 ## end of paste detection/handling |
1946
827bb478d8af
primitivus: paste is now detected, and put in edit bar, so use can check and validate it
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
456 |
1164 | 457 for i in input_: |
153
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
458 if isinstance(i,tuple): |
127
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
459 if i[0] == 'mouse press': |
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
460 if i[1] == 4: #Mouse wheel up |
1164 | 461 input_[input_.index(i)] = a_key['HISTORY_PREV'] |
127
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
462 if i[1] == 5: #Mouse wheel down |
1164 | 463 input_[input_.index(i)] = a_key['HISTORY_NEXT'] |
464 return input_ | |
127
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
465 |
1158
c0f15e52695a
primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
466 def keyHandler(self, input_): |
c0f15e52695a
primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
467 if input_ == a_key['MENU_HIDE']: |
181 | 468 """User want to (un)hide the menu roller""" |
128
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
469 try: |
1181
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
470 self.main_widget.hideSwitch('menu') |
128
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
471 except AttributeError: |
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
472 pass |
1158
c0f15e52695a
primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
473 elif input_ == a_key['NOTIFICATION_NEXT']: |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
474 """User wants to see next notification""" |
1181
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
475 self.notif_bar.showNext() |
1158
c0f15e52695a
primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
476 elif input_ == a_key['OVERLAY_HIDE']: |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
477 """User wants to (un)hide overlay window""" |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
478 if isinstance(self.loop.widget,urwid.Overlay): |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
479 self.__saved_overlay = self.loop.widget |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
480 self.loop.widget = self.main_widget |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
481 else: |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
482 if self.__saved_overlay: |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
483 self.loop.widget = self.__saved_overlay |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
484 self.__saved_overlay = None |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
485 |
1158
c0f15e52695a
primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
486 elif input_ == a_key['DEBUG'] and 'D' in self.bridge.getVersion(): #Debug only for dev versions |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
487 self.debug() |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
488 elif input_ == a_key['CONTACTS_HIDE']: #user wants to (un)hide the contact lists |
124 | 489 try: |
608
ea9aa51234eb
Primitivus: fixed contacts list (un)hidding
Goffi <goffi@goffi.org>
parents:
607
diff
changeset
|
490 for wid, options in self.center_part.contents: |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
491 if self.contact_lists_pile is wid: |
608
ea9aa51234eb
Primitivus: fixed contacts list (un)hidding
Goffi <goffi@goffi.org>
parents:
607
diff
changeset
|
492 self.center_part.contents.remove((wid, options)) |
ea9aa51234eb
Primitivus: fixed contacts list (un)hidding
Goffi <goffi@goffi.org>
parents:
607
diff
changeset
|
493 break |
124 | 494 else: |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
495 self.center_part.contents.insert(0, (self.contact_lists_pile, ('weight', 2, False))) |
124 | 496 except AttributeError: |
497 #The main widget is not built (probably in Profile Manager) | |
498 pass | |
1158
c0f15e52695a
primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
499 elif input_ == 'window resize': |
129
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
500 width,height = self.loop.screen_size |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
501 if height<=5 and width<=35: |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
502 if not 'save_main_widget' in dir(self): |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
503 self.save_main_widget = self.loop.widget |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
504 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
|
505 else: |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
506 if 'save_main_widget' in dir(self): |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
507 self.loop.widget = self.save_main_widget |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
508 del self.save_main_widget |
128
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
509 try: |
1158
c0f15e52695a
primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
510 return self.menu_roller.checkShortcuts(input_) |
128
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
511 except AttributeError: |
1158
c0f15e52695a
primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
512 return input_ |
124 | 513 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
514 def addMenus(self, menu, type_filter, menu_data=None): |
1093
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
515 """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
|
516 @param menu: sat_widgets.Menu instance |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
517 @param type_filter: menu type like is sat.core.sat_main.importMenu |
1093
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
518 @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
|
519 |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
520 """ |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
521 def add_menu_cb(callback_id): |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
522 self.launchAction(callback_id, menu_data, profile=self.current_profile) |
2126 | 523 for id_, type_, path, path_i18n, extra in self.bridge.menusGet("", C.NO_SECURITY_LIMIT ): # TODO: manage extra |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
524 if type_ != type_filter: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
525 continue |
1093
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
526 if len(path) != 2: |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
527 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
|
528 menu.addMenu(path_i18n[0], path_i18n[1], lambda dummy,id_=id_: add_menu_cb(id_)) |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
529 |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
530 |
755
e3ad48a2aab2
core, frontends: callMenu is now async and don't use callback_id anymore
Goffi <goffi@goffi.org>
parents:
752
diff
changeset
|
531 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
|
532 menu = sat_widgets.Menu(self.loop) |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
533 general = _("General") |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
534 menu.addMenu(general, _("Connect"), self.onConnectRequest) |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
535 menu.addMenu(general, _("Disconnect"), self.onDisconnectRequest) |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
536 menu.addMenu(general, _("Parameters"), self.onParam) |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
537 menu.addMenu(general, _("About"), self.onAboutRequest) |
1158
c0f15e52695a
primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
538 menu.addMenu(general, _("Exit"), self.onExitRequest, a_key['APP_QUIT']) |
1707
94c450972346
primitivus and plugins: renamed a few menus:
souliane <souliane@mailoo.org>
parents:
1676
diff
changeset
|
539 menu.addMenu(_("Contacts")) # add empty menu to save the place in the menu order |
94c450972346
primitivus and plugins: renamed a few menus:
souliane <souliane@mailoo.org>
parents:
1676
diff
changeset
|
540 groups = _("Groups") |
94c450972346
primitivus and plugins: renamed a few menus:
souliane <souliane@mailoo.org>
parents:
1676
diff
changeset
|
541 menu.addMenu(groups) |
94c450972346
primitivus and plugins: renamed a few menus:
souliane <souliane@mailoo.org>
parents:
1676
diff
changeset
|
542 menu.addMenu(groups, _("Join room"), self.onJoinRoomRequest, a_key['ROOM_JOIN']) |
145
c8b231abfe96
Primitivus: additionnal menus management
Goffi <goffi@goffi.org>
parents:
144
diff
changeset
|
543 #additionals menus |
c8b231abfe96
Primitivus: additionnal menus management
Goffi <goffi@goffi.org>
parents:
144
diff
changeset
|
544 #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
|
545 self.addMenus(menu, C.MENU_GLOBAL) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
546 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
547 menu_roller = sat_widgets.MenuRoller([(_('Main menu'), menu, C.MENU_ID_MAIN)]) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
548 return menu_roller |
131 | 549 |
755
e3ad48a2aab2
core, frontends: callMenu is now async and don't use callback_id anymore
Goffi <goffi@goffi.org>
parents:
752
diff
changeset
|
550 def _buildMainWidget(self): |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
551 self.contact_lists_pile = urwid.Pile([]) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
552 #self.center_part = urwid.Columns([('weight',2,self.contact_lists[profile]),('weight',8,Chat('',self))]) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
553 self.center_part = urwid.Columns([('weight', 2, self.contact_lists_pile), ('weight', 8, urwid.Filler(urwid.Text('')))]) |
524
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
554 |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
555 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
|
556 self.menu_roller = self._buildMenuRoller() |
1181
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
557 self.main_widget = PrimitivusTopWidget(self.center_part, self.menu_roller, self.notif_bar, self.editBar) |
118
76055a209ed9
primitivus: added edition zone at the bottom
Goffi <goffi@goffi.org>
parents:
117
diff
changeset
|
558 return self.main_widget |
112 | 559 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
560 def plugging_profiles(self): |
755
e3ad48a2aab2
core, frontends: callMenu is now async and don't use callback_id anymore
Goffi <goffi@goffi.org>
parents:
752
diff
changeset
|
561 self.loop.widget = self._buildMainWidget() |
415
3348331e0f09
primitivus: fixed screen redraw after plugin profile
Goffi <goffi@goffi.org>
parents:
411
diff
changeset
|
562 self.redraw() |
1159
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
563 try: |
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
564 # if a popup arrived before main widget is build, we need to show it now |
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
565 self.showPopUp(self._early_popup) |
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
566 except AttributeError: |
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
567 pass |
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
568 else: |
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
569 del self._early_popup |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
570 |
1938
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
571 def profilePlugged(self, profile): |
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
572 QuickApp.profilePlugged(self, profile) |
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
573 contact_list = self.widgets.getOrCreateWidget(ContactList, None, on_new_widget=None, on_click=self.contactSelected, on_change=lambda w: self.redraw(), profile=profile) |
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
574 self.contact_lists_pile.contents.append((contact_list, ('weight', 1))) |
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
575 return contact_list |
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
576 |
1787
d678b723460b
quick_frontend, primitivus: mechanism to signal a new message reception when the window is hidden (even if the message is actually displayed):
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
577 def isHidden(self): |
d678b723460b
quick_frontend, primitivus: mechanism to signal a new message reception when the window is hidden (even if the message is actually displayed):
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
578 """Tells if the frontend window is hidden. |
d678b723460b
quick_frontend, primitivus: mechanism to signal a new message reception when the window is hidden (even if the message is actually displayed):
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
579 |
d678b723460b
quick_frontend, primitivus: mechanism to signal a new message reception when the window is hidden (even if the message is actually displayed):
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
580 @return bool |
d678b723460b
quick_frontend, primitivus: mechanism to signal a new message reception when the window is hidden (even if the message is actually displayed):
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
581 """ |
d678b723460b
quick_frontend, primitivus: mechanism to signal a new message reception when the window is hidden (even if the message is actually displayed):
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
582 return False # FIXME: implement when necessary |
d678b723460b
quick_frontend, primitivus: mechanism to signal a new message reception when the window is hidden (even if the message is actually displayed):
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
583 |
1609
66f0e877625b
primitivus: fixed alert case + alert in profileManager
Goffi <goffi@goffi.org>
parents:
1582
diff
changeset
|
584 def alert(self, title, message): |
1580
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
585 """Shortcut method to create an alert message |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
586 |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
587 Alert will have an "OK" button, which remove it if pressed |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
588 @param title(unicode): title of the dialog |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
589 @param message(unicode): body of the dialog |
1609
66f0e877625b
primitivus: fixed alert case + alert in profileManager
Goffi <goffi@goffi.org>
parents:
1582
diff
changeset
|
590 @return (urwid_satext.Alert): the created Alert instance |
1580
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
591 """ |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
592 popup = sat_widgets.Alert(title, message) |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
593 popup.setCallback('ok', lambda dummy: self.removePopUp(popup)) |
3005 | 594 self.showPopUp(popup, width=75, height=20) |
1580
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
595 return popup |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
596 |
120 | 597 def removePopUp(self, widget=None): |
1580
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
598 """Remove current pop-up, and if there is other in queue, show it |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
599 |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
600 @param widget(None, urwid.Widget): if not None remove this popup from front or queue |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
601 """ |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
602 # TODO: refactor popup management in a cleaner way |
3016
0b1c17c24bba
core: fixed handling of button callback in popups:
Goffi <goffi@goffi.org>
parents:
3005
diff
changeset
|
603 # buttons' callback use themselve as first argument, and we never use |
0b1c17c24bba
core: fixed handling of button callback in popups:
Goffi <goffi@goffi.org>
parents:
3005
diff
changeset
|
604 # a Button directly in a popup, so we consider urwid.Button as None |
0b1c17c24bba
core: fixed handling of button callback in popups:
Goffi <goffi@goffi.org>
parents:
3005
diff
changeset
|
605 if widget is not None and not isinstance(widget, urwid.Button): |
1580
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
606 if isinstance(self.loop.widget, urwid.Overlay): |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
607 current_popup = self.loop.widget.top_w |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
608 if not current_popup == widget: |
1676
a0810e0f386e
primitivus: a warning is loggued when trying to remove an unknown popup, instead of an error raised
Goffi <goffi@goffi.org>
parents:
1659
diff
changeset
|
609 try: |
a0810e0f386e
primitivus: a warning is loggued when trying to remove an unknown popup, instead of an error raised
Goffi <goffi@goffi.org>
parents:
1659
diff
changeset
|
610 self.notif_bar.removePopUp(widget) |
a0810e0f386e
primitivus: a warning is loggued when trying to remove an unknown popup, instead of an error raised
Goffi <goffi@goffi.org>
parents:
1659
diff
changeset
|
611 except ValueError: |
a0810e0f386e
primitivus: a warning is loggued when trying to remove an unknown popup, instead of an error raised
Goffi <goffi@goffi.org>
parents:
1659
diff
changeset
|
612 log.warning(u"Trying to remove an unknown widget {}".format(widget)) |
1580
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
613 return |
117 | 614 self.loop.widget = self.main_widget |
1181
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
615 next_popup = self.notif_bar.getNextPopup() |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
616 if next_popup: |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
617 #we still have popup to show, we display it |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
618 self.showPopUp(next_popup) |
1580
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
619 else: |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
620 self.redraw() |
117 | 621 |
3005 | 622 def showPopUp(self, pop_up_widget, width=None, height=None, align='center', |
623 valign='middle'): | |
624 """Show a pop-up window if possible, else put it in queue | |
625 | |
626 @param pop_up_widget: pop up to show | |
627 @param width(int, None): width of the popup | |
628 None to use default | |
629 @param height(int, None): height of the popup | |
630 None to use default | |
631 @param align: same as for [urwid.Overlay] | |
632 """ | |
633 if width == None: | |
634 width = 75 if isinstance(pop_up_widget, xmlui.PrimitivusNoteDialog) else 135 | |
635 if height == None: | |
636 height = 20 if isinstance(pop_up_widget, xmlui.PrimitivusNoteDialog) else 40 | |
687
af0d08a84cc6
primitivus card_game: bug fix and improvement
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
637 if not isinstance(self.loop.widget, urwid.Overlay): |
3005 | 638 display_widget = urwid.Overlay( |
639 pop_up_widget, self.main_widget, align, width, valign, height) | |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
640 self.loop.widget = display_widget |
219
782319a64ac6
primitivus, wix: added forgotten profile
Goffi <goffi@goffi.org>
parents:
216
diff
changeset
|
641 self.redraw() |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
642 else: |
1181
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
643 self.notif_bar.addPopUp(pop_up_widget) |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
644 |
1972
02d21a589be2
quick_frontend, primitivus: notifications refactoring
Goffi <goffi@goffi.org>
parents:
1971
diff
changeset
|
645 def barNotify(self, message): |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
646 """"Notify message to user via notification bar""" |
1181
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
647 self.notif_bar.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
|
648 self.redraw() |
112 | 649 |
1972
02d21a589be2
quick_frontend, primitivus: notifications refactoring
Goffi <goffi@goffi.org>
parents:
1971
diff
changeset
|
650 def notify(self, type_, entity=None, message=None, subject=None, callback=None, cb_args=None, widget=None, profile=C.PROF_KEY_NONE): |
02d21a589be2
quick_frontend, primitivus: notifications refactoring
Goffi <goffi@goffi.org>
parents:
1971
diff
changeset
|
651 if widget is None or widget is not None and widget != self.selected_widget: |
02d21a589be2
quick_frontend, primitivus: notifications refactoring
Goffi <goffi@goffi.org>
parents:
1971
diff
changeset
|
652 # we ignore notification if the widget is selected but we can |
02d21a589be2
quick_frontend, primitivus: notifications refactoring
Goffi <goffi@goffi.org>
parents:
1971
diff
changeset
|
653 # still do a desktop notification is the X window has not the focus |
02d21a589be2
quick_frontend, primitivus: notifications refactoring
Goffi <goffi@goffi.org>
parents:
1971
diff
changeset
|
654 super(PrimitivusApp, self).notify(type_, entity, message, subject, callback, cb_args, widget, profile) |
2008
8a749ec21c50
primitivus: fixed notifications counter for simple messages in MUC rooms
Goffi <goffi@goffi.org>
parents:
1991
diff
changeset
|
655 # we don't want notifications without message on desktop |
8a749ec21c50
primitivus: fixed notifications counter for simple messages in MUC rooms
Goffi <goffi@goffi.org>
parents:
1991
diff
changeset
|
656 if message is not None and not self.x_notify.hasFocus(): |
1972
02d21a589be2
quick_frontend, primitivus: notifications refactoring
Goffi <goffi@goffi.org>
parents:
1971
diff
changeset
|
657 if message is None: |
02d21a589be2
quick_frontend, primitivus: notifications refactoring
Goffi <goffi@goffi.org>
parents:
1971
diff
changeset
|
658 message = _("{app}: a new event has just happened{entity}").format( |
02d21a589be2
quick_frontend, primitivus: notifications refactoring
Goffi <goffi@goffi.org>
parents:
1971
diff
changeset
|
659 app=C.APP_NAME, |
02d21a589be2
quick_frontend, primitivus: notifications refactoring
Goffi <goffi@goffi.org>
parents:
1971
diff
changeset
|
660 entity=u' ({})'.format(entity) if entity else '') |
02d21a589be2
quick_frontend, primitivus: notifications refactoring
Goffi <goffi@goffi.org>
parents:
1971
diff
changeset
|
661 self.x_notify.sendNotification(message) |
02d21a589be2
quick_frontend, primitivus: notifications refactoring
Goffi <goffi@goffi.org>
parents:
1971
diff
changeset
|
662 |
02d21a589be2
quick_frontend, primitivus: notifications refactoring
Goffi <goffi@goffi.org>
parents:
1971
diff
changeset
|
663 |
3004
d86cddc1cd05
primitivus: select the widget even if an other one is selected when the selection comes from an user action:
Goffi <goffi@goffi.org>
parents:
3001
diff
changeset
|
664 def newWidget(self, widget, user_action=False): |
d86cddc1cd05
primitivus: select the widget even if an other one is selected when the selection comes from an user action:
Goffi <goffi@goffi.org>
parents:
3001
diff
changeset
|
665 """Method called when a new widget is created |
d86cddc1cd05
primitivus: select the widget even if an other one is selected when the selection comes from an user action:
Goffi <goffi@goffi.org>
parents:
3001
diff
changeset
|
666 |
d86cddc1cd05
primitivus: select the widget even if an other one is selected when the selection comes from an user action:
Goffi <goffi@goffi.org>
parents:
3001
diff
changeset
|
667 if suitable, the widget will be displayed |
d86cddc1cd05
primitivus: select the widget even if an other one is selected when the selection comes from an user action:
Goffi <goffi@goffi.org>
parents:
3001
diff
changeset
|
668 @param widget(widget.PrimitivusWidget): created widget |
d86cddc1cd05
primitivus: select the widget even if an other one is selected when the selection comes from an user action:
Goffi <goffi@goffi.org>
parents:
3001
diff
changeset
|
669 @param user_action(bool): if True, the widget has been created following an |
d86cddc1cd05
primitivus: select the widget even if an other one is selected when the selection comes from an user action:
Goffi <goffi@goffi.org>
parents:
3001
diff
changeset
|
670 explicit user action. In this case, the widget may get focus immediately |
d86cddc1cd05
primitivus: select the widget even if an other one is selected when the selection comes from an user action:
Goffi <goffi@goffi.org>
parents:
3001
diff
changeset
|
671 """ |
1991
dbe025b03eba
primitivus: fixed XMLUI window creation
Goffi <goffi@goffi.org>
parents:
1982
diff
changeset
|
672 # FIXME: when several widgets are possible (e.g. with :split) |
dbe025b03eba
primitivus: fixed XMLUI window creation
Goffi <goffi@goffi.org>
parents:
1982
diff
changeset
|
673 # do not replace current widget when self.selected_widget != None |
3004
d86cddc1cd05
primitivus: select the widget even if an other one is selected when the selection comes from an user action:
Goffi <goffi@goffi.org>
parents:
3001
diff
changeset
|
674 if user_action or self.selected_widget is None: |
3001
ce52ac2fe213
primitivus: don't focus on new widget if one is already selected:
Goffi <goffi@goffi.org>
parents:
2900
diff
changeset
|
675 self.selectWidget(widget) |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
676 |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
677 def selectWidget(self, widget): |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
678 """Display a widget if possible, |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
679 |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
680 else add it in the notification bar queue |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
681 @param widget: BoxWidget |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
682 """ |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
683 assert len(self.center_part.widget_list)<=2 |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
684 wid_idx = len(self.center_part.widget_list)-1 |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
685 self.center_part.widget_list[wid_idx] = widget |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
686 try: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
687 self.menu_roller.removeMenu(C.MENU_ID_WIDGET) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
688 except KeyError: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
689 log.debug("No menu to delete") |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
690 self.selected_widget = widget |
1963
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
691 try: |
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
692 onSelected = self.selected_widget.onSelected |
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
693 except AttributeError: |
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
694 pass |
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
695 else: |
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
696 onSelected() |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
697 self._visible_widgets = set([widget]) # XXX: we can only have one widget visible at the time for now |
1938
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
698 self.contact_lists.select(None) |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
699 |
1938
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
700 for wid in self.visible_widgets: # FIXME: check if widgets.getWidgets is not more appropriate |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
701 if isinstance(wid, Chat): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
702 contact_list = self.contact_lists[wid.profile] |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
703 contact_list.select(wid.target) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
704 |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
705 self.redraw() |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
706 |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
707 def removeWindow(self): |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
708 """Remove window showed on the right column""" |
1336
2ecc07a8f91b
primitivus, quick_frontends: moved newMessage signal handler to quick_frontend
Goffi <goffi@goffi.org>
parents:
1290
diff
changeset
|
709 #TODO: better Window management than this hack |
2ecc07a8f91b
primitivus, quick_frontends: moved newMessage signal handler to quick_frontend
Goffi <goffi@goffi.org>
parents:
1290
diff
changeset
|
710 assert len(self.center_part.widget_list) <= 2 |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
711 wid_idx = len(self.center_part.widget_list)-1 |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
712 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
|
713 self.center_part.focus_position = 0 |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
714 self.redraw() |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
715 |
1636 | 716 def addProgress(self, pid, message, profile): |
717 """Follow a SàT progression | |
718 | |
719 @param pid: progression id | |
720 @param message: message to show to identify the progression | |
721 """ | |
722 self.progress_wid.add(pid, message, profile) | |
180
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
723 |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
724 def setProgress(self, percentage): |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
725 """Set the progression shown in notification bar""" |
1181
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
726 self.notif_bar.setProgress(percentage) |
180
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
727 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
728 def contactSelected(self, contact_list, entity): |
2016
f09562b0704d
quick_frontend, primitivus: better notifications handling
Goffi <goffi@goffi.org>
parents:
2013
diff
changeset
|
729 self.clearNotifs(entity, profile=contact_list.profile) |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
730 if entity.resource: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
731 # we have clicked on a private MUC conversation |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
732 chat_widget = self.widgets.getOrCreateWidget(Chat, entity, on_new_widget=None, force_hash = Chat.getPrivateHash(contact_list.profile, entity), profile=contact_list.profile) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
733 else: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
734 chat_widget = self.widgets.getOrCreateWidget(Chat, entity, on_new_widget=None, profile=contact_list.profile) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
735 self.selectWidget(chat_widget) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
736 self.menu_roller.addMenu(_('Chat menu'), chat_widget.getMenu(), C.MENU_ID_WIDGET) |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
737 |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
738 def _dialogOkCb(self, widget, data): |
1582
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
739 popup, answer_cb, answer_data = data |
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
740 self.removePopUp(popup) |
1612
48f324352c52
primitivus: fixed showDialog and XMLUI message dialog
Goffi <goffi@goffi.org>
parents:
1609
diff
changeset
|
741 if answer_cb is not None: |
48f324352c52
primitivus: fixed showDialog and XMLUI message dialog
Goffi <goffi@goffi.org>
parents:
1609
diff
changeset
|
742 answer_cb(True, answer_data) |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
743 |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
744 def _dialogCancelCb(self, widget, data): |
1582
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
745 popup, answer_cb, answer_data = data |
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
746 self.removePopUp(popup) |
1612
48f324352c52
primitivus: fixed showDialog and XMLUI message dialog
Goffi <goffi@goffi.org>
parents:
1609
diff
changeset
|
747 if answer_cb is not None: |
48f324352c52
primitivus: fixed showDialog and XMLUI message dialog
Goffi <goffi@goffi.org>
parents:
1609
diff
changeset
|
748 answer_cb(False, answer_data) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
749 |
2134
f45250052846
primitivus: fixed display of error if a message can't be sent
Goffi <goffi@goffi.org>
parents:
2126
diff
changeset
|
750 def showDialog(self, message, title="", type="info", answer_cb = None, answer_data = None): |
f45250052846
primitivus: fixed display of error if a message can't be sent
Goffi <goffi@goffi.org>
parents:
2126
diff
changeset
|
751 if type == 'info': |
1632 | 752 popup = sat_widgets.Alert(title, message, ok_cb=answer_cb) |
1582
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
753 if answer_cb is None: |
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
754 popup.setCallback('ok', lambda dummy: self.removePopUp(popup)) |
2134
f45250052846
primitivus: fixed display of error if a message can't be sent
Goffi <goffi@goffi.org>
parents:
2126
diff
changeset
|
755 elif type == 'error': |
1632 | 756 popup = sat_widgets.Alert(title, message, ok_cb=answer_cb) |
1582
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
757 if answer_cb is None: |
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
758 popup.setCallback('ok', lambda dummy: self.removePopUp(popup)) |
2134
f45250052846
primitivus: fixed display of error if a message can't be sent
Goffi <goffi@goffi.org>
parents:
2126
diff
changeset
|
759 elif type == 'yes/no': |
1612
48f324352c52
primitivus: fixed showDialog and XMLUI message dialog
Goffi <goffi@goffi.org>
parents:
1609
diff
changeset
|
760 popup = sat_widgets.ConfirmDialog(message) |
48f324352c52
primitivus: fixed showDialog and XMLUI message dialog
Goffi <goffi@goffi.org>
parents:
1609
diff
changeset
|
761 popup.setCallback('yes', self._dialogOkCb, (popup, answer_cb, answer_data)) |
48f324352c52
primitivus: fixed showDialog and XMLUI message dialog
Goffi <goffi@goffi.org>
parents:
1609
diff
changeset
|
762 popup.setCallback('no', self._dialogCancelCb, (popup, answer_cb, answer_data)) |
1582
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
763 else: |
1632 | 764 popup = sat_widgets.Alert(title, message, ok_cb=answer_cb) |
1582
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
765 if answer_cb is None: |
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
766 popup.setCallback('ok', lambda dummy: self.removePopUp(popup)) |
2134
f45250052846
primitivus: fixed display of error if a message can't be sent
Goffi <goffi@goffi.org>
parents:
2126
diff
changeset
|
767 log.error(u'unmanaged dialog type: {}'.format(type)) |
1582
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
768 self.showPopUp(popup) |
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
769 |
1468
731fbed0b9cf
quick_frontend, primitivus: handling of actionNew signal
Goffi <goffi@goffi.org>
parents:
1434
diff
changeset
|
770 def dialogFailure(self, failure): |
731fbed0b9cf
quick_frontend, primitivus: handling of actionNew signal
Goffi <goffi@goffi.org>
parents:
1434
diff
changeset
|
771 """Show a failure that has been returned by an asynchronous bridge method. |
731fbed0b9cf
quick_frontend, primitivus: handling of actionNew signal
Goffi <goffi@goffi.org>
parents:
1434
diff
changeset
|
772 |
731fbed0b9cf
quick_frontend, primitivus: handling of actionNew signal
Goffi <goffi@goffi.org>
parents:
1434
diff
changeset
|
773 @param failure (defer.Failure): Failure instance |
731fbed0b9cf
quick_frontend, primitivus: handling of actionNew signal
Goffi <goffi@goffi.org>
parents:
1434
diff
changeset
|
774 """ |
1609
66f0e877625b
primitivus: fixed alert case + alert in profileManager
Goffi <goffi@goffi.org>
parents:
1582
diff
changeset
|
775 self.alert(failure.classname, failure.message) |
1468
731fbed0b9cf
quick_frontend, primitivus: handling of actionNew signal
Goffi <goffi@goffi.org>
parents:
1434
diff
changeset
|
776 |
1181
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
777 def onNotification(self, notif_bar): |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
778 """Called when a new notification has been received""" |
1181
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
779 if not isinstance(self.main_widget, PrimitivusTopWidget): |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
780 #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
|
781 return |
1181
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
782 if self.notif_bar.canHide(): |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
783 #No notification left, we can hide the bar |
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
784 self.main_widget.hide('notif_bar') |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
785 else: |
1181
ca8ce5a47969
Primitivus: main_widget is now in its own class (PrimitivusTopWidget), menu and notification bar (un)hidding is cleaner
Goffi <goffi@goffi.org>
parents:
1165
diff
changeset
|
786 self.main_widget.show('notif_bar') |
1636 | 787 self.redraw() # FIXME: invalidate cache in a more efficient way |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
788 |
1468
731fbed0b9cf
quick_frontend, primitivus: handling of actionNew signal
Goffi <goffi@goffi.org>
parents:
1434
diff
changeset
|
789 def _actionManagerUnknownError(self): |
1609
66f0e877625b
primitivus: fixed alert case + alert in profileManager
Goffi <goffi@goffi.org>
parents:
1582
diff
changeset
|
790 self.alert(_("Error"), _(u"Unmanaged action")) |
759
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
791 |
1963
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
792 def roomJoinedHandler(self, room_jid_s, room_nicks, user_nick, subject, profile): |
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
793 super(PrimitivusApp, self).roomJoinedHandler(room_jid_s, room_nicks, user_nick, subject, profile) |
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
794 # if self.selected_widget is None: |
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
795 # for contact_list in self.widgets.getWidgets(ContactList): |
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
796 # if profile in contact_list.profiles: |
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
797 # contact_list.setFocus(jid.JID(room_jid_s), True) |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
798 |
1636 | 799 def progressStartedHandler(self, pid, metadata, profile): |
800 super(PrimitivusApp, self).progressStartedHandler(pid, metadata, profile) | |
801 self.addProgress(pid, metadata.get('name', _(u'unkown')), profile) | |
802 | |
803 def progressFinishedHandler(self, pid, metadata, profile): | |
804 log.info(u"Progress {} finished".format(pid)) | |
805 super(PrimitivusApp, self).progressFinishedHandler(pid, metadata, profile) | |
806 | |
807 def progressErrorHandler(self, pid, err_msg, profile): | |
808 log.warning(u"Progress {pid} error: {err_msg}".format(pid=pid, err_msg=err_msg)) | |
809 super(PrimitivusApp, self).progressErrorHandler(pid, err_msg, profile) | |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
810 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
811 |
153
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
812 ##DIALOGS CALLBACKS## |
120 | 813 def onJoinRoom(self, button, edit): |
814 self.removePopUp() | |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
815 room_jid = jid.JID(edit.get_edit_text()) |
1963
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
816 self.bridge.mucJoin(room_jid, self.profiles[self.current_profile].whoami.node, {}, self.current_profile, callback=lambda dummy: None, errback=self.dialogFailure) |
120 | 817 |
173 | 818 #MENU EVENTS# |
131 | 819 def onConnectRequest(self, menu): |
2142
be96beb7ca14
core, bridge, frontends: renamed asyncConnect to connect, and added options parameters (not used yet)
Goffi <goffi@goffi.org>
parents:
2134
diff
changeset
|
820 QuickApp.connect(self, self.current_profile) |
131 | 821 |
822 def onDisconnectRequest(self, menu): | |
1348
a39d2db03c80
frontends: add listeners 'profilePlugged', 'disconnect' and 'gotMenus' (the last one to be removed when the menus are refactored to quick_app)
souliane <souliane@mailoo.org>
parents:
1337
diff
changeset
|
823 self.disconnect(self.current_profile) |
131 | 824 |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
825 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
|
826 def success(params): |
1353
361b0fe72961
frontends (primitivus): assign the current profile to the parameters dialog
souliane <souliane@mailoo.org>
parents:
1350
diff
changeset
|
827 ui = xmlui.create(self, xml_data=params, profile=self.current_profile) |
1185
6184779544c7
Primitivus (xmlui): fixed window closing on save params + removed now unused onConfigureRoom in Chat
Goffi <goffi@goffi.org>
parents:
1181
diff
changeset
|
828 ui.show() |
777
5642939d254e
core, bridge: new method paramsRegisterApp to register frontend's specific parameters
souliane <souliane@mailoo.org>
parents:
776
diff
changeset
|
829 |
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
|
830 def failure(error): |
1609
66f0e877625b
primitivus: fixed alert case + alert in profileManager
Goffi <goffi@goffi.org>
parents:
1582
diff
changeset
|
831 self.alert(_("Error"), _("Can't get parameters (%s)") % error) |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
832 self.bridge.getParamsUI(app=C.APP_NAME, profile_key=self.current_profile, callback=success, errback=failure) |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
833 |
131 | 834 def onExitRequest(self, menu): |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
835 QuickApp.onExit(self) |
1949
c5fd304d0976
primitivus: added bracketed_paste option in sat.conf (if set, the bracketed paste mode will be activated on Primitivus start)
Goffi <goffi@goffi.org>
parents:
1948
diff
changeset
|
836 try: |
c5fd304d0976
primitivus: added bracketed_paste option in sat.conf (if set, the bracketed paste mode will be activated on Primitivus start)
Goffi <goffi@goffi.org>
parents:
1948
diff
changeset
|
837 if self._bracketed_mode_set: # we don't unset if bracketed paste mode was detected automatically (i.e. not in conf) |
c5fd304d0976
primitivus: added bracketed_paste option in sat.conf (if set, the bracketed paste mode will be activated on Primitivus start)
Goffi <goffi@goffi.org>
parents:
1948
diff
changeset
|
838 log.debug("unsetting bracketed paste mode") |
c5fd304d0976
primitivus: added bracketed_paste option in sat.conf (if set, the bracketed paste mode will be activated on Primitivus start)
Goffi <goffi@goffi.org>
parents:
1948
diff
changeset
|
839 sys.stdout.write("\033[?2004l") |
c5fd304d0976
primitivus: added bracketed_paste option in sat.conf (if set, the bracketed paste mode will be activated on Primitivus start)
Goffi <goffi@goffi.org>
parents:
1948
diff
changeset
|
840 except AttributeError: |
c5fd304d0976
primitivus: added bracketed_paste option in sat.conf (if set, the bracketed paste mode will be activated on Primitivus start)
Goffi <goffi@goffi.org>
parents:
1948
diff
changeset
|
841 pass |
131 | 842 raise urwid.ExitMainLoop() |
843 | |
844 def onJoinRoomRequest(self, menu): | |
845 """User wants to join a MUC room""" | |
1970
200cd707a46d
plugin XEP-0045, quick_frontend + primitivus (chat): cleaning of XEP-0045 (first pass):
Goffi <goffi@goffi.org>
parents:
1969
diff
changeset
|
846 pop_up_widget = sat_widgets.InputDialog(_("Entering a MUC room"), _("Please enter MUC's JID"), default_txt=self.bridge.mucGetDefaultService(), ok_cb=self.onJoinRoom) |
1580
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
847 pop_up_widget.setCallback('cancel', lambda dummy: self.removePopUp(pop_up_widget)) |
131 | 848 self.showPopUp(pop_up_widget) |
849 | |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
850 def onAboutRequest(self, menu): |
1609
66f0e877625b
primitivus: fixed alert case + alert in profileManager
Goffi <goffi@goffi.org>
parents:
1582
diff
changeset
|
851 self.alert(_("About"), C.APP_NAME + " v" + self.bridge.getVersion()) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
852 |
173 | 853 #MISC CALLBACKS# |
854 | |
1417
176de79c8c39
core, plugin XEP-0045, frontends: change frontend method "setStatusOnline" for "setPresenceStatus":
souliane <souliane@mailoo.org>
parents:
1409
diff
changeset
|
855 def setPresenceStatus(self, show='', status=None, profile=C.PROF_KEY_NONE): |
1938
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
856 contact_list_wid = self.widgets.getWidget(ContactList, profiles=profile) |
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
857 if contact_list_wid is not None: |
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
858 contact_list_wid.status_bar.setPresenceStatus(show, status) |
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
859 else: |
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
860 log.warning(u"No ContactList widget found for profile {}".format(profile)) |
737
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
861 |
3481
7892585b7e17
core (setup), jp, primitivus: update console scripts + classifiers:
Goffi <goffi@goffi.org>
parents:
3028
diff
changeset
|
862 if __name__ == '__main__': |
7892585b7e17
core (setup), jp, primitivus: update console scripts + classifiers:
Goffi <goffi@goffi.org>
parents:
3028
diff
changeset
|
863 PrimitivusApp().start() |