Mercurial > libervia-backend
annotate frontends/src/primitivus/primitivus @ 1966:d727aab9a80e
primitivus: basic handling of filter, only language can filtered for now
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 20 Jun 2016 19:19:16 +0200 |
parents | a2bc5089c2eb |
children | 5fbe09b9b568 |
rev | line source |
---|---|
1934
2daf7b4c6756
use of /usr/bin/env instead of /usr/bin/python in shebang
Goffi <goffi@goffi.org>
parents:
1795
diff
changeset
|
1 #!/usr/bin/env python2 |
112 | 2 # -*- coding: utf-8 -*- |
3 | |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
4 # Primitivus: a SAT frontend |
1766 | 5 # Copyright (C) 2009-2016 Jérôme Poisson (goffi@goffi.org) |
112 | 6 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
10 # (at your option) any later version. |
112 | 11 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
15 # GNU Affero General Public License for more details. |
112 | 16 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
112 | 19 |
20 | |
1225
82dabb442e2e
frontends (primitivus): new command :search <pattern>
souliane <souliane@mailoo.org>
parents:
1186
diff
changeset
|
21 from sat.core.i18n import _, D_ |
1010
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
22 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
|
23 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
|
24 log_config.satConfigure(C.LOG_BACKEND_STANDARD, C) |
1010
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
25 from sat.core import log as logging |
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
26 log = logging.getLogger(__name__) |
112 | 27 import urwid |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
28 from urwid_satext import sat_widgets |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
29 from urwid_satext.files_management import FileDialog |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
30 from sat_frontends.bridge.DBus import DBusBridgeFrontend |
225
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
31 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
|
32 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
|
33 from sat_frontends.quick_frontend import quick_chat |
225
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
34 from sat_frontends.primitivus.profile_manager import ProfileManager |
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
35 from sat_frontends.primitivus.contact_list import ContactList |
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
36 from sat_frontends.primitivus.chat import Chat |
1106
e2e1e27a3680
frontends: XMLUI refactoring + dialogs:
Goffi <goffi@goffi.org>
parents:
1103
diff
changeset
|
37 from sat_frontends.primitivus import xmlui |
225
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
38 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
|
39 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
|
40 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
|
41 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
|
42 from sat_frontends.tools.misc import InputHistory |
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 |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
44 from os.path import join |
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
|
45 import signal |
112 | 46 |
47 | |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
48 class EditBar(sat_widgets.ModalEdit): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
49 """ |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
50 The modal edit bar where you would enter messages and commands. |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
51 """ |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
52 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
53 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
|
54 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
|
55 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
|
56 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
|
57 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
|
58 self.host = host |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
59 self.setCompletionMethod(self._text_completion) |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
60 urwid.connect_signal(self, 'click', self.onTextEntered) |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
61 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
62 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
|
63 if mode == C.MODE_INSERTION: |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
64 return self._nick_completion(text, completion_data) |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
65 else: |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
66 return text |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
67 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
68 def _nick_completion(self, text, completion_data): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
69 """Completion method which complete pseudo in group chat |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
70 for params, see AdvancedEdit""" |
1350
32ccda01a2be
frontends (primitivus): fixes MUC nicks completion
souliane <souliane@mailoo.org>
parents:
1348
diff
changeset
|
71 nicks = [] |
32ccda01a2be
frontends (primitivus): fixes MUC nicks completion
souliane <souliane@mailoo.org>
parents:
1348
diff
changeset
|
72 for profile, clist in self.host.contact_lists.iteritems(): |
1938
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
73 for contact in clist.selected: |
1350
32ccda01a2be
frontends (primitivus): fixes MUC nicks completion
souliane <souliane@mailoo.org>
parents:
1348
diff
changeset
|
74 chat = self.host.widgets.getWidget(quick_chat.QuickChat, contact, profile) |
32ccda01a2be
frontends (primitivus): fixes MUC nicks completion
souliane <souliane@mailoo.org>
parents:
1348
diff
changeset
|
75 if chat.type != C.CHAT_GROUP: |
32ccda01a2be
frontends (primitivus): fixes MUC nicks completion
souliane <souliane@mailoo.org>
parents:
1348
diff
changeset
|
76 continue |
32ccda01a2be
frontends (primitivus): fixes MUC nicks completion
souliane <souliane@mailoo.org>
parents:
1348
diff
changeset
|
77 space = text.rfind(" ") |
32ccda01a2be
frontends (primitivus): fixes MUC nicks completion
souliane <souliane@mailoo.org>
parents:
1348
diff
changeset
|
78 start = text[space + 1:] |
32ccda01a2be
frontends (primitivus): fixes MUC nicks completion
souliane <souliane@mailoo.org>
parents:
1348
diff
changeset
|
79 nicks.extend(list(chat.occupants)) |
32ccda01a2be
frontends (primitivus): fixes MUC nicks completion
souliane <souliane@mailoo.org>
parents:
1348
diff
changeset
|
80 if nicks: |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
81 nicks.sort() |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
82 try: |
1350
32ccda01a2be
frontends (primitivus): fixes MUC nicks completion
souliane <souliane@mailoo.org>
parents:
1348
diff
changeset
|
83 start_idx = nicks.index(completion_data['last_nick']) + 1 |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
84 if start_idx == len(nicks): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
85 start_idx = 0 |
1350
32ccda01a2be
frontends (primitivus): fixes MUC nicks completion
souliane <souliane@mailoo.org>
parents:
1348
diff
changeset
|
86 except (KeyError, ValueError): |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
87 start_idx = 0 |
1350
32ccda01a2be
frontends (primitivus): fixes MUC nicks completion
souliane <souliane@mailoo.org>
parents:
1348
diff
changeset
|
88 for idx in range(start_idx, len(nicks)) + range(0, start_idx): |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
89 if nicks[idx].lower().startswith(start.lower()): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
90 completion_data['last_nick'] = nicks[idx] |
1350
32ccda01a2be
frontends (primitivus): fixes MUC nicks completion
souliane <souliane@mailoo.org>
parents:
1348
diff
changeset
|
91 return text[:space + 1] + nicks[idx] + (': ' if space < 0 else '') |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
92 return text |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
93 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
94 def onTextEntered(self, editBar): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
95 """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
|
96 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
|
97 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
|
98 chat_widget = self.host.selected_widget |
1955
633b5c21aefd
backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents:
1938
diff
changeset
|
99 self.host.messageSend( |
633b5c21aefd
backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents:
1938
diff
changeset
|
100 chat_widget.target, |
633b5c21aefd
backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents:
1938
diff
changeset
|
101 {'': editBar.get_edit_text()}, # TODO: handle language |
1963
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
102 mess_type = C.MESS_TYPE_GROUPCHAT if chat_widget.type == C.CHAT_GROUP else C.MESS_TYPE_CHAT, # TODO: put this in QuickChat |
1955
633b5c21aefd
backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents:
1938
diff
changeset
|
103 errback=lambda failure: self.host.notify(_("Error while sending message ({})").format(failure)), |
633b5c21aefd
backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents:
1938
diff
changeset
|
104 profile_key=chat_widget.profile |
633b5c21aefd
backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents:
1938
diff
changeset
|
105 ) |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
106 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
|
107 elif self.mode == C.MODE_COMMAND: |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
108 self.commandHandler() |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
109 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
110 def commandHandler(self): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
111 #TODO: separate class with auto documentation (with introspection) |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
112 # and completion method |
1119
5968fd8d2248
primitivus: change behavior of commands ":presence" and ":status" :
souliane <souliane@mailoo.org>
parents:
1106
diff
changeset
|
113 tokens = self.get_edit_text().split(' ') |
5968fd8d2248
primitivus: change behavior of commands ":presence" and ":status" :
souliane <souliane@mailoo.org>
parents:
1106
diff
changeset
|
114 command, args = tokens[0], tokens[1:] |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
115 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
|
116 self.host.onExit() |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
117 raise urwid.ExitMainLoop() |
1010
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
118 elif command == 'messages': |
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
119 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
|
120 self.host.selectWidget(wid) |
1434
b06047e1c1fb
primitivus: fix setting the presence and status
souliane <souliane@mailoo.org>
parents:
1417
diff
changeset
|
121 # 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
|
122 # elif command == 'presence': |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
123 # 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
|
124 # 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
|
125 # 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
|
126 # 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
|
127 # 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
|
128 # else: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
129 # 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
|
130 # elif command == 'status': |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
131 # if args: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
132 # 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
|
133 # else: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
134 # 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
|
135 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
|
136 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
|
137 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
|
138 try: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
139 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
|
140 except (IndexError, ValueError): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
141 limit = 50 |
1963
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
142 widget.updateHistory(size=limit, profile=widget.profile) |
1225
82dabb442e2e
frontends (primitivus): new command :search <pattern>
souliane <souliane@mailoo.org>
parents:
1186
diff
changeset
|
143 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
|
144 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
|
145 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
|
146 pattern = " ".join(args) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
147 if not pattern: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
148 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
|
149 else: |
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
150 widget.updateHistory(size=C.HISTORY_LIMIT_NONE, 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
|
151 elif command == 'filter': |
d727aab9a80e
primitivus: basic handling of filter, only language can filtered for now
Goffi <goffi@goffi.org>
parents:
1963
diff
changeset
|
152 # 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
|
153 # 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
|
154 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
|
155 # 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
|
156 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
|
157 widget.setFilter(args) |
737
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
158 else: |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
159 return |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
160 self.set_edit_text('') |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
161 |
1160
2ff15a6c5791
primitivus: moved history method definition out of keypress
Goffi <goffi@goffi.org>
parents:
1159
diff
changeset
|
162 def _historyCb(self, text): |
2ff15a6c5791
primitivus: moved history method definition out of keypress
Goffi <goffi@goffi.org>
parents:
1159
diff
changeset
|
163 self.set_edit_text(text) |
2ff15a6c5791
primitivus: moved history method definition out of keypress
Goffi <goffi@goffi.org>
parents:
1159
diff
changeset
|
164 self.set_edit_pos(len(text)) |
2ff15a6c5791
primitivus: moved history method definition out of keypress
Goffi <goffi@goffi.org>
parents:
1159
diff
changeset
|
165 |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
166 def keypress(self, size, key): |
671
4e691a231763
frontend, primitivus: added input history (mode-wise)
souliane <souliane@mailoo.org>
parents:
661
diff
changeset
|
167 """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
|
168 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
|
169 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
|
170 # 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
|
171 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
|
172 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
|
173 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
|
174 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
|
175 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
|
176 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
|
177 return |
1158
c0f15e52695a
primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
178 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
|
179 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
|
180 return |
1158
c0f15e52695a
primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
181 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
|
182 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
|
183 else: |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
184 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
|
185 and 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
|
186 and key not in sat_widgets.FOCUS_KEYS): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
187 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
|
188 |
671
4e691a231763
frontend, primitivus: added input history (mode-wise)
souliane <souliane@mailoo.org>
parents:
661
diff
changeset
|
189 return super(EditBar, self).keypress(size, key) |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
190 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
191 |
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
|
192 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
|
193 """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
|
194 _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
|
195 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
|
196 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
|
197 |
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 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
|
199 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
|
200 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
|
201 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
|
202 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
|
203 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
|
204 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
|
205 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
|
206 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
|
207 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
|
208 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
|
209 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
|
210 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
|
211 ) |
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
|
212 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
|
213 |
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
|
214 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
|
215 """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
|
216 |
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 @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
|
218 (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
|
219 @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
|
220 """ |
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 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
|
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 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
|
224 """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
|
225 |
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 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
|
227 """ |
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 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
|
229 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
|
230 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
|
231 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
|
232 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
|
233 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
|
234 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
|
235 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
|
236 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
|
237 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
|
238 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
|
239 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
|
240 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
|
241 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
|
242 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
|
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 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
|
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 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
|
248 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
|
249 |
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
|
250 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
|
251 |
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
|
252 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
|
253 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
|
254 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
|
255 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
|
256 |
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 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
|
258 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
|
259 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
|
260 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
|
261 |
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 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
|
263 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
|
264 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
|
265 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
|
266 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
|
267 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
|
268 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
|
269 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
|
270 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
|
271 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
|
272 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
|
273 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
|
274 |
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 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
|
276 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
|
277 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
|
278 |
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 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
|
280 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
|
281 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
|
282 |
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
|
283 |
671
4e691a231763
frontend, primitivus: added input history (mode-wise)
souliane <souliane@mailoo.org>
parents:
661
diff
changeset
|
284 class PrimitivusApp(QuickApp, InputHistory): |
1795
c38233e12c69
primivitus: Primivitus doesn't handle microblog yet, configure QuickApp accordingly
Goffi <goffi@goffi.org>
parents:
1787
diff
changeset
|
285 MB_HANDLE = False |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
286 |
112 | 287 def __init__(self): |
1468
731fbed0b9cf
quick_frontend, primitivus: handling of actionNew signal
Goffi <goffi@goffi.org>
parents:
1434
diff
changeset
|
288 QuickApp.__init__(self, create_bridge=DBusBridgeFrontend, xmlui=xmlui, check_options=quick_utils.check_options) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
289 |
112 | 290 ## main loop setup ## |
117 | 291 self.main_widget = ProfileManager(self) |
1010
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
292 self.loop = urwid.MainLoop(self.main_widget, C.PALETTE, event_loop=urwid.GLibEventLoop(), input_filter=self.inputFilter, unhandled_input=self.keyHandler) |
112 | 293 |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
294 ##misc setup## |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
295 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
|
296 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
|
297 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
|
298 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
299 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
|
300 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
|
301 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
|
302 |
507
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
503
diff
changeset
|
303 self.x_notify = Notify() |
524
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
304 |
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
|
305 # 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
|
306 signal.signal(signal.SIGINT, signal.SIG_IGN) |
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
|
307 |
524
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
308 @property |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
309 def visible_widgets(self): |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
310 return self._visible_widgets |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
311 |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
312 @property |
524
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
313 def mode(self): |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
314 return self.editBar.mode |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
315 |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
316 @mode.setter |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
317 def mode(self, value): |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
318 self.editBar.mode = value |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
319 |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
320 def modeHint(self, value): |
1010
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
321 """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
|
322 if not self.editBar.get_edit_text(): |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
323 self.mode = value |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
324 |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
325 def debug(self): |
1010
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
326 """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
|
327 log.info('Entered debug mode') |
180
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
328 try: |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
329 import pudb |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
330 pudb.set_trace() |
1010
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
331 except ImportError: |
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
332 import os |
180
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
333 os.system('reset') |
1010
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
334 try: |
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
335 import ipdb |
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
336 ipdb.set_trace() |
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
337 except ImportError: |
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
338 import pdb |
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
339 pdb.set_trace() |
129
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
340 |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
341 def redraw(self): |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
342 """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
|
343 try: |
5a18c5f08d9b
Primitivus: Profile Manager: fixed redraw on profile change + use of AdvandedEdit for login field
Goffi <goffi@goffi.org>
parents:
415
diff
changeset
|
344 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
|
345 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
|
346 pass |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
347 |
112 | 348 def start(self): |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
349 self.i = 0 |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
350 self.loop.set_alarm_in(0,lambda a,b: self.postInit()) |
112 | 351 self.loop.run() |
352 | |
1159
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
353 def postInit(self): |
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
354 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
|
355 config.applyConfig(self) |
1159
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
356 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
|
357 log.error(u"configuration error: {}".format(e)) |
1609
66f0e877625b
primitivus: fixed alert case + alert in profileManager
Goffi <goffi@goffi.org>
parents:
1582
diff
changeset
|
358 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
|
359 if self.options.profile: |
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
360 self._early_popup = popup |
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
361 else: |
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
362 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
|
363 super(PrimitivusApp, self).postInit(self.main_widget) |
1159
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
364 |
1164 | 365 def inputFilter(self, input_, raw): |
366 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
|
367 return |
1164 | 368 for i in input_: |
153
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
369 if isinstance(i,tuple): |
127
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
370 if i[0] == 'mouse press': |
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
371 if i[1] == 4: #Mouse wheel up |
1164 | 372 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
|
373 if i[1] == 5: #Mouse wheel down |
1164 | 374 input_[input_.index(i)] = a_key['HISTORY_NEXT'] |
375 return input_ | |
127
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
376 |
1158
c0f15e52695a
primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
377 def keyHandler(self, input_): |
c0f15e52695a
primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
378 if input_ == a_key['MENU_HIDE']: |
181 | 379 """User want to (un)hide the menu roller""" |
128
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
380 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
|
381 self.main_widget.hideSwitch('menu') |
128
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
382 except AttributeError: |
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
383 pass |
1158
c0f15e52695a
primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
384 elif input_ == a_key['NOTIFICATION_NEXT']: |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
385 """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
|
386 self.notif_bar.showNext() |
1158
c0f15e52695a
primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
387 elif input_ == a_key['OVERLAY_HIDE']: |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
388 """User wants to (un)hide overlay window""" |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
389 if isinstance(self.loop.widget,urwid.Overlay): |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
390 self.__saved_overlay = self.loop.widget |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
391 self.loop.widget = self.main_widget |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
392 else: |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
393 if self.__saved_overlay: |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
394 self.loop.widget = self.__saved_overlay |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
395 self.__saved_overlay = None |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
396 |
1158
c0f15e52695a
primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
397 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
|
398 self.debug() |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
399 elif input_ == a_key['CONTACTS_HIDE']: #user wants to (un)hide the contact lists |
124 | 400 try: |
608
ea9aa51234eb
Primitivus: fixed contacts list (un)hidding
Goffi <goffi@goffi.org>
parents:
607
diff
changeset
|
401 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
|
402 if self.contact_lists_pile is wid: |
608
ea9aa51234eb
Primitivus: fixed contacts list (un)hidding
Goffi <goffi@goffi.org>
parents:
607
diff
changeset
|
403 self.center_part.contents.remove((wid, options)) |
ea9aa51234eb
Primitivus: fixed contacts list (un)hidding
Goffi <goffi@goffi.org>
parents:
607
diff
changeset
|
404 break |
124 | 405 else: |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
406 self.center_part.contents.insert(0, (self.contact_lists_pile, ('weight', 2, False))) |
124 | 407 except AttributeError: |
408 #The main widget is not built (probably in Profile Manager) | |
409 pass | |
1158
c0f15e52695a
primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
410 elif input_ == 'window resize': |
129
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
411 width,height = self.loop.screen_size |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
412 if height<=5 and width<=35: |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
413 if not 'save_main_widget' in dir(self): |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
414 self.save_main_widget = self.loop.widget |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
415 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
|
416 else: |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
417 if 'save_main_widget' in dir(self): |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
418 self.loop.widget = self.save_main_widget |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
419 del self.save_main_widget |
128
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
420 try: |
1158
c0f15e52695a
primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
421 return self.menu_roller.checkShortcuts(input_) |
128
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
422 except AttributeError: |
1158
c0f15e52695a
primitivus: use of new keys modules from Urwid SàText
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
423 return input_ |
124 | 424 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
425 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
|
426 """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
|
427 @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
|
428 @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
|
429 @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
|
430 |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
431 """ |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
432 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
|
433 self.launchAction(callback_id, menu_data, profile=self.current_profile) |
1365
ba87b940f07a
core, quick_frontends: added an "extra" item in getMenus + use of new quick_menus module in QuickApp
Goffi <goffi@goffi.org>
parents:
1360
diff
changeset
|
434 for id_, type_, path, path_i18n, extra in self.bridge.getMenus("", 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
|
435 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
|
436 continue |
1093
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
437 if len(path) != 2: |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
438 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
|
439 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
|
440 |
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1063
diff
changeset
|
441 |
755
e3ad48a2aab2
core, frontends: callMenu is now async and don't use callback_id anymore
Goffi <goffi@goffi.org>
parents:
752
diff
changeset
|
442 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
|
443 menu = sat_widgets.Menu(self.loop) |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
444 general = _("General") |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
445 menu.addMenu(general, _("Connect"), self.onConnectRequest) |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
446 menu.addMenu(general, _("Disconnect"), self.onDisconnectRequest) |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
447 menu.addMenu(general, _("Parameters"), self.onParam) |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
448 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
|
449 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
|
450 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
|
451 groups = _("Groups") |
94c450972346
primitivus and plugins: renamed a few menus:
souliane <souliane@mailoo.org>
parents:
1676
diff
changeset
|
452 menu.addMenu(groups) |
94c450972346
primitivus and plugins: renamed a few menus:
souliane <souliane@mailoo.org>
parents:
1676
diff
changeset
|
453 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
|
454 #additionals menus |
c8b231abfe96
Primitivus: additionnal menus management
Goffi <goffi@goffi.org>
parents:
144
diff
changeset
|
455 #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
|
456 self.addMenus(menu, C.MENU_GLOBAL) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
457 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
458 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
|
459 return menu_roller |
131 | 460 |
755
e3ad48a2aab2
core, frontends: callMenu is now async and don't use callback_id anymore
Goffi <goffi@goffi.org>
parents:
752
diff
changeset
|
461 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
|
462 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
|
463 #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
|
464 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
|
465 |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
466 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
|
467 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
|
468 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
|
469 return self.main_widget |
112 | 470 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
471 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
|
472 self.loop.widget = self._buildMainWidget() |
415
3348331e0f09
primitivus: fixed screen redraw after plugin profile
Goffi <goffi@goffi.org>
parents:
411
diff
changeset
|
473 self.redraw() |
1159
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
474 try: |
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
475 # 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
|
476 self.showPopUp(self._early_popup) |
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
477 except AttributeError: |
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
478 pass |
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
479 else: |
85fd02356dba
primitivus: key can be changed in config:
Goffi <goffi@goffi.org>
parents:
1158
diff
changeset
|
480 del self._early_popup |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
481 |
1938
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
482 def profilePlugged(self, profile): |
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
483 QuickApp.profilePlugged(self, profile) |
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
484 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
|
485 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
|
486 return contact_list |
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
487 |
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
|
488 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
|
489 """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
|
490 |
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
|
491 @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
|
492 """ |
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
|
493 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
|
494 |
1609
66f0e877625b
primitivus: fixed alert case + alert in profileManager
Goffi <goffi@goffi.org>
parents:
1582
diff
changeset
|
495 def alert(self, title, message): |
1580
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
496 """Shortcut method to create an alert message |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
497 |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
498 Alert will have an "OK" button, which remove it if pressed |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
499 @param title(unicode): title of the dialog |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
500 @param message(unicode): body of the dialog |
1609
66f0e877625b
primitivus: fixed alert case + alert in profileManager
Goffi <goffi@goffi.org>
parents:
1582
diff
changeset
|
501 @return (urwid_satext.Alert): the created Alert instance |
1580
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
502 """ |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
503 popup = sat_widgets.Alert(title, message) |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
504 popup.setCallback('ok', lambda dummy: self.removePopUp(popup)) |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
505 self.showPopUp(popup) |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
506 return popup |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
507 |
120 | 508 def removePopUp(self, widget=None): |
1580
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
509 """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
|
510 |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
511 @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
|
512 """ |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
513 # TODO: refactor popup management in a cleaner way |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
514 if widget is not None: |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
515 if isinstance(self.loop.widget, urwid.Overlay): |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
516 current_popup = self.loop.widget.top_w |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
517 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
|
518 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
|
519 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
|
520 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
|
521 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
|
522 return |
117 | 523 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
|
524 next_popup = self.notif_bar.getNextPopup() |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
525 if next_popup: |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
526 #we still have popup to show, we display it |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
527 self.showPopUp(next_popup) |
1580
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
528 else: |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
529 self.redraw() |
117 | 530 |
737
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
531 def showPopUp(self, pop_up_widget, perc_width=40, perc_height=40, align='center', valign='middle'): |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
532 "Show a pop-up window if possible, else put it in queue" |
687
af0d08a84cc6
primitivus card_game: bug fix and improvement
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
533 if not isinstance(self.loop.widget, urwid.Overlay): |
737
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
534 display_widget = urwid.Overlay(pop_up_widget, self.main_widget, align, ('relative', perc_width), valign, ('relative', perc_height)) |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
535 self.loop.widget = display_widget |
219
782319a64ac6
primitivus, wix: added forgotten profile
Goffi <goffi@goffi.org>
parents:
216
diff
changeset
|
536 self.redraw() |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
537 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
|
538 self.notif_bar.addPopUp(pop_up_widget) |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
539 |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
540 def notify(self, message): |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
541 """"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
|
542 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
|
543 self.redraw() |
112 | 544 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
545 def newWidget(self, widget): |
1963
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
546 if self.selected_widget is None: |
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
547 self.selectWidget(widget) |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
548 |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
549 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
|
550 """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
|
551 |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
552 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
|
553 @param widget: BoxWidget |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
554 """ |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
555 assert len(self.center_part.widget_list)<=2 |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
556 wid_idx = len(self.center_part.widget_list)-1 |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
557 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
|
558 try: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
559 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
|
560 except KeyError: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
561 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
|
562 self.selected_widget = widget |
1963
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
563 try: |
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
564 onSelected = self.selected_widget.onSelected |
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
565 except AttributeError: |
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
566 pass |
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
567 else: |
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
568 onSelected() |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
569 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
|
570 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
|
571 |
1938
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
572 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
|
573 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
|
574 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
|
575 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
|
576 |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
577 self.redraw() |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
578 |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
579 def removeWindow(self): |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
580 """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
|
581 #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
|
582 assert len(self.center_part.widget_list) <= 2 |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
583 wid_idx = len(self.center_part.widget_list)-1 |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
584 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
|
585 self.center_part.focus_position = 0 |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
586 self.redraw() |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
587 |
1636 | 588 def addProgress(self, pid, message, profile): |
589 """Follow a SàT progression | |
590 | |
591 @param pid: progression id | |
592 @param message: message to show to identify the progression | |
593 """ | |
594 self.progress_wid.add(pid, message, profile) | |
180
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
595 |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
596 def setProgress(self, percentage): |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
597 """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
|
598 self.notif_bar.setProgress(percentage) |
180
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
599 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
600 def contactSelected(self, contact_list, entity): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
601 if entity.resource: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
602 # 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
|
603 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
|
604 else: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
605 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
|
606 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
|
607 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
|
608 |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
609 def _dialogOkCb(self, widget, data): |
1582
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
610 popup, answer_cb, answer_data = data |
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
611 self.removePopUp(popup) |
1612
48f324352c52
primitivus: fixed showDialog and XMLUI message dialog
Goffi <goffi@goffi.org>
parents:
1609
diff
changeset
|
612 if answer_cb is not None: |
48f324352c52
primitivus: fixed showDialog and XMLUI message dialog
Goffi <goffi@goffi.org>
parents:
1609
diff
changeset
|
613 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
|
614 |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
615 def _dialogCancelCb(self, widget, data): |
1582
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
616 popup, answer_cb, answer_data = data |
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
617 self.removePopUp(popup) |
1612
48f324352c52
primitivus: fixed showDialog and XMLUI message dialog
Goffi <goffi@goffi.org>
parents:
1609
diff
changeset
|
618 if answer_cb is not None: |
48f324352c52
primitivus: fixed showDialog and XMLUI message dialog
Goffi <goffi@goffi.org>
parents:
1609
diff
changeset
|
619 answer_cb(False, answer_data) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
620 |
1582
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
621 def showDialog(self, message, title="", type_="info", answer_cb = None, answer_data = None): |
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
622 if type_ == 'info': |
1632 | 623 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
|
624 if answer_cb is None: |
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
625 popup.setCallback('ok', lambda dummy: self.removePopUp(popup)) |
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
626 elif type_ == 'error': |
1632 | 627 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
|
628 if answer_cb is None: |
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
629 popup.setCallback('ok', lambda dummy: self.removePopUp(popup)) |
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
630 elif type_ == 'yes/no': |
1612
48f324352c52
primitivus: fixed showDialog and XMLUI message dialog
Goffi <goffi@goffi.org>
parents:
1609
diff
changeset
|
631 popup = sat_widgets.ConfirmDialog(message) |
48f324352c52
primitivus: fixed showDialog and XMLUI message dialog
Goffi <goffi@goffi.org>
parents:
1609
diff
changeset
|
632 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
|
633 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
|
634 else: |
1632 | 635 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
|
636 if answer_cb is None: |
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
637 popup.setCallback('ok', lambda dummy: self.removePopUp(popup)) |
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
638 log.error(u'unmanaged dialog type: {}'.format(type_)) |
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
639 self.showPopUp(popup) |
a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
Goffi <goffi@goffi.org>
parents:
1580
diff
changeset
|
640 |
1468
731fbed0b9cf
quick_frontend, primitivus: handling of actionNew signal
Goffi <goffi@goffi.org>
parents:
1434
diff
changeset
|
641 def dialogFailure(self, failure): |
731fbed0b9cf
quick_frontend, primitivus: handling of actionNew signal
Goffi <goffi@goffi.org>
parents:
1434
diff
changeset
|
642 """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
|
643 |
731fbed0b9cf
quick_frontend, primitivus: handling of actionNew signal
Goffi <goffi@goffi.org>
parents:
1434
diff
changeset
|
644 @param failure (defer.Failure): Failure instance |
731fbed0b9cf
quick_frontend, primitivus: handling of actionNew signal
Goffi <goffi@goffi.org>
parents:
1434
diff
changeset
|
645 """ |
1609
66f0e877625b
primitivus: fixed alert case + alert in profileManager
Goffi <goffi@goffi.org>
parents:
1582
diff
changeset
|
646 self.alert(failure.classname, failure.message) |
1468
731fbed0b9cf
quick_frontend, primitivus: handling of actionNew signal
Goffi <goffi@goffi.org>
parents:
1434
diff
changeset
|
647 |
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
|
648 def onNotification(self, notif_bar): |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
649 """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
|
650 if not isinstance(self.main_widget, PrimitivusTopWidget): |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
651 #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
|
652 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
|
653 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
|
654 #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
|
655 self.main_widget.hide('notif_bar') |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
656 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
|
657 self.main_widget.show('notif_bar') |
1636 | 658 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
|
659 |
1468
731fbed0b9cf
quick_frontend, primitivus: handling of actionNew signal
Goffi <goffi@goffi.org>
parents:
1434
diff
changeset
|
660 def _actionManagerUnknownError(self): |
1609
66f0e877625b
primitivus: fixed alert case + alert in profileManager
Goffi <goffi@goffi.org>
parents:
1582
diff
changeset
|
661 self.alert(_("Error"), _(u"Unmanaged action")) |
759
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
662 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
663 def askConfirmationHandler(self, confirmation_id, confirmation_type, data, profile): |
1385
0dca4f9b264d
primitivus: prefill "Join MUC" dialog with only the JID's node part when in debug version + display error directly from the DBus object
souliane <souliane@mailoo.org>
parents:
1365
diff
changeset
|
664 answer_data = {} |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
665 |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
666 def dir_selected_cb(path): |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
667 dest_path = join(path, data['filename']) |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
668 answer_data["dest_path"] = quick_utils.getNewPath(dest_path) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
669 self.addProgress(confirmation_id, dest_path) |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
670 accept_cb(None) |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
671 |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
672 def accept_file_transfer_cb(widget): |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
673 self.removePopUp() |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
674 pop_up_widget = FileDialog(dir_selected_cb, refuse_cb, title=_(u"Where do you want to save the file ?"), style=['dir']) |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
675 self.showPopUp(pop_up_widget) |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
676 |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
677 def accept_cb(widget): |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
678 self.removePopUp() |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
679 self.bridge.confirmationAnswer(confirmation_id, True, answer_data, profile) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
680 |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
681 def refuse_cb(widget): |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
682 self.removePopUp() |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
683 self.bridge.confirmationAnswer(confirmation_id, False, answer_data, profile) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
684 |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
685 if confirmation_type == "FILE_TRANSFER": |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
686 pop_up_widget = sat_widgets.ConfirmDialog(_("The contact %(jid)s wants to send you the file %(filename)s\nDo you accept ?") % {'jid':data["from"], 'filename':data["filename"]}, no_cb=refuse_cb, yes_cb=accept_file_transfer_cb) |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
687 self.showPopUp(pop_up_widget) |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
688 |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
689 elif confirmation_type == "YES/NO": |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
690 pop_up_widget = sat_widgets.ConfirmDialog(data["message"], no_cb=refuse_cb, yes_cb=accept_cb) |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
691 self.showPopUp(pop_up_widget) |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
692 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
693 def actionResultHandler(self, type_, id, data, profile): |
807
be4c5e24dab9
plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents:
804
diff
changeset
|
694 # FIXME: to be removed |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
695 |
153
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
696 if not id in self.current_action_ids: |
1010
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
697 log.debug (_('unknown id, ignoring')) |
153
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
698 return |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
699 if type_ == "SUPPRESS": |
153
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
700 self.current_action_ids.remove(id) |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
701 elif type_ == "XMLUI": |
153
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
702 self.current_action_ids.remove(id) |
1010
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
703 log.debug (_("XML user interface received")) |
153
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
704 misc = {} |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
705 #FIXME FIXME FIXME: must clean all this crap ! |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
706 title = _('Form') |
173 | 707 if data['type'] == 'registration': |
153
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
708 title = _('Registration') |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
709 misc['target'] = data['target'] |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
710 misc['action_back'] = self.bridge.gatewayRegister |
1360
8ea8fa13c351
frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents:
1353
diff
changeset
|
711 ui = xmlui.create(self, title=title, xml_data=data['xml'], misc=misc, profile=profile) |
173 | 712 if data['type'] == 'registration': |
713 ui.show('popup') | |
714 else: | |
715 ui.show('window') | |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
716 elif type_ == "ERROR": |
173 | 717 self.current_action_ids.remove(id) |
1609
66f0e877625b
primitivus: fixed alert case + alert in profileManager
Goffi <goffi@goffi.org>
parents:
1582
diff
changeset
|
718 self.alert(_("Error"), unicode(data["message"])) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
719 elif type_ == "RESULT": |
173 | 720 self.current_action_ids.remove(id) |
721 if self.current_action_ids_cb.has_key(id): | |
722 callback = self.current_action_ids_cb[id] | |
723 del self.current_action_ids_cb[id] | |
724 callback(data) | |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
725 elif type_ == "DICT_DICT": |
173 | 726 self.current_action_ids.remove(id) |
727 if self.current_action_ids_cb.has_key(id): | |
728 callback = self.current_action_ids_cb[id] | |
729 del self.current_action_ids_cb[id] | |
730 callback(data) | |
153
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
731 else: |
1010
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
1000
diff
changeset
|
732 log.error (_("FIXME FIXME FIXME: type [%s] not implemented") % type_) |
153
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
733 raise NotImplementedError |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
734 |
1963
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
735 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
|
736 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
|
737 # if self.selected_widget is None: |
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
738 # for contact_list in self.widgets.getWidgets(ContactList): |
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
739 # if profile in contact_list.profiles: |
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
740 # 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
|
741 |
1636 | 742 def progressStartedHandler(self, pid, metadata, profile): |
743 super(PrimitivusApp, self).progressStartedHandler(pid, metadata, profile) | |
744 self.addProgress(pid, metadata.get('name', _(u'unkown')), profile) | |
745 | |
746 def progressFinishedHandler(self, pid, metadata, profile): | |
747 log.info(u"Progress {} finished".format(pid)) | |
748 super(PrimitivusApp, self).progressFinishedHandler(pid, metadata, profile) | |
749 | |
750 def progressErrorHandler(self, pid, err_msg, profile): | |
751 log.warning(u"Progress {pid} error: {err_msg}".format(pid=pid, err_msg=err_msg)) | |
752 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
|
753 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
754 |
153
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
755 ##DIALOGS CALLBACKS## |
120 | 756 def onJoinRoom(self, button, edit): |
757 self.removePopUp() | |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
758 room_jid = jid.JID(edit.get_edit_text()) |
1963
a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents:
1955
diff
changeset
|
759 self.bridge.mucJoin(room_jid, self.profiles[self.current_profile].whoami.node, {}, self.current_profile, callback=lambda dummy: None, errback=self.dialogFailure) |
120 | 760 |
173 | 761 #MENU EVENTS# |
131 | 762 def onConnectRequest(self, menu): |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1225
diff
changeset
|
763 QuickApp.asyncConnect(self, self.current_profile) |
131 | 764 |
765 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
|
766 self.disconnect(self.current_profile) |
131 | 767 |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
768 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
|
769 def success(params): |
1353
361b0fe72961
frontends (primitivus): assign the current profile to the parameters dialog
souliane <souliane@mailoo.org>
parents:
1350
diff
changeset
|
770 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
|
771 ui.show() |
777
5642939d254e
core, bridge: new method paramsRegisterApp to register frontend's specific parameters
souliane <souliane@mailoo.org>
parents:
776
diff
changeset
|
772 |
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
|
773 def failure(error): |
1609
66f0e877625b
primitivus: fixed alert case + alert in profileManager
Goffi <goffi@goffi.org>
parents:
1582
diff
changeset
|
774 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
|
775 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
|
776 |
131 | 777 def onExitRequest(self, menu): |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
778 QuickApp.onExit(self) |
131 | 779 raise urwid.ExitMainLoop() |
780 | |
781 def onJoinRoomRequest(self, menu): | |
782 """User wants to join a MUC room""" | |
1580
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
783 pop_up_widget = sat_widgets.InputDialog(_("Entering a MUC room"), _("Please enter MUC's JID"), default_txt=self.bridge.getDefaultMUC(), ok_cb=self.onJoinRoom) |
641cfd2faefe
Primitivus: better popups handling:
Goffi <goffi@goffi.org>
parents:
1468
diff
changeset
|
784 pop_up_widget.setCallback('cancel', lambda dummy: self.removePopUp(pop_up_widget)) |
131 | 785 self.showPopUp(pop_up_widget) |
786 | |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
787 def onAboutRequest(self, menu): |
1609
66f0e877625b
primitivus: fixed alert case + alert in profileManager
Goffi <goffi@goffi.org>
parents:
1582
diff
changeset
|
788 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
|
789 |
173 | 790 #MISC CALLBACKS# |
791 | |
1417
176de79c8c39
core, plugin XEP-0045, frontends: change frontend method "setStatusOnline" for "setPresenceStatus":
souliane <souliane@mailoo.org>
parents:
1409
diff
changeset
|
792 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
|
793 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
|
794 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
|
795 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
|
796 else: |
011eff37e21d
quick frontend, primitivus: quickContactList refactored to handle several profiles at once
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
797 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
|
798 |
112 | 799 sat = PrimitivusApp() |
800 sat.start() |